potatosalad / erlang-libdecaf

ed448goldilocks (libdecaf) NIF with timeslice reductions for Erlang and Elixir.
MIT License
29 stars 16 forks source link

libdecaf:sha3_256 with data larger than 20 KB is not working #7

Closed sunboshan closed 2 years ago

sunboshan commented 5 years ago

Calculate hash for data larger than 20KB is not working. However if use init, update, final it will work.

Maybe a bug?

libdecaf version is 1.0.0

1> libdecaf:sha3_256(crypto:strong_rand_bytes(20000)).
<<93,249,210,182,15,124,72,229,33,20,176,138,65,135,82,
  163,206,222,244,208,22,75,251,38,168,139,97,215,142,...>>
2> libdecaf:sha3_256(crypto:strong_rand_bytes(20001)).
** exception error: bad argument
     in function  libdecaf_nif:sha3_256/2
        called as libdecaf_nif:sha3_256(<<34,98,160,36,155,196,126,100,240,33,190,11,144,97,19,
                                          62,77,66,192,135,8,107,232,59,173,94,181,81,...>>,
                                        32)
3> A=libdecaf:sha3_256_init().
#Ref<0.4064849607.894304259.76062>
4> A1=libdecaf:sha3_256_update(A,crypto:strong_rand_bytes(20001)).
#Ref<0.4064849607.894304259.76071>
5> A2=libdecaf:sha3_256_final(A1).
<<245,119,68,134,35,255,171,203,72,190,28,202,220,140,43,
  76,93,199,100,241,128,144,31,112,59,145,161,55,35,...>>
potatosalad commented 2 years ago

This should be fixed as part of libdecaf version 2.0.0.