Browse Source

Make xmss and xmss_fast test verify each signature

master
Joost Rijneveld 9 years ago
parent
commit
3b75e0e133
2 changed files with 55 additions and 57 deletions
  1. +27
    -28
      test/test_xmss.c
  2. +28
    -29
      test/test_xmss_fast.c

+ 27
- 28
test/test_xmss.c View File

@@ -49,37 +49,36 @@ int main()
xmss_sign(sk, sm, &smlen, mi, MLEN, params);
idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3];
printf("\nidx = %lu\n",idx);
}

r = memcmp(mi, sm+signature_length,MLEN);
printf("%d\n", r);
/* Test valid signature */
printf("verify\n");
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r);
r = memcmp(mi,mo,MLEN);
printf("%d\n", r);
printf("%llu\n", MLEN-mlen);
r = memcmp(mi, sm+signature_length,MLEN);
printf("%d\n", r);

/* Test with modified message */
sm[52] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
/* Test valid signature */
printf("verify\n");
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r);
r = memcmp(mi,mo,MLEN);
printf("%d\n", r);
printf("%llu\n", MLEN-mlen);

/* Test with modified signature */
sm[260] ^= 1;
sm[52] ^= 1;
sm[2] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
/* Test with modified message */
sm[52] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);

/* Test with modified signature */
sm[260] ^= 1;
sm[52] ^= 1;
sm[2] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
}

fclose(urandom);
return 0;


+ 28
- 29
test/test_xmss_fast.c View File

@@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>

#include "../xmss.h"
#include "../xmss_fast.h"

#define MLEN 3491
#define SIGNATURES 50
@@ -49,37 +49,36 @@ int main()
xmss_sign(sk, sm, &smlen, mi, MLEN, params);
idx = ((unsigned long)sm[0] << 24) | ((unsigned long)sm[1] << 16) | ((unsigned long)sm[2] << 8) | sm[3];
printf("\nidx = %lu\n",idx);
}

r = memcmp(mi, sm+signature_length,MLEN);
printf("%d\n", r);
/* Test valid signature */
printf("verify\n");
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r);
r = memcmp(mi,mo,MLEN);
printf("%d\n", r);
printf("%llu\n", MLEN-mlen);
r = memcmp(mi, sm+signature_length,MLEN);
printf("%d\n", r);

/* Test with modified message */
sm[52] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
/* Test valid signature */
printf("verify\n");
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r);
r = memcmp(mi,mo,MLEN);
printf("%d\n", r);
printf("%llu\n", MLEN-mlen);

/* Test with modified signature */
sm[260] ^= 1;
sm[52] ^= 1;
sm[2] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
/* Test with modified message */
sm[52] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);

/* Test with modified signature */
sm[260] ^= 1;
sm[52] ^= 1;
sm[2] ^= 1;
r = xmss_sign_open(mo, &mlen, sm, smlen, pk, params);
printf("%d\n", r+1);
r = memcmp(mi,mo,MLEN);
printf("%d\n", (r!=0) - 1);
printf("%llu\n", mlen+1);
}

fclose(urandom);
return 0;


Loading…
Cancel
Save