PageRenderTime 60ms CodeModel.GetById 28ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 0ms

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