SHA3/Keccak

This implementation is compatible with FIPS 202, rather than the original Keccak submission.

Macros

CF_SHA3_224_HASHSZ

The output size of SHA3-224: 28 bytes.

CF_SHA3_256_HASHSZ

The output size of SHA3-256: 32 bytes.

CF_SHA3_384_HASHSZ

The output size of SHA3-384: 48 bytes.

CF_SHA3_512_HASHSZ

The output size of SHA3-512: 64 bytes.

CF_SHA3_224_BLOCKSZ

The block size of SHA3-224.

CF_SHA3_256_BLOCKSZ

The block size of SHA3-256.

CF_SHA3_384_BLOCKSZ

The block size of SHA3-384.

CF_SHA3_512_BLOCKSZ

The block size of SHA3-512.

Types

cf_sha3_context

Incremental SHA3 hashing context.

cf_sha3_context.A

Intermediate state.

cf_sha3_context.partial

Unprocessed input.

cf_sha3_context.npartial

Number of bytes of unprocessed input.

cf_sha3_context.rate

Sponge absorption rate.

cf_sha3_context.rate

Sponge capacity.

Functions

void cf_sha3_224_init(cf_sha3_context *ctx)
void cf_sha3_256_init(cf_sha3_context *ctx)
void cf_sha3_384_init(cf_sha3_context *ctx)
void cf_sha3_512_init(cf_sha3_context *ctx)

Sets up ctx ready to hash a new message.

void cf_sha3_224_update(cf_sha3_context *ctx, const void *data, size_t nbytes)
void cf_sha3_256_update(cf_sha3_context *ctx, const void *data, size_t nbytes)
void cf_sha3_384_update(cf_sha3_context *ctx, const void *data, size_t nbytes)
void cf_sha3_512_update(cf_sha3_context *ctx, const void *data, size_t nbytes)

Hashes nbytes at data. Copies the data for processing later if there isn’t enough to make a full block.

void cf_sha3_224_digest(const cf_sha3_context *ctx, uint8_t hash[CF_SHA3_224_HASHSZ])
void cf_sha3_256_digest(const cf_sha3_context *ctx, uint8_t hash[CF_SHA3_256_HASHSZ])
void cf_sha3_384_digest(const cf_sha3_context *ctx, uint8_t hash[CF_SHA3_384_HASHSZ])
void cf_sha3_512_digest(const cf_sha3_context *ctx, uint8_t hash[CF_SHA3_512_HASHSZ])

Finishes the hashing operation, writing result to hash.

This leaves ctx unchanged.

void cf_sha3_224_digest_final(cf_sha3_context *ctx, uint8_t hash[CF_SHA3_224_HASHSZ])
void cf_sha3_256_digest_final(cf_sha3_context *ctx, uint8_t hash[CF_SHA3_256_HASHSZ])
void cf_sha3_384_digest_final(cf_sha3_context *ctx, uint8_t hash[CF_SHA3_384_HASHSZ])
void cf_sha3_512_digest_final(cf_sha3_context *ctx, uint8_t hash[CF_SHA3_512_HASHSZ])

Finishes the hashing operation, writing result to hash.

This destroys the contents of ctx.

Values

cf_sha3_224
cf_sha3_256
cf_sha3_384
cf_sha3_512

Abstract interface to SHA3 functions. See cf_chash for more information.