Back to index

lightning-sunbird  0.9+nobinonly
ec2_test.c
Go to the documentation of this file.
00001 /* 
00002  * ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is the elliptic curve math library for binary polynomial field curves.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Sun Microsystems, Inc.
00019  * Portions created by the Initial Developer are Copyright (C) 2003
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *   Douglas Stebila <douglas@stebila.ca>, Sun Microsystems Laboratories
00024  *
00025  * Alternatively, the contents of this file may be used under the terms of
00026  * either the GNU General Public License Version 2 or later (the "GPL"), or
00027  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00028  * in which case the provisions of the GPL or the LGPL are applicable instead
00029  * of those above. If you wish to allow use of your version of this file only
00030  * under the terms of either the GPL or the LGPL, and not to allow others to
00031  * use your version of this file under the terms of the MPL, indicate your
00032  * decision by deleting the provisions above and replace them with the notice
00033  * and other provisions required by the GPL or the LGPL. If you do not delete
00034  * the provisions above, a recipient may use your version of this file under
00035  * the terms of any one of the MPL, the GPL or the LGPL.
00036  *
00037  * ***** END LICENSE BLOCK ***** */
00038 
00039 #include "mpi.h"
00040 #include "mplogic.h"
00041 #include "mpprime.h"
00042 #include "mp_gf2m.h"
00043 #include "ecl.h"
00044 #include "ecl-curve.h"
00045 #include "ec2.h"
00046 #include <stdio.h>
00047 #include <strings.h>
00048 #include <assert.h>
00049 
00050 #include <time.h>
00051 #include <sys/time.h>
00052 #include <sys/resource.h>
00053 
00054 /* Time k repetitions of operation op. */
00055 #define M_TimeOperation(op, k) { \
00056        double dStart, dNow, dUserTime; \
00057        struct rusage ru; \
00058        int i; \
00059        getrusage(RUSAGE_SELF, &ru); \
00060        dStart = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
00061        for (i = 0; i < k; i++) { \
00062               { op; } \
00063        }; \
00064        getrusage(RUSAGE_SELF, &ru); \
00065        dNow = (double)ru.ru_utime.tv_sec+(double)ru.ru_utime.tv_usec*0.000001; \
00066        dUserTime = dNow-dStart; \
00067        if (dUserTime) printf("    %-45s k: %6i, t: %6.2f sec\n", #op, k, dUserTime); \
00068 }
00069 
00070 /* Test curve using generic field arithmetic. */
00071 #define ECTEST_GENERIC_GF2M(name_c, name) \
00072        printf("Testing %s using generic implementation...\n", name_c); \
00073        params = EC_GetNamedCurveParams(name); \
00074        if (params == NULL) { \
00075                      printf("  Error: could not construct params.\n"); \
00076                      res = MP_NO; \
00077                      goto CLEANUP; \
00078        } \
00079        ECGroup_free(group); \
00080        group = ECGroup_fromHex(params); \
00081        if (group == NULL) { \
00082               printf("  Error: could not construct group.\n"); \
00083               res = MP_NO; \
00084               goto CLEANUP; \
00085        } \
00086        MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 1) ); \
00087        printf("... okay.\n");
00088 
00089 /* Test curve using specific field arithmetic. */
00090 #define ECTEST_NAMED_GF2M(name_c, name) \
00091        printf("Testing %s using specific implementation...\n", name_c); \
00092        ECGroup_free(group); \
00093        group = ECGroup_fromName(name); \
00094        if (group == NULL) { \
00095               printf("  Warning: could not construct group.\n"); \
00096               printf("... failed; continuing with remaining tests.\n"); \
00097        } else { \
00098               MP_CHECKOK( ectest_curve_GF2m(group, ectestPrint, ectestTime, 0) ); \
00099               printf("... okay.\n"); \
00100        }
00101 
00102 /* Performs basic tests of elliptic curve cryptography over binary
00103  * polynomial fields. If tests fail, then it prints an error message,
00104  * aborts, and returns an error code. Otherwise, returns 0. */
00105 int
00106 ectest_curve_GF2m(ECGroup *group, int ectestPrint, int ectestTime,
00107                               int generic)
00108 {
00109 
00110        mp_int one, order_1, gx, gy, rx, ry, n;
00111        int size;
00112        mp_err res;
00113        char s[1000];
00114 
00115        /* initialize values */
00116        MP_CHECKOK(mp_init(&one));
00117        MP_CHECKOK(mp_init(&order_1));
00118        MP_CHECKOK(mp_init(&gx));
00119        MP_CHECKOK(mp_init(&gy));
00120        MP_CHECKOK(mp_init(&rx));
00121        MP_CHECKOK(mp_init(&ry));
00122        MP_CHECKOK(mp_init(&n));
00123 
00124        MP_CHECKOK(mp_set_int(&one, 1));
00125        MP_CHECKOK(mp_sub(&group->order, &one, &order_1));
00126 
00127        /* encode base point */
00128        if (group->meth->field_dec) {
00129               MP_CHECKOK(group->meth->field_dec(&group->genx, &gx, group->meth));
00130               MP_CHECKOK(group->meth->field_dec(&group->geny, &gy, group->meth));
00131        } else {
00132               MP_CHECKOK(mp_copy(&group->genx, &gx));
00133               MP_CHECKOK(mp_copy(&group->geny, &gy));
00134        }
00135 
00136        if (ectestPrint) {
00137               /* output base point */
00138               printf("  base point P:\n");
00139               MP_CHECKOK(mp_toradix(&gx, s, 16));
00140               printf("    %s\n", s);
00141               MP_CHECKOK(mp_toradix(&gy, s, 16));
00142               printf("    %s\n", s);
00143               if (group->meth->field_enc) {
00144                      printf("  base point P (encoded):\n");
00145                      MP_CHECKOK(mp_toradix(&group->genx, s, 16));
00146                      printf("    %s\n", s);
00147                      MP_CHECKOK(mp_toradix(&group->geny, s, 16));
00148                      printf("    %s\n", s);
00149               }
00150        }
00151 
00152 #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
00153        /* multiply base point by order - 1 and check for negative of base
00154         * point */
00155        MP_CHECKOK(ec_GF2m_pt_mul_aff
00156                         (&order_1, &group->genx, &group->geny, &rx, &ry, group));
00157        if (ectestPrint) {
00158               printf("  (order-1)*P (affine):\n");
00159               MP_CHECKOK(mp_toradix(&rx, s, 16));
00160               printf("    %s\n", s);
00161               MP_CHECKOK(mp_toradix(&ry, s, 16));
00162               printf("    %s\n", s);
00163        }
00164        MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
00165        if ((mp_cmp(&rx, &group->genx) != 0)
00166               || (mp_cmp(&ry, &group->geny) != 0)) {
00167               printf("  Error: invalid result (expected (- base point)).\n");
00168               res = MP_NO;
00169               goto CLEANUP;
00170        }
00171 #endif
00172 
00173        /* multiply base point by order - 1 and check for negative of base
00174         * point */
00175        MP_CHECKOK(ec_GF2m_pt_mul_mont
00176                         (&order_1, &group->genx, &group->geny, &rx, &ry, group));
00177        if (ectestPrint) {
00178               printf("  (order-1)*P (montgomery):\n");
00179               MP_CHECKOK(mp_toradix(&rx, s, 16));
00180               printf("    %s\n", s);
00181               MP_CHECKOK(mp_toradix(&ry, s, 16));
00182               printf("    %s\n", s);
00183        }
00184        MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
00185        if ((mp_cmp(&rx, &group->genx) != 0)
00186               || (mp_cmp(&ry, &group->geny) != 0)) {
00187               printf("  Error: invalid result (expected (- base point)).\n");
00188               res = MP_NO;
00189               goto CLEANUP;
00190        }
00191 
00192 #ifdef ECL_ENABLE_GF2M_PROJ
00193        /* multiply base point by order - 1 and check for negative of base
00194         * point */
00195        MP_CHECKOK(ec_GF2m_pt_mul_proj
00196                         (&order_1, &group->genx, &group->geny, &rx, &ry, group));
00197        if (ectestPrint) {
00198               printf("  (order-1)*P (projective):\n");
00199               MP_CHECKOK(mp_toradix(&rx, s, 16));
00200               printf("    %s\n", s);
00201               MP_CHECKOK(mp_toradix(&ry, s, 16));
00202               printf("    %s\n", s);
00203        }
00204        MP_CHECKOK(group->meth->field_add(&ry, &rx, &ry, group->meth));
00205        if ((mp_cmp(&rx, &group->genx) != 0)
00206               || (mp_cmp(&ry, &group->geny) != 0)) {
00207               printf("  Error: invalid result (expected (- base point)).\n");
00208               res = MP_NO;
00209               goto CLEANUP;
00210        }
00211 #endif
00212 
00213        /* multiply base point by order - 1 and check for negative of base
00214         * point */
00215        MP_CHECKOK(ECPoint_mul(group, &order_1, NULL, NULL, &rx, &ry));
00216        if (ectestPrint) {
00217               printf("  (order-1)*P (ECPoint_mul):\n");
00218               MP_CHECKOK(mp_toradix(&rx, s, 16));
00219               printf("    %s\n", s);
00220               MP_CHECKOK(mp_toradix(&ry, s, 16));
00221               printf("    %s\n", s);
00222        }
00223        MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
00224        if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
00225               printf("  Error: invalid result (expected (- base point)).\n");
00226               res = MP_NO;
00227               goto CLEANUP;
00228        }
00229 
00230        /* multiply base point by order - 1 and check for negative of base
00231         * point */
00232        MP_CHECKOK(ECPoint_mul(group, &order_1, &gx, &gy, &rx, &ry));
00233        if (ectestPrint) {
00234               printf("  (order-1)*P (ECPoint_mul):\n");
00235               MP_CHECKOK(mp_toradix(&rx, s, 16));
00236               printf("    %s\n", s);
00237               MP_CHECKOK(mp_toradix(&ry, s, 16));
00238               printf("    %s\n", s);
00239        }
00240        MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
00241        if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
00242               printf("  Error: invalid result (expected (- base point)).\n");
00243               res = MP_NO;
00244               goto CLEANUP;
00245        }
00246 
00247 #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
00248        /* multiply base point by order and check for point at infinity */
00249        MP_CHECKOK(ec_GF2m_pt_mul_aff
00250                         (&group->order, &group->genx, &group->geny, &rx, &ry,
00251                             group));
00252        if (ectestPrint) {
00253               printf("  (order)*P (affine):\n");
00254               MP_CHECKOK(mp_toradix(&rx, s, 16));
00255               printf("    %s\n", s);
00256               MP_CHECKOK(mp_toradix(&ry, s, 16));
00257               printf("    %s\n", s);
00258        }
00259        if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
00260               printf("  Error: invalid result (expected point at infinity).\n");
00261               res = MP_NO;
00262               goto CLEANUP;
00263        }
00264 #endif
00265 
00266        /* multiply base point by order and check for point at infinity */
00267        MP_CHECKOK(ec_GF2m_pt_mul_mont
00268                         (&group->order, &group->genx, &group->geny, &rx, &ry,
00269                             group));
00270        if (ectestPrint) {
00271               printf("  (order)*P (montgomery):\n");
00272               MP_CHECKOK(mp_toradix(&rx, s, 16));
00273               printf("    %s\n", s);
00274               MP_CHECKOK(mp_toradix(&ry, s, 16));
00275               printf("    %s\n", s);
00276        }
00277        if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
00278               printf("  Error: invalid result (expected point at infinity).\n");
00279               res = MP_NO;
00280               goto CLEANUP;
00281        }
00282 
00283 #ifdef ECL_ENABLE_GF2M_PROJ
00284        /* multiply base point by order and check for point at infinity */
00285        MP_CHECKOK(ec_GF2m_pt_mul_proj
00286                         (&group->order, &group->genx, &group->geny, &rx, &ry,
00287                             group));
00288        if (ectestPrint) {
00289               printf("  (order)*P (projective):\n");
00290               MP_CHECKOK(mp_toradix(&rx, s, 16));
00291               printf("    %s\n", s);
00292               MP_CHECKOK(mp_toradix(&ry, s, 16));
00293               printf("    %s\n", s);
00294        }
00295        if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
00296               printf("  Error: invalid result (expected point at infinity).\n");
00297               res = MP_NO;
00298               goto CLEANUP;
00299        }
00300 #endif
00301 
00302        /* multiply base point by order and check for point at infinity */
00303        MP_CHECKOK(ECPoint_mul(group, &group->order, NULL, NULL, &rx, &ry));
00304        if (ectestPrint) {
00305               printf("  (order)*P (ECPoint_mul):\n");
00306               MP_CHECKOK(mp_toradix(&rx, s, 16));
00307               printf("    %s\n", s);
00308               MP_CHECKOK(mp_toradix(&ry, s, 16));
00309               printf("    %s\n", s);
00310        }
00311        if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
00312               printf("  Error: invalid result (expected point at infinity).\n");
00313               res = MP_NO;
00314               goto CLEANUP;
00315        }
00316 
00317        /* multiply base point by order and check for point at infinity */
00318        MP_CHECKOK(ECPoint_mul(group, &group->order, &gx, &gy, &rx, &ry));
00319        if (ectestPrint) {
00320               printf("  (order)*P (ECPoint_mul):\n");
00321               MP_CHECKOK(mp_toradix(&rx, s, 16));
00322               printf("    %s\n", s);
00323               MP_CHECKOK(mp_toradix(&ry, s, 16));
00324               printf("    %s\n", s);
00325        }
00326        if (ec_GF2m_pt_is_inf_aff(&rx, &ry) != MP_YES) {
00327               printf("  Error: invalid result (expected point at infinity).\n");
00328               res = MP_NO;
00329               goto CLEANUP;
00330        }
00331 
00332        /* check that (order-1)P + (order-1)P + P == (order-1)P */
00333        MP_CHECKOK(ECPoints_mul
00334                         (group, &order_1, &order_1, &gx, &gy, &rx, &ry));
00335        MP_CHECKOK(ECPoints_mul(group, &one, &one, &rx, &ry, &rx, &ry));
00336        if (ectestPrint) {
00337               printf
00338                      ("  (order-1)*P + (order-1)*P + P == (order-1)*P (ECPoints_mul):\n");
00339               MP_CHECKOK(mp_toradix(&rx, s, 16));
00340               printf("    %s\n", s);
00341               MP_CHECKOK(mp_toradix(&ry, s, 16));
00342               printf("    %s\n", s);
00343        }
00344        MP_CHECKOK(ec_GF2m_add(&ry, &rx, &ry, group->meth));
00345        if ((mp_cmp(&rx, &gx) != 0) || (mp_cmp(&ry, &gy) != 0)) {
00346               printf("  Error: invalid result (expected (- base point)).\n");
00347               res = MP_NO;
00348               goto CLEANUP;
00349        }
00350 
00351        /* test validate_point function */
00352        if (ECPoint_validate(group, &gx, &gy) != MP_YES) {
00353               printf("  Error: validate point on base point failed.\n");
00354               res = MP_NO;
00355               goto CLEANUP;
00356        }
00357        MP_CHECKOK(mp_add_d(&gy, 1, &ry));
00358        if (ECPoint_validate(group, &gx, &ry) != MP_NO) {
00359               printf("  Error: validate point on invalid point passed.\n");
00360               res = MP_NO;
00361               goto CLEANUP;
00362        }
00363 
00364        if (ectestTime) {
00365               /* compute random scalar */
00366               size = mpl_significant_bits(&group->meth->irr);
00367               if (size < MP_OKAY) {
00368                      goto CLEANUP;
00369               }
00370               MP_CHECKOK(mpp_random_size(&n, (size + ECL_BITS - 1) / ECL_BITS));
00371               MP_CHECKOK(group->meth->field_mod(&n, &n, group->meth));
00372               /* timed test */
00373               if (generic) {
00374 #ifdef ECL_ENABLE_GF2M_PT_MUL_AFF
00375                      M_TimeOperation(MP_CHECKOK
00376                                                  (ec_GF2m_pt_mul_aff
00377                                                   (&n, &group->genx, &group->geny, &rx, &ry,
00378                                                    group)), 100);
00379 #endif
00380                      M_TimeOperation(MP_CHECKOK
00381                                                  (ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
00382                                                  100);
00383                      M_TimeOperation(MP_CHECKOK
00384                                                  (ECPoints_mul
00385                                                   (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
00386               } else {
00387                      M_TimeOperation(MP_CHECKOK
00388                                                  (ECPoint_mul(group, &n, NULL, NULL, &rx, &ry)),
00389                                                  100);
00390                      M_TimeOperation(MP_CHECKOK
00391                                                  (ECPoint_mul(group, &n, &gx, &gy, &rx, &ry)),
00392                                                  100);
00393                      M_TimeOperation(MP_CHECKOK
00394                                                  (ECPoints_mul
00395                                                   (group, &n, &n, &gx, &gy, &rx, &ry)), 100);
00396               }
00397        }
00398 
00399   CLEANUP:
00400        mp_clear(&one);
00401        mp_clear(&order_1);
00402        mp_clear(&gx);
00403        mp_clear(&gy);
00404        mp_clear(&rx);
00405        mp_clear(&ry);
00406        mp_clear(&n);
00407        if (res != MP_OKAY) {
00408               printf("  Error: exiting with error value %i\n", res);
00409        }
00410        return res;
00411 }
00412 
00413 /* Prints help information. */
00414 void
00415 printUsage()
00416 {
00417        printf("Usage: ecp_test [--print] [--time]\n");
00418        printf
00419               ("     --print     Print out results of each point arithmetic test.\n");
00420        printf
00421               ("     --time      Benchmark point operations and print results.\n");
00422 }
00423 
00424 /* Performs tests of elliptic curve cryptography over binary polynomial
00425  * fields. If tests fail, then it prints an error message, aborts, and
00426  * returns an error code. Otherwise, returns 0. */
00427 int
00428 main(int argv, char **argc)
00429 {
00430 
00431        int ectestTime = 0;
00432        int ectestPrint = 0;
00433        int i;
00434        ECGroup *group = NULL;
00435        ECCurveParams *params = NULL;
00436        mp_err res;
00437 
00438        /* read command-line arguments */
00439        for (i = 1; i < argv; i++) {
00440               if ((strcasecmp(argc[i], "time") == 0)
00441                      || (strcasecmp(argc[i], "-time") == 0)
00442                      || (strcasecmp(argc[i], "--time") == 0)) {
00443                      ectestTime = 1;
00444               } else if ((strcasecmp(argc[i], "print") == 0)
00445                                || (strcasecmp(argc[i], "-print") == 0)
00446                                || (strcasecmp(argc[i], "--print") == 0)) {
00447                      ectestPrint = 1;
00448               } else {
00449                      printUsage();
00450                      return 0;
00451               }
00452        }
00453 
00454        /* generic arithmetic tests */
00455        ECTEST_GENERIC_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
00456 
00457        /* specific arithmetic tests */
00458        ECTEST_NAMED_GF2M("NIST-K163", ECCurve_NIST_K163);
00459        ECTEST_NAMED_GF2M("NIST-B163", ECCurve_NIST_B163);
00460        ECTEST_NAMED_GF2M("NIST-K233", ECCurve_NIST_K233);
00461        ECTEST_NAMED_GF2M("NIST-B233", ECCurve_NIST_B233);
00462        ECTEST_NAMED_GF2M("NIST-K283", ECCurve_NIST_K283);
00463        ECTEST_NAMED_GF2M("NIST-B283", ECCurve_NIST_B283);
00464        ECTEST_NAMED_GF2M("NIST-K409", ECCurve_NIST_K409);
00465        ECTEST_NAMED_GF2M("NIST-B409", ECCurve_NIST_B409);
00466        ECTEST_NAMED_GF2M("NIST-K571", ECCurve_NIST_K571);
00467        ECTEST_NAMED_GF2M("NIST-B571", ECCurve_NIST_B571);
00468        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V1", ECCurve_X9_62_CHAR2_PNB163V1);
00469        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V2", ECCurve_X9_62_CHAR2_PNB163V2);
00470        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB163V3", ECCurve_X9_62_CHAR2_PNB163V3);
00471        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB176V1", ECCurve_X9_62_CHAR2_PNB176V1);
00472        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V1", ECCurve_X9_62_CHAR2_TNB191V1);
00473        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V2", ECCurve_X9_62_CHAR2_TNB191V2);
00474        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB191V3", ECCurve_X9_62_CHAR2_TNB191V3);
00475        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB208W1", ECCurve_X9_62_CHAR2_PNB208W1);
00476        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V1", ECCurve_X9_62_CHAR2_TNB239V1);
00477        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V2", ECCurve_X9_62_CHAR2_TNB239V2);
00478        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB239V3", ECCurve_X9_62_CHAR2_TNB239V3);
00479        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB272W1", ECCurve_X9_62_CHAR2_PNB272W1);
00480        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB304W1", ECCurve_X9_62_CHAR2_PNB304W1);
00481        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB359V1", ECCurve_X9_62_CHAR2_TNB359V1);
00482        ECTEST_NAMED_GF2M("ANSI X9.62 C2PNB368W1", ECCurve_X9_62_CHAR2_PNB368W1);
00483        ECTEST_NAMED_GF2M("ANSI X9.62 C2TNB431R1", ECCurve_X9_62_CHAR2_TNB431R1);
00484        ECTEST_NAMED_GF2M("SECT-113R1", ECCurve_SECG_CHAR2_113R1);
00485        ECTEST_NAMED_GF2M("SECT-113R2", ECCurve_SECG_CHAR2_113R2);
00486        ECTEST_NAMED_GF2M("SECT-131R1", ECCurve_SECG_CHAR2_131R1);
00487        ECTEST_NAMED_GF2M("SECT-131R2", ECCurve_SECG_CHAR2_131R2);
00488        ECTEST_NAMED_GF2M("SECT-163K1", ECCurve_SECG_CHAR2_163K1);
00489        ECTEST_NAMED_GF2M("SECT-163R1", ECCurve_SECG_CHAR2_163R1);
00490        ECTEST_NAMED_GF2M("SECT-163R2", ECCurve_SECG_CHAR2_163R2);
00491        ECTEST_NAMED_GF2M("SECT-193R1", ECCurve_SECG_CHAR2_193R1);
00492        ECTEST_NAMED_GF2M("SECT-193R2", ECCurve_SECG_CHAR2_193R2);
00493        ECTEST_NAMED_GF2M("SECT-233K1", ECCurve_SECG_CHAR2_233K1);
00494        ECTEST_NAMED_GF2M("SECT-233R1", ECCurve_SECG_CHAR2_233R1);
00495        ECTEST_NAMED_GF2M("SECT-239K1", ECCurve_SECG_CHAR2_239K1);
00496        ECTEST_NAMED_GF2M("SECT-283K1", ECCurve_SECG_CHAR2_283K1);
00497        ECTEST_NAMED_GF2M("SECT-283R1", ECCurve_SECG_CHAR2_283R1);
00498        ECTEST_NAMED_GF2M("SECT-409K1", ECCurve_SECG_CHAR2_409K1);
00499        ECTEST_NAMED_GF2M("SECT-409R1", ECCurve_SECG_CHAR2_409R1);
00500        ECTEST_NAMED_GF2M("SECT-571K1", ECCurve_SECG_CHAR2_571K1);
00501        ECTEST_NAMED_GF2M("SECT-571R1", ECCurve_SECG_CHAR2_571R1);
00502        ECTEST_NAMED_GF2M("WTLS-1 (113)", ECCurve_WTLS_1);
00503        ECTEST_NAMED_GF2M("WTLS-3 (163)", ECCurve_WTLS_3);
00504        ECTEST_NAMED_GF2M("WTLS-4 (113)", ECCurve_WTLS_4);
00505        ECTEST_NAMED_GF2M("WTLS-5 (163)", ECCurve_WTLS_5);
00506        ECTEST_NAMED_GF2M("WTLS-10 (233)", ECCurve_WTLS_10);
00507        ECTEST_NAMED_GF2M("WTLS-11 (233)", ECCurve_WTLS_11);
00508 
00509   CLEANUP:
00510        EC_FreeCurveParams(params);
00511        ECGroup_free(group);
00512        if (res != MP_OKAY) {
00513               printf("Error: exiting with error value %i\n", res);
00514        }
00515        return res;
00516 }