libnx  v4.6.0
sha1.h
Go to the documentation of this file.
1 /**
2  * @file sha1.h
3  * @brief Hardware accelerated SHA1 implementation.
4  * @copyright libnx Authors
5  */
6 #pragma once
7 #include "../types.h"
8 
9 #ifndef SHA1_HASH_SIZE
10 #define SHA1_HASH_SIZE 0x14
11 #endif
12 
13 #ifndef SHA1_BLOCK_SIZE
14 #define SHA1_BLOCK_SIZE 0x40
15 #endif
16 
17 /// Context for SHA1 operations.
18 typedef struct {
19  u32 intermediate_hash[SHA1_HASH_SIZE / sizeof(u32)];
20  u8 buffer[SHA1_BLOCK_SIZE];
21  u64 bits_consumed;
22  size_t num_buffered;
23  bool finalized;
24 } Sha1Context;
25 
26 /// Initialize a SHA1 context.
28 /// Updates SHA1 context with data to hash
29 void sha1ContextUpdate(Sha1Context *ctx, const void *src, size_t size);
30 /// Gets the context's output hash, finalizes the context.
31 void sha1ContextGetHash(Sha1Context *ctx, void *dst);
32 
33 /// Simple all-in-one SHA1 calculator.
34 void sha1CalculateHash(void *dst, const void *src, size_t size);
void sha1CalculateHash(void *dst, const void *src, size_t size)
Simple all-in-one SHA1 calculator.
void sha1ContextUpdate(Sha1Context *ctx, const void *src, size_t size)
Updates SHA1 context with data to hash.
void sha1ContextGetHash(Sha1Context *ctx, void *dst)
Gets the context's output hash, finalizes the context.
void sha1ContextCreate(Sha1Context *out)
Initialize a SHA1 context.
Context for SHA1 operations.
Definition: sha1.h:18
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