@@ -123,9 +123,7 @@ int scrypt_pbkdf(const unsigned char *password, unsigned long password_len,
123123 unsigned char * out , unsigned long outlen )
124124{
125125 unsigned char * B = NULL , * V = NULL , * XY = NULL ;
126- const unsigned char * pwd ;
127- unsigned long pwd_len , Blen , Vlen , XYlen , i ;
128- unsigned char zero_byte = 0 ;
126+ unsigned long Blen , Vlen , XYlen , i ;
129127 int err , hash_idx ;
130128
131129 LTC_ARGCHK (out != NULL );
@@ -143,15 +141,6 @@ int scrypt_pbkdf(const unsigned char *password, unsigned long password_len,
143141 hash_idx = find_hash ("sha256" );
144142 if (hash_idx == -1 ) return CRYPT_INVALID_HASH ;
145143
146- /* WORKAROUND: HMAC rejects zero-length keys; a single zero byte
147- * produces the same zero-padded key block as an empty key. */
148- pwd = password ;
149- pwd_len = password_len ;
150- if (pwd_len == 0 ) {
151- pwd = & zero_byte ;
152- pwd_len = 1 ;
153- }
154-
155144 Blen = 128 * r * p ;
156145 Vlen = 128 * r * N ;
157146 XYlen = 256 * r ;
@@ -167,7 +156,7 @@ int scrypt_pbkdf(const unsigned char *password, unsigned long password_len,
167156 /* 1: B = PBKDF2-HMAC-SHA256(password, salt, 1, p * 128 * r) */
168157 {
169158 unsigned long blen_out = Blen ;
170- err = pkcs_5_alg2 (pwd , pwd_len , salt , salt_len , 1 , hash_idx , B , & blen_out );
159+ err = pkcs_5_alg2 (password , password_len , salt , salt_len , 1 , hash_idx , B , & blen_out );
171160 if (err != CRYPT_OK ) goto cleanup ;
172161 }
173162 /* 2: for i = 0 to p-1: B[i] = ROMix(r, B[i], N) */
@@ -177,7 +166,7 @@ int scrypt_pbkdf(const unsigned char *password, unsigned long password_len,
177166 /* 3: DK = PBKDF2-HMAC-SHA256(password, B, 1, dkLen) */
178167 {
179168 unsigned long outlen_out = outlen ;
180- err = pkcs_5_alg2 (pwd , pwd_len , B , Blen , 1 , hash_idx , out , & outlen_out );
169+ err = pkcs_5_alg2 (password , password_len , B , Blen , 1 , hash_idx , out , & outlen_out );
181170 }
182171
183172cleanup :
0 commit comments