Sha3 structv0.1.0

Source
An incremental SHA-3 hash at any of its four sizes.
pub struct Sha3 {
    // private fields
}

Structural Copy; copying takes an independent snapshot of the sponge state.

Associated functions

New224

pub func New224() -> Sha3

A SHA3-224 state.

Returns: a hasher producing a 224-bit digest

Source

New256

pub func New256() -> Sha3

A SHA3-256 state.

Returns: a hasher producing a 256-bit digest

Source

New384

pub func New384() -> Sha3

A SHA3-384 state.

Returns: a hasher producing a 384-bit digest

Source

New512

pub func New512() -> Sha3

A SHA3-512 state.

Returns: a hasher producing a 512-bit digest

Source

Implements Digest

Sha3 conforms to Digest.

Update

pub func Update(self: &var Sha3, bytes: char8[..])

Absorbs bytes into the state.

NameTypeDescription
byteschar8[..]the bytes to absorb

Source

Finish

pub func Finish(self: &var Sha3, into: var char8[..])

Pads, permutes once more, and squeezes the digest out. The padding is the domain byte, then zeros, then a final bit at the top of the rate — so a rate with only one byte free receives both in the same byte, which is the case that separates a correct padding from one that works at every other length.

NameTypeDescription
intovar char8[..]receives the output

Source

DigestLength

pub func DigestLength(self: &Sha3) -> uint

Twenty-eight, thirty-two, forty-eight or sixty-four bytes.

Returns: how many bytes a digest occupies

Source

BlockLength

pub func BlockLength(self: &Sha3) -> uint

The rate, which differs per size — unlike the SHA-2 family, whose block is fixed.

Returns: how many bytes the compression function consumes at a time

Source

KeccakPermute

pub func KeccakPermute(lanes: *var uint64)

The Keccak-f1600 permutation, applied in place to twenty-five lanes. Twenty-four rounds of five steps: theta mixes each column into its neighbours, rho rotates each lane by its own offset, pi moves the lanes around, chi is the only non-linear step, and iota breaks the symmetry that would otherwise make every round identical.

Source

Parameters

NameTypeDescription
lanes*var uint64the state's twenty-five lanes, permuted in place

Sha3Of224

pub func Sha3Of224(bytes: char8[..], into: var char8[..])

The SHA3-224 digest of bytes, in one call.

Source

Parameters

NameTypeDescription
byteschar8[..]the bytes to absorb
intovar char8[..]receives the output

Sha3Of256

pub func Sha3Of256(bytes: char8[..], into: var char8[..])

The SHA3-256 digest of bytes, in one call.

Source

Parameters

NameTypeDescription
byteschar8[..]the bytes to absorb
intovar char8[..]receives the output

Sha3Of384

pub func Sha3Of384(bytes: char8[..], into: var char8[..])

The SHA3-384 digest of bytes, in one call.

Source

Parameters

NameTypeDescription
byteschar8[..]the bytes to absorb
intovar char8[..]receives the output

Sha3Of512

pub func Sha3Of512(bytes: char8[..], into: var char8[..])

The SHA3-512 digest of bytes, in one call.

Source

Parameters

NameTypeDescription
byteschar8[..]the bytes to absorb
intovar char8[..]receives the output