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.

keypair.c 1.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <stdio.h>
  2. #include <stdint.h>
  3. #include "../params.h"
  4. #include "../xmss.h"
  5. #ifdef XMSSMT
  6. #define XMSS_STR_TO_OID xmssmt_str_to_oid
  7. #define XMSS_PARSE_OID xmssmt_parse_oid
  8. #define XMSS_KEYPAIR xmssmt_keypair
  9. #else
  10. #define XMSS_STR_TO_OID xmss_str_to_oid
  11. #define XMSS_PARSE_OID xmss_parse_oid
  12. #define XMSS_KEYPAIR xmss_keypair
  13. #endif
  14. int main(int argc, char **argv)
  15. {
  16. xmss_params params;
  17. uint32_t oid = 0;
  18. int parse_oid_result = 0;
  19. if (argc != 2) {
  20. fprintf(stderr, "Expected parameter string (e.g. 'XMSS-SHA2_10_256')"
  21. " as only parameter.\n"
  22. "The keypair is written to stdout.\n");
  23. return -1;
  24. }
  25. XMSS_STR_TO_OID(&oid, argv[1]);
  26. parse_oid_result = XMSS_PARSE_OID(&params, oid);
  27. if (parse_oid_result != 0) {
  28. fprintf(stderr, "Error parsing oid.\n");
  29. return parse_oid_result;
  30. }
  31. unsigned char pk[XMSS_OID_LEN + params.pk_bytes];
  32. unsigned char sk[XMSS_OID_LEN + params.sk_bytes];
  33. XMSS_KEYPAIR(pk, sk, oid);
  34. fwrite(pk, 1, XMSS_OID_LEN + params.pk_bytes, stdout);
  35. fwrite(sk, 1, XMSS_OID_LEN + params.sk_bytes, stdout);
  36. fclose(stdout);
  37. return 0;
  38. }