OLD | NEW |
1 /* crypto/ec/ectest.c */ | 1 /* crypto/ec/ectest.c */ |
2 /* | 2 /* |
3 * Originally written by Bodo Moeller for the OpenSSL project. | 3 * Originally written by Bodo Moeller for the OpenSSL project. |
4 */ | 4 */ |
5 /* ==================================================================== | 5 /* ==================================================================== |
6 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. | 6 * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved. |
7 * | 7 * |
8 * Redistribution and use in source and binary forms, with or without | 8 * Redistribution and use in source and binary forms, with or without |
9 * modification, are permitted provided that the following conditions | 9 * modification, are permitted provided that the following conditions |
10 * are met: | 10 * are met: |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 if (EC_GROUP_get_degree(group) != 192) ABORT; | 425 if (EC_GROUP_get_degree(group) != 192) ABORT; |
426 fprintf(stdout, " ok\n"); | 426 fprintf(stdout, " ok\n"); |
427 | 427 |
428 fprintf(stdout, "verify group order ..."); | 428 fprintf(stdout, "verify group order ..."); |
429 fflush(stdout); | 429 fflush(stdout); |
430 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; | 430 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; |
431 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 431 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
432 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 432 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
433 fprintf(stdout, "."); | 433 fprintf(stdout, "."); |
434 fflush(stdout); | 434 fflush(stdout); |
435 #if 0 | |
436 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; | 435 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; |
437 #endif | |
438 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 436 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
439 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 437 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
440 fprintf(stdout, " ok\n"); | 438 fprintf(stdout, " ok\n"); |
441 | 439 |
442 if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; | 440 if (!(P_192 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; |
443 if (!EC_GROUP_copy(P_192, group)) ABORT; | 441 if (!EC_GROUP_copy(P_192, group)) ABORT; |
444 | 442 |
445 | 443 |
446 /* Curve P-224 (FIPS PUB 186-2, App. 6) */ | 444 /* Curve P-224 (FIPS PUB 186-2, App. 6) */ |
447 | 445 |
(...skipping 23 matching lines...) Expand all Loading... |
471 if (EC_GROUP_get_degree(group) != 224) ABORT; | 469 if (EC_GROUP_get_degree(group) != 224) ABORT; |
472 fprintf(stdout, " ok\n"); | 470 fprintf(stdout, " ok\n"); |
473 | 471 |
474 fprintf(stdout, "verify group order ..."); | 472 fprintf(stdout, "verify group order ..."); |
475 fflush(stdout); | 473 fflush(stdout); |
476 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; | 474 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; |
477 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 475 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
478 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 476 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
479 fprintf(stdout, "."); | 477 fprintf(stdout, "."); |
480 fflush(stdout); | 478 fflush(stdout); |
481 #if 0 | |
482 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; | 479 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; |
483 #endif | |
484 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 480 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
485 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 481 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
486 fprintf(stdout, " ok\n"); | 482 fprintf(stdout, " ok\n"); |
487 | 483 |
488 if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; | 484 if (!(P_224 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; |
489 if (!EC_GROUP_copy(P_224, group)) ABORT; | 485 if (!EC_GROUP_copy(P_224, group)) ABORT; |
490 | 486 |
491 | 487 |
492 /* Curve P-256 (FIPS PUB 186-2, App. 6) */ | 488 /* Curve P-256 (FIPS PUB 186-2, App. 6) */ |
493 | 489 |
(...skipping 24 matching lines...) Expand all Loading... |
518 if (EC_GROUP_get_degree(group) != 256) ABORT; | 514 if (EC_GROUP_get_degree(group) != 256) ABORT; |
519 fprintf(stdout, " ok\n"); | 515 fprintf(stdout, " ok\n"); |
520 | 516 |
521 fprintf(stdout, "verify group order ..."); | 517 fprintf(stdout, "verify group order ..."); |
522 fflush(stdout); | 518 fflush(stdout); |
523 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; | 519 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; |
524 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 520 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
525 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 521 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
526 fprintf(stdout, "."); | 522 fprintf(stdout, "."); |
527 fflush(stdout); | 523 fflush(stdout); |
528 #if 0 | |
529 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; | 524 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; |
530 #endif | |
531 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 525 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
532 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 526 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
533 fprintf(stdout, " ok\n"); | 527 fprintf(stdout, " ok\n"); |
534 | 528 |
535 if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; | 529 if (!(P_256 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; |
536 if (!EC_GROUP_copy(P_256, group)) ABORT; | 530 if (!EC_GROUP_copy(P_256, group)) ABORT; |
537 | 531 |
538 | 532 |
539 /* Curve P-384 (FIPS PUB 186-2, App. 6) */ | 533 /* Curve P-384 (FIPS PUB 186-2, App. 6) */ |
540 | 534 |
(...skipping 29 matching lines...) Expand all Loading... |
570 if (EC_GROUP_get_degree(group) != 384) ABORT; | 564 if (EC_GROUP_get_degree(group) != 384) ABORT; |
571 fprintf(stdout, " ok\n"); | 565 fprintf(stdout, " ok\n"); |
572 | 566 |
573 fprintf(stdout, "verify group order ..."); | 567 fprintf(stdout, "verify group order ..."); |
574 fflush(stdout); | 568 fflush(stdout); |
575 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; | 569 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; |
576 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 570 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
577 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 571 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
578 fprintf(stdout, "."); | 572 fprintf(stdout, "."); |
579 fflush(stdout); | 573 fflush(stdout); |
580 #if 0 | |
581 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; | 574 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; |
582 #endif | |
583 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 575 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
584 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 576 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
585 fprintf(stdout, " ok\n"); | 577 fprintf(stdout, " ok\n"); |
586 | 578 |
587 if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; | 579 if (!(P_384 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; |
588 if (!EC_GROUP_copy(P_384, group)) ABORT; | 580 if (!EC_GROUP_copy(P_384, group)) ABORT; |
589 | 581 |
590 | 582 |
591 /* Curve P-521 (FIPS PUB 186-2, App. 6) */ | 583 /* Curve P-521 (FIPS PUB 186-2, App. 6) */ |
592 | 584 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 if (EC_GROUP_get_degree(group) != 521) ABORT; | 620 if (EC_GROUP_get_degree(group) != 521) ABORT; |
629 fprintf(stdout, " ok\n"); | 621 fprintf(stdout, " ok\n"); |
630 | 622 |
631 fprintf(stdout, "verify group order ..."); | 623 fprintf(stdout, "verify group order ..."); |
632 fflush(stdout); | 624 fflush(stdout); |
633 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; | 625 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; |
634 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 626 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
635 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 627 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
636 fprintf(stdout, "."); | 628 fprintf(stdout, "."); |
637 fflush(stdout); | 629 fflush(stdout); |
638 #if 0 | |
639 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; | 630 if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; |
640 #endif | |
641 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; | 631 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; |
642 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; | 632 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; |
643 fprintf(stdout, " ok\n"); | 633 fprintf(stdout, " ok\n"); |
644 | 634 |
645 if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; | 635 if (!(P_521 = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; |
646 if (!EC_GROUP_copy(P_521, group)) ABORT; | 636 if (!EC_GROUP_copy(P_521, group)) ABORT; |
647 | 637 |
648 | 638 |
649 /* more tests using the last curve */ | 639 /* more tests using the last curve */ |
650 | 640 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 fprintf(stdout, "verify degree ..."); \ | 792 fprintf(stdout, "verify degree ..."); \ |
803 if (EC_GROUP_get_degree(group) != _degree) ABORT; \ | 793 if (EC_GROUP_get_degree(group) != _degree) ABORT; \ |
804 fprintf(stdout, " ok\n"); \ | 794 fprintf(stdout, " ok\n"); \ |
805 fprintf(stdout, "verify group order ..."); \ | 795 fprintf(stdout, "verify group order ..."); \ |
806 fflush(stdout); \ | 796 fflush(stdout); \ |
807 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; \ | 797 if (!EC_GROUP_get_order(group, z, ctx)) ABORT; \ |
808 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ | 798 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ |
809 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ | 799 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ |
810 fprintf(stdout, "."); \ | 800 fprintf(stdout, "."); \ |
811 fflush(stdout); \ | 801 fflush(stdout); \ |
812 » /* if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; */ \ | 802 » if (!EC_GROUP_precompute_mult(group, ctx)) ABORT; \ |
813 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ | 803 if (!EC_POINT_mul(group, Q, z, NULL, NULL, ctx)) ABORT; \ |
814 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ | 804 if (!EC_POINT_is_at_infinity(group, Q)) ABORT; \ |
815 fprintf(stdout, " ok\n"); \ | 805 fprintf(stdout, " ok\n"); \ |
816 if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \ | 806 if (!(_variable = EC_GROUP_new(EC_GROUP_method_of(group)))) ABORT; \ |
817 if (!EC_GROUP_copy(_variable, group)) ABORT; | 807 if (!EC_GROUP_copy(_variable, group)) ABORT; |
818 | 808 |
819 void char2_field_tests() | 809 void char2_field_tests() |
820 { | 810 { |
821 BN_CTX *ctx = NULL; | 811 BN_CTX *ctx = NULL; |
822 BIGNUM *p, *a, *b; | 812 BIGNUM *p, *a, *b; |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 puts(""); | 1319 puts(""); |
1330 char2_field_tests(); | 1320 char2_field_tests(); |
1331 /* test the internal curves */ | 1321 /* test the internal curves */ |
1332 internal_curve_test(); | 1322 internal_curve_test(); |
1333 | 1323 |
1334 #ifndef OPENSSL_NO_ENGINE | 1324 #ifndef OPENSSL_NO_ENGINE |
1335 ENGINE_cleanup(); | 1325 ENGINE_cleanup(); |
1336 #endif | 1326 #endif |
1337 CRYPTO_cleanup_all_ex_data(); | 1327 CRYPTO_cleanup_all_ex_data(); |
1338 ERR_free_strings(); | 1328 ERR_free_strings(); |
1339 » ERR_remove_state(0); | 1329 » ERR_remove_thread_state(NULL); |
1340 CRYPTO_mem_leaks_fp(stderr); | 1330 CRYPTO_mem_leaks_fp(stderr); |
1341 | 1331 |
1342 return 0; | 1332 return 0; |
1343 } | 1333 } |
1344 #endif | 1334 #endif |
OLD | NEW |