1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Merge pull request #5132 from openluopworld/origin/development_2.x

Backport 2.x: Fix GCM calculation with very long IV
This commit is contained in:
Gilles Peskine
2021-11-22 22:22:47 +01:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -257,6 +257,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
size_t i;
const unsigned char *p;
size_t use_len, olen = 0;
uint64_t iv_bits;
GCM_VALIDATE_RET( ctx != NULL );
GCM_VALIDATE_RET( iv != NULL );
@@ -286,7 +287,8 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
else
{
memset( work_buf, 0x00, 16 );
MBEDTLS_PUT_UINT32_BE( iv_len * 8, work_buf, 12 );
iv_bits = (uint64_t)iv_len * 8;
MBEDTLS_PUT_UINT64_BE( iv_bits, work_buf, 8 );
p = iv;
while( iv_len > 0 )