2
0

deprecated_test.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* LibTomCrypt, modular cryptographic library -- Tom St Denis */
  2. /* SPDX-License-Identifier: Unlicense */
  3. #define LTC_DEPRECATED(x)
  4. #include <tomcrypt_test.h>
  5. #ifdef LTC_MECC
  6. static void s_ecc_test(void)
  7. {
  8. const ltc_ecc_curve* dp;
  9. unsigned char buf[128];
  10. unsigned long len;
  11. ecc_key key;
  12. int stat;
  13. unsigned char data16[16] = { 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1, 0xd1 };
  14. /* We need an MPI provider for ECC */
  15. if (ltc_mp.name == NULL) return;
  16. ENSURE(ltc_ecc_curves[0].OID != NULL);
  17. DO(ecc_find_curve(ltc_ecc_curves[0].OID, &dp));
  18. DO(ecc_make_key_ex(&yarrow_prng, find_prng ("yarrow"), &key, dp));
  19. len = sizeof(buf);
  20. DO(ecc_sign_hash(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &key));
  21. stat = 0;
  22. DO(ecc_verify_hash(buf, len, data16, 16, &stat, &key));
  23. SHOULD_FAIL(ecc_verify_hash_rfc7518(buf, len, data16, 16, &stat, &key));
  24. len = sizeof(buf);
  25. DO(ecc_sign_hash_rfc7518(data16, 16, buf, &len, &yarrow_prng, find_prng ("yarrow"), &key));
  26. stat = 0;
  27. DO(ecc_verify_hash_rfc7518(buf, len, data16, 16, &stat, &key));
  28. SHOULD_FAIL(ecc_verify_hash(buf, len, data16, 16, &stat, &key));
  29. ecc_free(&key);
  30. }
  31. #endif
  32. int deprecated_test(void)
  33. {
  34. #ifdef LTC_MECC
  35. s_ecc_test();
  36. #endif
  37. return 0;
  38. }