Source code for fips.FIPS204.hash

import hashlib

[docs] class H: """ Shake 256 class """ def __init__(self): self.ctx = hashlib.shake_256()
[docs] def Absorb(self, input_bytestring: bytes): """ Injects data to be used in the absorbing phase of ``SHAKE256`` and updates context ctx. """ return self.ctx.update(input_bytestring)
[docs] def Squeeze(self, output_bytestring_length: int) -> bytes: """ Extracts 'output_bytestring_length' output bytes produced during the squeezing phase of ``SHAKE256`` and updates context ctx. """ return self.ctx.digest(output_bytestring_length)
[docs] class G: """ Shake 128 class """ def __init__(self): self.ctx = hashlib.shake_128()
[docs] def Absorb(self, input_bytestring: bytes): """ Injects data to be used in the absorbing phase of ``SHAKE256`` and updates context ctx. """ return self.ctx.update(input_bytestring)
[docs] def Squeeze(self, output_bytestring_length: int) -> bytes: """ Extracts 'output_bytestring_length' output bytes produced during the squeezing phase of ``SHAKE256`` and updates context ctx. """ return self.ctx.digest(output_bytestring_length)