std1.0.0-beta-7 SafeC docs

std :: crypto::sha512

Struct std::Sha512Ctx

#include <std/crypto/sha512.h> source

struct Sha512Ctx {
    unsigned long long h[8];
    unsigned char buf[SHA512_BLOCK_SIZE];
    unsigned long long total_bytes;
    int is384;
}

Fields

§unsigned long long h[8]source

current hash state

§unsigned char buf[SHA512_BLOCK_SIZE]source

partial block buffer

§unsigned long long total_bytessource

Total bytes processed. SHA-512's length field is 128 bits, but a single 64-bit counter is tracked here (matching every other hash module in this library) since no realistic input reaches 2^64 bytes — the length field's high 8 bytes are simply written as zero.

§int is384source

1 = SHA-384 variant

Methods

§static struct Sha512Ctx new()source · definition

A fresh SHA-512 context.

§static struct Sha512Ctx new_384()source · definition

A fresh SHA-384 context (same struct, is384 = 1).

§void update([]const unsigned char data)source · definition

Feed len bytes of data into the hash.

§void finish([]unsigned char digest)source · definition

Finalise and write the digest. For SHA-512: digest must be at least 64 bytes. For SHA-384: digest must be at least 48 bytes.

§unsigned long digest_size() constsource · definition

64 (SHA-512) or 48 (SHA-384) / SHA512_BLOCK_SIZE (hash.h's BlockHash).

§unsigned long block_size() constsource · definition