summaryrefslogtreecommitdiff
path: root/cipher/cipher.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2018-06-19 18:34:33 +0300
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2018-06-19 19:29:25 +0300
commit87d8caa47e00f1b1cea968fe38cf30c0ccc9749c (patch)
treeb6b5352e1dea7886886b213a5189f06ed188ca2a /cipher/cipher.c
parentf5168091c1930e948af8f25da11cad5dfa62c7ba (diff)
downloadlibgcrypt-87d8caa47e00f1b1cea968fe38cf30c0ccc9749c.tar.gz
Add separate handlers for CBC-CTS variant
* cipher/cipher-cbc.c (cbc_encrypt_inner, cbc_decrypt_inner) (_gcry_cipher_cbc_cts_encrypt, _gcry_cipher_cbc_cts_decrypt): New. (_gcry_cipher_cbc_encrypt, _gcry_cipher_cbc_decrypt): Remove CTS handling. * cipher/cipher-internal.h (_gcry_cipher_cbc_cts_encrypt) (_gcry_cipher_cbc_cts_decrypt): New. * cipher/cipher.c (cipher_encrypt, cipher_decrypt): Call CBC-CTS handler if CBC-CTS flag is set. -- Separate CTS handling to separate function for small decrease in CBC per call overhead. Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/cipher.c')
-rw-r--r--cipher/cipher.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 1b547a4b..54d00b46 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -1018,7 +1018,11 @@ cipher_encrypt (gcry_cipher_hd_t c, byte *outbuf, size_t outbuflen,
break;
case GCRY_CIPHER_MODE_CBC:
- rc = _gcry_cipher_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ if (!(c->flags & GCRY_CIPHER_CBC_CTS))
+ rc = _gcry_cipher_cbc_encrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ else
+ rc = _gcry_cipher_cbc_cts_encrypt (c, outbuf, outbuflen, inbuf,
+ inbuflen);
break;
case GCRY_CIPHER_MODE_CFB:
@@ -1153,7 +1157,11 @@ cipher_decrypt (gcry_cipher_hd_t c, byte *outbuf, size_t outbuflen,
break;
case GCRY_CIPHER_MODE_CBC:
- rc = _gcry_cipher_cbc_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ if (!(c->flags & GCRY_CIPHER_CBC_CTS))
+ rc = _gcry_cipher_cbc_decrypt (c, outbuf, outbuflen, inbuf, inbuflen);
+ else
+ rc = _gcry_cipher_cbc_cts_decrypt (c, outbuf, outbuflen, inbuf,
+ inbuflen);
break;
case GCRY_CIPHER_MODE_CFB: