Skip to content

Commit ec61e07

Browse files
committed
wolfcrypt/src/pwdbased.c: in wc_PKCS12_PBKDF_ex(), refactor the "Increment B by 1" loop to avoid bugprone-inc-dec-in-conditions.
1 parent d36ddf4 commit ec61e07

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

wolfcrypt/src/pwdbased.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,9 +687,12 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen,
687687
PKCS12_ByteReverseWords(Bw, Bw, v);
688688
#endif
689689
/* Increment B by 1. */
690-
k = nwc;
691-
while ((k-- > 0) && (++Bw[k] == 0))
692-
;
690+
for (k = nwc; k > 0; ) {
691+
--k;
692+
++Bw[k];
693+
if (Bw[k] != 0)
694+
break;
695+
}
693696

694697
#ifndef BIG_ENDIAN_ORDER
695698
PKCS12_ByteReverseWords((PKCS12_WORD*)I, (PKCS12_WORD*)I, nBlocks * v);

0 commit comments

Comments
 (0)