Skip to content

Commit 11978c1

Browse files
committed
make sure PKCS#5 iteration count is a "positive integer"
This fixes #552
1 parent c549f0f commit 11978c1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/misc/pkcs5/pkcs_5_1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ static int s_pkcs_5_alg1_common(const unsigned char *password,
5050
LTC_ARGCHK(out != NULL);
5151
LTC_ARGCHK(outlen != NULL);
5252

53+
if (iteration_count <= 0) {
54+
return CRYPT_INVALID_ARG;
55+
}
56+
5357
/* test hash IDX */
5458
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
5559
return err;

src/misc/pkcs5/pkcs_5_2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
3636
LTC_ARGCHK(out != NULL);
3737
LTC_ARGCHK(outlen != NULL);
3838

39+
if (iteration_count <= 0) {
40+
return CRYPT_INVALID_ARG;
41+
}
42+
3943
/* test hash IDX */
4044
if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
4145
return err;

0 commit comments

Comments
 (0)