[haiku-development] Re: Crypto Kit Future?

  • From: Hamish Morrison <hamishm53@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 3 Mar 2016 20:05:53 +0000

On Thu, Mar 3, 2016 at 3:53 PM, Alexander von Gluck IV
<kallisti5@xxxxxxxxxxx> wrote:

Feedback *very* desired.  I don't like merging big things without community 
input :-)

As far as the API goes - there are a few issues I can see:

Would be better to take a const uint8_t* or const char* input - to
avoid implicit conversions to void*.
Would be nice to provide a way of getting the digest as raw bytes -
not everyone wants a hexadecimal string.
Name() and Position() seem unnecessary - let the user keep track of
these if they want.
Result() should probably be const - we can create a digest from the
bytes consumed so far without changing the state of our object.

Can we continue appending more data after calling Result()? Seems like
it should be possible but it would be nice for the API to say so.

Since BCryptoHash maintains a pointer to the private implementation,
you need to implement a copy constructor and assignment operator so
the state is copied (right now you will end up with dangling pointers
when one is destructed).

There seems to be a lot of unnecessary copying of data into stack
buffers in the implementation (which also uses non-standard variable
length arrays).

What is the purpose of MaxBuffer()? None of the libraries you use seem
to impose any limits in that regard.

Cheers
Hamish

Other related posts: