diff options
author | Ben Laurie <ben@openssl.org> | 2001-07-08 19:42:10 +0000 |
---|---|---|
committer | Ben Laurie <ben@openssl.org> | 2001-07-08 19:42:10 +0000 |
commit | 7b6055d1afaf6eed5e422c342be33f34304430b3 (patch) | |
tree | 0f76ded098e067b61bf02b414f92b218a4f9e153 /crypto/evp/evp_enc.c | |
parent | f31b12503e6de9252d552b35df3e6e0f1f217b68 (diff) |
Handle the common case first (where input size is a multiple of block size).
Worth around 5% for encrypt. Slows down decrypt slightly, but I expect to
regain that later.
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r-- | crypto/evp/evp_enc.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index ae1a22ebb8..d723d095c1 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -162,8 +162,25 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, i=ctx->buf_len; bl=ctx->cipher->block_size; + if ((inl == 0) && (i != bl)) + { + *outl=0; + return 1; + } + if(i == 0 && (inl&(bl-1)) == 0) + { + if(ctx->cipher->do_cipher(ctx,out,in,inl)) + { + *outl=inl; + return 1; + } + else + { + *outl=0; + return 0; + } + } *outl=0; - if ((inl == 0) && (i != bl)) return 1; if (i != 0) { if (i+inl < bl) @@ -183,7 +200,6 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl, *outl+=bl; } } - // i=inl%bl; /* how much is left */ i=inl&(bl-1); inl-=i; if (inl > 0) |