libnx v4.9.0
Loading...
Searching...
No Matches
sha256.h
Go to the documentation of this file.
1/**
2 * @file sha256.h
3 * @brief Hardware accelerated SHA256 implementation.
4 * @copyright libnx Authors
5 */
6#pragma once
7#include "../types.h"
8
9
10#ifndef SHA256_HASH_SIZE
11#define SHA256_HASH_SIZE 0x20
12#endif
13
14#ifndef SHA256_BLOCK_SIZE
15#define SHA256_BLOCK_SIZE 0x40
16#endif
17
18/// Context for SHA256 operations.
19typedef struct {
20 u32 intermediate_hash[SHA256_HASH_SIZE / sizeof(u32)];
21 u8 buffer[SHA256_BLOCK_SIZE];
22 u64 bits_consumed;
23 size_t num_buffered;
24 bool finalized;
26
27/// Initialize a SHA256 context.
29/// Updates SHA256 context with data to hash
30void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size);
31/// Gets the context's output hash, finalizes the context.
32void sha256ContextGetHash(Sha256Context *ctx, void *dst);
33
34/// Simple all-in-one SHA256 calculator.
35void sha256CalculateHash(void *dst, const void *src, size_t size);
void sha256ContextCreate(Sha256Context *out)
Initialize a SHA256 context.
void sha256CalculateHash(void *dst, const void *src, size_t size)
Simple all-in-one SHA256 calculator.
void sha256ContextGetHash(Sha256Context *ctx, void *dst)
Gets the context's output hash, finalizes the context.
void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size)
Updates SHA256 context with data to hash.
Context for SHA256 operations.
Definition sha256.h:19
uint64_t u64
64-bit unsigned integer.
Definition types.h:22
uint8_t u8
8-bit unsigned integer.
Definition types.h:19
uint32_t u32
32-bit unsigned integer.
Definition types.h:21