ProtoCore v0.0.2
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
sha512.cpp File Reference

SHA-512 implementation (FIPS 180-4). More...

#include "crypto/hash/sha512.h"
#include "crypto/crypto_opt.h"
#include <string.h>
#include <mbedtls/sha512.h>

Go to the source code of this file.

Functions

PC_CRYPTO_HOT void pc_sha512_init (pc_sha512_ctx *ctx)
 Initialize a streaming SHA-512 context (ctx must not be NULL).
 
void pc_sha512_update (pc_sha512_ctx *ctx, const uint8_t *data, size_t len)
 Feed len bytes of data into the running hash.
 
void pc_sha512_final (pc_sha512_ctx *ctx, uint8_t digest[PC_SHA512_DIGEST_LEN])
 Finalize the hash and write the 64-byte digest. The context is undefined afterwards; call init() again before reuse.
 
void pc_sha512 (const uint8_t *data, size_t len, uint8_t digest[PC_SHA512_DIGEST_LEN])
 One-shot SHA-512: hash len bytes of data into digest (64 bytes).
 

Detailed Description

SHA-512 implementation (FIPS 180-4).

On Arduino builds streaming + one-shot delegate to mbedtls; on native builds the software path below is used. Shared by SSH (Ed25519 / kex), PQC, and SMB 3.1.1 preauth integrity.

Definition in file sha512.cpp.

Function Documentation

◆ pc_sha512_init()

PC_CRYPTO_HOT void pc_sha512_init ( pc_sha512_ctx ctx)

Initialize a streaming SHA-512 context (ctx must not be NULL).

Definition at line 28 of file sha512.cpp.

References pc_sha512_ctx::mbed.

Referenced by pc_ed25519_sign(), pc_ed25519_verify(), pc_hmac_sha512_final(), and pc_hmac_sha512_init().

◆ pc_sha512_update()

void pc_sha512_update ( pc_sha512_ctx ctx,
const uint8_t *  data,
size_t  len 
)

Feed len bytes of data into the running hash.

Definition at line 38 of file sha512.cpp.

References pc_sha512_ctx::mbed.

Referenced by pc_ed25519_sign(), pc_ed25519_verify(), pc_hmac_sha512_final(), pc_hmac_sha512_init(), and pc_hmac_sha512_update().

◆ pc_sha512_final()

void pc_sha512_final ( pc_sha512_ctx ctx,
uint8_t  digest[PC_SHA512_DIGEST_LEN] 
)

Finalize the hash and write the 64-byte digest. The context is undefined afterwards; call init() again before reuse.

Parameters
digestOutput buffer, PC_SHA512_DIGEST_LEN bytes.

Definition at line 47 of file sha512.cpp.

References pc_sha512_ctx::mbed.

Referenced by pc_ed25519_sign(), pc_ed25519_verify(), and pc_hmac_sha512_final().

◆ pc_sha512()

void pc_sha512 ( const uint8_t *  data,
size_t  len,
uint8_t  digest[PC_SHA512_DIGEST_LEN] 
)

One-shot SHA-512: hash len bytes of data into digest (64 bytes).

Definition at line 57 of file sha512.cpp.

Referenced by PC_CRYPTO_HOT::build_key_block(), pc_ed25519_pubkey(), pc_ed25519_sign(), pc_rsa_verify(), and ssh_rsa_sign().