core1.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <rtthread.h>
  2. #define TEST_NAME "core1"
  3. #include <assert.h>
  4. #include <errno.h>
  5. #include <limits.h>
  6. #include <stdio.h>
  7. #include <stdint.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include "sodium.h"
  11. static unsigned char shared[32] = { 0x4a, 0x5d, 0x9d, 0x5b, 0xa4, 0xce, 0x2d,
  12. 0xe1, 0x72, 0x8e, 0x3b, 0xf4, 0x80, 0x35,
  13. 0x0f, 0x25, 0xe0, 0x7e, 0x21, 0xc9, 0x47,
  14. 0xd1, 0x9e, 0x33, 0x76, 0xf0, 0x9b, 0x3c,
  15. 0x1e, 0x16, 0x17, 0x42 };
  16. static unsigned char zero[32];
  17. static unsigned char c[16] = { 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x20, 0x33,
  18. 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20, 0x6b };
  19. static unsigned char firstkey[32];
  20. int
  21. libsodium_core_1_test(void)
  22. {
  23. int i;
  24. crypto_core_hsalsa20(firstkey, zero, shared, c);
  25. for (i = 0; i < 32; ++i) {
  26. if (i > 0) {
  27. printf(",");
  28. } else {
  29. printf(" ");
  30. }
  31. printf("0x%02x", (unsigned int) firstkey[i]);
  32. if (i % 8 == 7) {
  33. printf("\n");
  34. }
  35. }
  36. assert(crypto_core_hsalsa20_outputbytes() > 0U);
  37. assert(crypto_core_hsalsa20_inputbytes() > 0U);
  38. assert(crypto_core_hsalsa20_keybytes() > 0U);
  39. assert(crypto_core_hsalsa20_constbytes() > 0U);
  40. return 0;
  41. }
  42. MSH_CMD_EXPORT(libsodium_core_1_test, libsodium core1 test)