diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2000-05-26 23:51:35 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2000-05-26 23:51:35 +0000 |
commit | 7f0606016cbbec917b1fe094b84b062e87abe7da (patch) | |
tree | 7238920f63ab28f7babc823ca9e8f18903e25192 /crypto/evp/evp_enc.c | |
parent | 7b224903f4d4e2c74d1548b6f0ca8b0ba31113ad (diff) | |
download | openssl-7f0606016cbbec917b1fe094b84b062e87abe7da.tar.gz |
Beginnings of EVP cipher overhaul. This should eventually
enhance and tidy up the EVP interface.
This patch adds initial support for variable length ciphers
and changes S/MIME code to use this.
Some other library functions need modifying to support use
of modified cipher parameters.
Also need to change all the cipher functions that should
return error codes, but currenly don't.
And of course it needs extensive testing...
Diffstat (limited to 'crypto/evp/evp_enc.c')
-rw-r--r-- | crypto/evp/evp_enc.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index 5299a65b6a..3f69c6052f 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -59,6 +59,7 @@ #include <stdio.h> #include "cryptlib.h" #include <openssl/evp.h> +#include <openssl/err.h> const char *EVP_version="EVP" OPENSSL_VERSION_PTEXT; @@ -99,7 +100,10 @@ void EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, unsigned char *key, unsigned char *iv) { if (cipher != NULL) + { ctx->cipher=cipher; + ctx->key_len = cipher->key_len; + } ctx->cipher->init(ctx,key,iv,1); ctx->encrypt=1; ctx->buf_len=0; @@ -109,7 +113,10 @@ void EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, unsigned char *key, unsigned char *iv) { if (cipher != NULL) + { ctx->cipher=cipher; + ctx->key_len = cipher->key_len; + } ctx->cipher->init(ctx,key,iv,0); ctx->encrypt=0; ctx->buf_len=0; @@ -268,3 +275,15 @@ void EVP_CIPHER_CTX_cleanup(EVP_CIPHER_CTX *c) memset(c,0,sizeof(EVP_CIPHER_CTX)); } +int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *c, int keylen) + { + if(c->key_len == keylen) return 1; + if((keylen > 0) && (c->cipher->flags & EVP_CIPH_VARIABLE_LENGTH)) + { + c->key_len = keylen; + return 1; + } + EVPerr(EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH,EVP_R_INVALID_KEY_LENGTH); + return 0; + } + |