This module implements SHA3 (Secure Hash Algorithm 3) set of cryptographic hash functions designed by Guido Bertoni, Joan Daemen, Michaƫl Peeters and Gilles Van Assche.
This module supports SHA3-224/256/384/512 and SHAKE-128/256.
Tests for SHA3-225/256/384/512 made according to [https://www.di-mgt.com.au/sha_testvectors.html]. Test for SHAKE-128/256 made according to [https://csrc.nist.gov/projects/cryptographic-standards-and-guidelines/example-values#aHashing] 0bit and 1600bit test vectors used.
Types
KeccakKind = enum Sha3, Keccak, Shake
KeccakContext[bits; kind] = object q: array[25, uint64] pt: int
keccak224 = KeccakContext[224, Keccak]
keccak256 = KeccakContext[256, Keccak]
keccak384 = KeccakContext[384, Keccak]
keccak512 = KeccakContext[512, Keccak]
sha3_224 = KeccakContext[224, Sha3]
sha3_256 = KeccakContext[256, Sha3]
sha3_384 = KeccakContext[384, Sha3]
sha3_512 = KeccakContext[512, Sha3]
shake128 = KeccakContext[128, Shake]
shake256 = KeccakContext[256, Shake]
keccak = keccak224 | keccak256 | keccak384 | keccak512 | sha3_224 | sha3_256 | sha3_384 | sha3_512
Procs
proc init(ctx: var KeccakContext)
proc clear(ctx: var KeccakContext) {...}{.inline.}
proc update(ctx: var KeccakContext; data: ptr byte; ulen: uint)
- "is greater" operator. This is the same as y < x.
proc update[T: bchar](ctx: var KeccakContext; data: openArray[T])
proc xof(ctx: var KeccakContext)
- unequals operator. This is a shorthand for not (x == y).
proc output(ctx: var KeccakContext; data: ptr byte; ulen: uint): uint
- unequals operator. This is a shorthand for not (x == y).
proc finish(ctx: var KeccakContext; data: ptr byte; ulen: uint): uint
- "is greater or equals" operator. This is the same as y <= x.
proc finish(ctx: var KeccakContext): MDigest[ctx.bits]
proc finish[T: bchar](ctx: var KeccakContext; data: var openArray[T])
- "is greater or equals" operator. This is the same as y <= x.
Templates
template sizeDigest(ctx: KeccakContext): uint
template sizeBlock(ctx: KeccakContext): uint
template sizeDigest(r: typedesc[keccak | shake128 | shake256]): int
template sizeBlock(r: typedesc[keccak | shake128 | shake256]): int