scalarmult7.c 909 B

12345678910111213141516171819202122232425262728293031323334
  1. #define TEST_NAME "scalarmult7"
  2. #include "cmptest.h"
  3. static unsigned char p1[32] = {
  4. 0x72, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
  5. 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
  6. 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0xea
  7. };
  8. static unsigned char p2[32] = {
  9. 0x85, 0x20, 0xf0, 0x09, 0x89, 0x30, 0xa7, 0x54, 0x74, 0x8b, 0x7d,
  10. 0xdc, 0xb4, 0x3e, 0xf7, 0x5a, 0x0d, 0xbf, 0x3a, 0x0d, 0x26, 0x38,
  11. 0x1a, 0xf4, 0xeb, 0xa4, 0xa9, 0x8e, 0xaa, 0x9b, 0x4e, 0x6a
  12. };
  13. static unsigned char scalar[32];
  14. static unsigned char out1[32];
  15. static unsigned char out2[32];
  16. int
  17. main(void)
  18. {
  19. int ret;
  20. scalar[0] = 1U;
  21. ret = crypto_scalarmult_curve25519(out1, scalar, p1);
  22. assert(ret == 0);
  23. ret = crypto_scalarmult_curve25519(out2, scalar, p2);
  24. assert(ret == 0);
  25. printf("%d\n", !!memcmp(out1, out2, 32));
  26. return 0;
  27. }