mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
Use local IV storage in e_aes_ebc_hmac_sha1.c
Inline the pre-13273237a65d46186b6bea0b51aec90670d4598a versions of EVP_CIPHER_CTX_iv(), EVP_CIPHER_CTX_original_iv(), and EVP_CIPHER_CTX_iv_noconst() in e_aes_cbc_hmac_sha1.c. For the legacy implementations, there's no need to use an in-provider storage for the IV, when the crypto operations themselves will be performed outside of the provider. Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12233)
This commit is contained in:
parent
9197c226ea
commit
18a49e168f
@ -26,6 +26,7 @@
|
||||
#include "crypto/modes.h"
|
||||
#include "crypto/evp.h"
|
||||
#include "internal/constant_time.h"
|
||||
#include "evp_local.h"
|
||||
|
||||
typedef struct {
|
||||
AES_KEY ks;
|
||||
@ -438,8 +439,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
&& (blocks = (plen - (sha_off + iv)) / SHA_CBLOCK)) {
|
||||
SHA1_Update(&key->md, in + iv, sha_off);
|
||||
|
||||
aesni_cbc_sha1_enc(in, out, blocks, &key->ks,
|
||||
EVP_CIPHER_CTX_iv_noconst(ctx),
|
||||
aesni_cbc_sha1_enc(in, out, blocks, &key->ks, ctx->iv,
|
||||
&key->md, in + iv + sha_off);
|
||||
blocks *= SHA_CBLOCK;
|
||||
aes_off += blocks;
|
||||
@ -471,10 +471,10 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
out[plen] = l;
|
||||
/* encrypt HMAC|padding at once */
|
||||
aesni_cbc_encrypt(out + aes_off, out + aes_off, len - aes_off,
|
||||
&key->ks, EVP_CIPHER_CTX_iv_noconst(ctx), 1);
|
||||
&key->ks, ctx->iv, 1);
|
||||
} else {
|
||||
aesni_cbc_encrypt(in + aes_off, out + aes_off, len - aes_off,
|
||||
&key->ks, EVP_CIPHER_CTX_iv_noconst(ctx), 1);
|
||||
&key->ks, ctx->iv, 1);
|
||||
}
|
||||
} else {
|
||||
union {
|
||||
@ -504,7 +504,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
return 0;
|
||||
|
||||
/* omit explicit iv */
|
||||
memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), in, AES_BLOCK_SIZE);
|
||||
memcpy(ctx->iv, in, AES_BLOCK_SIZE);
|
||||
|
||||
in += AES_BLOCK_SIZE;
|
||||
out += AES_BLOCK_SIZE;
|
||||
@ -525,7 +525,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
# endif
|
||||
/* decrypt HMAC|padding at once */
|
||||
aesni_cbc_encrypt(in, out, len, &key->ks,
|
||||
EVP_CIPHER_CTX_iv_noconst(ctx), 0);
|
||||
ctx->iv, 0);
|
||||
|
||||
/* figure out payload length */
|
||||
pad = out[len - 1];
|
||||
@ -761,7 +761,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
||||
# endif
|
||||
/* decrypt HMAC|padding at once */
|
||||
aesni_cbc_encrypt(in, out, len, &key->ks,
|
||||
EVP_CIPHER_CTX_iv_noconst(ctx), 0);
|
||||
ctx->iv, 0);
|
||||
|
||||
SHA1_Update(&key->md, out, len);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user