Browse Source

tweak definition of iteration count

David Rose 21 years ago
parent
commit
1711e96b18
2 changed files with 4 additions and 3 deletions
  1. 2 1
      panda/src/express/config_express.cxx
  2. 2 2
      panda/src/express/encryptStreamBuf.cxx

+ 2 - 1
panda/src/express/config_express.cxx

@@ -99,7 +99,8 @@ config_express.GetInt("encryption-key-length", 0);
 // a key when encrypting.  Its purpose is to make it computationally
 // a key when encrypting.  Its purpose is to make it computationally
 // more expensive for an attacker to search the key space
 // more expensive for an attacker to search the key space
 // exhaustively.  This should be a multiple of 1,000 and should not
 // exhaustively.  This should be a multiple of 1,000 and should not
-// exceed about 65 million.  This value is used only to control
+// exceed about 65 million; the value 0 indicates just one application
+// of the hashing algorithm.  This value is used only to control
 // encryption; the correct count will automatically be selected on
 // encryption; the correct count will automatically be selected on
 // decryption.
 // decryption.
 const int encryption_iteration_count =
 const int encryption_iteration_count =

+ 2 - 2
panda/src/express/encryptStreamBuf.cxx

@@ -131,7 +131,7 @@ open_read(istream *source, bool owns_source, const string &password) {
   result =
   result =
     PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(),
     PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(),
                            (unsigned char *)iv.data(), iv.length(), 
                            (unsigned char *)iv.data(), iv.length(), 
-                           count * iteration_count_factor, 
+                           count * iteration_count_factor + 1, 
                            key_length, key);
                            key_length, key);
   nassertv(result > 0);
   nassertv(result > 0);
 
 
@@ -232,7 +232,7 @@ open_write(ostream *dest, bool owns_dest, const string &password) {
   unsigned char *key = (unsigned char *)alloca(key_length);
   unsigned char *key = (unsigned char *)alloca(key_length);
   result =
   result =
     PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(),
     PKCS5_PBKDF2_HMAC_SHA1((const char *)password.data(), password.length(),
-                           iv, iv_length, count * iteration_count_factor,
+                           iv, iv_length, count * iteration_count_factor + 1,
                            key_length, key);
                            key_length, key);
   nassertv(result > 0);
   nassertv(result > 0);