Skip to content

Commit

Permalink
arm: Switch from denylisting Apple targets to allowlisting Android/Li…
Browse files Browse the repository at this point in the history
…nux.

The allowlist approach is safer.
  • Loading branch information
briansmith committed Jun 22, 2024
1 parent 9593d9b commit 3e9e2eb
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 37 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ include = [
"crypto/perlasm/x86gas.pl",
"crypto/perlasm/x86nasm.pl",
"crypto/perlasm/x86_64-xlate.pl",
"crypto/poly1305/internal.h",
"crypto/poly1305/poly1305.c",
"crypto/poly1305/poly1305_arm.c",
"crypto/poly1305/poly1305_arm_asm.S",
Expand Down
25 changes: 0 additions & 25 deletions crypto/poly1305/internal.h

This file was deleted.

1 change: 0 additions & 1 deletion crypto/poly1305/poly1305.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include <ring-core/poly1305.h>

#include "internal.h"
#include "../internal.h"


Expand Down
5 changes: 0 additions & 5 deletions crypto/poly1305/poly1305_arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@

#include <ring-core/poly1305.h>

#include "internal.h"
#include "../internal.h"


#if defined(OPENSSL_POLY1305_NEON)

#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wcast-align"

Expand Down Expand Up @@ -304,5 +301,3 @@ void CRYPTO_poly1305_finish_neon(poly1305_state *state, uint8_t mac[16]) {
h->v[8] += c->v[8];
fe1305x2_tobytearray(mac, h);
}

#endif // OPENSSL_POLY1305_NEON
4 changes: 2 additions & 2 deletions src/aead/poly1305.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ macro_rules! dispatch {
( $( $p:ident : $t:ty ),+ )
( $( $a:expr ),+ ) ) => {
match () {
// Apple's 32-bit ARM ABI is incompatible with the assembly code.
#[cfg(all(target_arch = "arm", not(target_vendor = "apple")))]
// BoringSSL uses `!defined(OPENSSL_APPLE)`.
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
() if cpu::arm::NEON.available($features) => {
prefixed_extern! {
fn $neon_f( $( $p : $t ),+ );
Expand Down
7 changes: 4 additions & 3 deletions src/ec/curve25519/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn x25519_public_from_private(
let private_key: &[u8; SCALAR_LEN] = private_key.bytes_less_safe().try_into()?;
let private_key = ops::MaskedScalar::from_bytes_masked(*private_key);

#[cfg(all(not(target_vendor = "apple"), target_arch = "arm"))]
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
{
if cpu::arm::NEON.available(cpu_features) {
static MONTGOMERY_BASE_POINT: [u8; 32] = [
Expand Down Expand Up @@ -108,7 +108,7 @@ fn x25519_ecdh(
point: &ops::EncodedPoint,
#[allow(unused_variables)] cpu_features: cpu::Features,
) {
#[cfg(all(not(target_vendor = "apple"), target_arch = "arm"))]
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
{
if cpu::arm::NEON.available(cpu_features) {
return x25519_neon(out, scalar, point);
Expand Down Expand Up @@ -157,7 +157,8 @@ fn x25519_ecdh(
Ok(())
}

#[cfg(all(not(target_vendor = "apple"), target_arch = "arm"))]
// BoringSSL uses `!defined(OPENSSL_APPLE)`.
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
fn x25519_neon(out: &mut ops::EncodedPoint, scalar: &ops::MaskedScalar, point: &ops::EncodedPoint) {
prefixed_extern! {
fn x25519_NEON(
Expand Down

0 comments on commit 3e9e2eb

Please sign in to comment.