#include "blake.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mbedtls/bignum.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-C3!");
blake512_test();
Serial.println("Done!");
}
void blake512_test()
{
int i, v;
uint8_t in[144], out[64];
uint8_t test1[] =
{
0x97, 0x96, 0x15, 0x87, 0xf6, 0xd9, 0x70, 0xfa, 0xba, 0x6d, 0x24, 0x78, 0x04, 0x5d, 0xe6, 0xd1,
0xfa, 0xbd, 0x09, 0xb6, 0x1a, 0xe5, 0x09, 0x32, 0x05, 0x4d, 0x52, 0xbc, 0x29, 0xd3, 0x1b, 0xe4,
0xff, 0x91, 0x02, 0xb9, 0xf6, 0x9e, 0x2b, 0xbd, 0xb8, 0x3b, 0xe1, 0x3d, 0x4b, 0x9c, 0x06, 0x09,
0x1e, 0x5f, 0xa0, 0xb4, 0x8b, 0xd0, 0x81, 0xb6, 0x34, 0x05, 0x8b, 0xe0, 0xec, 0x49, 0xbe, 0xb3
};
uint8_t test2[] =
{
0x31, 0x37, 0x17, 0xd6, 0x08, 0xe9, 0xcf, 0x75, 0x8d, 0xcb, 0x1e, 0xb0, 0xf0, 0xc3, 0xcf, 0x9f,
0xC1, 0x50, 0xb2, 0xd5, 0x00, 0xfb, 0x33, 0xf5, 0x1c, 0x52, 0xaf, 0xc9, 0x9d, 0x35, 0x8a, 0x2f,
0x13, 0x74, 0xb8, 0xa3, 0x8b, 0xba, 0x79, 0x74, 0xe7, 0xf6, 0xef, 0x79, 0xca, 0xb1, 0x6f, 0x22,
0xCE, 0x1e, 0x64, 0x9d, 0x6e, 0x01, 0xad, 0x95, 0x89, 0xc2, 0x13, 0x04, 0x5d, 0x54, 0x5d, 0xde
};
memset( in, 0, 144 );
blake512_hash( out, in, 1 );
v = 0;
for( i = 0; i < 64; ++i )
{
if ( out[i] != test1[i] ) v = 1;
}
if ( v ) Serial.println( "test 1 error\n" );
blake512_hash( out, in, 144 );
v = 0;
for( i = 0; i < 64; ++i )
{
if ( out[i] != test2[i] ) v = 1;
}
if ( v ) Serial.println( "test 2 error\n" );
Serial.println("BLAKE512:");
for( i = 0; i < 64; ++i )
{
Serial.print( out[i], 16);
}
Serial.println();
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}