Sanity check lengths for AES wrap algorithm.
Reviewed-by: Tim Hudson <tjh@openssl.org>
(cherry picked from commit d12eef1501
)
This commit is contained in:
parent
6ccd120f5f
commit
6e1e5996df
2 changed files with 6 additions and 2 deletions
|
@ -2076,7 +2076,11 @@ static int aes_wrap_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
|
|||
EVP_AES_WRAP_CTX *wctx = ctx->cipher_data;
|
||||
size_t rv;
|
||||
if (inlen % 8)
|
||||
return 0;
|
||||
return -1;
|
||||
if (ctx->encrypt && inlen < 8)
|
||||
return -1;
|
||||
if (!ctx->encrypt && inlen < 16)
|
||||
return -1;
|
||||
if (!out)
|
||||
{
|
||||
if (ctx->encrypt)
|
||||
|
|
|
@ -106,7 +106,7 @@ size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv,
|
|||
unsigned char *A, B[16], *R;
|
||||
size_t i, j, t;
|
||||
inlen -= 8;
|
||||
if ((inlen & 0x7) || (inlen < 8) || (inlen > CRYPTO128_WRAP_MAX))
|
||||
if ((inlen & 0x7) || (inlen < 16) || (inlen > CRYPTO128_WRAP_MAX))
|
||||
return 0;
|
||||
A = B;
|
||||
t = 6 * (inlen >> 3);
|
||||
|
|
Loading…
Reference in a new issue