1
0
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:
Paul Bakker
2012-04-18 14:16:09 +00:00
parent 7890405856
commit 369e14bbf1
3 changed files with 16 additions and 26 deletions

View File

@ -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] );