mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
- Small code rewrite
This commit is contained in:
@ -888,7 +888,7 @@ int aes_crypt_ctr( aes_context *ctx,
|
||||
const unsigned char *input,
|
||||
unsigned char *output )
|
||||
{
|
||||
int c, i, cb;
|
||||
int c, i;
|
||||
size_t n = *nc_off;
|
||||
|
||||
while( length-- )
|
||||
@ -896,12 +896,9 @@ int aes_crypt_ctr( aes_context *ctx,
|
||||
if( n == 0 ) {
|
||||
aes_crypt_ecb( ctx, AES_ENCRYPT, nonce_counter, stream_block );
|
||||
|
||||
i = 15;
|
||||
do {
|
||||
nonce_counter[i]++;
|
||||
cb = nonce_counter[i] == 0;
|
||||
} while( i-- && cb );
|
||||
|
||||
for( i = 16; i > 0; i-- )
|
||||
if( ++nonce_counter[i - 1] != 0 )
|
||||
break;
|
||||
}
|
||||
c = *input++;
|
||||
*output++ = (unsigned char)( c ^ stream_block[n] );
|
||||
|
Reference in New Issue
Block a user