Skip to content

Commit a9511e1

Browse files
committed
Add SP800-132 112 bit minimum applicable after stretch/strengthen
1 parent a365d38 commit a9511e1

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

wolfcrypt/src/pwdbased.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ int wc_PBKDF1_ex(byte* key, int keyLen, byte* iv, int ivLen,
183183
int wc_PBKDF1(byte* output, const byte* passwd, int pLen, const byte* salt,
184184
int sLen, int iterations, int kLen, int hashType)
185185
{
186+
186187
return wc_PBKDF1_ex(output, kLen, NULL, 0,
187188
passwd, pLen, salt, sLen, iterations, hashType, NULL);
188189
}
@@ -209,6 +210,15 @@ int wc_PBKDF2_ex(byte* output, const byte* passwd, int pLen, const byte* salt,
209210
return BAD_FUNC_ARG;
210211
}
211212

213+
#if FIPS_VERSION3_GE(6,0,0)
214+
/* Per SP800-132 section 5 "The kLen value shall be at least 112 bits in
215+
* length", ensure the returned bits for the derived master key are at a
216+
* minimum 14-bytes or 112-bits after stretching and strengthening
217+
* (iterations) */
218+
if (kLen < HMAC_FIPS_MIN_KEY/8)
219+
return BAD_LENGTH_E;
220+
#endif
221+
212222
if (iterations <= 0)
213223
iterations = 1;
214224

0 commit comments

Comments
 (0)