Bug 1905691 - ChaChaXor to return after the function r=nss-reviewers,jschanck
authorAnna Weine <anna.weine@mozilla.com>
Wed, 17 Jul 2024 16:16:57 +0000 (12 months ago)
changeset 16940 525c5044cc9e53f5015c697b04b1405df91003ac
parent 16939 fbbfe0db0ecae5b599a696bef62ead35bd535ac3
child 16941 964825d7bfa1cb767164efbe41c22a977b3cac03
push id4569
push usernkulatova@mozilla.com
push dateWed, 17 Jul 2024 16:19:04 +0000 (12 months ago)
reviewersnss-reviewers, jschanck
bugs1905691
Bug 1905691 - ChaChaXor to return after the function r=nss-reviewers,jschanck Differential Revision: https://phabricator.services.mozilla.com/D215892
lib/freebl/chacha20poly1305.c
--- a/lib/freebl/chacha20poly1305.c
+++ b/lib/freebl/chacha20poly1305.c
@@ -210,33 +210,37 @@ ChaCha20Poly1305_DestroyContext(ChaCha20
 void
 ChaCha20Xor(uint8_t *output, uint8_t *block, uint32_t len, uint8_t *k,
             uint8_t *nonce, uint32_t ctr)
 {
 #ifdef NSS_X64
 #ifndef NSS_DISABLE_AVX2
     if (avx2_support()) {
         Hacl_Chacha20_Vec256_chacha20_encrypt_256(len, output, block, k, nonce, ctr);
+        return;
     }
 #endif
 
 #ifndef NSS_DISABLE_SSE3
     if (ssse3_support() && sse4_1_support() && avx_support()) {
         Hacl_Chacha20_Vec128_chacha20_encrypt_128(len, output, block, k, nonce, ctr);
+        return;
     }
 #endif
 
 #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
     !defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
     if (ppc_crypto_support()) {
         chacha20vsx(len, output, block, k, nonce, ctr);
-    } else
+        return;
+    }
 #endif
     {
         Hacl_Chacha20_chacha20_encrypt(len, output, block, k, nonce, ctr);
+        return;
     }
 }
 #endif /* NSS_DISABLE_CHACHAPOLY */
 
 SECStatus
 ChaCha20_Xor(unsigned char *output, const unsigned char *block, unsigned int len,
              const unsigned char *k, const unsigned char *nonce, PRUint32 ctr)
 {
@@ -446,26 +450,24 @@ ChaCha20Poly1305_Encrypt(const ChaCha20P
 #ifndef NSS_DISABLE_SSE3
     if (ssse3_support() && sse4_1_support() && avx_support()) {
         Hacl_Chacha20Poly1305_128_aead_encrypt(
             (uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, inputLen,
             (uint8_t *)input, output, outTag);
         goto finish;
     }
 #endif
-
-    else
 #elif defined(__powerpc64__) && defined(__LITTLE_ENDIAN__) && \
     !defined(NSS_DISABLE_ALTIVEC) && !defined(NSS_DISABLE_CRYPTO_VSX)
     if (ppc_crypto_support()) {
         Chacha20Poly1305_vsx_aead_encrypt(
             (uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, inputLen,
             (uint8_t *)input, output, outTag);
         goto finish;
-    } else
+    }
 #endif
     {
         Hacl_Chacha20Poly1305_32_aead_encrypt(
             (uint8_t *)ctx->key, (uint8_t *)nonce, adLen, (uint8_t *)ad, inputLen,
             (uint8_t *)input, output, outTag);
         goto finish;
     }