Common Lisp Package: SHA3

README:

FUNCTION

Public

SHA3-COPY (STATE)

Return an independent copy of the SHA-3 state `state'.

SHA3-DIGEST-FILE (PATHNAME &KEY (OUTPUT-BIT-LENGTH 512))

Calculate an SHA-3 message-digest of the file specified by `pathname'. The bit length of the message digest produced is controlled by `output-bit-length', which can take on the values 224, 256, 288, 384 and 512, which is the default value.

SHA3-DIGEST-STREAM (STREAM &KEY (OUTPUT-BIT-LENGTH 512))

Calculate an SHA-3 message-digest of data read from `stream', which should be a stream with element type (unsigned-byte 8). The bit length of the message digest produced is controlled by `output-bit-length', which can take on the values 224, 256, 288, 384 and 512, which is the default value.

SHA3-DIGEST-VECTOR (VECTOR &KEY (START 0) END (OUTPUT-BIT-LENGTH 512))

Calculate an SHA-3 message-digest of data in `vector', which should be a 1d simple-array with element type (unsigned-byte 8), bounded by `start' and `end'. The bit length of the message digest produced is controlled by `output-bit-length', which can take on the values 224, 256, 288, 384 and 512, which is the default value.

SHA3-FINAL (STATE &KEY (OUTPUT-BIT-LENGTH NIL OUTPUT-BIT-LENGTH-P))

If the given SHA-3 state `state' has not already been finalized, finalize it by processing any remaining input in its buffer, with suitable padding as specified by the SHA-3 standard. Returns the message digest as a simple-array of (unsigned-byte 8). The length of the returned digest is determined either by the output bit length or bit rate specified on state creation, or for the special case of default parameters being used, by the optional keyword argument `output-bit-length'. If the state has previously been finalized, the function will return the digest again.

SHA3-INIT (&KEY (OUTPUT-BIT-LENGTH NIL OUTPUT-BIT-LENGTH-P) (BIT-RATE (IF (AND OUTPUT-BIT-LENGTH-P OUTPUT-BIT-LENGTH) (- 1600 (* 2 OUTPUT-BIT-LENGTH)) 1024)))

Create and return a new SHA-3 state. If `output-bit-length' is specified then the state will run at the bit rate specified for the given output bit length. If `output-bit-length' is unspecified, `bit-rate' can be specified to select a suitable bit rate. If both are left unspecified then a default bit rate of 1024 bits is selected, which is suitable for arbitrary output bit lengths of up to 288 bits.

SHA3-UPDATE (STATE VECTOR &KEY (START 0) (END (LENGTH VECTOR)))

Update the given SHA-3 state `state' from `vector', which must be a simple-array with element-type (unsigned-byte 8), bounded by `start' and `end', which must be numeric bounding-indices.

Undocumented

SHA3-STATE-P (OBJECT)

Private

PAD-MESSAGE-TO-WIDTH (MESSAGE BIT-WIDTH)

Destructively pad the given message to the given bit-width according to Keccak padding rules and return the padded message.

SHA3-STATE-BIT-RATE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SHA3-STATE-BUFFER (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SHA3-STATE-BUFFER-INDEX (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SHA3-STATE-FINALIZED-P (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

SHA3-STATE-STATE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

TRIVIAL-MACROEXPAND-ALL (FORM ENV)

Trivial and very restricted code-walker used in partial evaluation macros. Only supports atoms and function forms, no special forms.

Undocumented

COPY-SHA3-STATE (INSTANCE)

KECCAK-F

KECCAK-F-ROT

KECCAK-F-ROUND-CONSTANT

KECCAK-STATE-EXTRACT-OUTPUT (STATE OUTPUT-BITS)

KECCAK-STATE-MERGE-INPUT

MAKE-KECCAK-1600-STATE

MAKE-SHA3-STATE (BIT-RATE)

SETFSHA3-STATE-BUFFER-INDEX (NEW-VALUE INSTANCE)

SETFSHA3-STATE-FINALIZED-P (NEW-VALUE INSTANCE)

MACRO

Private

DOTIMES-UNROLLED ((VAR LIMIT) &BODY BODY &ENVIRONMENT ENV)

Unroll the loop body at compile-time.

WITH-STATE-ACCESSORS ((&REST STATES) &BODY BODY)

Bind the contents of the state(s) array(s) to local variables, and save the content on normal form exit.

WITH-TEMP-ROWS ((&REST ROWS) &BODY BODY)

Bind local variables for each temporary row.

WITH-TEMP-STATE ((&REST TEMPS) &BODY BODY)

Bind local variables for each temporary state.

Undocumented

GET-ROTATE-OFFSET (X Y &ENVIRONMENT ENV)

VARIABLE

Private

*KECCAK-F-ROTATE-OFFSETS*

Keccak Rotate Offsets

*KECCAK-F-ROUND-CONSTANTS*

Keccak Round Constants

*OPTIMIZE-DECLARATION*

Global optimize declaration used for performance critical functions. This can be changed prior to compiling the package for debugging/testing purposes.

CLASS

Public

Undocumented

SHA3-STATE

CONSTANT

Private

+BUFFER-SIZE+

Size of internal buffer to use for `sha3-digest-stream' and `sha3-digest-file' operations.

+KECCAK-1600-LANE-BYTE-WIDTH+

Lane width in bytes for Keccak-1600.

+KECCAK-1600-LANE-WIDTH+

Lane width for Keccak-1600.

+KECCAK-STATE-COLUMNS+

Width of Keccak state in the x axis

+KECCAK-STATE-LANES+

Total number of lanes in Keccak state

+KECCAK-STATE-ROWS+

Width of Keccak state in the y axis