From 137f1fd82bc9136d434ca41f58d62091b64df6db Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Mon, 30 Jan 2023 17:47:01 +0000 Subject: cipher: Enable the fast path to ChaCha20 only when supported. cipher/cipher-poly1305.c (_gcry_cipher_poly1305_encrypt) (_gcry_cipher_poly1305_decrypt) [USE_CHACHA20]: Conditionalize. -- GnuPG-bug-id: 6384 Reported-by: Andrew Collier Signed-off-by: NIIBE Yutaka --- cipher/cipher-poly1305.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cipher') diff --git a/cipher/cipher-poly1305.c b/cipher/cipher-poly1305.c index 5cd3561b..0fd3e4e0 100644 --- a/cipher/cipher-poly1305.c +++ b/cipher/cipher-poly1305.c @@ -164,10 +164,12 @@ _gcry_cipher_poly1305_encrypt (gcry_cipher_hd_t c, return GPG_ERR_INV_LENGTH; } +#ifdef USE_CHACHA20 if (LIKELY(inbuflen > 0) && LIKELY(c->spec->algo == GCRY_CIPHER_CHACHA20)) { return _gcry_chacha20_poly1305_encrypt (c, outbuf, inbuf, inbuflen); } +#endif while (inbuflen) { @@ -224,10 +226,12 @@ _gcry_cipher_poly1305_decrypt (gcry_cipher_hd_t c, return GPG_ERR_INV_LENGTH; } +#ifdef USE_CHACHA20 if (LIKELY(inbuflen > 0) && LIKELY(c->spec->algo == GCRY_CIPHER_CHACHA20)) { return _gcry_chacha20_poly1305_decrypt (c, outbuf, inbuf, inbuflen); } +#endif while (inbuflen) { -- cgit v1.2.1