- Small code rewrite
diff --git a/library/aes.c b/library/aes.c
index c355bfc..2f52202 100644
--- a/library/aes.c
+++ b/library/aes.c
@@ -888,7 +888,7 @@
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 @@
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] );