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.

51 lines
1.5 KiB

  1. #define TEST_NAME "scalarmult6"
  2. #include "cmptest.h"
  3. unsigned char bobsk_[crypto_scalarmult_SCALARBYTES]
  4. = { 0x5d, 0xab, 0x08, 0x7e, 0x62, 0x4a, 0x8a, 0x4b, 0x79, 0xe1, 0x7f,
  5. 0x8b, 0x83, 0x80, 0x0e, 0xe6, 0x6f, 0x3b, 0xb1, 0x29, 0x26, 0x18,
  6. 0xb6, 0xfd, 0x1c, 0x2f, 0x8b, 0x27, 0xff, 0x88, 0xe0, 0xeb };
  7. unsigned char alicepk_[crypto_scalarmult_SCALARBYTES]
  8. = { 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
  9. 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
  10. 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a };
  11. unsigned char k[32];
  12. int main(void)
  13. {
  14. unsigned char *k;
  15. unsigned char *bobsk;
  16. unsigned char *alicepk;
  17. int i;
  18. k = (unsigned char *) sodium_malloc(crypto_scalarmult_BYTES);
  19. bobsk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
  20. alicepk = (unsigned char *) sodium_malloc(crypto_scalarmult_SCALARBYTES);
  21. assert(k != NULL && bobsk != NULL && alicepk != NULL);
  22. memcpy(bobsk, bobsk_, crypto_scalarmult_SCALARBYTES);
  23. memcpy(alicepk, alicepk_, crypto_scalarmult_SCALARBYTES);
  24. crypto_scalarmult(k, bobsk, alicepk);
  25. sodium_free(alicepk);
  26. sodium_free(bobsk);
  27. for (i = 0; i < 32; ++i) {
  28. if (i > 0) {
  29. printf(",");
  30. } else {
  31. printf(" ");
  32. }
  33. printf("0x%02x", (unsigned int)k[i]);
  34. if (i % 8 == 7) {
  35. printf("\n");
  36. }
  37. }
  38. sodium_free(k);
  39. return 0;
  40. }