You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

  1. #include "../params.h"
  2. #include "../xmss_core.h"
  3. #include <stdio.h>
  4. #define MLEN 32
  5. int main(int argc, char **argv) {
  6. FILE *keypair;
  7. xmss_params params;
  8. uint32_t oid;
  9. int ret;
  10. if (argc != 2) {
  11. fprintf(stderr, "Expected keypair filename as only parameter, "
  12. "and the signature + message via stdin.\n"
  13. "Keypair file needs only to contain the public key.\n"
  14. "The return code 0 indicates verification success.\n");
  15. return -1;
  16. }
  17. keypair = fopen(argv[1], "rb");
  18. if (keypair == NULL) {
  19. return -1;
  20. }
  21. fread(&oid, 1, XMSS_OID_LEN, keypair);
  22. xmss_parse_oid(&params, oid);
  23. unsigned char pk[params.publickey_bytes];
  24. unsigned char sm[params.bytes + MLEN];
  25. unsigned char m[params.bytes + MLEN];
  26. unsigned long long mlen;
  27. fread(pk, 1, params.publickey_bytes, keypair);
  28. fread(sm, 1, params.bytes + MLEN, stdin);
  29. ret = xmss_core_sign_open(&params, m, &mlen, sm, params.bytes + MLEN, pk);
  30. if (ret) {
  31. printf("Verification failed!\n");
  32. }
  33. else {
  34. printf("Verification succeeded.\n");
  35. }
  36. return ret;
  37. }