Make xmss and xmss_fast test verify each signature
This commit is contained in:
parent
6ee57d1883
commit
3b75e0e133
@ -50,37 +50,36 @@ int main()
|
|||||||
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
/* 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);
|
fclose(urandom);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "../xmss.h"
|
#include "../xmss_fast.h"
|
||||||
|
|
||||||
#define MLEN 3491
|
#define MLEN 3491
|
||||||
#define SIGNATURES 50
|
#define SIGNATURES 50
|
||||||
@ -50,37 +50,36 @@ int main()
|
|||||||
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
/* 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
/* 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);
|
fclose(urandom);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user