aboutsummaryrefslogtreecommitdiff
path: root/crypto/evp/evp_enc.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2001-10-02 16:19:49 +0000
committerDr. Stephen Henson <steve@openssl.org>2001-10-02 16:19:49 +0000
commitf329b8d73b52c7abd95eb4813f902bd85589c67b (patch)
treed3cff8b38dc44b7654c7b375b1ac0ea40b842ab6 /crypto/evp/evp_enc.c
parent3d90a324294ba440e73081c8fb955fa3cef93b6a (diff)
downloadopenssl-f329b8d73b52c7abd95eb4813f902bd85589c67b.zip
openssl-f329b8d73b52c7abd95eb4813f902bd85589c67b.tar.gz
openssl-f329b8d73b52c7abd95eb4813f902bd85589c67b.tar.bz2
Make EVP_DecryptUpdate work again.
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r--crypto/evp/evp_enc.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index ff7f770..3fbe5c6 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -302,7 +302,7 @@ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
const unsigned char *in, int inl)
{
- int b;
+ int b, fix_len;
if (inl == 0)
{
@@ -314,12 +314,17 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
return EVP_EncryptUpdate(ctx, out, outl, in, inl);
b=ctx->cipher->block_size;
+
if(ctx->final_used)
{
memcpy(out,ctx->final,b);
out+=b;
+ fix_len = 1;
}
-
+ else
+ fix_len = 0;
+
+
if(!EVP_EncryptUpdate(ctx,out,outl,in,inl))
return 0;
@@ -327,18 +332,16 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
* we have a copy of this last block */
if (b > 1 && !ctx->buf_len)
{
- if(!ctx->final_used)
- {
- *outl-=b;
- ctx->final_used=1;
- }
+ *outl-=b;
+ ctx->final_used=1;
memcpy(ctx->final,&out[*outl],b);
}
- else if(ctx->final_used)
- {
- ctx->final_used=0;
- *outl+=b;
- }
+ else
+ ctx->final_used = 0;
+
+ if (fix_len)
+ *outl += b;
+
return 1;
}