@@ -1,14 +1,14 @@ | |||||
test/test_chacha | test/test_chacha | ||||
test/test_wots | test/test_wots | ||||
test/test_horst | test/test_horst | ||||
test/test_xmss | |||||
test/test_xmss_fast | |||||
test/test_xmssmt | |||||
test/test_xmssmt_fast | |||||
test/test_xmss_XMSS* | |||||
test/test_xmss_fast_XMSS* | |||||
test/test_xmssmt_XMSSMT* | |||||
test/test_xmssmt_fast_XMSSMT* | |||||
test/test_xmss_core | |||||
test/test_xmss_core_fast | |||||
test/test_xmssmt_core | |||||
test/test_xmssmt_core_fast | |||||
test/test_xmss_core_XMSS* | |||||
test/test_xmss_core_fast_XMSS* | |||||
test/test_xmssmt_core_XMSSMT* | |||||
test/test_xmssmt_core_fast_XMSSMT* | |||||
test/speed | test/speed | ||||
test/gen_testvectors | test/gen_testvectors | ||||
params_XMSS_*.h | params_XMSS_*.h | ||||
@@ -2,10 +2,10 @@ CC = /usr/bin/gcc | |||||
CFLAGS = -Wall -g -O3 -Wextra | CFLAGS = -Wall -g -O3 -Wextra | ||||
all: test/test_wots \ | all: test/test_wots \ | ||||
test/test_xmss_XMSS_SHA2-256_W16_H10 \ | |||||
test/test_xmss_fast_XMSS_SHA2-256_W16_H10 \ | |||||
test/test_xmssmt_fast_XMSSMT_SHA2-256_W16_H20_D4 \ | |||||
test/test_xmssmt_XMSSMT_SHA2-256_W16_H20_D4 | |||||
test/test_xmss_core_XMSS_SHA2-256_W16_H10 \ | |||||
test/test_xmss_core_fast_XMSS_SHA2-256_W16_H10 \ | |||||
test/test_xmssmt_core_fast_XMSSMT_SHA2-256_W16_H20_D4 \ | |||||
test/test_xmssmt_core_XMSSMT_SHA2-256_W16_H20_D4 \ | |||||
.PHONY: clean | .PHONY: clean | ||||
.PRECIOUS: params_%.h | .PRECIOUS: params_%.h | ||||
@@ -17,29 +17,29 @@ test/test_wots: params_XMSS_SHA2-256_W16_H10.h hash.c fips202.c hash_address.c r | |||||
ln -sf params_XMSS_SHA2-256_W16_H10.h params.h | ln -sf params_XMSS_SHA2-256_W16_H10.h params.h | ||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_commons.c test/test_wots.c -o $@ -lcrypto -lm | $(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_commons.c test/test_wots.c -o $@ -lcrypto -lm | ||||
test/test_xmss_XMSS_%: params_XMSS_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss.c xmss_commons.c test/test_xmss.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss.h xmss_commons.h | |||||
ln -sf params_XMSS_$(patsubst test/test_xmss_XMSS_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss.c xmss_commons.c test/test_xmss.c -o $@ -lcrypto -lm | |||||
test/test_xmss_core_XMSS_%: params_XMSS_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core.c xmss_commons.c test/test_xmss_core.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_core.h xmss_commons.h | |||||
ln -sf params_XMSS_$(patsubst test/test_xmss_core_XMSS_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core.c xmss_commons.c test/test_xmss_core.c -o $@ -lcrypto -lm | |||||
test/test_xmss_fast_XMSS_%: params_XMSS_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_fast.c xmss_commons.c test/test_xmss_fast.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_fast.h xmss_commons.h | |||||
ln -sf params_XMSS_$(patsubst test/test_xmss_fast_XMSS_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_fast.c xmss_commons.c test/test_xmss_fast.c -o $@ -lcrypto -lm | |||||
test/test_xmss_core_fast_XMSS_%: params_XMSS_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core_fast.c xmss_commons.c test/test_xmss_core_fast.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_core_fast.h xmss_commons.h | |||||
ln -sf params_XMSS_$(patsubst test/test_xmss_core_fast_XMSS_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core_fast.c xmss_commons.c test/test_xmss_core_fast.c -o $@ -lcrypto -lm | |||||
test/test_xmssmt_XMSSMT_%: params_XMSSMT_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss.c xmss_commons.c test/test_xmssmt.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss.h xmss_commons.h | |||||
ln -sf params_XMSSMT_$(patsubst test/test_xmssmt_XMSSMT_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss.c xmss_commons.c test/test_xmssmt.c -o $@ -lcrypto -lm | |||||
test/test_xmssmt_core_XMSSMT_%: params_XMSSMT_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core.c xmss_commons.c test/test_xmssmt_core.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_core.h xmss_commons.h | |||||
ln -sf params_XMSSMT_$(patsubst test/test_xmssmt_core_XMSSMT_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core.c xmss_commons.c test/test_xmssmt_core.c -o $@ -lcrypto -lm | |||||
test/test_xmssmt_fast_XMSSMT_%: params_XMSSMT_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_fast.c xmss_commons.c test/test_xmssmt_fast.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_fast.h xmss_commons.h | |||||
ln -sf params_XMSSMT_$(patsubst test/test_xmssmt_fast_XMSSMT_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_fast.c xmss_commons.c test/test_xmssmt_fast.c -o $@ -lcrypto -lm | |||||
test/test_xmssmt_core_fast_XMSSMT_%: params_XMSSMT_%.h hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core_fast.c xmss_commons.c test/test_xmssmt_core_fast.c hash.h fips202.h hash_address.h randombytes.h wots.h xmss_core_fast.h xmss_commons.h | |||||
ln -sf params_XMSSMT_$(patsubst test/test_xmssmt_core_fast_XMSSMT_%,%,$@).h params.h | |||||
$(CC) $(CFLAGS) hash.c fips202.c hash_address.c randombytes.c wots.c xmss_core_fast.c xmss_commons.c test/test_xmssmt_core_fast.c -o $@ -lcrypto -lm | |||||
clean: | clean: | ||||
-rm *.o *.s | -rm *.o *.s | ||||
-rm test/test_wots | -rm test/test_wots | ||||
-rm test/test_xmss_XMSS* | |||||
-rm test/test_xmss_fast_XMSS* | |||||
-rm test/test_xmssmt_XMSS* | |||||
-rm test/test_xmssmt_fast_XMSS* | |||||
-rm test/test_xmss_core_XMSS* | |||||
-rm test/test_xmss_core_fast_XMSS* | |||||
-rm test/test_xmssmt_core_XMSS* | |||||
-rm test/test_xmssmt_core_fast_XMSS* | |||||
distclean: | distclean: | ||||
-rm params.h | -rm params.h |
@@ -1,7 +1,7 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "../xmss.h" | |||||
#include "../xmss_core.h" | |||||
#include "../params.h" | #include "../params.h" | ||||
#include "../randombytes.h" | #include "../randombytes.h" | ||||
@@ -26,7 +26,7 @@ int main() | |||||
unsigned char sm[MLEN+signature_length]; | unsigned char sm[MLEN+signature_length]; | ||||
printf("keypair\n"); | printf("keypair\n"); | ||||
xmss_keypair(pk, sk); | |||||
xmss_core_keypair(pk, sk); | |||||
// check pub_seed in SK | // check pub_seed in SK | ||||
for (i = 0; i < XMSS_N; i++) { | for (i = 0; i < XMSS_N; i++) { | ||||
if (pk[XMSS_N+i] != sk[4+2*XMSS_N+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | if (pk[XMSS_N+i] != sk[4+2*XMSS_N+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | ||||
@@ -41,7 +41,7 @@ int main() | |||||
randombytes(mi, MLEN); | randombytes(mi, MLEN); | ||||
printf("sign\n"); | printf("sign\n"); | ||||
xmss_sign(sk, sm, &smlen, mi, MLEN); | |||||
xmss_core_sign(sk, sm, &smlen, mi, MLEN); | |||||
idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3]; | idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3]; | ||||
printf("\nidx = %lu\n",idx); | printf("\nidx = %lu\n",idx); | ||||
@@ -55,7 +55,7 @@ int main() | |||||
/* Test valid signature */ | /* Test valid signature */ | ||||
printf("verify\n"); | printf("verify\n"); | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r); | printf("%d\n", r); | ||||
if (r != 0) errors++; | if (r != 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -64,7 +64,7 @@ int main() | |||||
/* Test with modified message */ | /* Test with modified message */ | ||||
sm[signature_length+10] ^= 1; | sm[signature_length+10] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -75,7 +75,7 @@ int main() | |||||
/* Modified index */ | /* Modified index */ | ||||
sm[signature_length+10] ^= 1; | sm[signature_length+10] ^= 1; | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -85,7 +85,7 @@ int main() | |||||
/* Modified R */ | /* Modified R */ | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
sm[5] ^= 1; | sm[5] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -95,7 +95,7 @@ int main() | |||||
/* Modified OTS sig */ | /* Modified OTS sig */ | ||||
sm[5] ^= 1; | sm[5] ^= 1; | ||||
sm[240] ^= 1; | sm[240] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -105,7 +105,7 @@ int main() | |||||
/* Modified AUTH */ | /* Modified AUTH */ | ||||
sm[240] ^= 1; | sm[240] ^= 1; | ||||
sm[signature_length - 10] ^= 1; | sm[signature_length - 10] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); |
@@ -2,7 +2,7 @@ | |||||
#include <string.h> | #include <string.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include "../xmss_fast.h" | |||||
#include "../xmss_core_fast.h" | |||||
#include "../params.h" | #include "../params.h" | ||||
#include "../randombytes.h" | #include "../randombytes.h" | ||||
@@ -55,7 +55,7 @@ int main() | |||||
printf("keypair\n"); | printf("keypair\n"); | ||||
t1 = cpucycles(); | t1 = cpucycles(); | ||||
xmss_keypair(pk, sk, state); | |||||
xmss_core_keypair(pk, sk, state); | |||||
t2 = cpucycles(); | t2 = cpucycles(); | ||||
printf("cycles = %llu\n", (t2-t1)); | printf("cycles = %llu\n", (t2-t1)); | ||||
double sec = (t2-t1)/3500000; | double sec = (t2-t1)/3500000; | ||||
@@ -72,7 +72,7 @@ int main() | |||||
for (i = 0; i < SIGNATURES; i++) { | for (i = 0; i < SIGNATURES; i++) { | ||||
printf("sign\n"); | printf("sign\n"); | ||||
xmss_sign(sk, state, sm, &smlen, mi, MLEN); | |||||
xmss_core_sign(sk, state, sm, &smlen, mi, MLEN); | |||||
idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3]; | idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3]; | ||||
printf("\nidx = %lu\n",idx); | printf("\nidx = %lu\n",idx); | ||||
@@ -81,7 +81,7 @@ int main() | |||||
/* Test valid signature */ | /* Test valid signature */ | ||||
printf("verify\n"); | printf("verify\n"); | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r); | printf("%d\n", r); | ||||
if (r != 0) errors++; | if (r != 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -90,7 +90,7 @@ int main() | |||||
/* Test with modified message */ | /* Test with modified message */ | ||||
sm[signature_length+10] ^= 1; | sm[signature_length+10] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -101,7 +101,7 @@ int main() | |||||
/* Modified index */ | /* Modified index */ | ||||
sm[signature_length+10] ^= 1; | sm[signature_length+10] ^= 1; | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -111,7 +111,7 @@ int main() | |||||
/* Modified R */ | /* Modified R */ | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
sm[5] ^= 1; | sm[5] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -121,7 +121,7 @@ int main() | |||||
/* Modified OTS sig */ | /* Modified OTS sig */ | ||||
sm[5] ^= 1; | sm[5] ^= 1; | ||||
sm[240] ^= 1; | sm[240] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
@@ -131,7 +131,7 @@ int main() | |||||
/* Modified AUTH */ | /* Modified AUTH */ | ||||
sm[240] ^= 1; | sm[240] ^= 1; | ||||
sm[signature_length - 10] ^= 1; | sm[signature_length - 10] ^= 1; | ||||
r = xmss_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmss_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
if (r == 0) errors++; | if (r == 0) errors++; | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); |
@@ -1,7 +1,7 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "../xmss.h" | |||||
#include "../xmss_core.h" | |||||
#include "../params.h" | #include "../params.h" | ||||
#include "../randombytes.h" | #include "../randombytes.h" | ||||
@@ -25,7 +25,7 @@ int main() | |||||
unsigned char sm[MLEN+signature_length]; | unsigned char sm[MLEN+signature_length]; | ||||
printf("keypair\n"); | printf("keypair\n"); | ||||
xmssmt_keypair(pk, sk); | |||||
xmssmt_core_keypair(pk, sk); | |||||
// check pub_seed in SK | // check pub_seed in SK | ||||
for (i = 0; i < XMSS_N; i++) { | for (i = 0; i < XMSS_N; i++) { | ||||
if (pk[XMSS_N+i] != sk[XMSS_INDEX_LEN+2*XMSS_N+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | if (pk[XMSS_N+i] != sk[XMSS_INDEX_LEN+2*XMSS_N+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | ||||
@@ -46,7 +46,7 @@ int main() | |||||
randombytes(mi, MLEN); | randombytes(mi, MLEN); | ||||
printf("sign\n"); | printf("sign\n"); | ||||
xmssmt_sign(sk, sm, &smlen, mi, MLEN); | |||||
xmssmt_core_sign(sk, sm, &smlen, mi, MLEN); | |||||
idx = 0; | idx = 0; | ||||
for (j = 0; j < idx_len; j++) { | for (j = 0; j < idx_len; j++) { | ||||
idx += ((unsigned long long)sm[j]) << 8*(idx_len - 1 - j); | idx += ((unsigned long long)sm[j]) << 8*(idx_len - 1 - j); | ||||
@@ -62,7 +62,7 @@ int main() | |||||
/* Test valid signature */ | /* Test valid signature */ | ||||
printf("verify\n"); | printf("verify\n"); | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r); | printf("%d\n", r); | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
printf("%d\n", r); | printf("%d\n", r); | ||||
@@ -70,7 +70,7 @@ int main() | |||||
/* Test with modified message */ | /* Test with modified message */ | ||||
sm[52] ^= 1; | sm[52] ^= 1; | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
printf("%d\n", (r!=0) - 1); | printf("%d\n", (r!=0) - 1); | ||||
@@ -80,7 +80,7 @@ int main() | |||||
sm[260] ^= 1; | sm[260] ^= 1; | ||||
sm[52] ^= 1; | sm[52] ^= 1; | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
printf("%d\n", (r!=0) - 1); | printf("%d\n", (r!=0) - 1); |
@@ -1,7 +1,7 @@ | |||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "../xmss_fast.h" | |||||
#include "../xmss_core_fast.h" | |||||
#include "../params.h" | #include "../params.h" | ||||
#include "../randombytes.h" | #include "../randombytes.h" | ||||
@@ -67,7 +67,7 @@ int main() | |||||
randombytes(mi, MLEN); | randombytes(mi, MLEN); | ||||
printf("keypair\n"); | printf("keypair\n"); | ||||
xmssmt_keypair(pk, sk, states, wots_sigs); | |||||
xmssmt_core_keypair(pk, sk, states, wots_sigs); | |||||
// check pub_seed in SK | // check pub_seed in SK | ||||
for (i = 0; i < n; i++) { | for (i = 0; i < n; i++) { | ||||
if (pk[n+i] != sk[XMSS_INDEX_LEN+2*n+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | if (pk[n+i] != sk[XMSS_INDEX_LEN+2*n+i]) printf("pk.pub_seed != sk.pub_seed %llu",i); | ||||
@@ -87,7 +87,7 @@ int main() | |||||
for (i = 0; i < SIGNATURES; i++) { | for (i = 0; i < SIGNATURES; i++) { | ||||
printf("sign\n"); | printf("sign\n"); | ||||
t1 = cpucycles(); | t1 = cpucycles(); | ||||
xmssmt_sign(sk, states, wots_sigs, sm, &smlen, mi, MLEN); | |||||
xmssmt_core_sign(sk, states, wots_sigs, sm, &smlen, mi, MLEN); | |||||
t2 = cpucycles(); | t2 = cpucycles(); | ||||
printf("signing cycles = %llu\n", (t2-t1)); | printf("signing cycles = %llu\n", (t2-t1)); | ||||
@@ -102,7 +102,7 @@ int main() | |||||
/* Test valid signature */ | /* Test valid signature */ | ||||
printf("verify\n"); | printf("verify\n"); | ||||
t1 = cpucycles(); | t1 = cpucycles(); | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
t2 = cpucycles(); | t2 = cpucycles(); | ||||
printf("verification cycles = %llu\n", (t2-t1)); | printf("verification cycles = %llu\n", (t2-t1)); | ||||
printf("%d\n", r); | printf("%d\n", r); | ||||
@@ -112,7 +112,7 @@ int main() | |||||
/* Test with modified message */ | /* Test with modified message */ | ||||
sm[52] ^= 1; | sm[52] ^= 1; | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
printf("%d\n", (r!=0) - 1); | printf("%d\n", (r!=0) - 1); | ||||
@@ -122,7 +122,7 @@ int main() | |||||
sm[260] ^= 1; | sm[260] ^= 1; | ||||
sm[52] ^= 1; | sm[52] ^= 1; | ||||
sm[2] ^= 1; | sm[2] ^= 1; | ||||
r = xmssmt_sign_open(mo, &mlen, sm, smlen, pk); | |||||
r = xmssmt_core_sign_open(mo, &mlen, sm, smlen, pk); | |||||
printf("%d\n", r+1); | printf("%d\n", r+1); | ||||
r = memcmp(mi,mo,MLEN); | r = memcmp(mi,mo,MLEN); | ||||
printf("%d\n", (r!=0) - 1); | printf("%d\n", (r!=0) - 1); |
@@ -146,7 +146,7 @@ static void validate_authpath(unsigned char *root, const unsigned char *leaf, un | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
*/ | */ | ||||
int xmss_sign_open(unsigned char *m, unsigned long long *mlen, const unsigned char *sm, unsigned long long smlen, const unsigned char *pk) | |||||
int xmss_core_sign_open(unsigned char *m, unsigned long long *mlen, const unsigned char *sm, unsigned long long smlen, const unsigned char *pk) | |||||
{ | { | ||||
unsigned long long i, m_len; | unsigned long long i, m_len; | ||||
unsigned long idx=0; | unsigned long idx=0; | ||||
@@ -229,7 +229,7 @@ fail: | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
*/ | */ | ||||
int xmssmt_sign_open(unsigned char *m, unsigned long long *mlen, const unsigned char *sm, unsigned long long smlen, const unsigned char *pk) | |||||
int xmssmt_core_sign_open(unsigned char *m, unsigned long long *mlen, const unsigned char *sm, unsigned long long smlen, const unsigned char *pk) | |||||
{ | { | ||||
uint64_t idx_tree; | uint64_t idx_tree; | ||||
uint32_t idx_leaf; | uint32_t idx_leaf; | ||||
@@ -15,6 +15,6 @@ void hexdump(const unsigned char *a, size_t len); | |||||
void gen_leaf_wots(unsigned char *leaf, const unsigned char *sk_seed, const unsigned char *pub_seed, uint32_t ltree_addr[8], uint32_t ots_addr[8]); | void gen_leaf_wots(unsigned char *leaf, const unsigned char *sk_seed, const unsigned char *pub_seed, uint32_t ltree_addr[8], uint32_t ots_addr[8]); | ||||
void get_seed(unsigned char *seed, const unsigned char *sk_seed, uint32_t addr[8]); | void get_seed(unsigned char *seed, const unsigned char *sk_seed, uint32_t addr[8]); | ||||
void l_tree(unsigned char *leaf, unsigned char *wots_pk, const unsigned char *pub_seed, uint32_t addr[8]); | void l_tree(unsigned char *leaf, unsigned char *wots_pk, const unsigned char *pub_seed, uint32_t addr[8]); | ||||
int xmss_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmss_core_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmssmt_core_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
#endif | #endif |
@@ -5,7 +5,7 @@ Joost Rijneveld | |||||
Public domain. | Public domain. | ||||
*/ | */ | ||||
#include "xmss.h" | |||||
#include "xmss_core.h" | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
@@ -120,7 +120,7 @@ static void compute_authpath_wots(unsigned char *root, unsigned char *authpath, | |||||
* Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmss_keypair(unsigned char *pk, unsigned char *sk) | |||||
int xmss_core_keypair(unsigned char *pk, unsigned char *sk) | |||||
{ | { | ||||
// Set idx = 0 | // Set idx = 0 | ||||
sk[0] = 0; | sk[0] = 0; | ||||
@@ -147,7 +147,7 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk) | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmss_sign(unsigned char *sk, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
int xmss_core_sign(unsigned char *sk, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
{ | { | ||||
uint16_t i = 0; | uint16_t i = 0; | ||||
@@ -246,7 +246,7 @@ int xmss_sign(unsigned char *sk, unsigned char *sm, unsigned long long *smlen, c | |||||
* Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED] | * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmssmt_keypair(unsigned char *pk, unsigned char *sk) | |||||
int xmssmt_core_keypair(unsigned char *pk, unsigned char *sk) | |||||
{ | { | ||||
uint16_t i; | uint16_t i; | ||||
// Set idx = 0 | // Set idx = 0 | ||||
@@ -275,7 +275,7 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk) | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmssmt_sign(unsigned char *sk, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
int xmssmt_core_sign(unsigned char *sk, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
{ | { | ||||
uint64_t idx_tree; | uint64_t idx_tree; | ||||
uint32_t idx_leaf; | uint32_t idx_leaf; |
@@ -7,15 +7,15 @@ Public domain. | |||||
#include "wots.h" | #include "wots.h" | ||||
#ifndef XMSS_H | |||||
#define XMSS_H | |||||
#ifndef XMSS_CORE_H | |||||
#define XMSS_CORE_H | |||||
/** | /** | ||||
* Generates a XMSS key pair for a given parameter set. | * Generates a XMSS key pair for a given parameter set. | ||||
* Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmss_keypair(unsigned char *pk, unsigned char *sk); | |||||
int xmss_core_keypair(unsigned char *pk, unsigned char *sk); | |||||
/** | /** | ||||
* Signs a message. | * Signs a message. | ||||
* Returns | * Returns | ||||
@@ -23,20 +23,20 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk); | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmss_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
int xmss_core_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
* | * | ||||
* Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg). | * Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg). | ||||
*/ | */ | ||||
int xmss_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmss_core_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
/* | /* | ||||
* Generates a XMSSMT key pair for a given parameter set. | * Generates a XMSSMT key pair for a given parameter set. | ||||
* Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmssmt_keypair(unsigned char *pk, unsigned char *sk); | |||||
int xmssmt_core_keypair(unsigned char *pk, unsigned char *sk); | |||||
/** | /** | ||||
* Signs a message. | * Signs a message. | ||||
* Returns | * Returns | ||||
@@ -44,10 +44,10 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk); | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmssmt_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
int xmssmt_core_sign(unsigned char *sk, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
*/ | */ | ||||
int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmssmt_core_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
#endif | #endif | ||||
@@ -5,7 +5,7 @@ Joost Rijneveld | |||||
Public domain. | Public domain. | ||||
*/ | */ | ||||
#include "xmss_fast.h" | |||||
#include "xmss_core_fast.h" | |||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <stdint.h> | #include <stdint.h> | ||||
@@ -331,7 +331,7 @@ static void bds_round(bds_state *state, const unsigned long leaf_idx, const unsi | |||||
* Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state) | |||||
int xmss_core_keypair(unsigned char *pk, unsigned char *sk, bds_state *state) | |||||
{ | { | ||||
// Set idx = 0 | // Set idx = 0 | ||||
sk[0] = 0; | sk[0] = 0; | ||||
@@ -359,7 +359,7 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state) | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
int xmss_core_sign(unsigned char *sk, bds_state *state, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
{ | { | ||||
uint16_t i = 0; | uint16_t i = 0; | ||||
@@ -464,7 +464,7 @@ int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sm, unsigned l | |||||
* Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs) | |||||
int xmssmt_core_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs) | |||||
{ | { | ||||
unsigned char ots_seed[XMSS_N]; | unsigned char ots_seed[XMSS_N]; | ||||
int i; | int i; | ||||
@@ -501,7 +501,7 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsi | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmssmt_sign(unsigned char *sk, bds_state *states, unsigned char *wots_sigs, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
int xmssmt_core_sign(unsigned char *sk, bds_state *states, unsigned char *wots_sigs, unsigned char *sm, unsigned long long *smlen, const unsigned char *m, unsigned long long mlen) | |||||
{ | { | ||||
uint64_t idx_tree; | uint64_t idx_tree; | ||||
uint32_t idx_leaf; | uint32_t idx_leaf; |
@@ -7,8 +7,8 @@ Public domain. | |||||
#include "wots.h" | #include "wots.h" | ||||
#ifndef XMSS_H | |||||
#define XMSS_H | |||||
#ifndef XMSS_CORE_H | |||||
#define XMSS_CORE_H | |||||
typedef struct{ | typedef struct{ | ||||
unsigned int h; | unsigned int h; | ||||
@@ -39,7 +39,7 @@ void xmss_set_bds_state(bds_state *state, unsigned char *stack, int stackoffset, | |||||
* Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(32bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state); | |||||
int xmss_core_keypair(unsigned char *pk, unsigned char *sk, bds_state *state); | |||||
/** | /** | ||||
* Signs a message. | * Signs a message. | ||||
* Returns | * Returns | ||||
@@ -47,20 +47,20 @@ int xmss_keypair(unsigned char *pk, unsigned char *sk, bds_state *state); | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmss_sign(unsigned char *sk, bds_state *state, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen); | |||||
int xmss_core_sign(unsigned char *sk, bds_state *state, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg,unsigned long long msglen); | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
* | * | ||||
* Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg). | * Note: msg and msglen are pure outputs which carry the message in case verification succeeds. The (input) message is assumed to be within sig_msg which has the form (sig||msg). | ||||
*/ | */ | ||||
int xmss_sign_open(unsigned char *msg,unsigned long long *msglen, const unsigned char *sig_msg,unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmss_core_sign_open(unsigned char *msg,unsigned long long *msglen, const unsigned char *sig_msg,unsigned long long sig_msg_len, const unsigned char *pk); | |||||
/* | /* | ||||
* Generates a XMSSMT key pair for a given parameter set. | * Generates a XMSSMT key pair for a given parameter set. | ||||
* Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | * Format sk: [(ceil(h/8) bit) idx || SK_SEED || SK_PRF || PUB_SEED || root] | ||||
* Format pk: [root || PUB_SEED] omitting algo oid. | * Format pk: [root || PUB_SEED] omitting algo oid. | ||||
*/ | */ | ||||
int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs); | |||||
int xmssmt_core_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsigned char *wots_sigs); | |||||
/** | /** | ||||
* Signs a message. | * Signs a message. | ||||
* Returns | * Returns | ||||
@@ -68,10 +68,10 @@ int xmssmt_keypair(unsigned char *pk, unsigned char *sk, bds_state *states, unsi | |||||
* 2. an updated secret key! | * 2. an updated secret key! | ||||
* | * | ||||
*/ | */ | ||||
int xmssmt_sign(unsigned char *sk, bds_state *state, unsigned char *wots_sigs, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
int xmssmt_core_sign(unsigned char *sk, bds_state *state, unsigned char *wots_sigs, unsigned char *sig_msg, unsigned long long *sig_msg_len, const unsigned char *msg, unsigned long long msglen); | |||||
/** | /** | ||||
* Verifies a given message signature pair under a given public key. | * Verifies a given message signature pair under a given public key. | ||||
*/ | */ | ||||
int xmssmt_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
int xmssmt_core_sign_open(unsigned char *msg, unsigned long long *msglen, const unsigned char *sig_msg, unsigned long long sig_msg_len, const unsigned char *pk); | |||||
#endif | #endif | ||||