mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-24 02:21:11 +00:00
Check input lengths in GCM
This commit is contained in:
parent
5bad6afd8c
commit
4467fb7507
|
@ -197,6 +197,15 @@ int gcm_crypt_and_tag( gcm_context *ctx,
|
||||||
uint64_t orig_len = length * 8;
|
uint64_t orig_len = length * 8;
|
||||||
uint64_t orig_add_len = add_len * 8;
|
uint64_t orig_add_len = add_len * 8;
|
||||||
|
|
||||||
|
/* 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 ||
|
||||||
|
tag_len > 16 || tag_len < 4 ||
|
||||||
|
length > 0x03FFFFE0llu )
|
||||||
|
{
|
||||||
|
return( POLARSSL_ERR_GCM_BAD_INPUT );
|
||||||
|
}
|
||||||
|
|
||||||
memset( y, 0x00, 16 );
|
memset( y, 0x00, 16 );
|
||||||
memset( work_buf, 0x00, 16 );
|
memset( work_buf, 0x00, 16 );
|
||||||
memset( tag, 0x00, tag_len );
|
memset( tag, 0x00, tag_len );
|
||||||
|
|
Loading…
Reference in a new issue