Pārlūkot izejas kodu

rename arguments

Steffen Jaeckel 6 gadi atpakaļ
vecāks
revīzija
d4233e9156
3 mainītis faili ar 19 papildinājumiem un 19 dzēšanām
  1. 5 5
      doc/crypt.tex
  2. 4 4
      src/headers/tomcrypt_misc.h
  3. 10 10
      src/misc/bcrypt/bcrypt.c

+ 5 - 5
doc/crypt.tex

@@ -7106,13 +7106,13 @@ To hash a password with the bcrypt PBKDF algorithm, the following API function i
 
 \index{bcrypt()}
 \begin{alltt}
-int bcrypt_pbkdf_openbsd(const          char *password, unsigned long password_len,
-                         const unsigned char *salt,     unsigned long salt_len,
-                               unsigned int  rounds,              int hash_idx,
-                               unsigned char *out,      unsigned long *outlen);
+int bcrypt_pbkdf_openbsd(const          void *secret, unsigned long secret_len,
+                         const unsigned char *salt,   unsigned long salt_len,
+                               unsigned int  rounds,            int hash_idx,
+                               unsigned char *out,    unsigned long *outlen);
 \end{alltt}
 
-The \textit{password} parameter is the utf-8 encoded user password of length \textit{password\_len}.
+The \textit{secret} parameter is the secret of length \textit{secret\_len} (most of the time a utf-8 encoded user password).
 The \textit{salt} parameter is a pointer to the array of octets of length \textit{salt\_len} containing the salt.
 The \textit{rounds} parameter defines the number of iterations of the expensive key setup that shall be executed.
 The \textit{hash\_idx} parameter defines the hash algorithm that shall be used. 

+ 4 - 4
src/headers/tomcrypt_misc.h

@@ -60,10 +60,10 @@ int base16_decode(const          char *in,  unsigned long  inlen,
 #endif
 
 #ifdef LTC_BCRYPT
-int bcrypt_pbkdf_openbsd(const          char *password, unsigned long password_len,
-                         const unsigned char *salt,     unsigned long salt_len,
-                               unsigned int  rounds,              int hash_idx,
-                               unsigned char *out,      unsigned long *outlen);
+int bcrypt_pbkdf_openbsd(const          void *secret, unsigned long secret_len,
+                         const unsigned char *salt,   unsigned long salt_len,
+                               unsigned int  rounds,            int hash_idx,
+                               unsigned char *out,    unsigned long *outlen);
 #endif
 
 /* ===> LTC_HKDF -- RFC5869 HMAC-based Key Derivation Function <=== */

+ 10 - 10
src/misc/bcrypt/bcrypt.c

@@ -78,10 +78,10 @@ static int _bcrypt_pbkdf_hash(const unsigned char *pass, unsigned long passlen,
    @param outlen            [in/out] The desired size of the algorithm output
    @return CRYPT_OK if successful
 */
-int bcrypt_pbkdf_openbsd(const          char *password, unsigned long password_len,
-                         const unsigned char *salt,     unsigned long salt_len,
-                               unsigned int  rounds,              int hash_idx,
-                               unsigned char *out,      unsigned long *outlen)
+int bcrypt_pbkdf_openbsd(const          void *secret, unsigned long secret_len,
+                         const unsigned char *salt,   unsigned long salt_len,
+                               unsigned int  rounds,            int hash_idx,
+                               unsigned char *out,    unsigned long *outlen)
 {
    int err;
    ulong32 blkno;
@@ -89,12 +89,12 @@ int bcrypt_pbkdf_openbsd(const          char *password, unsigned long password_l
    unsigned char *buf[3], blkbuf[4];
    unsigned char *hashed_pass;
 
-   LTC_ARGCHK(password != NULL);
-   LTC_ARGCHK(salt     != NULL);
-   LTC_ARGCHK(out      != NULL);
-   LTC_ARGCHK(outlen   != NULL);
+   LTC_ARGCHK(secret != NULL);
+   LTC_ARGCHK(salt   != NULL);
+   LTC_ARGCHK(out    != NULL);
+   LTC_ARGCHK(outlen != NULL);
 
-   if ((password_len == 0) || (salt_len == 0) || (*outlen == 0)) {
+   if ((secret_len == 0) || (salt_len == 0) || (*outlen == 0)) {
       return CRYPT_INVALID_ARG;
    }
    /* test hash IDX */
@@ -127,7 +127,7 @@ int bcrypt_pbkdf_openbsd(const          char *password, unsigned long password_l
    steps = (*outlen + step_size - 1) / step_size;
 
    hashed_pass_len = MAXBLOCKSIZE;
-   if ((err = hash_memory(hash_idx, (unsigned char*)password, password_len, hashed_pass, &hashed_pass_len)) != CRYPT_OK) {
+   if ((err = hash_memory(hash_idx, (unsigned char*)secret, secret_len, hashed_pass, &hashed_pass_len)) != CRYPT_OK) {
       goto LBL_ERR;
    }