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

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/nss/lib/freebl/ecl/tests/ec2_test.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,482 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#include "mpi.h"
     1.9 +#include "mplogic.h"
    1.10 +#include "mpprime.h"
    1.11 +#include "mp_gf2m.h"
    1.12 +#include "ecl.h"
    1.13 +#include "ecl-curve.h"
    1.14 +#include "ec2.h"
    1.15 +#include <stdio.h>
    1.16 +#include <strings.h>
    1.17 +#include <assert.h>
    1.18 +
    1.19 +#include <time.h>
    1.20 +#include <sys/time.h>
    1.21 +#include <sys/resource.h>
    1.22 +
    1.23 +/* Time k repetitions of operation op. */
    1.24 +#define M_TimeOperation(op, k) { \
    1.25 +	double dStart, dNow, dUserTime; \
    1.26 +	struct rusage ru; \
    1.27 +	int i; \
    1.28 +	getrusage(RUSAGE_SELF, &ru); \
    1.29 +	dStart = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
    1.30 +	for (i = 0; i < k; i++) { \
    1.31 +		{ op; } \
    1.32 +	}; \
    1.33 +	getrusage(RUSAGE_SELF, &ru); \
    1.34 +	dNow = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
    1.35 +	dUserTime = dNow-dStart; \
    1.36 +	if (dUserTime) printf("    %-45s k: %6i, t: %6.2f sec\n", #op, k, dUserTime); \
    1.37 +}
    1.38 +
    1.39 +/* Test curve using generic field arithmetic. */
    1.40 +#define ECTEST_GENERIC_GF2M(name_c, name) \
    1.41 +	printf("Testing %s using generic implementation...\n", name_c); \
    1.42 +	params = EC_GetNamedCurveParams(name); \
    1.43 +	if (params == NULL) { \
    1.44 +			printf("  Error: could not construct params.\n"); \
    1.45 +			res = MP_NO; \
    1.46 +			goto CLEANUP; \
    1.47 +	} \
    1.48 +	ECGroup_free(group); \
    1.49 +	group = ECGroup_fromHex(params); \
    1.50 +	if (group == NULL) { \
    1.51 +		printf("  Error: could not construct group.\n"); \
    1.52 +		res = MP_NO; \
    1.53 +		goto CLEANUP; \
    1.54 +	} \
    1.55 +	MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 1) ); \
    1.56 +	printf("... okay.\n");
    1.57 +
    1.58 +/* Test curve using specific field arithmetic. */
    1.59 +#define ECTEST_NAMED_GF2M(name_c, name) \
    1.60 +	printf("Testing %s using specific implementation...\n", name_c); \
    1.61 +	ECGroup_free(group); \
    1.62 +	group = ECGroup_fromName(name); \
    1.63 +	if (group == NULL) { \
    1.64 +		printf("  Warning: could not construct group.\n"); \
    1.65 +		printf("... failed; continuing with remaining tests.\n"); \
    1.66 +	} else { \
    1.67 +		MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 0) ); \
    1.68 +		printf("... okay.\n"); \
    1.69 +	}
    1.70 +
    1.71 +/* Performs basic tests of elliptic curve cryptography over binary
    1.72 + * polynomial fields. If tests fail, then it prints an error message,
    1.73 + * aborts, and returns an error code. Otherwise, returns 0. */
    1.74 +int
    1.75 +ectest_curve_GF2m(ECGroup *group, int ectestPrint, int ectestTime,
    1.76 +				  int generic)
    1.77 +{
    1.78 +
    1.79 +	mp_int one, order_1, gx, gy, rx, ry, n;
    1.80 +	int size;
    1.81 +	mp_err res;
    1.82 +	char s[1000];
    1.83 +
    1.84 +	/* initialize values */
    1.85 +	MP_CHECKOK(mp_init(&one));
    1.86 +	MP_CHECKOK(mp_init(&order_1));
    1.87 +	MP_CHECKOK(mp_init(&gx));
    1.88 +	MP_CHECKOK(mp_init(&gy));
    1.89 +	MP_CHECKOK(mp_init(&rx));
    1.90 +	MP_CHECKOK(mp_init(&ry));
    1.91 +	MP_CHECKOK(mp_init(&n));
    1.92 +
    1.93 +	MP_CHECKOK(mp_set_int(&one, 1));
    1.94 +	MP_CHECKOK(mp_sub(&group->order, &one, &order_1));
    1.95 +
    1.96 +	/* encode base point */
    1.97 +	if (group->meth->field_dec) {
    1.98 +		MP_CHECKOK(group->meth->field_dec(&group->genx, &gx, group->meth));
    1.99 +		MP_CHECKOK(group->meth->field_dec(&group->geny, &gy, group->meth));
   1.100 +	} else {
   1.101 +		MP_CHECKOK(mp_copy(&group->genx, &gx));
   1.102 +		MP_CHECKOK(mp_copy(&group->geny, &gy));
   1.103 +	}
   1.104 +
   1.105 +	if (ectestPrint) {
   1.106 +		/* output base point */
   1.107 +		printf("  base point P:\n");
   1.108 +		MP_CHECKOK(mp_toradix(&gx, s, 16));
   1.109 +		printf("    %s\n", s);
   1.110 +		MP_CHECKOK(mp_toradix(&gy, s, 16));
   1.111 +		printf("    %s\n", s);
   1.112 +		if (group->meth->field_enc) {
   1.113 +			printf("  base point P (encoded):\n");
   1.114 +			MP_CHECKOK(mp_toradix(&group->genx, s, 16));
   1.115 +			printf("    %s\n", s);
   1.116 +			MP_CHECKOK(mp_toradix(&group->geny, s, 16));
   1.117 +			printf("    %s\n", s);
   1.118 +		}
   1.119 +	}
   1.120 +
   1.121 +#ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
   1.122 +	/* multiply base point by order - 1 and check for negative of base
   1.123 +	 * point */
   1.124 +	MP_CHECKOK(ec_GF2m_pt_mul_aff
   1.125 +			   (&order_1, &group->genx, &group->geny, &rx, &ry, group));
   1.126 +	if (ectestPrint) {
   1.127 +		printf("  (order-1)*P (affine):\n");
   1.128 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.129 +		printf("    %s\n", s);
   1.130 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.131 +		printf("    %s\n", s);
   1.132 +	}
   1.133 +	MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
   1.134 +	if ((mp_cmp(&rx, &group->genx) != 0)
   1.135 +		|| (mp_cmp(&ry, &group->geny) != 0)) {
   1.136 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.137 +		res = MP_NO;
   1.138 +		goto CLEANUP;
   1.139 +	}
   1.140 +#endif
   1.141 +
   1.142 +	/* multiply base point by order - 1 and check for negative of base
   1.143 +	 * point */
   1.144 +	MP_CHECKOK(ec_GF2m_pt_mul_mont
   1.145 +			   (&order_1, &group->genx, &group->geny, &rx, &ry, group));
   1.146 +	if (ectestPrint) {
   1.147 +		printf("  (order-1)*P (montgomery):\n");
   1.148 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.149 +		printf("    %s\n", s);
   1.150 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.151 +		printf("    %s\n", s);
   1.152 +	}
   1.153 +	MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
   1.154 +	if ((mp_cmp(&rx, &group->genx) != 0)
   1.155 +		|| (mp_cmp(&ry, &group->geny) != 0)) {
   1.156 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.157 +		res = MP_NO;
   1.158 +		goto CLEANUP;
   1.159 +	}
   1.160 +
   1.161 +#ifdef ECL_ENABLE_GF2M_PROJ
   1.162 +	/* multiply base point by order - 1 and check for negative of base
   1.163 +	 * point */
   1.164 +	MP_CHECKOK(ec_GF2m_pt_mul_proj
   1.165 +			   (&order_1, &group->genx, &group->geny, &rx, &ry, group));
   1.166 +	if (ectestPrint) {
   1.167 +		printf("  (order-1)*P (projective):\n");
   1.168 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.169 +		printf("    %s\n", s);
   1.170 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.171 +		printf("    %s\n", s);
   1.172 +	}
   1.173 +	MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
   1.174 +	if ((mp_cmp(&rx, &group->genx) != 0)
   1.175 +		|| (mp_cmp(&ry, &group->geny) != 0)) {
   1.176 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.177 +		res = MP_NO;
   1.178 +		goto CLEANUP;
   1.179 +	}
   1.180 +#endif
   1.181 +
   1.182 +	/* multiply base point by order - 1 and check for negative of base
   1.183 +	 * point */
   1.184 +	MP_CHECKOK(ECPoint_mul(group, &order_1, NULL, NULL, &rx, &ry));
   1.185 +	if (ectestPrint) {
   1.186 +		printf("  (order-1)*P (ECPoint_mul):\n");
   1.187 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.188 +		printf("    %s\n", s);
   1.189 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.190 +		printf("    %s\n", s);
   1.191 +	}
   1.192 +	MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
   1.193 +	if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
   1.194 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.195 +		res = MP_NO;
   1.196 +		goto CLEANUP;
   1.197 +	}
   1.198 +
   1.199 +	/* multiply base point by order - 1 and check for negative of base
   1.200 +	 * point */
   1.201 +	MP_CHECKOK(ECPoint_mul(group, &order_1, &gx, &gy, &rx, &ry));
   1.202 +	if (ectestPrint) {
   1.203 +		printf("  (order-1)*P (ECPoint_mul):\n");
   1.204 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.205 +		printf("    %s\n", s);
   1.206 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.207 +		printf("    %s\n", s);
   1.208 +	}
   1.209 +	MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
   1.210 +	if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
   1.211 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.212 +		res = MP_NO;
   1.213 +		goto CLEANUP;
   1.214 +	}
   1.215 +
   1.216 +#ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
   1.217 +	/* multiply base point by order and check for point at infinity */
   1.218 +	MP_CHECKOK(ec_GF2m_pt_mul_aff
   1.219 +			   (&group->order, &group->genx, &group->geny, &rx, &ry,
   1.220 +				group));
   1.221 +	if (ectestPrint) {
   1.222 +		printf("  (order)*P (affine):\n");
   1.223 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.224 +		printf("    %s\n", s);
   1.225 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.226 +		printf("    %s\n", s);
   1.227 +	}
   1.228 +	if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
   1.229 +		printf("  Error: invalid result (expected point at infinity).\n");
   1.230 +		res = MP_NO;
   1.231 +		goto CLEANUP;
   1.232 +	}
   1.233 +#endif
   1.234 +
   1.235 +	/* multiply base point by order and check for point at infinity */
   1.236 +	MP_CHECKOK(ec_GF2m_pt_mul_mont
   1.237 +			   (&group->order, &group->genx, &group->geny, &rx, &ry,
   1.238 +				group));
   1.239 +	if (ectestPrint) {
   1.240 +		printf("  (order)*P (montgomery):\n");
   1.241 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.242 +		printf("    %s\n", s);
   1.243 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.244 +		printf("    %s\n", s);
   1.245 +	}
   1.246 +	if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
   1.247 +		printf("  Error: invalid result (expected point at infinity).\n");
   1.248 +		res = MP_NO;
   1.249 +		goto CLEANUP;
   1.250 +	}
   1.251 +
   1.252 +#ifdef ECL_ENABLE_GF2M_PROJ
   1.253 +	/* multiply base point by order and check for point at infinity */
   1.254 +	MP_CHECKOK(ec_GF2m_pt_mul_proj
   1.255 +			   (&group->order, &group->genx, &group->geny, &rx, &ry,
   1.256 +				group));
   1.257 +	if (ectestPrint) {
   1.258 +		printf("  (order)*P (projective):\n");
   1.259 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.260 +		printf("    %s\n", s);
   1.261 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.262 +		printf("    %s\n", s);
   1.263 +	}
   1.264 +	if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
   1.265 +		printf("  Error: invalid result (expected point at infinity).\n");
   1.266 +		res = MP_NO;
   1.267 +		goto CLEANUP;
   1.268 +	}
   1.269 +#endif
   1.270 +
   1.271 +	/* multiply base point by order and check for point at infinity */
   1.272 +	MP_CHECKOK(ECPoint_mul(group, &group->order, NULL, NULL, &rx, &ry));
   1.273 +	if (ectestPrint) {
   1.274 +		printf("  (order)*P (ECPoint_mul):\n");
   1.275 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.276 +		printf("    %s\n", s);
   1.277 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.278 +		printf("    %s\n", s);
   1.279 +	}
   1.280 +	if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
   1.281 +		printf("  Error: invalid result (expected point at infinity).\n");
   1.282 +		res = MP_NO;
   1.283 +		goto CLEANUP;
   1.284 +	}
   1.285 +
   1.286 +	/* multiply base point by order and check for point at infinity */
   1.287 +	MP_CHECKOK(ECPoint_mul(group, &group->order, &gx, &gy, &rx, &ry));
   1.288 +	if (ectestPrint) {
   1.289 +		printf("  (order)*P (ECPoint_mul):\n");
   1.290 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.291 +		printf("    %s\n", s);
   1.292 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.293 +		printf("    %s\n", s);
   1.294 +	}
   1.295 +	if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
   1.296 +		printf("  Error: invalid result (expected point at infinity).\n");
   1.297 +		res = MP_NO;
   1.298 +		goto CLEANUP;
   1.299 +	}
   1.300 +
   1.301 +	/* check that (order-1)P + (order-1)P + P == (order-1)P */
   1.302 +	MP_CHECKOK(ECPoints_mul
   1.303 +			   (group, &order_1, &order_1, &gx, &gy, &rx, &ry));
   1.304 +	MP_CHECKOK(ECPoints_mul(group, &one, &one, &rx, &ry, &rx, &ry));
   1.305 +	if (ectestPrint) {
   1.306 +		printf
   1.307 +			("  (order-1)*P + (order-1)*P + P == (order-1)*P (ECPoints_mul):\n");
   1.308 +		MP_CHECKOK(mp_toradix(&rx, s, 16));
   1.309 +		printf("    %s\n", s);
   1.310 +		MP_CHECKOK(mp_toradix(&ry, s, 16));
   1.311 +		printf("    %s\n", s);
   1.312 +	}
   1.313 +	MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
   1.314 +	if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
   1.315 +		printf("  Error: invalid result (expected (- base point)).\n");
   1.316 +		res = MP_NO;
   1.317 +		goto CLEANUP;
   1.318 +	}
   1.319 +
   1.320 +	/* test validate_point function */
   1.321 +	if (ECPoint_validate(group, &gx, &gy) != MP_YES) {
   1.322 +		printf("  Error: validate point on base point failed.\n");
   1.323 +		res = MP_NO;
   1.324 +		goto CLEANUP;
   1.325 +	}
   1.326 +	MP_CHECKOK(mp_add_d(&gy, 1, &ry));
   1.327 +	if (ECPoint_validate(group, &gx, &ry) != MP_NO) {
   1.328 +		printf("  Error: validate point on invalid point passed.\n");
   1.329 +		res = MP_NO;
   1.330 +		goto CLEANUP;
   1.331 +	}
   1.332 +
   1.333 +	if (ectestTime) {
   1.334 +		/* compute random scalar */
   1.335 +		size = mpl_significant_bits(&group->meth->irr);
   1.336 +		if (size < MP_OKAY) {
   1.337 +			goto CLEANUP;
   1.338 +		}
   1.339 +		MP_CHECKOK(mpp_random_size(&n, (size + ECL_BITS - 1) / ECL_BITS));
   1.340 +		MP_CHECKOK(group->meth->field_mod(&n, &n, group->meth));
   1.341 +		/* timed test */
   1.342 +		if (generic) {
   1.343 +#ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
   1.344 +			M_TimeOperation(MP_CHECKOK
   1.345 +							(ec_GF2m_pt_mul_aff
   1.346 +							 (&n, &group->genx, &group->geny, &rx, &ry,
   1.347 +							  group)), 100);
   1.348 +#endif
   1.349 +			M_TimeOperation(MP_CHECKOK
   1.350 +							(ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
   1.351 +							100);
   1.352 +			M_TimeOperation(MP_CHECKOK
   1.353 +							(ECPoints_mul
   1.354 +							 (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
   1.355 +		} else {
   1.356 +			M_TimeOperation(MP_CHECKOK
   1.357 +							(ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
   1.358 +							100);
   1.359 +			M_TimeOperation(MP_CHECKOK
   1.360 +							(ECPoint_mul(group, &n, &gx, &gy, &rx, &ry)),
   1.361 +							100);
   1.362 +			M_TimeOperation(MP_CHECKOK
   1.363 +							(ECPoints_mul
   1.364 +							 (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
   1.365 +		}
   1.366 +	}
   1.367 +
   1.368 +  CLEANUP:
   1.369 +	mp_clear(&one);
   1.370 +	mp_clear(&order_1);
   1.371 +	mp_clear(&gx);
   1.372 +	mp_clear(&gy);
   1.373 +	mp_clear(&rx);
   1.374 +	mp_clear(&ry);
   1.375 +	mp_clear(&n);
   1.376 +	if (res != MP_OKAY) {
   1.377 +		printf("  Error: exiting with error value %i\n", res);
   1.378 +	}
   1.379 +	return res;
   1.380 +}
   1.381 +
   1.382 +/* Prints help information. */
   1.383 +void
   1.384 +printUsage()
   1.385 +{
   1.386 +	printf("Usage: ecp_test [--print] [--time]\n");
   1.387 +	printf
   1.388 +		("	--print     Print out results of each point arithmetic test.\n");
   1.389 +	printf
   1.390 +		("	--time      Benchmark point operations and print results.\n");
   1.391 +}
   1.392 +
   1.393 +/* Performs tests of elliptic curve cryptography over binary polynomial
   1.394 + * fields. If tests fail, then it prints an error message, aborts, and
   1.395 + * returns an error code. Otherwise, returns 0. */
   1.396 +int
   1.397 +main(int argv, char **argc)
   1.398 +{
   1.399 +
   1.400 +	int ectestTime = 0;
   1.401 +	int ectestPrint = 0;
   1.402 +	int i;
   1.403 +	ECGroup *group = NULL;
   1.404 +	ECCurveParams *params = NULL;
   1.405 +	mp_err res;
   1.406 +
   1.407 +	/* read command-line arguments */
   1.408 +	for (i = 1; i < argv; i++) {
   1.409 +		if ((strcasecmp(argc[i], "time") == 0)
   1.410 +			|| (strcasecmp(argc[i], "-time") == 0)
   1.411 +			|| (strcasecmp(argc[i], "--time") == 0)) {
   1.412 +			ectestTime = 1;
   1.413 +		} else if ((strcasecmp(argc[i], "print") == 0)
   1.414 +				   || (strcasecmp(argc[i], "-print") == 0)
   1.415 +				   || (strcasecmp(argc[i], "--print") == 0)) {
   1.416 +			ectestPrint = 1;
   1.417 +		} else {
   1.418 +			printUsage();
   1.419 +			return 0;
   1.420 +		}
   1.421 +	}
   1.422 +
   1.423 +	/* generic arithmetic tests */
   1.424 +	ECTEST_GENERIC_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
   1.425 +
   1.426 +	/* specific arithmetic tests */
   1.427 +	ECTEST_NAMED_GF2M("NIST-K163", ECCurve_NIST_K163);
   1.428 +	ECTEST_NAMED_GF2M("NIST-B163", ECCurve_NIST_B163);
   1.429 +	ECTEST_NAMED_GF2M("NIST-K233", ECCurve_NIST_K233);
   1.430 +	ECTEST_NAMED_GF2M("NIST-B233", ECCurve_NIST_B233);
   1.431 +	ECTEST_NAMED_GF2M("NIST-K283", ECCurve_NIST_K283);
   1.432 +	ECTEST_NAMED_GF2M("NIST-B283", ECCurve_NIST_B283);
   1.433 +	ECTEST_NAMED_GF2M("NIST-K409", ECCurve_NIST_K409);
   1.434 +	ECTEST_NAMED_GF2M("NIST-B409", ECCurve_NIST_B409);
   1.435 +	ECTEST_NAMED_GF2M("NIST-K571", ECCurve_NIST_K571);
   1.436 +	ECTEST_NAMED_GF2M("NIST-B571", ECCurve_NIST_B571);
   1.437 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V1", ECCurve_X9_62_CHAR2_PNB163V1);
   1.438 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V2", ECCurve_X9_62_CHAR2_PNB163V2);
   1.439 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V3", ECCurve_X9_62_CHAR2_PNB163V3);
   1.440 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB176V1", ECCurve_X9_62_CHAR2_PNB176V1);
   1.441 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V1", ECCurve_X9_62_CHAR2_TNB191V1);
   1.442 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V2", ECCurve_X9_62_CHAR2_TNB191V2);
   1.443 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V3", ECCurve_X9_62_CHAR2_TNB191V3);
   1.444 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB208W1", ECCurve_X9_62_CHAR2_PNB208W1);
   1.445 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V1", ECCurve_X9_62_CHAR2_TNB239V1);
   1.446 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V2", ECCurve_X9_62_CHAR2_TNB239V2);
   1.447 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V3", ECCurve_X9_62_CHAR2_TNB239V3);
   1.448 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB272W1", ECCurve_X9_62_CHAR2_PNB272W1);
   1.449 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB304W1", ECCurve_X9_62_CHAR2_PNB304W1);
   1.450 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB359V1", ECCurve_X9_62_CHAR2_TNB359V1);
   1.451 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB368W1", ECCurve_X9_62_CHAR2_PNB368W1);
   1.452 +	ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB431R1", ECCurve_X9_62_CHAR2_TNB431R1);
   1.453 +	ECTEST_NAMED_GF2M("SECT-113R1", ECCurve_SECG_CHAR2_113R1);
   1.454 +	ECTEST_NAMED_GF2M("SECT-113R2", ECCurve_SECG_CHAR2_113R2);
   1.455 +	ECTEST_NAMED_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
   1.456 +	ECTEST_NAMED_GF2M("SECT-131R2", ECCurve_SECG_CHAR2_131R2);
   1.457 +	ECTEST_NAMED_GF2M("SECT-163K1", ECCurve_SECG_CHAR2_163K1);
   1.458 +	ECTEST_NAMED_GF2M("SECT-163R1", ECCurve_SECG_CHAR2_163R1);
   1.459 +	ECTEST_NAMED_GF2M("SECT-163R2", ECCurve_SECG_CHAR2_163R2);
   1.460 +	ECTEST_NAMED_GF2M("SECT-193R1", ECCurve_SECG_CHAR2_193R1);
   1.461 +	ECTEST_NAMED_GF2M("SECT-193R2", ECCurve_SECG_CHAR2_193R2);
   1.462 +	ECTEST_NAMED_GF2M("SECT-233K1", ECCurve_SECG_CHAR2_233K1);
   1.463 +	ECTEST_NAMED_GF2M("SECT-233R1", ECCurve_SECG_CHAR2_233R1);
   1.464 +	ECTEST_NAMED_GF2M("SECT-239K1", ECCurve_SECG_CHAR2_239K1);
   1.465 +	ECTEST_NAMED_GF2M("SECT-283K1", ECCurve_SECG_CHAR2_283K1);
   1.466 +	ECTEST_NAMED_GF2M("SECT-283R1", ECCurve_SECG_CHAR2_283R1);
   1.467 +	ECTEST_NAMED_GF2M("SECT-409K1", ECCurve_SECG_CHAR2_409K1);
   1.468 +	ECTEST_NAMED_GF2M("SECT-409R1", ECCurve_SECG_CHAR2_409R1);
   1.469 +	ECTEST_NAMED_GF2M("SECT-571K1", ECCurve_SECG_CHAR2_571K1);
   1.470 +	ECTEST_NAMED_GF2M("SECT-571R1", ECCurve_SECG_CHAR2_571R1);
   1.471 +	ECTEST_NAMED_GF2M("WTLS-1 (113)", ECCurve_WTLS_1);
   1.472 +	ECTEST_NAMED_GF2M("WTLS-3 (163)", ECCurve_WTLS_3);
   1.473 +	ECTEST_NAMED_GF2M("WTLS-4 (113)", ECCurve_WTLS_4);
   1.474 +	ECTEST_NAMED_GF2M("WTLS-5 (163)", ECCurve_WTLS_5);
   1.475 +	ECTEST_NAMED_GF2M("WTLS-10 (233)", ECCurve_WTLS_10);
   1.476 +	ECTEST_NAMED_GF2M("WTLS-11 (233)", ECCurve_WTLS_11);
   1.477 +
   1.478 +  CLEANUP:
   1.479 +	EC_FreeCurveParams(params);
   1.480 +	ECGroup_free(group);
   1.481 +	if (res != MP_OKAY) {
   1.482 +		printf("Error: exiting with error value %i\n", res);
   1.483 +	}
   1.484 +	return res;
   1.485 +}

mercurial