summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorAndy Polyakov <appro@openssl.org>2011-05-30 10:10:05 +0000
committerAndy Polyakov <appro@openssl.org>2011-05-30 10:10:05 +0000
commite76cbcf686cf8f1c700da57aa65b2a31754dbbac (patch)
treeae4f21bcca05d26fd7b299f88a57be823873ca16 /crypto
parentd1fff483d6c27c2e434e80972ea84e1ddb1a2f09 (diff)
e_aes.c: fix aes_cfb1_cipher.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/evp/e_aes.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/crypto/evp/e_aes.c b/crypto/evp/e_aes.c
index 93d6d973e0..00bb519cfb 100644
--- a/crypto/evp/e_aes.c
+++ b/crypto/evp/e_aes.c
@@ -196,14 +196,30 @@ static int aes_cfb8_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
return 1;
}
+#define MAXBITCHUNK ((size_t)1<<(sizeof(size_t)*8-4))
+
static int aes_cfb1_cipher(EVP_CIPHER_CTX *ctx,unsigned char *out,
const unsigned char *in,size_t len)
{
- CRYPTO_cfb128_1_encrypt(in,out,len,ctx->cipher_data,
- ctx->iv,&ctx->num,ctx->encrypt,
- OPENSSL_ia32cap_P[1]&AESNI_CAPABLE ?
+ block128_f block = OPENSSL_ia32cap_P[1]&AESNI_CAPABLE ?
(block128_f)aesni_encrypt :
(block128_f)AES_encrypt);
+
+ if (ctx->flags&EVP_CIPH_FLAG_LENGTH_BITS) {
+ CRYPTO_cfb128_1_encrypt(in,out,len,ctx->cipher_data,
+ ctx->iv,&ctx->num,ctx->encrypt,block);
+ return 1;
+ }
+
+ while (len>=MAXBITCHUNK) {
+ CRYPTO_cfb128_1_encrypt(in,out,MAXBITCHUNK*8,ctx->cipher_data,
+ ctx->iv,&ctx->num,ctx->encrypt,block);
+ len-=MAXBITCHUNK;
+ }
+ if (len)
+ CRYPTO_cfb128_1_encrypt(in,out,len*8,ctx->cipher_data,
+ ctx->iv,&ctx->num,ctx->encrypt,block);
+
return 1;
}