libnx  v4.2.0
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.
19 typedef 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
30 void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size);
31 /// Gets the context's output hash, finalizes the context.
32 void sha256ContextGetHash(Sha256Context *ctx, void *dst);
33 
34 /// Simple all-in-one SHA256 calculator.
35 void sha256CalculateHash(void *dst, const void *src, size_t size);
Sha256Context
Context for SHA256 operations.
Definition: sha256.h:19
sha256CalculateHash
void sha256CalculateHash(void *dst, const void *src, size_t size)
Simple all-in-one SHA256 calculator.
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
sha256ContextCreate
void sha256ContextCreate(Sha256Context *out)
Initialize a SHA256 context.
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
sha256ContextUpdate
void sha256ContextUpdate(Sha256Context *ctx, const void *src, size_t size)
Updates SHA256 context with data to hash.
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
sha256ContextGetHash
void sha256ContextGetHash(Sha256Context *ctx, void *dst)
Gets the context's output hash, finalizes the context.