libtom / libtomcrypt

LibTomCrypt is a fairly comprehensive, modular and portable cryptographic toolkit that provides developers with a vast array of well known published block ciphers, one-way hash functions, chaining modes, pseudo-random number generators, public key cryptography and a plethora of other routines.
https://www.libtom.net
Other
1.51k stars 449 forks source link

Support for reading SHAKE output in chunks. #615

Closed donaastor closed 1 year ago

donaastor commented 1 year ago

Could there be a mode in which one could read the output of SHAKE-128 and SHAKE-256 in chunks using some function like int sha3_shake_read(unsigned char *output, unsigned int length, hash_state *state) so that I can call it many times after I process the message? The current design allows only one read which means that I have to allocate a huge continuous block of memory if I want a huge hash.

sjaeckel commented 1 year ago

You can already do that, the hash_state is not terminated after calling sha3_shake_done().

   sha3_shake_done(&c, hash, 32);
   // has the same result as
   sha3_shake_done(&c, hash, 16);
   sha3_shake_done(&c, &hash[16], 16);
donaastor commented 1 year ago

@sjaeckel That's great! Thank you. Maybe it should be added in the documentation.

sjaeckel commented 1 year ago

Feel free to open a PR :)

donaastor commented 1 year ago

@sjaeckel It's interesting how I for real went to write that, but then shook it off my mind as it seemed too unimportant of a change. Good to be encouraged, but I'll admit it that I am a bit lost on internet in general, can you please just confirm this summary of what I need to do: I need to make a fork, then edit the file, then somehow finalize it and push for merge? Is that right? Or perhaps I can just download the file, edit it and upload the file alone somewhere? I apologize if I'm being a nuisance.

sjaeckel commented 1 year ago

I need to make a fork, then edit the file, then somehow finalize it and push for merge?

Indeed, that's the ideal way to go.

  1. click on the fork button on top of this repo's index page
  2. clone that fork to your hard disk
  3. checkout a fresh branch based on the develop branch and make your modifications
  4. build the changes, in your case you want to build the docs [^CI]
  5. commit your changes and push to your fork
  6. open a PR against this repo [^PR]

There are also multiple other ways to tackle this (GH web editor etc.), that's the way I would propose to go.

HTH

[^CI]: I'm not sure if you have a latex installation at hand (then it's just a make docs away) or how experienced you are with Docker (then you could run the texlive/texlive:latest-medium image and run make docs in there), but IME if you can't identify with one of the two options before and you can run Docker on your machine, the easiest way would be to use act. Install act on your machine, then run act -j Docs inside the checked out repo. This job will in the end fail, since it's trying to upload the generated pdf, but it will also show a [CI/Docs] ✅ Success - Main generate PDF if your changes were successfully built.

[^PR]: this will be automatically suggested by the GH homepage as soon as you pushed a new branch to your fork and visit either your fork's index page or this repo's index page