1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-10-12 18:44:56 +03:00

fix for issue 1118: check if iv is zero in gcm.

1) found by roberto in mbedtls forum
2) if iv_len is zero, return an error
3) add tests for invalid parameters
This commit is contained in:
Ron Eldor
2016-12-16 16:15:56 +02:00
committed by Simon Butcher
parent 53c2e47a1b
commit e2efaeaafc
9 changed files with 76 additions and 3 deletions

View File

@@ -277,8 +277,10 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
size_t use_len, olen = 0;
/* IV and AD are limited to 2^64 bits, so 2^61 bytes */
if( ( (uint64_t) iv_len ) >> 61 != 0 ||
( (uint64_t) add_len ) >> 61 != 0 )
/* IV is not allowed to be zero length */
if( iv_len == 0 ||
( (uint64_t) iv_len ) >> 61 != 0 ||
( (uint64_t) add_len ) >> 61 != 0 )
{
return( MBEDTLS_ERR_GCM_BAD_INPUT );
}