wolfcrypt/src/pwdbased.c: in wc_PKCS12_PBKDF_ex(), refactor the "Increment B by 1" loop to avoid bugprone-inc-dec-in-conditions.

This commit is contained in:
Daniel Pouzzner
2026-03-24 12:07:04 -05:00
parent d36ddf4063
commit ec61e07d18
+6 -3
View File
@@ -687,9 +687,12 @@ int wc_PKCS12_PBKDF_ex(byte* output, const byte* passwd, int passLen,
PKCS12_ByteReverseWords(Bw, Bw, v);
#endif
/* Increment B by 1. */
k = nwc;
while ((k-- > 0) && (++Bw[k] == 0))
;
for (k = nwc; k > 0; ) {
--k;
++Bw[k];
if (Bw[k] != 0)
break;
}
#ifndef BIG_ENDIAN_ORDER
PKCS12_ByteReverseWords((PKCS12_WORD*)I, (PKCS12_WORD*)I, nBlocks * v);