Browse Source

Init

master
Henry Case 5 months ago
parent
commit
f6f2e7c444
1 changed files with 21 additions and 29 deletions
  1. +21
    -29
      test/vectors.c

+ 21
- 29
test/vectors.c View File

@@ -2,22 +2,22 @@
* Generate intermediate test vectors useful to test implementations.
*/

#include <stdio.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>

#include "../wots.h"
#include "../randombytes.h"
#include "../params.h"
#include "../fips202.h"
#include "../params.h"
#include "../randombytes.h"
#include "../utils.h"
#include "../wots.h"
#include "../xmss_commons.h"
#include "../xmss_core.h"

void print_hex(unsigned char *buf, int len) {
for (int i = 0; i < len; i++) {
printf("%x%x", buf[i] / 16, buf[i] & 15);
}
for (int i = 0; i < len; i++) { printf("0x%02X, ", buf[i]); }
printf("\n");
//printf("%x%x", buf[i] / 16, buf[i] & 15); }
}

void print_hash(unsigned char *buf, int len) {
@@ -42,9 +42,7 @@ void vectors_xmss(uint32_t oid, int mt) {
unsigned char sm[params.sig_bytes + 1];
unsigned long long smlen = 0;

for (unsigned int i = 0; i < 3*params.n; i++) {
seed[i] = i;
}
for (unsigned int i = 0; i < 3 * params.n; i++) { seed[i] = i; }

xmssmt_core_seed_keypair(&params, pk, sk, seed);

@@ -61,10 +59,11 @@ void vectors_xmss(uint32_t oid, int mt) {
} else {
printf("XMSS ");
}
printf("%d ", oid);
print_hash(pk, params.pk_bytes);
printf("%X ", oid);
print_hex(pk, params.pk_bytes);
print_hex(pk, params.pk_bytes);
printf(" ");
print_hash(sm, params.sig_bytes);
print_hex(sm, params.sig_bytes);
printf("\n");
}

@@ -81,18 +80,18 @@ void vectors_wots(uint32_t oid) {

unsigned char sig[params.wots_sig_bytes];
unsigned char m[params.n];
uint32_t addr[8] = {0};
uint32_t addr[8] = {0};
uint32_t addr2[8] = {0};

for (unsigned int i = 0; i < 8; i++) {
addr[i] = 500000000*i;
addr2[i] = 400000000*i;
addr[i] = 500000000 * i;
addr2[i] = 400000000 * i;
}

for (unsigned int i = 0; i < params.n; i++) {
m[i] = 3*i;
pub_seed[i] = 2*i;
sk_seed[i] = i;
m[i] = 3 * i;
pub_seed[i] = 2 * i;
sk_seed[i] = i;
}

wots_pkgen(&params, pk, sk_seed, pub_seed, addr);
@@ -112,14 +111,7 @@ void vectors_wots(uint32_t oid) {
}

int main() {
for (uint32_t oid = 1; oid <= 0x15; oid += 3) {
vectors_wots(oid);
}
for (uint32_t oid = 2; oid <= 56; oid += 8) {
vectors_xmss(oid, 1);
}
for (uint32_t oid = 1; oid <= 0x15; oid += 3) {
vectors_xmss(oid, 0);
}
//for (uint32_t oid = 1; oid <= 0x15; oid += 3) { vectors_wots(oid); }
//for (uint32_t oid = 2; oid <= 56; oid += 8) { vectors_xmss(oid, 1); }
for (uint32_t oid = 1; oid <= 0x15; oid += 3) { vectors_xmss(oid, 0); }
}


Loading…
Cancel
Save