core/crypto/kmac
kmac
Types
1Constants
3MIN_KEY_SIZE_128
MIN_KEY_SIZE_128 :: 128 / 8SourceMIN_KEY_SIZE_128 is the minimum key size for KMAC128 in bytes.
MIN_KEY_SIZE_256
MIN_KEY_SIZE_256 :: 256 / 8SourceMIN_KEY_SIZE_256 is the minimum key size for KMAC256 in bytes.
MIN_TAG_SIZE
MIN_TAG_SIZE :: 32 / 8SourceMIN_TAG_SIZE is the absolute minimum tag size for KMAC in bytes (8.4.2). Most callers SHOULD use at least 128-bits if not 256-bits for the tag size.
Procedures
8clone
clone :: proc(ctx: ^Context, other: ^Context)Sourceclone clones the Context other into ctx.
final
final :: proc(ctx: ^Context, dst: []u8)Sourcefinal finalizes the Context, writes the tag to dst, and calls reset on the Context. This routine will panic if the dst length is less than MIN_TAG_SIZE.
init_128
init_128 :: proc(ctx: ^Context, key: []u8, domain_sep: []u8)Sourceinit_128 initializes a Context for KMAC28. This routine will panic if the key length is less than MIN_KEY_SIZE_128.
init_256
init_256 :: proc(ctx: ^Context, key: []u8, domain_sep: []u8)Sourceinit_256 initializes a Context for KMAC256. This routine will panic if the key length is less than MIN_KEY_SIZE_256.
reset
reset :: proc(ctx: ^Context)Sourcereset sanitizes the Context. The Context must be re-initialized to be used again.
sum
sum :: proc(sec_strength: int, dst: []u8, msg: []u8, key: []u8, domain_sep: []u8)Sourcesum will compute the KMAC with the specified security strength, key, and domain separator over msg, and write the computed digest to dst.
update
update :: proc(ctx: ^Context, data: []u8)Sourceupdate adds more data to the Context.
verify
verify :: proc(
sec_strength: int,
tag: []u8,
msg: []u8,
key: []u8,
domain_sep: []u8,
allocator: _ = context.temp_allocator,
) -> (bool)Sourceverify will verify the KMAC tag computed with the specified security strength, key and domain separator over msg and return true if and only if (⟺) the tag is valid.