sha
This commit is contained in:
@ -11,6 +11,7 @@
|
||||
#include <config.h>
|
||||
#include <socket.h>
|
||||
|
||||
#include <sha256.h>
|
||||
|
||||
const uint32_t COUNTER_FREQUENCY = 1.0e6;
|
||||
|
||||
@ -33,6 +34,7 @@ typedef struct __attribute__((__packed__)) {
|
||||
typedef struct __attribute__((__packed__)) {
|
||||
char deviceId[sizeof(((t_configBlock*)0)->deviceId)];
|
||||
char location[sizeof(((t_configBlock*)0)->location)];
|
||||
uint8_t hash[SHA256_BLOCK_SIZE];
|
||||
uint8_t done;
|
||||
t_event events[SECONDS_PER_MINUTE];
|
||||
} t_minuteStruct;
|
||||
@ -87,6 +89,48 @@ void counterMinuteTick(void *handle) {
|
||||
memset(minuteBuffer->s.location, 0, sizeof(minuteBuffer->s.location));
|
||||
strcpy(minuteBuffer->s.location, config->location);
|
||||
|
||||
memcpy(minuteBuffer->s.hash, config->sharedSecret, SHA256_BLOCK_SIZE);
|
||||
SHA256_CTX ctx;
|
||||
sha256_init(&ctx);
|
||||
sha256_update(&ctx, minuteBuffer->b, sizeof(minuteBuffer->b));
|
||||
sha256_final(&ctx, minuteBuffer->s.hash);
|
||||
coloredMsg(LOG_BLUE, "cmt, hash, 1. half is %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
minuteBuffer->s.hash[0],
|
||||
minuteBuffer->s.hash[1],
|
||||
minuteBuffer->s.hash[2],
|
||||
minuteBuffer->s.hash[3],
|
||||
minuteBuffer->s.hash[4],
|
||||
minuteBuffer->s.hash[5],
|
||||
minuteBuffer->s.hash[6],
|
||||
minuteBuffer->s.hash[7],
|
||||
minuteBuffer->s.hash[8],
|
||||
minuteBuffer->s.hash[9],
|
||||
minuteBuffer->s.hash[10],
|
||||
minuteBuffer->s.hash[11],
|
||||
minuteBuffer->s.hash[12],
|
||||
minuteBuffer->s.hash[13],
|
||||
minuteBuffer->s.hash[14],
|
||||
minuteBuffer->s.hash[15]
|
||||
);
|
||||
coloredMsg(LOG_BLUE, "cmt, hash, 2. half is %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
minuteBuffer->s.hash[16],
|
||||
minuteBuffer->s.hash[17],
|
||||
minuteBuffer->s.hash[18],
|
||||
minuteBuffer->s.hash[19],
|
||||
minuteBuffer->s.hash[20],
|
||||
minuteBuffer->s.hash[21],
|
||||
minuteBuffer->s.hash[22],
|
||||
minuteBuffer->s.hash[23],
|
||||
minuteBuffer->s.hash[24],
|
||||
minuteBuffer->s.hash[25],
|
||||
minuteBuffer->s.hash[26],
|
||||
minuteBuffer->s.hash[27],
|
||||
minuteBuffer->s.hash[28],
|
||||
minuteBuffer->s.hash[29],
|
||||
minuteBuffer->s.hash[30],
|
||||
minuteBuffer->s.hash[31]
|
||||
);
|
||||
|
||||
int8_t res = counterSendMinuteBuffer(minuteBuffer);
|
||||
if (res == 1) {
|
||||
coloredMsg(LOG_BLUE, "cmt, successfully sent");
|
||||
|
Reference in New Issue
Block a user