@@ -26,10 +26,7 @@ void AEADChaCha20Poly1305::SetKey(Span<const std::byte> key) noexcept
2626
2727namespace {
2828
29- #ifndef HAVE_TIMINGSAFE_BCMP
30- #define HAVE_TIMINGSAFE_BCMP
31-
32- int timingsafe_bcmp (const unsigned char * b1, const unsigned char * b2, size_t n) noexcept
29+ int timingsafe_bcmp_internal (const unsigned char * b1, const unsigned char * b2, size_t n) noexcept
3330{
3431 const unsigned char *p1 = b1, *p2 = b2;
3532 int ret = 0 ;
@@ -38,8 +35,6 @@ int timingsafe_bcmp(const unsigned char* b1, const unsigned char* b2, size_t n)
3835 return (ret != 0 );
3936}
4037
41- #endif
42-
4338/* * Compute poly1305 tag. chacha20 must be set to the right nonce, block 0. Will be at block 1 after. */
4439void ComputeTag (ChaCha20& chacha20, Span<const std::byte> aad, Span<const std::byte> cipher, Span<std::byte> tag) noexcept
4540{
@@ -93,7 +88,7 @@ bool AEADChaCha20Poly1305::Decrypt(Span<const std::byte> cipher, Span<const std:
9388 m_chacha20.Seek (nonce, 0 );
9489 std::byte expected_tag[EXPANSION];
9590 ComputeTag (m_chacha20, aad, cipher.first (cipher.size () - EXPANSION), expected_tag);
96- if (timingsafe_bcmp (UCharCast (expected_tag), UCharCast (cipher.last (EXPANSION).data ()), EXPANSION)) return false ;
91+ if (timingsafe_bcmp_internal (UCharCast (expected_tag), UCharCast (cipher.last (EXPANSION).data ()), EXPANSION)) return false ;
9792
9893 // Decrypt (starting at block 1).
9994 m_chacha20.Crypt (cipher.first (plain1.size ()), plain1);
0 commit comments