Open reynir opened 7 months ago
I struggled a bit with the tests as k Digestif.t
is opaque and we don't have the type equality k Digestif.t = k
:(
Do you have a reason to define type hmac
and not to use type ctx
?
Yes. type hmac = ctx * string
where the string is the "outer" part of the key. We could as well use ctx
, but then:
hmac_init
and hmac_get
would take the key whereas with this design only hmac_init
takes the key => room for mixing up keys at init and get.get
on a hmac ctx
which results in the wrong hmacinit
instead of hmac_init
or you might use empty
and compute a "hmac" with that and finally call hmac_get ~key ctx
to get a (wrong) hmac.Another possible solution is to define a type 'a ctx'
and use a phantom type to keep track of whether we're computing a hmac (where we must do some extra initial and final steps) or a digest.
Another possible solution is to define a type 'a ctx' and use a phantom type to keep track of whether we're computing a hmac (where we must do some extra initial and final steps) or a digest.
Yes but it will breaks the API. I'm ok with the initial change. I will merge that when I have a time :+1:.
Analogous to
ctx
andfeed_*
but for computing hmacs incrementally. For whenhmaci_*
is not suitable. Fixes #154.I'm open for suggestions in naming. The type
hmac
could behmac_ctx
for example, and the functions could befeed_hmac_bytes
instead ofhmac_feed_bytes
.