]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
cgo: Use the correct operation to re-align AES.
authorNick Mathewson <nickm@torproject.org>
Thu, 5 Jun 2025 20:12:24 +0000 (16:12 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 5 Jun 2025 20:12:50 +0000 (16:12 -0400)
By accident, this doesn't cause a bug, since 480 = 15*16*2.
Still, it's better to avoid problems in the future.

Closes #41091.

src/core/crypto/relay_crypto_cgo.c

index d3622de22883f00403cfea19579947e7ac8174ef..1e900861fe580c8eada22da48e27ccc96830d169 100644 (file)
@@ -190,7 +190,7 @@ cgo_prf_xor_t0(cgo_prf_t *prf, const uint8_t *input,
   // Re-align the cipher.
   //
   // This approach is faster than EVP_CIPHER_set_num!
-  const int ns = 16 - (PRF_T0_DATA_LEN % 0xf);
+  const int ns = 16 - (PRF_T0_DATA_LEN & 0xf);
   // We're not using the hash for anything, so it's okay to overwrite
   aes_crypt_inplace(prf->k, (char*)hash,  ns);
 }