xmss-KAT-generator/test/test_wots.c

54 lignes
1.1 KiB
C
Brut Vue normale Historique

2015-08-11 11:08:27 +01:00
#include <stdio.h>
2016-07-11 10:15:16 +01:00
#include <math.h>
#include <stdint.h>
2015-08-11 11:08:27 +01:00
#include "../wots.h"
#include "../randombytes.h"
#include "../params.h"
2015-08-11 11:08:27 +01:00
static void hexdump(unsigned char *a, size_t len)
{
size_t i;
for (i = 0; i < len; i++)
printf("%02x", a[i]);
}
int main()
{
unsigned char seed[XMSS_N];
unsigned char pub_seed[XMSS_N];
2015-08-11 11:08:27 +01:00
int sig_len = XMSS_WOTS_LEN*XMSS_N;
2015-08-11 11:08:27 +01:00
2015-10-28 14:49:46 +00:00
unsigned char pk1[sig_len];
unsigned char pk2[sig_len];
unsigned char sig[sig_len];
2016-07-11 10:15:16 +01:00
uint32_t addr[8] = {1,2,3,4};
2015-08-11 11:08:27 +01:00
unsigned char msg[XMSS_N];
2015-08-11 11:08:27 +01:00
int i;
randombytes(seed, XMSS_N);
randombytes(pub_seed, XMSS_N);
randombytes(msg, XMSS_N);
2015-08-11 11:08:27 +01:00
//randombytes(addr, 16);
wots_pkgen(pk1, seed, pub_seed, addr);
wots_sign(sig, msg, seed, pub_seed, addr);
wots_pkFromSig(pk2, sig, msg, pub_seed, addr);
2015-08-11 11:08:27 +01:00
for (i = 0; i < sig_len; i++)
if (pk1[i] != pk2[i]) {
2015-08-12 13:37:49 +01:00
printf("pk1 != pk2 %d\n",i);
2015-08-11 11:08:27 +01:00
return -1;
}
printf("worked great!\npk1: ");
hexdump(pk1, sig_len);
printf("\npk2: ");
hexdump(pk2, sig_len);
printf("\nsig: ");
hexdump(sig, sig_len);
printf("\n");
2015-08-11 11:08:27 +01:00
return 0;
}