diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2023-01-30 17:47:01 +0000 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2023-04-04 16:07:17 +0900 |
commit | 4128f73d3a83c7f901924488c3bbf047b75db20f (patch) | |
tree | c448be817917e787c6285fb07da60c65898dd91f | |
parent | f2ab06bc3cccd1f6c9a012275d90df9f3956572b (diff) | |
download | libgcrypt-4128f73d3a83c7f901924488c3bbf047b75db20f.tar.gz |
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.
--
Cherry-picked master commit of:
137f1fd82bc9136d434ca41f58d62091b64df6db
GnuPG-bug-id: 6384
Reported-by: Andrew Collier
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
-rw-r--r-- | cipher/cipher-poly1305.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/cipher/cipher-poly1305.c b/cipher/cipher-poly1305.c index bb475236..9abd8b0c 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) { @@ -222,10 +224,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) { |