sha3 internal state export & import

rmlibre at riseup.net rmlibre at riseup.net
Fri Aug 27 13:35:09 EDT 2021


The hashlib module's SHA3 functions (specifically, sha3_256 & sha3_512)
are not able to be pickled as far as I'm able to see. I know that the
internal state of a SHA3 object can be easily represented by two unique
values, the 1600-bit `S`-state value, and the last, smaller than
`r`-rate number of bits (1088 for sha3_256, and 576 for sha3_512) of
data which have not yet been incorporated into the `S`-state.

Is there a simple way to export these two internal values from a
sha3_256 or sha3_512 object, and conversely, a simple way to import
these two exported values back into a new object? The goal is to be able
to pause a hash object, then to store the state for some later time at
which a new object can be created that's functionally equivalent to the
first. Is there a simple way to do this?

Best,
rmlibre


More information about the Python-list mailing list