Skip to content

Latest commit

 

History

History
42 lines (29 loc) · 1.59 KB

cshake128.rst

File metadata and controls

42 lines (29 loc) · 1.59 KB

cSHAKE128

cSHAKE128 is an extendable-output function (XOF) in the SHA-3 family, as specified in SP 800-185.

As a XOF, cSHAKE128 is a generalization of a cryptographic hash function. It is not limited to creating fixed-length digests (e.g., SHA-256 will always output exactly 32 bytes): it produces digests of any length, and it can be used as a Pseudo Random Generator (PRG).

Output bits do not depend on the output length.

The 128 in its name indicates its maximum security level (in bits), as described in Section 3.1 of SP 800-185.

cSHAKE128 is a customizable version of SHAKE128 and allows for additional domain separation via a customization string (custom parameter to Crypto.Hash.cSHAKE128.new).

Hint

For instance, if you are using cSHAKE128 in two applications, by picking different customization strings you can ensure that they will never end up using the same digest in practice. The important factor is that the strings are different; what the strings say does not matter.

If the customization string is empty, cSHAKE128 defaults back to shake128. See also Section 3.3 of SP 800-185.

In the following example, we extract 26 bytes (208 bits) from the XOF:

>>> from Crypto.Hash import cSHAKE128
>>>
>>> shake = cSHAKE128.new(custom=b'Email Signature')
>>> shake.update(b'Some data')
>>> print(shake.read(26).hex())

Crypto.Hash.cSHAKE128