On Tue, 2017-05-16 at 22:47 +0200, Niels Möller wrote:
and a comment in .bootstrap for the testsuite/.test-rules.make which I always seem to forget and spend an hour figuring out what is going on. Ideally .test-rules.make should depend on Makefile.in.
Have you tested if it works to just add that dependency?
It seems to do. The first patch attached does just that.
+void
+hkdf_extract(void *mac_ctx,
- nettle_hmac_set_key_func *set_key,
- nettle_hash_update_func *update,
- nettle_hash_digest_func *digest,
- size_t digest_size,
- size_t salt_size, const uint8_t *salt,
- size_t secret_size, const uint8_t *secret,
- uint8_t *dst)
+{
- set_key(mac_ctx, salt_size, salt);
- update(mac_ctx, secret_size, secret);
- digest(mac_ctx, digest_size, dst);
+}
This looks like a plain application of a mac, digest = MAC(salt, secret), is this really useful?
I've kept it because it makes the mapping from RFC to hkdf.h simpler. Let me know if you would prefer a macro or inline function.
Not sure about the typedef nettle_hmac_set_key_func, there's nothing hmac specific, besides key size being variable? And it's identical to nettle_hash_update_func, right?
No longer there.
- while(left > 0) {
/* T(i) */set_key(mac_ctx, prk_size, prk);if (started != 0) {update(mac_ctx, digest_size, Ttmp);} else {started = 1;}if (info_size)update(mac_ctx, info_size, info);update(mac_ctx, 1, &i);if (left < digest_size)digest_size = left;digest(mac_ctx, digest_size, dst);Ttmp = dst;left -= digest_size;dst += digest_size;i++;- }
I think this loop would clearer if Ttmp was replaced by (dst - digest_size), and maybe it would make sense to take out the first and/or final iterations.
Patch 0005 unrolls the first loop and does that change. I find that longer and not as easy to follow, but I may have not caught what you meant.
The last patch adds documentation for the added functions.
regards, Nikos