add sha256 impl

This commit is contained in:
Conor Patrick
2018-05-06 14:53:43 -04:00
parent ed6308eaa1
commit 0c5c3dc742
4 changed files with 240 additions and 0 deletions

37
crypto.c Normal file
View File

@@ -0,0 +1,37 @@
/*
* Wrapper for crypto implementation on device
*
* */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
#include "crypto.h"
#ifdef USE_SOFTWARE_IMPLEMENTATION
#include "sha256.h"
static SHA256_CTX sha256_ctx;
void crypto_sha256_init()
{
sha256_init(&sha256_ctx);
}
void crypto_sha256_update(uint8_t * data, size_t len)
{
sha256_update(&sha256_ctx, data, len);
}
void crypto_sha256_final(uint8_t * hash)
{
sha256_final(&sha256_ctx, hash);
}
#else
#error "No crypto implementation defined"
#endif