mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 11:54:19 +01:00
Cleanup of the GCM code
Removed unused variable 'v' orig_len and orig_add_len are now uint64_t to support larger than 2^29 data sizes
This commit is contained in:
parent
286bf3c501
commit
0ecdb23eed
@ -80,7 +80,7 @@ static void gcm_gen_table( gcm_context *ctx )
|
|||||||
|
|
||||||
for( i = 4; i > 0; i >>= 1 )
|
for( i = 4; i > 0; i >>= 1 )
|
||||||
{
|
{
|
||||||
uint32_t T = ( vl & 1 ) ? 0xe1000000U : 0;
|
uint32_t T = ( vl & 1 ) * 0xe1000000U;
|
||||||
vl = ( vh << 63 ) | ( vl >> 1 );
|
vl = ( vh << 63 ) | ( vl >> 1 );
|
||||||
vh = ( vh >> 1 ) ^ ( (uint64_t) T << 32);
|
vh = ( vh >> 1 ) ^ ( (uint64_t) T << 32);
|
||||||
|
|
||||||
@ -128,12 +128,10 @@ void gcm_mult( gcm_context *ctx, const unsigned char x[16], unsigned char output
|
|||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
unsigned char z[16];
|
unsigned char z[16];
|
||||||
unsigned char v[16];
|
|
||||||
unsigned char lo, hi, rem;
|
unsigned char lo, hi, rem;
|
||||||
uint64_t zh, zl;
|
uint64_t zh, zl;
|
||||||
|
|
||||||
memset( z, 0x00, 16 );
|
memset( z, 0x00, 16 );
|
||||||
memcpy( v, x, 16 );
|
|
||||||
|
|
||||||
lo = x[15] & 0xf;
|
lo = x[15] & 0xf;
|
||||||
hi = x[15] >> 4;
|
hi = x[15] >> 4;
|
||||||
@ -191,8 +189,8 @@ int gcm_crypt_and_tag( gcm_context *ctx,
|
|||||||
const unsigned char *p;
|
const unsigned char *p;
|
||||||
unsigned char *out_p = output;
|
unsigned char *out_p = output;
|
||||||
size_t use_len;
|
size_t use_len;
|
||||||
size_t orig_len = length * 8;
|
uint64_t orig_len = length * 8;
|
||||||
size_t orig_add_len = add_len * 8;
|
uint64_t orig_add_len = add_len * 8;
|
||||||
|
|
||||||
memset( y, 0x00, 16 );
|
memset( y, 0x00, 16 );
|
||||||
memset( work_buf, 0x00, 16 );
|
memset( work_buf, 0x00, 16 );
|
||||||
@ -280,8 +278,10 @@ int gcm_crypt_and_tag( gcm_context *ctx,
|
|||||||
{
|
{
|
||||||
memset( work_buf, 0x00, 16 );
|
memset( work_buf, 0x00, 16 );
|
||||||
|
|
||||||
PUT_UINT32_BE( orig_add_len , work_buf, 4 );
|
PUT_UINT32_BE( ( orig_add_len >> 32 ), work_buf, 0 );
|
||||||
PUT_UINT32_BE( orig_len , work_buf, 12 );
|
PUT_UINT32_BE( ( orig_add_len ), work_buf, 4 );
|
||||||
|
PUT_UINT32_BE( ( orig_len >> 32 ), work_buf, 8 );
|
||||||
|
PUT_UINT32_BE( ( orig_len ), work_buf, 12 );
|
||||||
|
|
||||||
for( i = 0; i < 16; i++ )
|
for( i = 0; i < 16; i++ )
|
||||||
buf[i] ^= work_buf[i];
|
buf[i] ^= work_buf[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user