1 /* Copyright 2014, Kenneth MacKay. Licensed under the BSD 2-clause license. */
10 #include "/Projects/lpc11xx/peripherals/uart.h"
11 #include "/Projects/lpc11xx/peripherals/time.h"
13 static uint64_t g_rand = 88172645463325252ull;
14 int fake_rng(uint8_t *p_dest, unsigned p_size)
18 g_rand ^= (g_rand << 13);
19 g_rand ^= (g_rand >> 7);
20 g_rand ^= (g_rand << 17);
22 unsigned l_amount = (p_size > 8 ? 8 : p_size);
23 memcpy(p_dest, &g_rand, l_amount);
34 uartInit(BAUD_115200);
37 uECC_set_rng(&fake_rng);
40 uint8_t l_public[uECC_BYTES*2];
41 uint8_t l_private[uECC_BYTES];
43 uint8_t l_hash[uECC_BYTES];
45 uint8_t l_sig[uECC_BYTES*2];
49 printf("Testing 256 signatures\n");
58 if(!uECC_make_key(l_public, l_private))
60 printf("uECC_make_key() failed\n");
63 memcpy(l_hash, l_public, uECC_BYTES);
65 if(!uECC_sign(l_private, l_hash, l_sig))
67 printf("uECC_sign() failed\n");
71 if(!uECC_verify(l_public, l_hash, l_sig))
73 printf("uECC_verify() failed\n");