ec_internal_test.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. /*
  10. * Low level APIs are deprecated for public use, but still ok for internal use.
  11. */
  12. #include "internal/deprecated.h"
  13. #include "internal/nelem.h"
  14. #include "testutil.h"
  15. #include <openssl/ec.h>
  16. #include "ec_local.h"
  17. #include <openssl/objects.h>
  18. static size_t crv_len = 0;
  19. static EC_builtin_curve *curves = NULL;
  20. /* sanity checks field_inv function pointer in EC_METHOD */
  21. static int group_field_tests(const EC_GROUP *group, BN_CTX *ctx)
  22. {
  23. BIGNUM *a = NULL, *b = NULL, *c = NULL;
  24. int ret = 0;
  25. if (group->meth->field_inv == NULL || group->meth->field_mul == NULL)
  26. return 1;
  27. BN_CTX_start(ctx);
  28. a = BN_CTX_get(ctx);
  29. b = BN_CTX_get(ctx);
  30. if (!TEST_ptr(c = BN_CTX_get(ctx))
  31. /* 1/1 = 1 */
  32. || !TEST_true(group->meth->field_inv(group, b, BN_value_one(), ctx))
  33. || !TEST_true(BN_is_one(b))
  34. /* (1/a)*a = 1 */
  35. || !TEST_true(BN_rand(a, BN_num_bits(group->field) - 1,
  36. BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ANY))
  37. || !TEST_true(group->meth->field_inv(group, b, a, ctx))
  38. || (group->meth->field_encode &&
  39. !TEST_true(group->meth->field_encode(group, a, a, ctx)))
  40. || (group->meth->field_encode &&
  41. !TEST_true(group->meth->field_encode(group, b, b, ctx)))
  42. || !TEST_true(group->meth->field_mul(group, c, a, b, ctx))
  43. || (group->meth->field_decode &&
  44. !TEST_true(group->meth->field_decode(group, c, c, ctx)))
  45. || !TEST_true(BN_is_one(c)))
  46. goto err;
  47. /* 1/0 = error */
  48. BN_zero(a);
  49. if (!TEST_false(group->meth->field_inv(group, b, a, ctx))
  50. || !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)
  51. || !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==
  52. EC_R_CANNOT_INVERT)
  53. /* 1/p = error */
  54. || !TEST_false(group->meth->field_inv(group, b, group->field, ctx))
  55. || !TEST_true(ERR_GET_LIB(ERR_peek_last_error()) == ERR_LIB_EC)
  56. || !TEST_true(ERR_GET_REASON(ERR_peek_last_error()) ==
  57. EC_R_CANNOT_INVERT))
  58. goto err;
  59. ERR_clear_error();
  60. ret = 1;
  61. err:
  62. BN_CTX_end(ctx);
  63. return ret;
  64. }
  65. /* wrapper for group_field_tests for explicit curve params and EC_METHOD */
  66. static int field_tests(const EC_METHOD *meth, const unsigned char *params,
  67. int len)
  68. {
  69. BN_CTX *ctx = NULL;
  70. BIGNUM *p = NULL, *a = NULL, *b = NULL;
  71. EC_GROUP *group = NULL;
  72. int ret = 0;
  73. if (!TEST_ptr(ctx = BN_CTX_new()))
  74. return 0;
  75. BN_CTX_start(ctx);
  76. p = BN_CTX_get(ctx);
  77. a = BN_CTX_get(ctx);
  78. if (!TEST_ptr(b = BN_CTX_get(ctx))
  79. || !TEST_ptr(group = EC_GROUP_new(meth))
  80. || !TEST_true(BN_bin2bn(params, len, p))
  81. || !TEST_true(BN_bin2bn(params + len, len, a))
  82. || !TEST_true(BN_bin2bn(params + 2 * len, len, b))
  83. || !TEST_true(EC_GROUP_set_curve(group, p, a, b, ctx))
  84. || !group_field_tests(group, ctx))
  85. goto err;
  86. ret = 1;
  87. err:
  88. BN_CTX_end(ctx);
  89. BN_CTX_free(ctx);
  90. if (group != NULL)
  91. EC_GROUP_free(group);
  92. return ret;
  93. }
  94. /* NIST prime curve P-256 */
  95. static const unsigned char params_p256[] = {
  96. /* p */
  97. 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  98. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
  99. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
  100. /* a */
  101. 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
  102. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF,
  103. 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFC,
  104. /* b */
  105. 0x5A, 0xC6, 0x35, 0xD8, 0xAA, 0x3A, 0x93, 0xE7, 0xB3, 0xEB, 0xBD, 0x55,
  106. 0x76, 0x98, 0x86, 0xBC, 0x65, 0x1D, 0x06, 0xB0, 0xCC, 0x53, 0xB0, 0xF6,
  107. 0x3B, 0xCE, 0x3C, 0x3E, 0x27, 0xD2, 0x60, 0x4B
  108. };
  109. #ifndef OPENSSL_NO_EC2M
  110. /* NIST binary curve B-283 */
  111. static const unsigned char params_b283[] = {
  112. /* p */
  113. 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  114. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  115. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xA1,
  116. /* a */
  117. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  118. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  119. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
  120. /* b */
  121. 0x02, 0x7B, 0x68, 0x0A, 0xC8, 0xB8, 0x59, 0x6D, 0xA5, 0xA4, 0xAF, 0x8A,
  122. 0x19, 0xA0, 0x30, 0x3F, 0xCA, 0x97, 0xFD, 0x76, 0x45, 0x30, 0x9F, 0xA2,
  123. 0xA5, 0x81, 0x48, 0x5A, 0xF6, 0x26, 0x3E, 0x31, 0x3B, 0x79, 0xA2, 0xF5
  124. };
  125. #endif
  126. /* test EC_GFp_simple_method directly */
  127. static int field_tests_ecp_simple(void)
  128. {
  129. TEST_info("Testing EC_GFp_simple_method()\n");
  130. return field_tests(EC_GFp_simple_method(), params_p256,
  131. sizeof(params_p256) / 3);
  132. }
  133. /* test EC_GFp_mont_method directly */
  134. static int field_tests_ecp_mont(void)
  135. {
  136. TEST_info("Testing EC_GFp_mont_method()\n");
  137. return field_tests(EC_GFp_mont_method(), params_p256,
  138. sizeof(params_p256) / 3);
  139. }
  140. #ifndef OPENSSL_NO_EC2M
  141. /* Test that decoding of invalid GF2m field parameters fails. */
  142. static int ec2m_field_sanity(void)
  143. {
  144. int ret = 0;
  145. BN_CTX *ctx = BN_CTX_new();
  146. BIGNUM *p, *a, *b;
  147. EC_GROUP *group1 = NULL, *group2 = NULL, *group3 = NULL;
  148. TEST_info("Testing GF2m hardening\n");
  149. BN_CTX_start(ctx);
  150. p = BN_CTX_get(ctx);
  151. a = BN_CTX_get(ctx);
  152. if (!TEST_ptr(b = BN_CTX_get(ctx))
  153. || !TEST_true(BN_one(a))
  154. || !TEST_true(BN_one(b)))
  155. goto out;
  156. /* Even pentanomial value should be rejected */
  157. if (!TEST_true(BN_set_word(p, 0xf2)))
  158. goto out;
  159. if (!TEST_ptr_null(group1 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
  160. TEST_error("Zero constant term accepted in GF2m polynomial");
  161. /* Odd hexanomial should also be rejected */
  162. if (!TEST_true(BN_set_word(p, 0xf3)))
  163. goto out;
  164. if (!TEST_ptr_null(group2 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
  165. TEST_error("Hexanomial accepted as GF2m polynomial");
  166. /* Excessive polynomial degree should also be rejected */
  167. if (!TEST_true(BN_set_word(p, 0x71))
  168. || !TEST_true(BN_set_bit(p, OPENSSL_ECC_MAX_FIELD_BITS + 1)))
  169. goto out;
  170. if (!TEST_ptr_null(group3 = EC_GROUP_new_curve_GF2m(p, a, b, ctx)))
  171. TEST_error("GF2m polynomial degree > %d accepted",
  172. OPENSSL_ECC_MAX_FIELD_BITS);
  173. ret = group1 == NULL && group2 == NULL && group3 == NULL;
  174. out:
  175. EC_GROUP_free(group1);
  176. EC_GROUP_free(group2);
  177. EC_GROUP_free(group3);
  178. BN_CTX_end(ctx);
  179. BN_CTX_free(ctx);
  180. return ret;
  181. }
  182. /* test EC_GF2m_simple_method directly */
  183. static int field_tests_ec2_simple(void)
  184. {
  185. TEST_info("Testing EC_GF2m_simple_method()\n");
  186. return field_tests(EC_GF2m_simple_method(), params_b283,
  187. sizeof(params_b283) / 3);
  188. }
  189. #endif
  190. /* test default method for a named curve */
  191. static int field_tests_default(int n)
  192. {
  193. BN_CTX *ctx = NULL;
  194. EC_GROUP *group = NULL;
  195. int nid = curves[n].nid;
  196. int ret = 0;
  197. TEST_info("Testing curve %s\n", OBJ_nid2sn(nid));
  198. if (!TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))
  199. || !TEST_ptr(ctx = BN_CTX_new())
  200. || !group_field_tests(group, ctx))
  201. goto err;
  202. ret = 1;
  203. err:
  204. if (group != NULL)
  205. EC_GROUP_free(group);
  206. if (ctx != NULL)
  207. BN_CTX_free(ctx);
  208. return ret;
  209. }
  210. #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
  211. /*
  212. * Tests a point known to cause an incorrect underflow in an old version of
  213. * ecp_nist521.c
  214. */
  215. static int underflow_test(void)
  216. {
  217. BN_CTX *ctx = NULL;
  218. EC_GROUP *grp = NULL;
  219. EC_POINT *P = NULL, *Q = NULL, *R = NULL;
  220. BIGNUM *x1 = NULL, *y1 = NULL, *z1 = NULL, *x2 = NULL, *y2 = NULL;
  221. BIGNUM *k = NULL;
  222. int testresult = 0;
  223. const char *x1str =
  224. "1534f0077fffffe87e9adcfe000000000000000000003e05a21d2400002e031b1f4"
  225. "b80000c6fafa4f3c1288798d624a247b5e2ffffffffffffffefe099241900004";
  226. const char *p521m1 =
  227. "1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
  228. "fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe";
  229. ctx = BN_CTX_new();
  230. if (!TEST_ptr(ctx))
  231. return 0;
  232. BN_CTX_start(ctx);
  233. x1 = BN_CTX_get(ctx);
  234. y1 = BN_CTX_get(ctx);
  235. z1 = BN_CTX_get(ctx);
  236. x2 = BN_CTX_get(ctx);
  237. y2 = BN_CTX_get(ctx);
  238. k = BN_CTX_get(ctx);
  239. if (!TEST_ptr(k))
  240. goto err;
  241. grp = EC_GROUP_new_by_curve_name(NID_secp521r1);
  242. P = EC_POINT_new(grp);
  243. Q = EC_POINT_new(grp);
  244. R = EC_POINT_new(grp);
  245. if (!TEST_ptr(grp) || !TEST_ptr(P) || !TEST_ptr(Q) || !TEST_ptr(R))
  246. goto err;
  247. if (!TEST_int_gt(BN_hex2bn(&x1, x1str), 0)
  248. || !TEST_int_gt(BN_hex2bn(&y1, p521m1), 0)
  249. || !TEST_int_gt(BN_hex2bn(&z1, p521m1), 0)
  250. || !TEST_int_gt(BN_hex2bn(&k, "02"), 0)
  251. || !TEST_true(ossl_ec_GFp_simple_set_Jprojective_coordinates_GFp(grp, P, x1,
  252. y1, z1, ctx))
  253. || !TEST_true(EC_POINT_mul(grp, Q, NULL, P, k, ctx))
  254. || !TEST_true(EC_POINT_get_affine_coordinates(grp, Q, x1, y1, ctx))
  255. || !TEST_true(EC_POINT_dbl(grp, R, P, ctx))
  256. || !TEST_true(EC_POINT_get_affine_coordinates(grp, R, x2, y2, ctx)))
  257. goto err;
  258. if (!TEST_int_eq(BN_cmp(x1, x2), 0)
  259. || !TEST_int_eq(BN_cmp(y1, y2), 0))
  260. goto err;
  261. testresult = 1;
  262. err:
  263. BN_CTX_end(ctx);
  264. EC_POINT_free(P);
  265. EC_POINT_free(Q);
  266. EC_POINT_free(R);
  267. EC_GROUP_free(grp);
  268. BN_CTX_free(ctx);
  269. return testresult;
  270. }
  271. #endif
  272. /*
  273. * Tests behavior of the EC_KEY_set_private_key
  274. */
  275. static int set_private_key(void)
  276. {
  277. EC_KEY *key = NULL, *aux_key = NULL;
  278. int testresult = 0;
  279. key = EC_KEY_new_by_curve_name(NID_secp224r1);
  280. aux_key = EC_KEY_new_by_curve_name(NID_secp224r1);
  281. if (!TEST_ptr(key)
  282. || !TEST_ptr(aux_key)
  283. || !TEST_int_eq(EC_KEY_generate_key(key), 1)
  284. || !TEST_int_eq(EC_KEY_generate_key(aux_key), 1))
  285. goto err;
  286. /* Test setting a valid private key */
  287. if (!TEST_int_eq(EC_KEY_set_private_key(key, aux_key->priv_key), 1))
  288. goto err;
  289. /* Test compliance with legacy behavior for NULL private keys */
  290. if (!TEST_int_eq(EC_KEY_set_private_key(key, NULL), 0)
  291. || !TEST_ptr_null(key->priv_key))
  292. goto err;
  293. testresult = 1;
  294. err:
  295. EC_KEY_free(key);
  296. EC_KEY_free(aux_key);
  297. return testresult;
  298. }
  299. /*
  300. * Tests behavior of the decoded_from_explicit_params flag and API
  301. */
  302. static int decoded_flag_test(void)
  303. {
  304. EC_GROUP *grp;
  305. EC_GROUP *grp_copy = NULL;
  306. ECPARAMETERS *ecparams = NULL;
  307. ECPKPARAMETERS *ecpkparams = NULL;
  308. EC_KEY *key = NULL;
  309. unsigned char *encodedparams = NULL;
  310. const unsigned char *encp;
  311. int encodedlen;
  312. int testresult = 0;
  313. /* Test EC_GROUP_new not setting the flag */
  314. grp = EC_GROUP_new(EC_GFp_simple_method());
  315. if (!TEST_ptr(grp)
  316. || !TEST_int_eq(grp->decoded_from_explicit_params, 0))
  317. goto err;
  318. EC_GROUP_free(grp);
  319. /* Test EC_GROUP_new_by_curve_name not setting the flag */
  320. grp = EC_GROUP_new_by_curve_name(NID_X9_62_prime256v1);
  321. if (!TEST_ptr(grp)
  322. || !TEST_int_eq(grp->decoded_from_explicit_params, 0))
  323. goto err;
  324. /* Test EC_GROUP_new_from_ecparameters not setting the flag */
  325. if (!TEST_ptr(ecparams = EC_GROUP_get_ecparameters(grp, NULL))
  326. || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecparameters(ecparams))
  327. || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
  328. goto err;
  329. EC_GROUP_free(grp_copy);
  330. grp_copy = NULL;
  331. ECPARAMETERS_free(ecparams);
  332. ecparams = NULL;
  333. /* Test EC_GROUP_new_from_ecpkparameters not setting the flag */
  334. if (!TEST_int_eq(EC_GROUP_get_asn1_flag(grp), OPENSSL_EC_NAMED_CURVE)
  335. || !TEST_ptr(ecpkparams = EC_GROUP_get_ecpkparameters(grp, NULL))
  336. || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecpkparameters(ecpkparams))
  337. || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0)
  338. || !TEST_ptr(key = EC_KEY_new())
  339. /* Test EC_KEY_decoded_from_explicit_params on key without a group */
  340. || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), -1)
  341. || !TEST_int_eq(EC_KEY_set_group(key, grp_copy), 1)
  342. /* Test EC_KEY_decoded_from_explicit_params negative case */
  343. || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), 0))
  344. goto err;
  345. EC_GROUP_free(grp_copy);
  346. grp_copy = NULL;
  347. ECPKPARAMETERS_free(ecpkparams);
  348. ecpkparams = NULL;
  349. /* Test d2i_ECPKParameters with named params not setting the flag */
  350. if (!TEST_int_gt(encodedlen = i2d_ECPKParameters(grp, &encodedparams), 0)
  351. || !TEST_ptr(encp = encodedparams)
  352. || !TEST_ptr(grp_copy = d2i_ECPKParameters(NULL, &encp, encodedlen))
  353. || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
  354. goto err;
  355. EC_GROUP_free(grp_copy);
  356. grp_copy = NULL;
  357. OPENSSL_free(encodedparams);
  358. encodedparams = NULL;
  359. /* Asn1 flag stays set to explicit with EC_GROUP_new_from_ecpkparameters */
  360. EC_GROUP_set_asn1_flag(grp, OPENSSL_EC_EXPLICIT_CURVE);
  361. if (!TEST_ptr(ecpkparams = EC_GROUP_get_ecpkparameters(grp, NULL))
  362. || !TEST_ptr(grp_copy = EC_GROUP_new_from_ecpkparameters(ecpkparams))
  363. || !TEST_int_eq(EC_GROUP_get_asn1_flag(grp_copy), OPENSSL_EC_EXPLICIT_CURVE)
  364. || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 0))
  365. goto err;
  366. EC_GROUP_free(grp_copy);
  367. grp_copy = NULL;
  368. /* Test d2i_ECPKParameters with explicit params setting the flag */
  369. if (!TEST_int_gt(encodedlen = i2d_ECPKParameters(grp, &encodedparams), 0)
  370. || !TEST_ptr(encp = encodedparams)
  371. || !TEST_ptr(grp_copy = d2i_ECPKParameters(NULL, &encp, encodedlen))
  372. || !TEST_int_eq(EC_GROUP_get_asn1_flag(grp_copy), OPENSSL_EC_EXPLICIT_CURVE)
  373. || !TEST_int_eq(grp_copy->decoded_from_explicit_params, 1)
  374. || !TEST_int_eq(EC_KEY_set_group(key, grp_copy), 1)
  375. /* Test EC_KEY_decoded_from_explicit_params positive case */
  376. || !TEST_int_eq(EC_KEY_decoded_from_explicit_params(key), 1))
  377. goto err;
  378. testresult = 1;
  379. err:
  380. EC_KEY_free(key);
  381. EC_GROUP_free(grp);
  382. EC_GROUP_free(grp_copy);
  383. ECPARAMETERS_free(ecparams);
  384. ECPKPARAMETERS_free(ecpkparams);
  385. OPENSSL_free(encodedparams);
  386. return testresult;
  387. }
  388. static
  389. int ecpkparams_i2d2i_test(int n)
  390. {
  391. EC_GROUP *g1 = NULL, *g2 = NULL;
  392. FILE *fp = NULL;
  393. int nid = curves[n].nid;
  394. int testresult = 0;
  395. /* create group */
  396. if (!TEST_ptr(g1 = EC_GROUP_new_by_curve_name(nid)))
  397. goto end;
  398. /* encode params to file */
  399. if (!TEST_ptr(fp = fopen("params.der", "wb"))
  400. || !TEST_true(i2d_ECPKParameters_fp(fp, g1)))
  401. goto end;
  402. /* flush and close file */
  403. if (!TEST_int_eq(fclose(fp), 0)) {
  404. fp = NULL;
  405. goto end;
  406. }
  407. fp = NULL;
  408. /* decode params from file */
  409. if (!TEST_ptr(fp = fopen("params.der", "rb"))
  410. || !TEST_ptr(g2 = d2i_ECPKParameters_fp(fp, NULL)))
  411. goto end;
  412. testresult = 1; /* PASS */
  413. end:
  414. if (fp != NULL)
  415. fclose(fp);
  416. EC_GROUP_free(g1);
  417. EC_GROUP_free(g2);
  418. return testresult;
  419. }
  420. int setup_tests(void)
  421. {
  422. crv_len = EC_get_builtin_curves(NULL, 0);
  423. if (!TEST_ptr(curves = OPENSSL_malloc(sizeof(*curves) * crv_len))
  424. || !TEST_true(EC_get_builtin_curves(curves, crv_len)))
  425. return 0;
  426. ADD_TEST(field_tests_ecp_simple);
  427. ADD_TEST(field_tests_ecp_mont);
  428. #ifndef OPENSSL_NO_EC2M
  429. ADD_TEST(ec2m_field_sanity);
  430. ADD_TEST(field_tests_ec2_simple);
  431. #endif
  432. ADD_ALL_TESTS(field_tests_default, crv_len);
  433. #ifndef OPENSSL_NO_EC_NISTP_64_GCC_128
  434. ADD_TEST(underflow_test);
  435. #endif
  436. ADD_TEST(set_private_key);
  437. ADD_TEST(decoded_flag_test);
  438. ADD_ALL_TESTS(ecpkparams_i2d2i_test, crv_len);
  439. return 1;
  440. }
  441. void cleanup_tests(void)
  442. {
  443. OPENSSL_free(curves);
  444. }