nisse@lysator.liu.se (Niels Möller) writes:
Simon Josefsson simon@josefsson.org writes:
nisse@lysator.liu.se (Niels Möller) writes:
If you can make an updated patch for manual and ChangeLog, that'd be great. I'll take care of the code.
Here it is.
Thanks. Checked in now. Hope I got all the pieces. I also added a PBKDF2 macro with the casting tricks.
Thank you!
And a pbkdf2_hmac_sha1 function can now be implemented as follows:
void pbkdf2_hmac_sha1 (unsigned key_length, const uint8_t *key, unsigned length, uint8_t *dst, unsigned iterations, unsigned salt_length, const uint8_t *salt) { struct hmac_sha1_ctx ctx; hmac_sha1_set_key (&ctx, key_length, key); PBKDF2 (&ctx, SHA1_DIGEST_SIZE, hmac_sha1_update, hmac_sha1_digest, length, dst, iterations, salt_length, salt); }
Could you add that, or should I submit a patch? I think having pbkdf2_hmac_sha256 as well would be good, but no others.
Any final interface tweaks? Is the order of the arguments sensible and consistent with other nettle interfaces? I.e., currently
void pbkdf2 (void *mac_ctx, unsigned digest_size, nettle_hash_update_func *update, nettle_hash_digest_func *digest, unsigned length, uint8_t *dst, unsigned iterations, unsigned salt_length, const uint8_t *salt);
Hmm, looking at cbc_encrypt/cbc_decrypt, it might be more consistent to (1) put digest_size after the function pointers, and (2) put the length, dst arguments last (this depends a bit on whether or not one wants to think of the salt as an src input or as some auxillary "parameter". At east the iteration count should go earlier in the list. So maybe
void pbkdf2 (void *mac_ctx, nettle_hash_update_func *update, nettle_hash_digest_func *digest, unsigned digest_size, unsigned iterations, unsigned salt_length, const uint8_t *salt, unsigned length, uint8_t *dst);
What do you think? This *is* nit-picking, but interface consistency is important and this is the right time to tweak it.
I prefer this new variant. The pbkdf2_hmac_* functions should follow this pattern too, so it would be:
void pbkdf2_hmac_sha1 (unsigned key_length, const uint8_t *key, unsigned iterations, unsigned salt_length, const uint8_t *salt, unsigned length, uint8_t *dst)
/Simon