/security/nss/lib/freebl/ecl/tests/ec2_test.c

http://github.com/zpao/v8monkey · C · 516 lines · 412 code · 32 blank · 72 comment · 85 complexity · 31e11c41ce060cddd15dc77a62d962e8 MD5 · raw file

  1. /*
  2. * ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is the elliptic curve math library for binary polynomial field curves.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Sun Microsystems, Inc.
  19. * Portions created by the Initial Developer are Copyright (C) 2003
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
  24. *
  25. * Alternatively, the contents of this file may be used under the terms of
  26. * either the GNU General Public License Version 2 or later (the "GPL"), or
  27. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. * in which case the provisions of the GPL or the LGPL are applicable instead
  29. * of those above. If you wish to allow use of your version of this file only
  30. * under the terms of either the GPL or the LGPL, and not to allow others to
  31. * use your version of this file under the terms of the MPL, indicate your
  32. * decision by deleting the provisions above and replace them with the notice
  33. * and other provisions required by the GPL or the LGPL. If you do not delete
  34. * the provisions above, a recipient may use your version of this file under
  35. * the terms of any one of the MPL, the GPL or the LGPL.
  36. *
  37. * ***** END LICENSE BLOCK ***** */
  38. #include "mpi.h"
  39. #include "mplogic.h"
  40. #include "mpprime.h"
  41. #include "mp_gf2m.h"
  42. #include "ecl.h"
  43. #include "ecl-curve.h"
  44. #include "ec2.h"
  45. #include <stdio.h>
  46. #include <strings.h>
  47. #include <assert.h>
  48. #include <time.h>
  49. #include <sys/time.h>
  50. #include <sys/resource.h>
  51. /* Time k repetitions of operation op. */
  52. #define M_TimeOperation(op, k) { \
  53. double dStart, dNow, dUserTime; \
  54. struct rusage ru; \
  55. int i; \
  56. getrusage(RUSAGE_SELF, &ru); \
  57. dStart = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
  58. for (i = 0; i < k; i++) { \
  59. { op; } \
  60. }; \
  61. getrusage(RUSAGE_SELF, &ru); \
  62. dNow = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
  63. dUserTime = dNow-dStart; \
  64. if (dUserTime) printf(" %-45s k: %6i, t: %6.2f sec\n", #op, k, dUserTime); \
  65. }
  66. /* Test curve using generic field arithmetic. */
  67. #define ECTEST_GENERIC_GF2M(name_c, name) \
  68. printf("Testing %s using generic implementation...\n", name_c); \
  69. params = EC_GetNamedCurveParams(name); \
  70. if (params == NULL) { \
  71. printf(" Error: could not construct params.\n"); \
  72. res = MP_NO; \
  73. goto CLEANUP; \
  74. } \
  75. ECGroup_free(group); \
  76. group = ECGroup_fromHex(params); \
  77. if (group == NULL) { \
  78. printf(" Error: could not construct group.\n"); \
  79. res = MP_NO; \
  80. goto CLEANUP; \
  81. } \
  82. MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 1) ); \
  83. printf("... okay.\n");
  84. /* Test curve using specific field arithmetic. */
  85. #define ECTEST_NAMED_GF2M(name_c, name) \
  86. printf("Testing %s using specific implementation...\n", name_c); \
  87. ECGroup_free(group); \
  88. group = ECGroup_fromName(name); \
  89. if (group == NULL) { \
  90. printf(" Warning: could not construct group.\n"); \
  91. printf("... failed; continuing with remaining tests.\n"); \
  92. } else { \
  93. MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 0) ); \
  94. printf("... okay.\n"); \
  95. }
  96. /* Performs basic tests of elliptic curve cryptography over binary
  97. * polynomial fields. If tests fail, then it prints an error message,
  98. * aborts, and returns an error code. Otherwise, returns 0. */
  99. int
  100. ectest_curve_GF2m(ECGroup *group, int ectestPrint, int ectestTime,
  101. int generic)
  102. {
  103. mp_int one, order_1, gx, gy, rx, ry, n;
  104. int size;
  105. mp_err res;
  106. char s[1000];
  107. /* initialize values */
  108. MP_CHECKOK(mp_init(&one));
  109. MP_CHECKOK(mp_init(&order_1));
  110. MP_CHECKOK(mp_init(&gx));
  111. MP_CHECKOK(mp_init(&gy));
  112. MP_CHECKOK(mp_init(&rx));
  113. MP_CHECKOK(mp_init(&ry));
  114. MP_CHECKOK(mp_init(&n));
  115. MP_CHECKOK(mp_set_int(&one, 1));
  116. MP_CHECKOK(mp_sub(&group->order, &one, &order_1));
  117. /* encode base point */
  118. if (group->meth->field_dec) {
  119. MP_CHECKOK(group->meth->field_dec(&group->genx, &gx, group->meth));
  120. MP_CHECKOK(group->meth->field_dec(&group->geny, &gy, group->meth));
  121. } else {
  122. MP_CHECKOK(mp_copy(&group->genx, &gx));
  123. MP_CHECKOK(mp_copy(&group->geny, &gy));
  124. }
  125. if (ectestPrint) {
  126. /* output base point */
  127. printf(" base point P:\n");
  128. MP_CHECKOK(mp_toradix(&gx, s, 16));
  129. printf(" %s\n", s);
  130. MP_CHECKOK(mp_toradix(&gy, s, 16));
  131. printf(" %s\n", s);
  132. if (group->meth->field_enc) {
  133. printf(" base point P (encoded):\n");
  134. MP_CHECKOK(mp_toradix(&group->genx, s, 16));
  135. printf(" %s\n", s);
  136. MP_CHECKOK(mp_toradix(&group->geny, s, 16));
  137. printf(" %s\n", s);
  138. }
  139. }
  140. #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
  141. /* multiply base point by order - 1 and check for negative of base
  142. * point */
  143. MP_CHECKOK(ec_GF2m_pt_mul_aff
  144. (&order_1, &group->genx, &group->geny, &rx, &ry, group));
  145. if (ectestPrint) {
  146. printf(" (order-1)*P (affine):\n");
  147. MP_CHECKOK(mp_toradix(&rx, s, 16));
  148. printf(" %s\n", s);
  149. MP_CHECKOK(mp_toradix(&ry, s, 16));
  150. printf(" %s\n", s);
  151. }
  152. MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
  153. if ((mp_cmp(&rx, &group->genx) != 0)
  154. || (mp_cmp(&ry, &group->geny) != 0)) {
  155. printf(" Error: invalid result (expected (- base point)).\n");
  156. res = MP_NO;
  157. goto CLEANUP;
  158. }
  159. #endif
  160. /* multiply base point by order - 1 and check for negative of base
  161. * point */
  162. MP_CHECKOK(ec_GF2m_pt_mul_mont
  163. (&order_1, &group->genx, &group->geny, &rx, &ry, group));
  164. if (ectestPrint) {
  165. printf(" (order-1)*P (montgomery):\n");
  166. MP_CHECKOK(mp_toradix(&rx, s, 16));
  167. printf(" %s\n", s);
  168. MP_CHECKOK(mp_toradix(&ry, s, 16));
  169. printf(" %s\n", s);
  170. }
  171. MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
  172. if ((mp_cmp(&rx, &group->genx) != 0)
  173. || (mp_cmp(&ry, &group->geny) != 0)) {
  174. printf(" Error: invalid result (expected (- base point)).\n");
  175. res = MP_NO;
  176. goto CLEANUP;
  177. }
  178. #ifdef ECL_ENABLE_GF2M_PROJ
  179. /* multiply base point by order - 1 and check for negative of base
  180. * point */
  181. MP_CHECKOK(ec_GF2m_pt_mul_proj
  182. (&order_1, &group->genx, &group->geny, &rx, &ry, group));
  183. if (ectestPrint) {
  184. printf(" (order-1)*P (projective):\n");
  185. MP_CHECKOK(mp_toradix(&rx, s, 16));
  186. printf(" %s\n", s);
  187. MP_CHECKOK(mp_toradix(&ry, s, 16));
  188. printf(" %s\n", s);
  189. }
  190. MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
  191. if ((mp_cmp(&rx, &group->genx) != 0)
  192. || (mp_cmp(&ry, &group->geny) != 0)) {
  193. printf(" Error: invalid result (expected (- base point)).\n");
  194. res = MP_NO;
  195. goto CLEANUP;
  196. }
  197. #endif
  198. /* multiply base point by order - 1 and check for negative of base
  199. * point */
  200. MP_CHECKOK(ECPoint_mul(group, &order_1, NULL, NULL, &rx, &ry));
  201. if (ectestPrint) {
  202. printf(" (order-1)*P (ECPoint_mul):\n");
  203. MP_CHECKOK(mp_toradix(&rx, s, 16));
  204. printf(" %s\n", s);
  205. MP_CHECKOK(mp_toradix(&ry, s, 16));
  206. printf(" %s\n", s);
  207. }
  208. MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
  209. if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
  210. printf(" Error: invalid result (expected (- base point)).\n");
  211. res = MP_NO;
  212. goto CLEANUP;
  213. }
  214. /* multiply base point by order - 1 and check for negative of base
  215. * point */
  216. MP_CHECKOK(ECPoint_mul(group, &order_1, &gx, &gy, &rx, &ry));
  217. if (ectestPrint) {
  218. printf(" (order-1)*P (ECPoint_mul):\n");
  219. MP_CHECKOK(mp_toradix(&rx, s, 16));
  220. printf(" %s\n", s);
  221. MP_CHECKOK(mp_toradix(&ry, s, 16));
  222. printf(" %s\n", s);
  223. }
  224. MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
  225. if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
  226. printf(" Error: invalid result (expected (- base point)).\n");
  227. res = MP_NO;
  228. goto CLEANUP;
  229. }
  230. #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
  231. /* multiply base point by order and check for point at infinity */
  232. MP_CHECKOK(ec_GF2m_pt_mul_aff
  233. (&group->order, &group->genx, &group->geny, &rx, &ry,
  234. group));
  235. if (ectestPrint) {
  236. printf(" (order)*P (affine):\n");
  237. MP_CHECKOK(mp_toradix(&rx, s, 16));
  238. printf(" %s\n", s);
  239. MP_CHECKOK(mp_toradix(&ry, s, 16));
  240. printf(" %s\n", s);
  241. }
  242. if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
  243. printf(" Error: invalid result (expected point at infinity).\n");
  244. res = MP_NO;
  245. goto CLEANUP;
  246. }
  247. #endif
  248. /* multiply base point by order and check for point at infinity */
  249. MP_CHECKOK(ec_GF2m_pt_mul_mont
  250. (&group->order, &group->genx, &group->geny, &rx, &ry,
  251. group));
  252. if (ectestPrint) {
  253. printf(" (order)*P (montgomery):\n");
  254. MP_CHECKOK(mp_toradix(&rx, s, 16));
  255. printf(" %s\n", s);
  256. MP_CHECKOK(mp_toradix(&ry, s, 16));
  257. printf(" %s\n", s);
  258. }
  259. if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
  260. printf(" Error: invalid result (expected point at infinity).\n");
  261. res = MP_NO;
  262. goto CLEANUP;
  263. }
  264. #ifdef ECL_ENABLE_GF2M_PROJ
  265. /* multiply base point by order and check for point at infinity */
  266. MP_CHECKOK(ec_GF2m_pt_mul_proj
  267. (&group->order, &group->genx, &group->geny, &rx, &ry,
  268. group));
  269. if (ectestPrint) {
  270. printf(" (order)*P (projective):\n");
  271. MP_CHECKOK(mp_toradix(&rx, s, 16));
  272. printf(" %s\n", s);
  273. MP_CHECKOK(mp_toradix(&ry, s, 16));
  274. printf(" %s\n", s);
  275. }
  276. if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
  277. printf(" Error: invalid result (expected point at infinity).\n");
  278. res = MP_NO;
  279. goto CLEANUP;
  280. }
  281. #endif
  282. /* multiply base point by order and check for point at infinity */
  283. MP_CHECKOK(ECPoint_mul(group, &group->order, NULL, NULL, &rx, &ry));
  284. if (ectestPrint) {
  285. printf(" (order)*P (ECPoint_mul):\n");
  286. MP_CHECKOK(mp_toradix(&rx, s, 16));
  287. printf(" %s\n", s);
  288. MP_CHECKOK(mp_toradix(&ry, s, 16));
  289. printf(" %s\n", s);
  290. }
  291. if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
  292. printf(" Error: invalid result (expected point at infinity).\n");
  293. res = MP_NO;
  294. goto CLEANUP;
  295. }
  296. /* multiply base point by order and check for point at infinity */
  297. MP_CHECKOK(ECPoint_mul(group, &group->order, &gx, &gy, &rx, &ry));
  298. if (ectestPrint) {
  299. printf(" (order)*P (ECPoint_mul):\n");
  300. MP_CHECKOK(mp_toradix(&rx, s, 16));
  301. printf(" %s\n", s);
  302. MP_CHECKOK(mp_toradix(&ry, s, 16));
  303. printf(" %s\n", s);
  304. }
  305. if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
  306. printf(" Error: invalid result (expected point at infinity).\n");
  307. res = MP_NO;
  308. goto CLEANUP;
  309. }
  310. /* check that (order-1)P + (order-1)P + P == (order-1)P */
  311. MP_CHECKOK(ECPoints_mul
  312. (group, &order_1, &order_1, &gx, &gy, &rx, &ry));
  313. MP_CHECKOK(ECPoints_mul(group, &one, &one, &rx, &ry, &rx, &ry));
  314. if (ectestPrint) {
  315. printf
  316. (" (order-1)*P + (order-1)*P + P == (order-1)*P (ECPoints_mul):\n");
  317. MP_CHECKOK(mp_toradix(&rx, s, 16));
  318. printf(" %s\n", s);
  319. MP_CHECKOK(mp_toradix(&ry, s, 16));
  320. printf(" %s\n", s);
  321. }
  322. MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
  323. if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
  324. printf(" Error: invalid result (expected (- base point)).\n");
  325. res = MP_NO;
  326. goto CLEANUP;
  327. }
  328. /* test validate_point function */
  329. if (ECPoint_validate(group, &gx, &gy) != MP_YES) {
  330. printf(" Error: validate point on base point failed.\n");
  331. res = MP_NO;
  332. goto CLEANUP;
  333. }
  334. MP_CHECKOK(mp_add_d(&gy, 1, &ry));
  335. if (ECPoint_validate(group, &gx, &ry) != MP_NO) {
  336. printf(" Error: validate point on invalid point passed.\n");
  337. res = MP_NO;
  338. goto CLEANUP;
  339. }
  340. if (ectestTime) {
  341. /* compute random scalar */
  342. size = mpl_significant_bits(&group->meth->irr);
  343. if (size < MP_OKAY) {
  344. goto CLEANUP;
  345. }
  346. MP_CHECKOK(mpp_random_size(&n, (size + ECL_BITS - 1) / ECL_BITS));
  347. MP_CHECKOK(group->meth->field_mod(&n, &n, group->meth));
  348. /* timed test */
  349. if (generic) {
  350. #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
  351. M_TimeOperation(MP_CHECKOK
  352. (ec_GF2m_pt_mul_aff
  353. (&n, &group->genx, &group->geny, &rx, &ry,
  354. group)), 100);
  355. #endif
  356. M_TimeOperation(MP_CHECKOK
  357. (ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
  358. 100);
  359. M_TimeOperation(MP_CHECKOK
  360. (ECPoints_mul
  361. (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
  362. } else {
  363. M_TimeOperation(MP_CHECKOK
  364. (ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
  365. 100);
  366. M_TimeOperation(MP_CHECKOK
  367. (ECPoint_mul(group, &n, &gx, &gy, &rx, &ry)),
  368. 100);
  369. M_TimeOperation(MP_CHECKOK
  370. (ECPoints_mul
  371. (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
  372. }
  373. }
  374. CLEANUP:
  375. mp_clear(&one);
  376. mp_clear(&order_1);
  377. mp_clear(&gx);
  378. mp_clear(&gy);
  379. mp_clear(&rx);
  380. mp_clear(&ry);
  381. mp_clear(&n);
  382. if (res != MP_OKAY) {
  383. printf(" Error: exiting with error value %i\n", res);
  384. }
  385. return res;
  386. }
  387. /* Prints help information. */
  388. void
  389. printUsage()
  390. {
  391. printf("Usage: ecp_test [--print] [--time]\n");
  392. printf
  393. (" --print Print out results of each point arithmetic test.\n");
  394. printf
  395. (" --time Benchmark point operations and print results.\n");
  396. }
  397. /* Performs tests of elliptic curve cryptography over binary polynomial
  398. * fields. If tests fail, then it prints an error message, aborts, and
  399. * returns an error code. Otherwise, returns 0. */
  400. int
  401. main(int argv, char **argc)
  402. {
  403. int ectestTime = 0;
  404. int ectestPrint = 0;
  405. int i;
  406. ECGroup *group = NULL;
  407. ECCurveParams *params = NULL;
  408. mp_err res;
  409. /* read command-line arguments */
  410. for (i = 1; i < argv; i++) {
  411. if ((strcasecmp(argc[i], "time") == 0)
  412. || (strcasecmp(argc[i], "-time") == 0)
  413. || (strcasecmp(argc[i], "--time") == 0)) {
  414. ectestTime = 1;
  415. } else if ((strcasecmp(argc[i], "print") == 0)
  416. || (strcasecmp(argc[i], "-print") == 0)
  417. || (strcasecmp(argc[i], "--print") == 0)) {
  418. ectestPrint = 1;
  419. } else {
  420. printUsage();
  421. return 0;
  422. }
  423. }
  424. /* generic arithmetic tests */
  425. ECTEST_GENERIC_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
  426. /* specific arithmetic tests */
  427. ECTEST_NAMED_GF2M("NIST-K163", ECCurve_NIST_K163);
  428. ECTEST_NAMED_GF2M("NIST-B163", ECCurve_NIST_B163);
  429. ECTEST_NAMED_GF2M("NIST-K233", ECCurve_NIST_K233);
  430. ECTEST_NAMED_GF2M("NIST-B233", ECCurve_NIST_B233);
  431. ECTEST_NAMED_GF2M("NIST-K283", ECCurve_NIST_K283);
  432. ECTEST_NAMED_GF2M("NIST-B283", ECCurve_NIST_B283);
  433. ECTEST_NAMED_GF2M("NIST-K409", ECCurve_NIST_K409);
  434. ECTEST_NAMED_GF2M("NIST-B409", ECCurve_NIST_B409);
  435. ECTEST_NAMED_GF2M("NIST-K571", ECCurve_NIST_K571);
  436. ECTEST_NAMED_GF2M("NIST-B571", ECCurve_NIST_B571);
  437. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V1", ECCurve_X9_62_CHAR2_PNB163V1);
  438. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V2", ECCurve_X9_62_CHAR2_PNB163V2);
  439. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V3", ECCurve_X9_62_CHAR2_PNB163V3);
  440. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB176V1", ECCurve_X9_62_CHAR2_PNB176V1);
  441. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V1", ECCurve_X9_62_CHAR2_TNB191V1);
  442. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V2", ECCurve_X9_62_CHAR2_TNB191V2);
  443. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V3", ECCurve_X9_62_CHAR2_TNB191V3);
  444. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB208W1", ECCurve_X9_62_CHAR2_PNB208W1);
  445. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V1", ECCurve_X9_62_CHAR2_TNB239V1);
  446. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V2", ECCurve_X9_62_CHAR2_TNB239V2);
  447. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V3", ECCurve_X9_62_CHAR2_TNB239V3);
  448. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB272W1", ECCurve_X9_62_CHAR2_PNB272W1);
  449. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB304W1", ECCurve_X9_62_CHAR2_PNB304W1);
  450. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB359V1", ECCurve_X9_62_CHAR2_TNB359V1);
  451. ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB368W1", ECCurve_X9_62_CHAR2_PNB368W1);
  452. ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB431R1", ECCurve_X9_62_CHAR2_TNB431R1);
  453. ECTEST_NAMED_GF2M("SECT-113R1", ECCurve_SECG_CHAR2_113R1);
  454. ECTEST_NAMED_GF2M("SECT-113R2", ECCurve_SECG_CHAR2_113R2);
  455. ECTEST_NAMED_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
  456. ECTEST_NAMED_GF2M("SECT-131R2", ECCurve_SECG_CHAR2_131R2);
  457. ECTEST_NAMED_GF2M("SECT-163K1", ECCurve_SECG_CHAR2_163K1);
  458. ECTEST_NAMED_GF2M("SECT-163R1", ECCurve_SECG_CHAR2_163R1);
  459. ECTEST_NAMED_GF2M("SECT-163R2", ECCurve_SECG_CHAR2_163R2);
  460. ECTEST_NAMED_GF2M("SECT-193R1", ECCurve_SECG_CHAR2_193R1);
  461. ECTEST_NAMED_GF2M("SECT-193R2", ECCurve_SECG_CHAR2_193R2);
  462. ECTEST_NAMED_GF2M("SECT-233K1", ECCurve_SECG_CHAR2_233K1);
  463. ECTEST_NAMED_GF2M("SECT-233R1", ECCurve_SECG_CHAR2_233R1);
  464. ECTEST_NAMED_GF2M("SECT-239K1", ECCurve_SECG_CHAR2_239K1);
  465. ECTEST_NAMED_GF2M("SECT-283K1", ECCurve_SECG_CHAR2_283K1);
  466. ECTEST_NAMED_GF2M("SECT-283R1", ECCurve_SECG_CHAR2_283R1);
  467. ECTEST_NAMED_GF2M("SECT-409K1", ECCurve_SECG_CHAR2_409K1);
  468. ECTEST_NAMED_GF2M("SECT-409R1", ECCurve_SECG_CHAR2_409R1);
  469. ECTEST_NAMED_GF2M("SECT-571K1", ECCurve_SECG_CHAR2_571K1);
  470. ECTEST_NAMED_GF2M("SECT-571R1", ECCurve_SECG_CHAR2_571R1);
  471. ECTEST_NAMED_GF2M("WTLS-1 (113)", ECCurve_WTLS_1);
  472. ECTEST_NAMED_GF2M("WTLS-3 (163)", ECCurve_WTLS_3);
  473. ECTEST_NAMED_GF2M("WTLS-4 (113)", ECCurve_WTLS_4);
  474. ECTEST_NAMED_GF2M("WTLS-5 (163)", ECCurve_WTLS_5);
  475. ECTEST_NAMED_GF2M("WTLS-10 (233)", ECCurve_WTLS_10);
  476. ECTEST_NAMED_GF2M("WTLS-11 (233)", ECCurve_WTLS_11);
  477. CLEANUP:
  478. EC_FreeCurveParams(params);
  479. ECGroup_free(group);
  480. if (res != MP_OKAY) {
  481. printf("Error: exiting with error value %i\n", res);
  482. }
  483. return res;
  484. }