TPLShakeXOF

Data types, cryptography

Description

TPLShakeXOF is the caller-owned state of the streaming SHAKE extendable-output function. It stores the 25-word Keccak state, the selected rate, the SHAKE domain byte and the current position inside the absorb or squeeze block.

The intended sequence is PLShakeXOFInit, zero or more PLShakeXOFAbsorb calls, PLShakeXOFFinalize, then one or more PLShakeXOFSqueeze calls. The record has no managed fields and can live on the stack.

Syntax

Delphi

TPLShakeXOF = Record
  State: Array [0..24] Of UInt64;
  Rate: Integer;
  Suffix: Byte;
  Absorbing: Boolean;
  SqueezePos: Integer;
End;

Fields

State25-word Keccak-f[1600] state, XORed and read little-endian per byte
RateAbsorb and squeeze block size: 168 bytes for SHAKE128, 136 for SHAKE256
SuffixDomain-separation byte, $1F for SHAKE
AbsorbingTrue while the context still accepts absorb calls
SqueezePosNext byte position inside the current rate block

Remarks

PLShakeXOFInit zeroes the whole record and then sets Rate, Suffix, Absorbing and SqueezePos; declaring the record is not enough to make it usable.

PLShakeXOFFinalize applies the pad10*1 suffix and permutes the state; a second call is a no-op.

PLShakeXOFSqueeze finalizes automatically when the context is still absorbing, so an explicit finalize is optional.

PLShakeXOFAbsorb ignores nil data, a count of zero or a context that has already been finalized.

Repeated squeezes continue from SqueezePos across permutations; the type imposes no total output limit.

See also

PLShakeXOFInit, PLShakeXOFAbsorb, PLShakeXOFFinalize, PLShakeXOFSqueeze, PLShakeXOF, SHAKE256ByteArray