CTS-SAT-1-OBC-Firmware
Toggle main menu visibility
Loading...
Searching...
No Matches
firmware
Core
Inc
crypto
sha256.h
Go to the documentation of this file.
1
/*********************************************************************
2
* Source: https://github.com/B-Con/crypto-algorithms
3
* Filename: sha256.h
4
* Author: Brad Conte (brad AT bradconte.com)
5
* Copyright:
6
* Disclaimer: This code is presented "as is" without any guarantees.
7
* Details: Defines the API for the corresponding SHA1 implementation.
8
*********************************************************************/
9
10
#ifndef SHA256_H
11
#define SHA256_H
12
13
/*************************** HEADER FILES ***************************/
14
#include <stddef.h>
15
#include <stdint.h>
16
17
/****************************** MACROS ******************************/
18
#define SHA256_BLOCK_SIZE 32
// SHA256 outputs a 32 byte digest
19
20
/**************************** DATA TYPES ****************************/
21
typedef
uint8_t
BYTE
;
22
typedef
uint32_t
WORD
;
23
24
typedef
struct
{
25
BYTE
data
[64];
26
WORD
datalen
;
27
unsigned
long
long
bitlen
;
28
WORD
state
[8];
29
}
SHA256_CTX
;
30
31
/*********************** FUNCTION DECLARATIONS **********************/
32
void
sha256_init
(
SHA256_CTX
*ctx);
33
void
sha256_update
(
SHA256_CTX
*ctx,
const
BYTE
data[],
size_t
len);
34
void
sha256_final
(
SHA256_CTX
*ctx,
BYTE
hash[]);
35
36
37
void
CRYPT_compute_sha256_hash
(
const
uint8_t message[],
size_t
message_length, uint8_t hash[32]);
38
39
#endif
// SHA256_H
sha256_final
void sha256_final(SHA256_CTX *ctx, BYTE hash[])
Definition
sha256.c:115
BYTE
uint8_t BYTE
Definition
sha256.h:21
sha256_update
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
Definition
sha256.c:100
WORD
uint32_t WORD
Definition
sha256.h:22
CRYPT_compute_sha256_hash
void CRYPT_compute_sha256_hash(const uint8_t message[], size_t message_length, uint8_t hash[32])
Computes the SHA256 hash of the message and stores the 32 byte hash at hash.
Definition
sha256.c:166
sha256_init
void sha256_init(SHA256_CTX *ctx)
Definition
sha256.c:86
SHA256_CTX
Definition
sha256.h:24
SHA256_CTX::state
WORD state[8]
Definition
sha256.h:28
SHA256_CTX::bitlen
unsigned long long bitlen
Definition
sha256.h:27
SHA256_CTX::data
BYTE data[64]
Definition
sha256.h:25
SHA256_CTX::datalen
WORD datalen
Definition
sha256.h:26
Generated by
1.17.0