diff options
Diffstat (limited to 'crypto/openssl/crypto/evp/e_idea.c')
-rw-r--r-- | crypto/openssl/crypto/evp/e_idea.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/crypto/openssl/crypto/evp/e_idea.c b/crypto/openssl/crypto/evp/e_idea.c index 8d3c88d..b9efa75 100644 --- a/crypto/openssl/crypto/evp/e_idea.c +++ b/crypto/openssl/crypto/evp/e_idea.c @@ -56,13 +56,14 @@ * [including the GNU Public Licence.] */ -#ifndef NO_IDEA +#ifndef OPENSSL_NO_IDEA #include <stdio.h> #include "cryptlib.h" #include <openssl/evp.h> #include <openssl/objects.h> #include "evp_locl.h" +#include <openssl/idea.h> static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv,int enc); @@ -75,17 +76,22 @@ static int idea_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, unsigned int inl) { BLOCK_CIPHER_ecb_loop() - idea_ecb_encrypt(in + i, out + i, &ctx->c.idea_ks); + idea_ecb_encrypt(in + i, out + i, ctx->cipher_data); return 1; } /* Can't use IMPLEMENT_BLOCK_CIPHER because idea_ecb_encrypt is different */ -BLOCK_CIPHER_func_cbc(idea, idea, idea_ks) -BLOCK_CIPHER_func_ofb(idea, idea, idea_ks) -BLOCK_CIPHER_func_cfb(idea, idea, idea_ks) +typedef struct + { + IDEA_KEY_SCHEDULE ks; + } EVP_IDEA_KEY; + +BLOCK_CIPHER_func_cbc(idea, idea, EVP_IDEA_KEY, ks) +BLOCK_CIPHER_func_ofb(idea, idea, 64, EVP_IDEA_KEY, ks) +BLOCK_CIPHER_func_cfb(idea, idea, 64, EVP_IDEA_KEY, ks) -BLOCK_CIPHER_defs(idea, idea_ks, NID_idea, 8, 16, 8, +BLOCK_CIPHER_defs(idea, IDEA_KEY_SCHEDULE, NID_idea, 8, 16, 8, 64, 0, idea_init_key, NULL, EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) @@ -96,14 +102,14 @@ static int idea_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_OFB_MODE) enc = 1; else if (EVP_CIPHER_CTX_mode(ctx) == EVP_CIPH_CFB_MODE) enc = 1; } - if (enc) idea_set_encrypt_key(key,&(ctx->c.idea_ks)); + if (enc) idea_set_encrypt_key(key,ctx->cipher_data); else { IDEA_KEY_SCHEDULE tmp; idea_set_encrypt_key(key,&tmp); - idea_set_decrypt_key(&tmp,&(ctx->c.idea_ks)); - memset((unsigned char *)&tmp,0, + idea_set_decrypt_key(&tmp,ctx->cipher_data); + OPENSSL_cleanse((unsigned char *)&tmp, sizeof(IDEA_KEY_SCHEDULE)); } return 1; |