mirage / digestif

Simple hash algorithms in OCaml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

to_hex / of_hex without unitialized bytes in the implementation

cfcs opened this issue · comments

I believe the existing ocaml implementations are correct in src/digestif_conv.ml are correct, but they allocate buffers of unitialized (aka "old freed data") and overwrite them later, which gives me a nervous feeling.

I provided some example alternative implementations here:
https://github.com/mirage/digestif/pull/31/files/ac17c284be51994697de2e2fd09a4ca99edbb6a0#diff-0e4a0d0e4fd4a1679a3417f2c48841c2

  • My comment about to_hex avoiding branches doesn't make sense since the current implementation does not branch either.

  • My of_hex example is a bit complicated, but it was the best that I could come up with that matches the existing behavior. Not sure if it should be replaced by a cleaner version?

ping @dinosaure

Oh, I see you already opened issues for these, #32