dd86k / blake2-d

Pure D implementation of BLAKE2 + DUB package
https://code.dlang.org/packages/blake2-d
Boost Software License 1.0
7 stars 1 forks source link

Fix HMAC usage #3

Open dd86k opened 2 years ago

dd86k commented 2 years ago

While the Digest API uses std.digest.hmac.HMAC for HMAC, which adds a secret hashed key using the template API, the way BLAKE2 does is just... Weird.

At initiation:

Which is simply not possible with the HMAC structure template. Unless there's a hack I don't know of.

dd86k commented 2 years ago

I think I could do a void key(scope const(ubyte)[] data...) function that performs a "second stage" initiation.

dd86k commented 2 years ago

Got key stuff in but that's not hmac so keeping this open.

dd86k commented 1 year ago

For the HMAC templates to work, the key needs to be initiated at compile-time. The issue is, while the default key is the IV, they are of different types in the s (uint) and b (ulong) variants.