diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:06:40 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-01-02 21:06:40 +0100 |
commit | f4a12fc67689a830e9da1c87fd11afe5bc09deb3 (patch) | |
tree | 211ae0cd022a6c11b0026ecc7761a550c584583c /security/nss/lib/freebl/gcm.c | |
parent | f7d30133221896638f7bf4f66c504255c4b14f48 (diff) | |
download | UXP-f4a12fc67689a830e9da1c87fd11afe5bc09deb3.tar UXP-f4a12fc67689a830e9da1c87fd11afe5bc09deb3.tar.gz UXP-f4a12fc67689a830e9da1c87fd11afe5bc09deb3.tar.lz UXP-f4a12fc67689a830e9da1c87fd11afe5bc09deb3.tar.xz UXP-f4a12fc67689a830e9da1c87fd11afe5bc09deb3.zip |
Issue #1338 - Part 2: Update NSS to 3.48-RTM
Diffstat (limited to 'security/nss/lib/freebl/gcm.c')
-rw-r--r-- | security/nss/lib/freebl/gcm.c | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/security/nss/lib/freebl/gcm.c b/security/nss/lib/freebl/gcm.c index e93970b88..737252eec 100644 --- a/security/nss/lib/freebl/gcm.c +++ b/security/nss/lib/freebl/gcm.c @@ -17,6 +17,12 @@ #include <limits.h> +/* old gcc doesn't support some poly64x2_t intrinsic */ +#if defined(__aarch64__) && defined(IS_LITTLE_ENDIAN) && \ + (defined(__clang__) || defined(__GNUC__) && __GNUC__ > 6) +#define USE_ARM_GCM +#endif + /* Forward declarations */ SECStatus gcm_HashInit_hw(gcmHashContext *ghash); SECStatus gcm_HashWrite_hw(gcmHashContext *ghash, unsigned char *outbuf); @@ -30,7 +36,7 @@ SECStatus gcm_HashMult_sftw32(gcmHashContext *ghash, const unsigned char *buf, /* Stub definitions for the above *_hw functions, which shouldn't be * used unless NSS_X86_OR_X64 is defined */ -#ifndef NSS_X86_OR_X64 +#if !defined(NSS_X86_OR_X64) && !defined(USE_ARM_GCM) && !defined(USE_PPC_CRYPTO) SECStatus gcm_HashWrite_hw(gcmHashContext *ghash, unsigned char *outbuf) { @@ -59,7 +65,7 @@ gcm_HashZeroX_hw(gcmHashContext *ghash) PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); return SECFailure; } -#endif /* NSS_X86_OR_X64 */ +#endif /* !NSS_X86_OR_X64 && !USE_ARM_GCM && !USE_PPC_CRYPTO */ uint64_t get64(const unsigned char *bytes) @@ -86,7 +92,13 @@ gcmHash_InitContext(gcmHashContext *ghash, const unsigned char *H, PRBool sw) ghash->h_low = get64(H + 8); ghash->h_high = get64(H); +#ifdef USE_ARM_GCM + if (arm_pmull_support() && !sw) { +#elif defined(USE_PPC_CRYPTO) + if (ppc_crypto_support() && !sw) { +#else if (clmul_support() && !sw) { +#endif rv = gcm_HashInit_hw(ghash); } else { /* We fall back to the software implementation if we can't use / don't @@ -531,6 +543,15 @@ GCM_CreateContext(void *context, freeblCipherFunc cipher, PORT_SetError(SEC_ERROR_INVALID_ARGS); return NULL; } + + if (gcmParams->ulTagBits != 128 && gcmParams->ulTagBits != 120 && + gcmParams->ulTagBits != 112 && gcmParams->ulTagBits != 104 && + gcmParams->ulTagBits != 96 && gcmParams->ulTagBits != 64 && + gcmParams->ulTagBits != 32) { + PORT_SetError(SEC_ERROR_INVALID_ARGS); + return NULL; + } + gcm = PORT_ZNew(GCMContext); if (gcm == NULL) { return NULL; |