mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
Use local IV storage in EVP BLOCK_* macros
Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and EVP_CIPHER_CTX_iv_noconst() in evp.h. These macros are internal-only, used to implement legacy libcrypto EVP ciphers, with no real provider involvement. Accordingly, just use the EVP_CIPHER_CTX storage directly and don't try to reach into a provider-side context. This does necessitate including evp_local.h in several more files. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12233)
This commit is contained in:
parent
d91f902d73
commit
2f5c405a16
@ -20,6 +20,7 @@
|
||||
# include "crypto/evp.h"
|
||||
# include <openssl/objects.h>
|
||||
# include <openssl/blowfish.h>
|
||||
# include "evp_local.h"
|
||||
|
||||
static int bf_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc);
|
||||
|
@ -21,6 +21,7 @@
|
||||
# include <openssl/objects.h>
|
||||
# include "crypto/evp.h"
|
||||
# include <openssl/cast.h>
|
||||
# include "evp_local.h"
|
||||
|
||||
static int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc);
|
||||
|
@ -22,6 +22,7 @@
|
||||
# include <openssl/objects.h>
|
||||
# include "crypto/evp.h"
|
||||
# include <openssl/idea.h>
|
||||
# include "evp_local.h"
|
||||
|
||||
/* Can't use IMPLEMENT_BLOCK_CIPHER because IDEA_ecb_encrypt is different */
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
# include <openssl/objects.h>
|
||||
# include "crypto/evp.h"
|
||||
# include <openssl/rc2.h>
|
||||
# include "evp_local.h"
|
||||
|
||||
static int rc2_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <assert.h>
|
||||
#include <openssl/seed.h>
|
||||
#include "crypto/evp.h"
|
||||
#include "evp_local.h"
|
||||
|
||||
static int seed_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
|
||||
const unsigned char *iv, int enc);
|
||||
|
@ -311,7 +311,7 @@ static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns
|
||||
{\
|
||||
while(inl>=EVP_MAXCHUNK) {\
|
||||
int num = EVP_CIPHER_CTX_num(ctx);\
|
||||
cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
|
||||
cprefix##_ofb##cbits##_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, &num); \
|
||||
EVP_CIPHER_CTX_set_num(ctx, num);\
|
||||
inl-=EVP_MAXCHUNK;\
|
||||
in +=EVP_MAXCHUNK;\
|
||||
@ -319,7 +319,7 @@ static int cname##_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns
|
||||
}\
|
||||
if (inl) {\
|
||||
int num = EVP_CIPHER_CTX_num(ctx);\
|
||||
cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), &num); \
|
||||
cprefix##_ofb##cbits##_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, &num); \
|
||||
EVP_CIPHER_CTX_set_num(ctx, num);\
|
||||
}\
|
||||
return 1;\
|
||||
@ -330,13 +330,13 @@ static int cname##_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const uns
|
||||
{\
|
||||
while(inl>=EVP_MAXCHUNK) \
|
||||
{\
|
||||
cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
|
||||
cprefix##_cbc_encrypt(in, out, (long)EVP_MAXCHUNK, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, EVP_CIPHER_CTX_encrypting(ctx));\
|
||||
inl-=EVP_MAXCHUNK;\
|
||||
in +=EVP_MAXCHUNK;\
|
||||
out+=EVP_MAXCHUNK;\
|
||||
}\
|
||||
if (inl)\
|
||||
cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx), EVP_CIPHER_CTX_encrypting(ctx));\
|
||||
cprefix##_cbc_encrypt(in, out, (long)inl, &EVP_C_DATA(kstruct,ctx)->ksched, ctx->iv, EVP_CIPHER_CTX_encrypting(ctx));\
|
||||
return 1;\
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ static int cname##_cfb##cbits##_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
((cbits == 1) \
|
||||
&& !EVP_CIPHER_CTX_test_flags(ctx, EVP_CIPH_FLAG_LENGTH_BITS) \
|
||||
? chunk*8 : chunk), \
|
||||
&EVP_C_DATA(kstruct, ctx)->ksched, EVP_CIPHER_CTX_iv_noconst(ctx),\
|
||||
&EVP_C_DATA(kstruct, ctx)->ksched, ctx->iv,\
|
||||
&num, EVP_CIPHER_CTX_encrypting(ctx));\
|
||||
EVP_CIPHER_CTX_set_num(ctx, num);\
|
||||
inl -= chunk;\
|
||||
|
Loading…
Reference in New Issue
Block a user