sha
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
#include <spi.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <sha256.h>
|
||||
|
||||
#define CONFIG_MAGIC 0xdead0006
|
||||
|
||||
typedef struct __attribute__((__packed__)) s_configBlock {
|
||||
@ -13,7 +15,7 @@ typedef struct __attribute__((__packed__)) s_configBlock {
|
||||
uint8_t macAddress[6];
|
||||
char ntpServer[48];
|
||||
char deviceId[16];
|
||||
char sharedSecret[32];
|
||||
char sharedSecret[SHA256_BLOCK_SIZE];
|
||||
char location[48];
|
||||
char sinkServer[48];
|
||||
uint8_t filler[6];
|
||||
|
35
cube/User/Inc/sha256.h
Normal file
35
cube/User/Inc/sha256.h
Normal file
@ -0,0 +1,35 @@
|
||||
/*********************************************************************
|
||||
* Filename: sha256.h
|
||||
* Author: Brad Conte (brad AT bradconte.com)
|
||||
* Copyright:
|
||||
* Disclaimer: This code is presented "as is" without any guarantees.
|
||||
* Details: Defines the API for the corresponding SHA1 implementation.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef SHA256_H
|
||||
#define SHA256_H
|
||||
|
||||
/*************************** HEADER FILES ***************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
|
||||
|
||||
/**************************** DATA TYPES ****************************/
|
||||
typedef uint8_t BYTE; // 8-bit byte
|
||||
typedef uint32_t WORD; // 32-bit word, change to "long" for 16-bit machines
|
||||
|
||||
typedef struct {
|
||||
BYTE data[64];
|
||||
WORD datalen;
|
||||
unsigned long long bitlen;
|
||||
WORD state[8];
|
||||
} SHA256_CTX;
|
||||
|
||||
/*********************** FUNCTION DECLARATIONS **********************/
|
||||
void sha256_init(SHA256_CTX *ctx);
|
||||
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
|
||||
void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
|
||||
|
||||
#endif // SHA256_H
|
Reference in New Issue
Block a user