fix ctr mode counter, add ctr test

This commit is contained in:
toorls
2022-09-06 05:34:27 -07:00
parent 60c3c33116
commit db06ccff49
2 changed files with 45 additions and 1 deletions

View File

@@ -95,7 +95,7 @@ int sm4_cbc_padding_decrypt(const SM4_KEY *key, const uint8_t iv[16],
static void ctr_incr(uint8_t a[16])
{
int i;
for (i = 15; i > 0; i--) {
for (i = 15; i >= 0; i--) {
a[i]++;
if (a[i]) break;
}