mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2025-12-23 15:55:10 +01:00
Merge remote-tracking branch 'public/pr/1099' into development-proposed
This commit is contained in:
commit
7904f94550
5 changed files with 261 additions and 8 deletions
|
|
@ -237,9 +237,13 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
|
|||
const unsigned char *iv, size_t iv_len )
|
||||
{
|
||||
size_t actual_iv_size;
|
||||
|
||||
if( NULL == ctx || NULL == ctx->cipher_info || NULL == iv )
|
||||
if( NULL == ctx || NULL == ctx->cipher_info )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
else if( NULL == iv && iv_len != 0 )
|
||||
return( MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA );
|
||||
|
||||
if( NULL == iv && iv_len == 0 )
|
||||
ctx->iv_size = 0;
|
||||
|
||||
/* avoid buffer overflow in ctx->iv */
|
||||
if( iv_len > MBEDTLS_MAX_IV_LENGTH )
|
||||
|
|
@ -268,8 +272,11 @@ int mbedtls_cipher_set_iv( mbedtls_cipher_context_t *ctx,
|
|||
}
|
||||
#endif
|
||||
|
||||
memcpy( ctx->iv, iv, actual_iv_size );
|
||||
ctx->iv_size = actual_iv_size;
|
||||
if ( actual_iv_size != 0 )
|
||||
{
|
||||
memcpy( ctx->iv, iv, actual_iv_size );
|
||||
ctx->iv_size = actual_iv_size;
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ static const mbedtls_cipher_info_t aes_128_ecb_info = {
|
|||
MBEDTLS_MODE_ECB,
|
||||
128,
|
||||
"AES-128-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
|
|
@ -269,7 +269,7 @@ static const mbedtls_cipher_info_t aes_192_ecb_info = {
|
|||
MBEDTLS_MODE_ECB,
|
||||
192,
|
||||
"AES-192-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
|
|
@ -280,7 +280,7 @@ static const mbedtls_cipher_info_t aes_256_ecb_info = {
|
|||
MBEDTLS_MODE_ECB,
|
||||
256,
|
||||
"AES-256-ECB",
|
||||
16,
|
||||
0,
|
||||
0,
|
||||
16,
|
||||
&aes_info
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue