summaryrefslogtreecommitdiff
path: root/cipher/cipher-ofb.c
diff options
context:
space:
mode:
authorJussi Kivilinna <jussi.kivilinna@iki.fi>2017-01-28 10:26:09 +0200
committerJussi Kivilinna <jussi.kivilinna@iki.fi>2017-01-28 12:02:38 +0200
commitefa9042f82ffed3d076b8e26ac62d29e00bb756a (patch)
tree02dce8950df7e553f1d6d214a8cd1e548d697807 /cipher/cipher-ofb.c
parente7b941c3de9c9b6319298c02f844cc0cadbf8562 (diff)
downloadlibgcrypt-efa9042f82ffed3d076b8e26ac62d29e00bb756a.tar.gz
cipher: add explicit blocksize checks to allow better optimization
* cipher/cipher-cbc.c (_gcry_cipher_cbc_encrypt) (_gcry_cipher_cbc_decrypt): Add explicit check for cipher blocksize of 64-bit or 128-bit. * cipher/cipher-cfb.c (_gcry_cipher_cfb_encrypt) (_gcry_cipher_cfb_decrypt): Ditto. * cipher/cipher-cmac.c (cmac_write, cmac_generate_subkeys) (cmac_final): Ditto. * cipher/cipher-ctr.c (_gcry_cipher_ctr_encrypt): Ditto. * cipher/cipher-ofb.c (_gcry_cipher_ofb_encrypt): Ditto. -- Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Diffstat (limited to 'cipher/cipher-ofb.c')
-rw-r--r--cipher/cipher-ofb.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cipher/cipher-ofb.c b/cipher/cipher-ofb.c
index 7db76580..f821d1be 100644
--- a/cipher/cipher-ofb.c
+++ b/cipher/cipher-ofb.c
@@ -40,6 +40,11 @@ _gcry_cipher_ofb_encrypt (gcry_cipher_hd_t c,
size_t blocksize = c->spec->blocksize;
unsigned int burn, nburn;
+ /* Tell compiler that we require a cipher with a 64bit or 128 bit block
+ * length, to allow better optimization of this function. */
+ if (blocksize > 16 || blocksize < 8 || blocksize & (8 - 1))
+ return GPG_ERR_INV_LENGTH;
+
if (outbuflen < inbuflen)
return GPG_ERR_BUFFER_TOO_SHORT;