2017-10-17 16:11:18 +01:00
|
|
|
#include "../params.h"
|
2017-10-26 13:24:10 +01:00
|
|
|
#include "../xmss.h"
|
2017-10-17 16:11:18 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define MLEN 32
|
|
|
|
|
2017-10-26 12:47:29 +01:00
|
|
|
#ifdef XMSSMT
|
|
|
|
#define XMSS_PARSE_OID xmssmt_parse_oid
|
2017-10-26 13:24:10 +01:00
|
|
|
#define XMSS_SIGN_OPEN xmssmt_sign_open
|
2017-10-26 12:47:29 +01:00
|
|
|
#else
|
|
|
|
#define XMSS_PARSE_OID xmss_parse_oid
|
2017-10-26 13:24:10 +01:00
|
|
|
#define XMSS_SIGN_OPEN xmss_sign_open
|
2017-10-26 12:47:29 +01:00
|
|
|
#endif
|
|
|
|
|
2017-10-17 16:11:18 +01:00
|
|
|
int main(int argc, char **argv) {
|
|
|
|
FILE *keypair;
|
|
|
|
xmss_params params;
|
|
|
|
uint32_t oid;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
fprintf(stderr, "Expected keypair filename as only parameter, "
|
2017-10-19 15:08:09 +01:00
|
|
|
"and the signature + message via stdin.\n"
|
2017-10-17 16:11:18 +01:00
|
|
|
"Keypair file needs only to contain the public key.\n"
|
|
|
|
"The return code 0 indicates verification success.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
keypair = fopen(argv[1], "rb");
|
|
|
|
if (keypair == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
fread(&oid, 1, XMSS_OID_LEN, keypair);
|
2017-10-26 12:47:29 +01:00
|
|
|
XMSS_PARSE_OID(¶ms, oid);
|
2017-10-17 16:11:18 +01:00
|
|
|
|
2017-10-26 13:24:10 +01:00
|
|
|
unsigned char pk[XMSS_OID_LEN + params.pk_bytes];
|
2017-10-24 16:51:56 +01:00
|
|
|
unsigned char sm[params.sig_bytes + MLEN];
|
|
|
|
unsigned char m[params.sig_bytes + MLEN];
|
2017-10-17 16:11:18 +01:00
|
|
|
unsigned long long mlen;
|
|
|
|
|
2017-10-26 13:24:10 +01:00
|
|
|
fseek(keypair, 0, SEEK_SET);
|
|
|
|
fread(pk, 1, XMSS_OID_LEN + params.pk_bytes, keypair);
|
2017-10-24 16:51:56 +01:00
|
|
|
fread(sm, 1, params.sig_bytes + MLEN, stdin);
|
2017-10-17 16:11:18 +01:00
|
|
|
|
2017-10-26 13:24:10 +01:00
|
|
|
ret = XMSS_SIGN_OPEN(m, &mlen, sm, params.sig_bytes + MLEN, pk);
|
2017-10-17 16:11:18 +01:00
|
|
|
|
|
|
|
if (ret) {
|
|
|
|
printf("Verification failed!\n");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("Verification succeeded.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|