summaryrefslogtreecommitdiffstats
path: root/crypto/evp/evp_enc.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2001-10-17 00:37:12 +0000
committerDr. Stephen Henson <steve@openssl.org>2001-10-17 00:37:12 +0000
commit581f1c84940d77451c2592e9fa470893f6c3c3eb (patch)
tree33ebc8fc45b20aceff7589249bbc9a12282d543d /crypto/evp/evp_enc.c
parent41ebed27faa5e7b283313f97729a9f52746c1ac2 (diff)
Modify EVP cipher behaviour in a similar way
to digests to retain compatibility.
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r--crypto/evp/evp_enc.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 0f5a128d68..eb39539ca6 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -73,11 +73,14 @@ void EVP_CIPHER_CTX_init(EVP_CIPHER_CTX *ctx)
/* ctx->cipher=NULL; */
}
+
int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
const unsigned char *key, const unsigned char *iv, int enc)
{
+ EVP_CIPHER_CTX_init(ctx);
return EVP_CipherInit_ex(ctx,cipher,NULL,key,iv,enc);
}
+
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
const unsigned char *key, const unsigned char *iv, int enc)
{
@@ -187,6 +190,13 @@ int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
else return EVP_DecryptUpdate(ctx,out,outl,in,inl);
}
+int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
+ {
+ if (ctx->encrypt)
+ return EVP_EncryptFinal_ex(ctx,out,outl);
+ else return EVP_DecryptFinal_ex(ctx,out,outl);
+ }
+
int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
if (ctx->encrypt)
@@ -197,7 +207,7 @@ int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
const unsigned char *key, const unsigned char *iv)
{
- return EVP_CipherInit_ex(ctx, cipher, NULL, key, iv, 1);
+ return EVP_CipherInit(ctx, cipher, key, iv, 1);
}
int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx,const EVP_CIPHER *cipher, ENGINE *impl,
@@ -276,6 +286,14 @@ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
+ int ret;
+ ret = EVP_EncryptFinal_ex(ctx, out, outl);
+ EVP_CIPHER_CTX_cleanup(ctx);
+ return ret;
+ }
+
+int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
+ {
int i,n,b,bl,ret;
b=ctx->cipher->block_size;
@@ -359,6 +377,14 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
{
+ int ret;
+ ret = EVP_DecryptFinal_ex(ctx, out, outl);
+ EVP_CIPHER_CTX_cleanup(ctx);
+ return ret;
+ }
+
+int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl)
+ {
int i,b;
int n;