Browse Source

make sure PKCS#5 iteration count is a "positive integer"

This fixes #552
Steffen Jaeckel 4 years ago
parent
commit
11978c16d7
2 changed files with 8 additions and 0 deletions
  1. 4 0
      src/misc/pkcs5/pkcs_5_1.c
  2. 4 0
      src/misc/pkcs5/pkcs_5_2.c

+ 4 - 0
src/misc/pkcs5/pkcs_5_1.c

@@ -50,6 +50,10 @@ static int s_pkcs_5_alg1_common(const unsigned char *password,
    LTC_ARGCHK(out      != NULL);
    LTC_ARGCHK(outlen   != NULL);
 
+   if (iteration_count <= 0) {
+      return CRYPT_INVALID_ARG;
+   }
+
    /* test hash IDX */
    if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
       return err;

+ 4 - 0
src/misc/pkcs5/pkcs_5_2.c

@@ -36,6 +36,10 @@ int pkcs_5_alg2(const unsigned char *password, unsigned long password_len,
    LTC_ARGCHK(out      != NULL);
    LTC_ARGCHK(outlen   != NULL);
 
+   if (iteration_count <= 0) {
+      return CRYPT_INVALID_ARG;
+   }
+
    /* test hash IDX */
    if ((err = hash_is_valid(hash_idx)) != CRYPT_OK) {
       return err;