aboutsummaryrefslogtreecommitdiff
path: root/crypto/evp
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2002-03-16 23:20:05 +0000
committerDr. Stephen Henson <steve@openssl.org>2002-03-16 23:20:05 +0000
commit3e268d2717df4f74acddccf2ffe954f63b54b8a0 (patch)
treefa42cc83c246d5b5d3cbbc21da1cffa9723a0fc9 /crypto/evp
parentc46acbacde2b6976b91971669a8e759837123af3 (diff)
downloadopenssl-3e268d2717df4f74acddccf2ffe954f63b54b8a0.zip
openssl-3e268d2717df4f74acddccf2ffe954f63b54b8a0.tar.gz
openssl-3e268d2717df4f74acddccf2ffe954f63b54b8a0.tar.bz2
Ensure EVP_CipherInit() uses the correct encode/decode parameter if
enc == -1 [Reported by Markus Friedl <markus@openbsd.org>] Fix typo in dh_lib.c (use of DSAerr instead of DHerr).
Diffstat (limited to 'crypto/evp')
-rw-r--r--crypto/evp/evp_enc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c
index 22a7b74..d28a7d2 100644
--- a/crypto/evp/evp_enc.c
+++ b/crypto/evp/evp_enc.c
@@ -85,7 +85,14 @@ int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher,
int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, ENGINE *impl,
const unsigned char *key, const unsigned char *iv, int enc)
{
- if(enc && (enc != -1)) enc = 1;
+ if (enc == -1)
+ enc = ctx->encrypt;
+ else
+ {
+ if (enc)
+ enc = 1;
+ ctx->encrypt = enc;
+ }
/* Whether it's nice or not, "Inits" can be used on "Final"'d contexts
* so this context may already have an ENGINE! Try to avoid releasing
* the previous handle, re-querying for an ENGINE, and having a
@@ -184,7 +191,6 @@ skip_to_init:
if(key || (ctx->cipher->flags & EVP_CIPH_ALWAYS_CALL_INIT)) {
if(!ctx->cipher->init(ctx,key,iv,enc)) return 0;
}
- if(enc != -1) ctx->encrypt=enc;
ctx->buf_len=0;
ctx->final_used=0;
ctx->block_mask=ctx->cipher->block_size-1;