1 /* crypto/ecdsa/ecdsatest.c */
2 /* ====================================================================
3 * Copyright (c) 2000-2002 The OpenSSL Project. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
17 * 3. All advertising materials mentioning features or use of this
18 * software must display the following acknowledgment:
19 * "This product includes software developed by the OpenSSL Project
20 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
22 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
23 * endorse or promote products derived from this software without
24 * prior written permission. For written permission, please contact
25 * licensing@OpenSSL.org.
27 * 5. Products derived from this software may not be called "OpenSSL"
28 * nor may "OpenSSL" appear in their names without prior written
29 * permission of the OpenSSL Project.
31 * 6. Redistributions of any form whatsoever must retain the following
33 * "This product includes software developed by the OpenSSL Project
34 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
36 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
37 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
38 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
39 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
40 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
42 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
43 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
45 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
46 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
47 * OF THE POSSIBILITY OF SUCH DAMAGE.
48 * ====================================================================
50 * This product includes cryptographic software written by Eric Young
51 * (eay@cryptsoft.com). This product includes software written by Tim
52 * Hudson (tjh@cryptsoft.com).
55 /* ====================================================================
56 * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
58 * Portions of the attached software ("Contribution") are developed by
59 * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project.
61 * The Contribution is licensed pursuant to the OpenSSL open source
62 * license provided above.
64 * In addition, Sun covenants to all licensees who provide a reciprocal
65 * covenant with respect to their own patents if any, not to sue under
66 * current and future patent claims necessarily infringed by the making,
67 * using, practicing, selling, offering for sale and/or otherwise
68 * disposing of the Contribution as delivered hereunder
69 * (or portions thereof), provided that such covenant shall not apply:
70 * 1) for code that a licensee deletes from the Contribution;
71 * 2) separates from the Contribution; or
72 * 3) for infringements caused by:
73 * i) the modification of the Contribution or
74 * ii) the combination of the Contribution with other software or
75 * devices where such combination causes the infringement.
77 * The elliptic curve binary polynomial software is originally written by
78 * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories.
88 /* "To determine the time in seconds, the value returned
89 * by the clock function should be divided by the value
90 * of the macro CLOCKS_PER_SEC."
94 /* "`CLOCKS_PER_SEC' undeclared (first use this function)"
95 * -- cc on NeXTstep/OpenStep */
97 # define CLOCKS_PER_SEC 1
100 #ifdef OPENSSL_NO_ECDSA
101 int main(int argc, char * argv[]) { puts("Elliptic curves are disabled."); return 0; }
104 #include <openssl/crypto.h>
105 #include <openssl/bio.h>
106 #include <openssl/evp.h>
107 #include <openssl/x509.h>
108 #include <openssl/ecdsa.h>
109 #include <openssl/engine.h>
110 #include <openssl/err.h>
112 static BIO *bio_err=NULL;
113 static const char rnd_seed[] = "string to make the random number generator think it has entropy";
115 #define ECDSA_NIST_TESTS 10
116 ECDSA_SIG* signatures[ECDSA_NIST_TESTS];
117 unsigned char digest[ECDSA_NIST_TESTS][20];
119 void clear_ecdsa(EC_KEY *ecdsa)
125 EC_GROUP_free(ecdsa->group);
130 EC_POINT_free(ecdsa->pub_key);
131 ecdsa->pub_key = NULL;
135 BN_free(ecdsa->priv_key);
136 ecdsa->priv_key = NULL;
140 int set_p192_param(EC_KEY *ecdsa)
147 if ((ctx = BN_CTX_new()) == NULL) goto err;
150 if ((ecdsa->group = EC_GROUP_new_by_name(EC_GROUP_X9_62_PRIME_192V1)) == NULL)
152 BIO_printf(bio_err,"ECDSA_SET_GROUP_P_192_V1() failed \n");
155 if ((ecdsa->pub_key = EC_POINT_new(ecdsa->group)) == NULL)
157 BIO_printf(bio_err,"EC_POINT_new failed \n");
161 if (!BN_dec2bn(&(ecdsa->priv_key), "651056770906015076056810763456358567190100156695615665659")) goto err;
162 if (!EC_POINT_mul(ecdsa->group,ecdsa->pub_key,ecdsa->priv_key,NULL,NULL,ctx))
164 BIO_printf(bio_err,"EC_POINT_mul() failed \n");
169 err : if (ctx) BN_CTX_free(ctx);
173 int set_p239_param(EC_KEY *ecdsa)
180 if ((ctx = BN_CTX_new()) == NULL) goto err;
183 if ((ecdsa->group = EC_GROUP_new_by_name(EC_GROUP_X9_62_PRIME_239V1)) == NULL)
185 BIO_printf(bio_err,"ECDSA_SET_GROUP_P_239_V1() failed \n");
188 if ((ecdsa->pub_key = EC_POINT_new(ecdsa->group)) == NULL)
190 BIO_printf(bio_err,"EC_POINT_new failed \n");
194 if (!BN_dec2bn(&(ecdsa->priv_key), "876300101507107567501066130761671078357010671067781776716671676178726717")) goto err;
195 if (!EC_POINT_mul(ecdsa->group,ecdsa->pub_key,ecdsa->priv_key,NULL,NULL,ctx))
197 BIO_printf(bio_err,"EC_POINT_mul() failed \n");
202 err : if (ctx) BN_CTX_free(ctx);
206 int test_sig_vrf(EC_KEY *ecdsa, const unsigned char* dgst)
209 unsigned char *buffer=NULL;
210 unsigned int buf_len;
213 if (!ecdsa || !ecdsa->group || !ecdsa->pub_key || !ecdsa->priv_key)
215 if ((buf_len = ECDSA_size(ecdsa)) == 0)
217 BIO_printf(bio_err, "ECDSA_size() == 0 \n");
220 if ((buffer = OPENSSL_malloc(buf_len)) == NULL)
224 if (!ECDSA_sign(type, dgst , 20, buffer, &buf_len, ecdsa))
226 BIO_printf(bio_err, "ECDSA_sign() FAILED \n");
230 BIO_printf(bio_err, " [ ECDSA_sign() %.2f"UNIT, (double)tim/(CLOCKS_PER_SEC));
233 ret = ECDSA_verify(type, dgst, 20, buffer, buf_len, ecdsa);
236 BIO_printf(bio_err, "ECDSA_verify() FAILED \n");
240 BIO_printf(bio_err, " and ECDSA_verify() %.2f"UNIT" ] ", (double)tim/(CLOCKS_PER_SEC));
242 err: OPENSSL_free(buffer);
246 int test_x962_sig_vrf(EC_KEY *eckey, const unsigned char *dgst,
247 const char *k_in, const char *r_in, const char *s_in)
251 EC_POINT *point=NULL;
252 BIGNUM *r=NULL,*s=NULL,*k=NULL,*x=NULL,*y=NULL,*m=NULL,*ord=NULL;
255 ECDSA_DATA *ecdsa = ecdsa_check(eckey);;
257 if (!eckey || !eckey->group || !eckey->pub_key || !eckey->priv_key
260 if ((point = EC_POINT_new(eckey->group)) == NULL) goto err;
261 if ((r = BN_new()) == NULL || (s = BN_new()) == NULL
262 || (k = BN_new()) == NULL || (x = BN_new()) == NULL ||
263 (y = BN_new()) == NULL || (m = BN_new()) == NULL ||
264 (ord = BN_new()) == NULL) goto err;
265 if ((ctx = BN_CTX_new()) == NULL) goto err;
266 if (!BN_bin2bn(dgst, 20, m)) goto err;
267 if (!BN_dec2bn(&k, k_in)) goto err;
268 if (!EC_POINT_mul(eckey->group, point, k, NULL, NULL, ctx)) goto err;
269 if (!EC_POINT_get_affine_coordinates_GFp(eckey->group, point, x, y,
271 if (!EC_GROUP_get_order(eckey->group, ord, ctx)) goto err;
272 if ((ecdsa->r = BN_dup(x)) == NULL) goto err;
273 if ((ecdsa->kinv = BN_mod_inverse(NULL, k, ord, ctx)) == NULL)
276 if ((sig = ECDSA_do_sign(dgst, 20, eckey)) == NULL)
278 BIO_printf(bio_err,"ECDSA_do_sign() failed \n");
282 if (!BN_dec2bn(&r, r_in)) goto err;
283 if (!BN_dec2bn(&s, s_in)) goto err;
284 if (BN_cmp(sig->r,r) != 0 || BN_cmp(sig->s,s) != 0)
286 tmp_char = OPENSSL_malloc(128);
287 if (tmp_char == NULL) goto err;
288 tmp_char = BN_bn2dec(sig->r);
289 BIO_printf(bio_err,"unexpected signature \n");
290 BIO_printf(bio_err,"sig->r = %s\n",tmp_char);
291 tmp_char = BN_bn2dec(sig->s);
292 BIO_printf(bio_err,"sig->s = %s\n",tmp_char);
295 ret = ECDSA_do_verify(dgst, 20, sig, eckey);
298 BIO_printf(bio_err,"ECDSA_do_verify : signature verification failed \n");
303 err : if (r) BN_free(r);
309 if (ord) BN_free(ord);
310 if (sig) ECDSA_SIG_free(sig);
311 if (ctx) BN_CTX_free(ctx);
312 if (point) EC_POINT_free(point);
313 if (tmp_char) OPENSSL_free(tmp_char);
317 int ecdsa_cmp(const EC_KEY *a, const EC_KEY *b)
321 BIGNUM *tmp_a1=NULL, *tmp_a2=NULL, *tmp_a3=NULL;
322 BIGNUM *tmp_b1=NULL, *tmp_b2=NULL, *tmp_b3=NULL;
324 if ((ctx = BN_CTX_new()) == NULL) return 1;
325 if ((tmp_a1 = BN_new()) == NULL || (tmp_a2 = BN_new()) == NULL || (tmp_a3 = BN_new()) == NULL) goto err;
326 if ((tmp_b1 = BN_new()) == NULL || (tmp_b2 = BN_new()) == NULL || (tmp_b3 = BN_new()) == NULL) goto err;
328 if (a->pub_key && b->pub_key)
329 if (EC_POINT_cmp(a->group, a->pub_key, b->pub_key, ctx) != 0) goto err;
330 if (a->priv_key && b->priv_key)
331 if (BN_cmp(a->priv_key, b->priv_key) != 0) goto err;
332 if (!EC_GROUP_get_curve_GFp(a->group, tmp_a1, tmp_a2, tmp_a3, ctx)) goto err;
333 if (!EC_GROUP_get_curve_GFp(a->group, tmp_b1, tmp_b2, tmp_b3, ctx)) goto err;
334 if (BN_cmp(tmp_a1, tmp_b1) != 0) goto err;
335 if (BN_cmp(tmp_a2, tmp_b2) != 0) goto err;
336 if (BN_cmp(tmp_a3, tmp_b3) != 0) goto err;
339 err: if (tmp_a1) BN_free(tmp_a1);
340 if (tmp_a2) BN_free(tmp_a2);
341 if (tmp_a3) BN_free(tmp_a3);
342 if (tmp_b1) BN_free(tmp_b1);
343 if (tmp_b2) BN_free(tmp_b2);
344 if (tmp_b3) BN_free(tmp_b3);
345 if (ctx) BN_CTX_free(ctx);
351 EC_KEY *ecdsa=NULL, *ret_ecdsa=NULL;
353 X509_PUBKEY *x509_pubkey=NULL;
354 PKCS8_PRIV_KEY_INFO *pkcs8=NULL;
355 EVP_PKEY *pkey=NULL, *ret_pkey=NULL;
357 unsigned char *dgst=NULL;
360 unsigned char *buffer=NULL;
364 EVP_MD_CTX *md_ctx=NULL;
366 /* enable memory leak checking unless explicitly disabled */
367 if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) && (0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off"))))
369 CRYPTO_malloc_debug_init();
370 CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
374 /* OPENSSL_DEBUG_MEMORY=off */
375 CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
377 CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
379 ERR_load_crypto_strings();
382 bio_err=BIO_new_fp(stderr, BIO_NOCLOSE);
384 RAND_seed(rnd_seed, sizeof(rnd_seed));
386 if ((ecdsa = EC_KEY_new()) == NULL) goto err;
388 set_p192_param(ecdsa);
389 EC_KEY_print(bio_err, ecdsa, 0);
391 /* en- decode tests */
393 /* i2d_ - d2i_ECParameters() */
394 BIO_printf(bio_err, "\nTesting i2d_ - d2i_ECDSAParameters \n");
395 buf_len = i2d_ECParameters(ecdsa, NULL);
396 if (!buf_len || (buffer = OPENSSL_malloc(buf_len)) == NULL) goto err;
398 if (!i2d_ECParameters(ecdsa, &pp)) goto err;
400 if ((ret_ecdsa = d2i_ECParameters(&ret_ecdsa, (const unsigned char **)&pp,
401 buf_len)) == NULL) goto err;
402 ECParameters_print(bio_err, ret_ecdsa);
403 if (ecdsa_cmp(ecdsa, ret_ecdsa)) goto err;
404 OPENSSL_free(buffer);
406 EC_KEY_free(ret_ecdsa);
409 /* i2d_ - d2i_ECPrivateKey() */
410 BIO_printf(bio_err, "\nTesting i2d_ - d2i_ECDSAPrivateKey \n");
411 buf_len = i2d_ECPrivateKey(ecdsa, NULL);
412 if (!buf_len || (buffer = OPENSSL_malloc(buf_len)) == NULL) goto err;
414 if (!i2d_ECPrivateKey(ecdsa, &pp)) goto err;
416 if ((ret_ecdsa = d2i_ECPrivateKey(&ret_ecdsa, (const unsigned char**)&pp,
417 buf_len)) == NULL) goto err;
418 EC_KEY_print(bio_err, ret_ecdsa, 0);
419 if (ecdsa_cmp(ecdsa, ret_ecdsa)) goto err;
420 EC_KEY_free(ret_ecdsa);
422 OPENSSL_free(buffer);
425 /* X509_PUBKEY_set() & X509_PUBKEY_get() */
427 BIO_printf(bio_err, "\nTesting X509_PUBKEY_{get,set} : ");
428 if ((pkey = EVP_PKEY_new()) == NULL) goto err;
429 EVP_PKEY_assign_EC_KEY(pkey, ecdsa);
430 if ((x509_pubkey = X509_PUBKEY_new()) == NULL) goto err;
431 if (!X509_PUBKEY_set(&x509_pubkey, pkey)) goto err;
433 if ((ret_pkey = X509_PUBKEY_get(x509_pubkey)) == NULL) goto err;
434 ret_ecdsa = EVP_PKEY_get1_EC_KEY(ret_pkey);
435 EVP_PKEY_free(ret_pkey);
438 if (ecdsa_cmp(ecdsa, ret_ecdsa))
440 BIO_printf(bio_err, "TEST FAILED \n");
443 else BIO_printf(bio_err, "TEST OK \n");
444 X509_PUBKEY_free(x509_pubkey);
446 EC_KEY_free(ret_ecdsa);
449 /* Testing PKCS8_PRIV_KEY_INFO <-> EVP_PKEY */
450 BIO_printf(bio_err, "Testing PKCS8_PRIV_KEY_INFO <-> EVP_PKEY : \n");
451 BIO_printf(bio_err, "PKCS8_OK : ");
452 if ((pkcs8 = EVP_PKEY2PKCS8_broken(pkey, PKCS8_OK)) == NULL) goto err;
453 if ((ret_pkey = EVP_PKCS82PKEY(pkcs8)) == NULL) goto err;
454 ret_ecdsa = EVP_PKEY_get1_EC_KEY(ret_pkey);
455 if (ecdsa_cmp(ecdsa, ret_ecdsa))
457 BIO_printf(bio_err, "TEST FAILED \n");
460 else BIO_printf(bio_err, "TEST OK \n");
461 EVP_PKEY_free(ret_pkey);
463 EC_KEY_free(ret_ecdsa);
465 PKCS8_PRIV_KEY_INFO_free(pkcs8);
466 BIO_printf(bio_err, "PKCS8_NO_OCTET : ");
467 if ((pkcs8 = EVP_PKEY2PKCS8_broken(pkey, PKCS8_NO_OCTET)) == NULL) goto err;
468 if ((ret_pkey = EVP_PKCS82PKEY(pkcs8)) == NULL) goto err;
469 ret_ecdsa = EVP_PKEY_get1_EC_KEY(ret_pkey);
470 if (ecdsa_cmp(ecdsa, ret_ecdsa))
472 BIO_printf(bio_err, "TEST FAILED \n");
475 else BIO_printf(bio_err, "TEST OK \n");
476 EVP_PKEY_free(ret_pkey);
478 EC_KEY_free(ret_ecdsa);
480 PKCS8_PRIV_KEY_INFO_free(pkcs8);
481 BIO_printf(bio_err, "PKCS8_EMBEDDED_PARAM : ");
482 if ((pkcs8 = EVP_PKEY2PKCS8_broken(pkey, PKCS8_EMBEDDED_PARAM)) == NULL) goto err;
483 if ((ret_pkey = EVP_PKCS82PKEY(pkcs8)) == NULL) goto err;
484 ret_ecdsa = EVP_PKEY_get1_EC_KEY(ret_pkey);
485 if (ecdsa_cmp(ecdsa, ret_ecdsa))
487 BIO_printf(bio_err, "TEST FAILED \n");
490 else BIO_printf(bio_err, "TEST OK \n");
491 EVP_PKEY_free(ret_pkey);
493 EC_KEY_free(ret_ecdsa);
495 PKCS8_PRIV_KEY_INFO_free(pkcs8);
496 BIO_printf(bio_err, "PKCS8_NS_DB : ");
497 if ((pkcs8 = EVP_PKEY2PKCS8_broken(pkey, PKCS8_NS_DB)) == NULL) goto err;
498 if ((ret_pkey = EVP_PKCS82PKEY(pkcs8)) == NULL) goto err;
499 ret_ecdsa = EVP_PKEY_get1_EC_KEY(ret_pkey);
500 if (ecdsa_cmp(ecdsa, ret_ecdsa))
502 BIO_printf(bio_err, "TEST FAILED \n");
505 else BIO_printf(bio_err, "TEST OK \n");
506 EVP_PKEY_free(ret_pkey);
508 EC_KEY_free(ret_ecdsa);
513 PKCS8_PRIV_KEY_INFO_free(pkcs8);
516 /* sign and verify tests */
517 if ((d = BN_new()) == NULL) goto err;
519 if (!BN_dec2bn(&d, "968236873715988614170569073515315707566766479517")) goto err;
520 dgst_len = BN_num_bytes(d);
521 if ((dgst = OPENSSL_malloc(dgst_len)) == NULL) goto err;
522 if (!BN_bn2bin(d, dgst)) goto err;
524 BIO_printf(bio_err, "Performing tests based on examples H.3.1 and H.3.2 of X9.62 \n");
526 BIO_printf(bio_err, "PRIME_192_V1 : ");
527 if ((ecdsa = EC_KEY_new()) == NULL) goto err;
528 if (!set_p192_param(ecdsa)) goto err;
529 if (!test_x962_sig_vrf(ecdsa, dgst, "6140507067065001063065065565667405560006161556565665656654",
530 "3342403536405981729393488334694600415596881826869351677613",
531 "5735822328888155254683894997897571951568553642892029982342"))
534 BIO_printf(bio_err, "OK\n");
535 BIO_printf(bio_err, "PRIME_239_V1 : ");
536 if (!set_p239_param(ecdsa))
538 if (!test_x962_sig_vrf(ecdsa, dgst, "700000017569056646655505781757157107570501575775705779575555657156756655",
539 "308636143175167811492622547300668018854959378758531778147462058306432176",
540 "323813553209797357708078776831250505931891051755007842781978505179448783"))
543 BIO_printf(bio_err, "OK\n");
550 for (i=0; i<ECDSA_NIST_TESTS; i++)
551 if (!RAND_bytes(digest[i], 20)) goto err;
553 BIO_printf(bio_err, "\n");
555 /* Macro for each test */
556 #define ECDSA_GROUP_TEST(text, curve) \
557 BIO_printf(bio_err, "Testing sign & verify with %s : \n", text); \
558 EC_KEY_free(ecdsa); \
559 if ((ecdsa = EC_KEY_new()) == NULL) goto err; \
560 if ((ecdsa->group = EC_GROUP_new_by_name(curve)) == NULL) goto err; \
561 if (!EC_KEY_generate_key(ecdsa)) goto err; \
563 for (i=0; i<ECDSA_NIST_TESTS; i++) \
564 if ((signatures[i] = ECDSA_do_sign(digest[i], 20, ecdsa)) == NULL) goto err; \
565 tim = clock() - tim; \
566 tim_d = (double)tim / CLOCKS_PER_SEC; \
567 BIO_printf(bio_err, "%d x ECDSA_do_sign() in %.2f"UNIT" => average time for ECDSA_do_sign() %.4f"UNIT"\n" \
568 , ECDSA_NIST_TESTS, tim_d, tim_d / ECDSA_NIST_TESTS); \
570 for (i=0; i<ECDSA_NIST_TESTS; i++) \
571 if (!ECDSA_do_verify(digest[i], 20, signatures[i], ecdsa)) goto err; \
572 tim = clock() - tim; \
573 tim_d = (double)tim / CLOCKS_PER_SEC; \
574 BIO_printf(bio_err, "%d x ECDSA_do_verify() in %.2f"UNIT" => average time for ECDSA_do_verify() %.4f"UNIT"\n" \
575 , ECDSA_NIST_TESTS, tim_d, tim_d/ECDSA_NIST_TESTS); \
576 for (i=0; i<ECDSA_NIST_TESTS; i++) \
578 ECDSA_SIG_free(signatures[i]); \
579 signatures[i] = NULL; \
582 /* NIST PRIME CURVES TESTS */
583 ECDSA_GROUP_TEST("NIST Prime-Curve P-192", EC_GROUP_NIST_PRIME_192);
584 ECDSA_GROUP_TEST("NIST Prime-Curve P-224", EC_GROUP_NIST_PRIME_224);
585 ECDSA_GROUP_TEST("NIST Prime-Curve P-256", EC_GROUP_NIST_PRIME_256);
586 ECDSA_GROUP_TEST("NIST Prime-Curve P-384", EC_GROUP_NIST_PRIME_384);
587 ECDSA_GROUP_TEST("NIST Prime-Curve P-521", EC_GROUP_NIST_PRIME_521);
588 /* NIST BINARY CURVES TESTS */
589 ECDSA_GROUP_TEST("NIST Binary-Curve K-163", EC_GROUP_NIST_CHAR2_K163);
590 ECDSA_GROUP_TEST("NIST Binary-Curve B-163", EC_GROUP_NIST_CHAR2_B163);
591 ECDSA_GROUP_TEST("NIST Binary-Curve K-233", EC_GROUP_NIST_CHAR2_K233);
592 ECDSA_GROUP_TEST("NIST Binary-Curve B-233", EC_GROUP_NIST_CHAR2_B233);
593 ECDSA_GROUP_TEST("NIST Binary-Curve K-283", EC_GROUP_NIST_CHAR2_K283);
594 ECDSA_GROUP_TEST("NIST Binary-Curve B-283", EC_GROUP_NIST_CHAR2_B283);
595 ECDSA_GROUP_TEST("NIST Binary-Curve K-409", EC_GROUP_NIST_CHAR2_K409);
596 ECDSA_GROUP_TEST("NIST Binary-Curve B-409", EC_GROUP_NIST_CHAR2_B409);
597 ECDSA_GROUP_TEST("NIST Binary-Curve K-571", EC_GROUP_NIST_CHAR2_K571);
598 ECDSA_GROUP_TEST("NIST Binary-Curve B-571", EC_GROUP_NIST_CHAR2_B571);
599 #undef ECDSA_GROUP_TEST
603 OPENSSL_free(buffer);
610 BIO_printf(bio_err, "TEST FAILED \n");
612 BIO_printf(bio_err, "TEST PASSED \n");
614 ERR_print_errors(bio_err);
615 if (ecdsa) EC_KEY_free(ecdsa);
617 if (dgst) OPENSSL_free(dgst);
618 if (md_ctx) EVP_MD_CTX_destroy(md_ctx);
619 if (pkey) EVP_PKEY_free(pkey);
620 CRYPTO_cleanup_all_ex_data();
623 CRYPTO_mem_leaks(bio_err);