Decreate the length after decryption for the stitched ciphers

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12288)
This commit is contained in:
Matt Caswell 2020-06-23 14:34:45 +01:00
parent 09ce6e0854
commit f29dbb0866
4 changed files with 21 additions and 0 deletions

View File

@ -60,6 +60,8 @@ static int aesni_cbc_hmac_sha1_init_key(PROV_CIPHER_CTX *vctx,
ctx->payload_length = NO_PAYLOAD_LENGTH;
vctx->removetlspad = SHA_DIGEST_LENGTH + AES_BLOCK_SIZE;
return ret < 0 ? 0 : 1;
}

View File

@ -62,6 +62,8 @@ static int aesni_cbc_hmac_sha256_init_key(PROV_CIPHER_CTX *vctx,
ctx->payload_length = NO_PAYLOAD_LENGTH;
vctx->removetlspad = SHA256_DIGEST_LENGTH + AES_BLOCK_SIZE;
return ret < 0 ? 0 : 1;
}

View File

@ -358,6 +358,18 @@ int cipher_generic_stream_update(void *vctx, unsigned char *out, size_t *outl,
}
*outl = inl;
/*
* Remove any TLS padding. Only used by cipher_aes_cbc_hmac_sha1_hw.c and
* cipher_aes_cbc_hmac_sha256_hw.c
*/
if (!ctx->enc && ctx->removetlspad > 0) {
/* The actual padding length */
*outl -= out[inl - 1] + 1;
/* MAC and explicit IV */
*outl -= ctx->removetlspad;
}
return 1;
}
int cipher_generic_stream_final(void *vctx, unsigned char *out, size_t *outl,

View File

@ -58,6 +58,11 @@ struct prov_cipher_ctx_st {
* points into the user buffer.
*/
size_t tlsmacsize; /* Size of the TLS MAC */
size_t removetlspad; /*
* Length of the fixed size data to remove when
* removing TLS padding (equals mac size plus
* IV size if applicable)
*/
/*
* num contains the number of bytes of |iv| which are valid for modes that