core/crypto/sha2
sha2
Types
2Context_256
Context_256 :: struct {
block: [64]u8,
h: [8]u32,
bitlength: u64,
length: u64,
md_bits: int,
is_hw_accelerated: bool,
is_initialized: bool,
}SourceContext_256 is a SHA-224 or SHA-256 instance.
Context_512
Context_512 :: struct {
block: [128]u8,
h: [8]u64,
bitlength: u64,
length: u64,
md_bits: int,
is_hw_accelerated: bool,
is_initialized: bool,
}SourceContext_512 is a SHA-384, SHA-512 or SHA-512/256 instance.
Constants
7BLOCK_SIZE_256
BLOCK_SIZE_256 :: 64SourceBLOCK_SIZE_256 is the SHA-224 and SHA-256 block size in bytes.
BLOCK_SIZE_512
BLOCK_SIZE_512 :: 128SourceBLOCK_SIZE_512 is the SHA-384, SHA-512, and SHA-512/256 block size in bytes.
DIGEST_SIZE_224
DIGEST_SIZE_224 :: 28SourceDIGEST_SIZE_224 is the SHA-224 digest size in bytes.
DIGEST_SIZE_256
DIGEST_SIZE_256 :: 32SourceDIGEST_SIZE_256 is the SHA-256 digest size in bytes.
DIGEST_SIZE_384
DIGEST_SIZE_384 :: 48SourceDIGEST_SIZE_384 is the SHA-384 digest size in bytes.
DIGEST_SIZE_512
DIGEST_SIZE_512 :: 64SourceDIGEST_SIZE_512 is the SHA-512 digest size in bytes.
DIGEST_SIZE_512_256
DIGEST_SIZE_512_256 :: 32SourceDIGEST_SIZE_512_256 is the SHA-512/256 digest size in bytes.
Procedures
11clone
clone :: proc(ctx: ^T, other: ^T)Sourceclone clones the Context other into ctx.
final
final :: proc(ctx: ^T, hash: []u8, finalize_clone: bool)Sourcefinal finalizes the Context, writes the digest to hash, and calls reset on the Context.
If and only if (⟺) finalize_clone is set, final will work on a copy of the Context, which is useful for for calculating rolling digests.
init_224
init_224 :: proc(ctx: ^Context_256)Sourceinit_224 initializes a Context_256 for SHA-224.
init_256
init_256 :: proc(ctx: ^Context_256)Sourceinit_256 initializes a Context_256 for SHA-256.
init_384
init_384 :: proc(ctx: ^Context_512)Sourceinit_384 initializes a Context_512 for SHA-384.
init_512
init_512 :: proc(ctx: ^Context_512)Sourceinit_512 initializes a Context_512 for SHA-512.
init_512_256
init_512_256 :: proc(ctx: ^Context_512)Sourceinit_512_256 initializes a Context_512 for SHA-512/256.
is_hardware_accelerated_256
is_hardware_accelerated_256 :: proc() -> (bool)Sourceis_hardware_accelerated_256 returns true if and only if (⟺) hardware accelerated SHA-224/SHA-256 is supported.
is_hardware_accelerated_512
is_hardware_accelerated_512 :: proc() -> (bool)Sourceis_hardware_accelerated_512 returns true if and only if (⟺) hardware accelerated SHA-384, SHA-512, and SHA-512/256 are supported.
reset
reset :: proc(ctx: ^T)Sourcereset sanitizes the Context. The Context must be re-initialized to be used again.
update
update :: proc(ctx: ^T, data: []u8)Sourceupdate adds more data to the Context.