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:
@@ -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 );
|
||||
}
|
||||
|
Reference in New Issue
Block a user