Skip to content

Commit 88a3445

Browse files
committed
arm: Switch from denylisting Apple targets to allowlisting Android/Linux.
The allowlist approach is safer.
1 parent 9593d9b commit 88a3445

File tree

6 files changed

+6
-37
lines changed

6 files changed

+6
-37
lines changed

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ include = [
9999
"crypto/perlasm/x86gas.pl",
100100
"crypto/perlasm/x86nasm.pl",
101101
"crypto/perlasm/x86_64-xlate.pl",
102-
"crypto/poly1305/internal.h",
103102
"crypto/poly1305/poly1305.c",
104103
"crypto/poly1305/poly1305_arm.c",
105104
"crypto/poly1305/poly1305_arm_asm.S",

crypto/poly1305/internal.h

Lines changed: 0 additions & 25 deletions
This file was deleted.

crypto/poly1305/poly1305.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include <ring-core/poly1305.h>
2020

21-
#include "internal.h"
2221
#include "../internal.h"
2322

2423

crypto/poly1305/poly1305_arm.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@
1717

1818
#include <ring-core/poly1305.h>
1919

20-
#include "internal.h"
2120
#include "../internal.h"
2221

2322

24-
#if defined(OPENSSL_POLY1305_NEON)
25-
2623
#pragma GCC diagnostic ignored "-Wsign-conversion"
2724
#pragma GCC diagnostic ignored "-Wcast-align"
2825

@@ -304,5 +301,3 @@ void CRYPTO_poly1305_finish_neon(poly1305_state *state, uint8_t mac[16]) {
304301
h->v[8] += c->v[8];
305302
fe1305x2_tobytearray(mac, h);
306303
}
307-
308-
#endif // OPENSSL_POLY1305_NEON

src/aead/poly1305.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ macro_rules! dispatch {
5555
( $( $p:ident : $t:ty ),+ )
5656
( $( $a:expr ),+ ) ) => {
5757
match () {
58-
// Apple's 32-bit ARM ABI is incompatible with the assembly code.
59-
#[cfg(all(target_arch = "arm", not(target_vendor = "apple")))]
58+
// BoringSSL uses `!defined(OPENSSL_APPLE)`.
59+
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
6060
() if cpu::arm::NEON.available($features) => {
6161
prefixed_extern! {
6262
fn $neon_f( $( $p : $t ),+ );

src/ec/curve25519/x25519.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fn x25519_public_from_private(
6262
let private_key: &[u8; SCALAR_LEN] = private_key.bytes_less_safe().try_into()?;
6363
let private_key = ops::MaskedScalar::from_bytes_masked(*private_key);
6464

65-
#[cfg(all(not(target_vendor = "apple"), target_arch = "arm"))]
65+
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
6666
{
6767
if cpu::arm::NEON.available(cpu_features) {
6868
static MONTGOMERY_BASE_POINT: [u8; 32] = [
@@ -108,7 +108,7 @@ fn x25519_ecdh(
108108
point: &ops::EncodedPoint,
109109
#[allow(unused_variables)] cpu_features: cpu::Features,
110110
) {
111-
#[cfg(all(not(target_vendor = "apple"), target_arch = "arm"))]
111+
#[cfg(all(target_arch = "arm", any(target_os = "android", target_os = "linux")))]
112112
{
113113
if cpu::arm::NEON.available(cpu_features) {
114114
return x25519_neon(out, scalar, point);
@@ -157,7 +157,8 @@ fn x25519_ecdh(
157157
Ok(())
158158
}
159159

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

0 commit comments

Comments
 (0)