diff options
author | Adam Langley <agl@google.com> | 2015-01-10 02:44:37 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2015-01-15 02:38:11 +0300 |
commit | 3e6526575ac2349a44a04a0bbc7acb917fab5a0b (patch) | |
tree | 51f4fbc4677ec256a8ff1f747df201f13ed50157 /crypto/bn/generic.c | |
parent | bc44c089fbd87de0924130453058131ce30cd483 (diff) |
aarch64 support.
This is an initial cut at aarch64 support. I have only qemu to test it
however—hopefully hardware will be coming soon.
This also affects 32-bit ARM in that aarch64 chips can run 32-bit code
and we would like to be able to take advantage of the crypto operations
even in 32-bit mode. AES and GHASH should Just Work in this case: the
-armx.pl files can be built for either 32- or 64-bit mode based on the
flavour argument given to the Perl script.
SHA-1 and SHA-256 don't work like this however because they've never
support for multiple implementations, thus BoringSSL built for 32-bit
won't use the SHA instructions on an aarch64 chip.
No dedicated ChaCha20 or Poly1305 support yet.
Change-Id: Ib275bc4894a365c8ec7c42f4e91af6dba3bd686c
Reviewed-on: https://boringssl-review.googlesource.com/2801
Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'crypto/bn/generic.c')
-rw-r--r-- | crypto/bn/generic.c | 81 |
1 files changed, 3 insertions, 78 deletions
diff --git a/crypto/bn/generic.c b/crypto/bn/generic.c index 8b3b0f87..224a47cf 100644 --- a/crypto/bn/generic.c +++ b/crypto/bn/generic.c @@ -130,40 +130,8 @@ BN_UMULT_LOHI(r0, r1, tmp, tmp); \ } -#elif defined(BN_UMULT_HIGH) -#define mul_add(r, a, w, c) \ - { \ - BN_ULONG high, low, ret, tmp = (a); \ - ret = (r); \ - high = BN_UMULT_HIGH(w, tmp); \ - ret += (c); \ - low = (w) * tmp; \ - (c) = (ret < (c)) ? 1 : 0; \ - (c) += high; \ - ret += low; \ - (c) += (ret < low) ? 1 : 0; \ - (r) = ret; \ - } - -#define mul(r, a, w, c) \ - { \ - BN_ULONG high, low, ret, ta = (a); \ - low = (w) * ta; \ - high = BN_UMULT_HIGH(w, ta); \ - ret = low + (c); \ - (c) = high; \ - (c) += (ret < low) ? 1 : 0; \ - (r) = ret; \ - } - -#define sqr(r0, r1, a) \ - { \ - BN_ULONG tmp = (a); \ - (r0) = tmp * tmp; \ - (r1) = BN_UMULT_HIGH(tmp, tmp); \ - } - #else + /************************************************************* * No long long type */ @@ -424,7 +392,7 @@ void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n) { #endif /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */ -#if defined(BN_LLONG) && defined(BN_DIV2W) +#if defined(BN_LLONG) BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { return (BN_ULONG)(((((BN_ULLONG)h) << BN_BITS2) | l) / (BN_ULLONG)d); @@ -502,7 +470,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { return ret; } -#endif /* !defined(BN_LLONG) && defined(BN_DIV2W) */ +#endif /* !defined(BN_LLONG) */ #ifdef BN_LLONG BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, @@ -749,49 +717,6 @@ BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, #define sqr_add_c2(a, i, j, c0, c1, c2) mul_add_c2((a)[i], (a)[j], c0, c1, c2) -#elif defined(BN_UMULT_HIGH) - -/* Keep in mind that additions to hi can not overflow, because - * the high word of a multiplication result cannot be all-ones. */ -#define mul_add_c(a, b, c0, c1, c2) \ - do { \ - BN_ULONG ta = (a), tb = (b); \ - BN_ULONG lo = ta * tb; \ - BN_ULONG hi = BN_UMULT_HIGH(ta, tb); \ - c0 += lo; \ - hi += (c0 < lo) ? 1 : 0; \ - c1 += hi; \ - c2 += (c1 < hi) ? 1 : 0; \ - } while (0) - -#define mul_add_c2(a, b, c0, c1, c2) \ - do { \ - BN_ULONG ta = (a), tb = (b), tt; \ - BN_ULONG lo = ta * tb; \ - BN_ULONG hi = BN_UMULT_HIGH(ta, tb); \ - c0 += lo; \ - tt = hi + ((c0 < lo) ? 1 : 0); \ - c1 += tt; \ - c2 += (c1 < tt) ? 1 : 0; \ - c0 += lo; \ - hi += (c0 < lo) ? 1 : 0; \ - c1 += hi; \ - c2 += (c1 < hi) ? 1 : 0; \ - } while (0) - -#define sqr_add_c(a, i, c0, c1, c2) \ - do { \ - BN_ULONG ta = (a)[i]; \ - BN_ULONG lo = ta * ta; \ - BN_ULONG hi = BN_UMULT_HIGH(ta, ta); \ - c0 += lo; \ - hi += (c0 < lo) ? 1 : 0; \ - c1 += hi; \ - c2 += (c1 < hi) ? 1 : 0; \ - } while (0) - -#define sqr_add_c2(a, i, j, c0, c1, c2) mul_add_c2((a)[i], (a)[j], c0, c1, c2) - #else /* !BN_LLONG */ /* Keep in mind that additions to hi can not overflow, because |