<div dir="ltr"><br clear="all"><div>Hi All,</div><div><br></div><div>In the API gcry_kdf_scrypt implementation i see the below code.</div><div><br></div><div><div>240 gcry_err_code_t</div><div>241 _gcry_kdf_scrypt (const unsigned char *passwd, size_t passwdlen,</div><div>242 int algo, int subalgo,</div><div>243 const unsigned char *salt, size_t saltlen,</div><div>244 unsigned long iterations,</div><div>245 size_t dkLen, unsigned char *DK)</div><div>246 {</div><div>247 u64 N = subalgo; /* CPU/memory cost parameter. */</div><div>248 u32 r; /* Block size. */</div><div>249 u32 p = iterations; /* Parallelization parameter. */ <<<<<<<<<<<</div><div>250</div><div>251 gpg_err_code_t ec;</div><div>252 u32 i;</div><div>253 unsigned char *B = NULL;</div><div>254 unsigned char *tmp1 = NULL;</div><div>255 unsigned char *tmp2 = NULL;</div><div>256 size_t r128;</div><div>257 size_t nbytes;</div></div><div><br></div><div>Here iterations should have been assigned to N (CPU/memory cost supposed to be higher) but it is assigned to p (parallelization). The same wrapper api gcry_kdf_derive() api's iteration argument has been correcly used in _gcry_kdf_pkdf2().</div><div><br></div><div>when i set iterations to 20,000 (for PBKDF2) and 16384 (for scrypt) in gcry_kdf_derive(), on my machine PBKDF2 took less than a second to generate the key/hash where as scrypt took almost 35 minutes.</div><div><br></div><div>when i set iterations = 1 (subalgo) and subalgo = 16384, it took less than a second to generate the key.</div><div><br></div><div>Suggested fix:</div><div><br></div><div>1. Either we should document the arguments properly.</div><div><br></div><div>OR</div><div><br></div><div>2. </div><div><br></div><div><div> u64 N = iterations; /* CPU/memory cost parameter. */</div><div> u32 r; /* Block size. */</div><div> u32 p = subalgo; /* Parallelization parameter. */ <<<<<<<<<<<</div></div><div><br></div><div>Please let me know.</div><div><br></div><div>Thanks</div><div><br></div><div>P.S : I have raised a task on gnupg : <a href="https://dev.gnupg.org/T3737">https://dev.gnupg.org/T3737</a></div>
</div>