summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/bn/bn_test.c245
1 files changed, 134 insertions, 111 deletions
diff --git a/src/regress/lib/libcrypto/bn/bn_test.c b/src/regress/lib/libcrypto/bn/bn_test.c
index d95d826535..068d93fafe 100644
--- a/src/regress/lib/libcrypto/bn/bn_test.c
+++ b/src/regress/lib/libcrypto/bn/bn_test.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_test.c,v 1.4 2023/04/07 22:14:20 tb Exp $ */ 1/* $OpenBSD: bn_test.c,v 1.5 2023/04/07 22:18:42 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -128,7 +128,6 @@ static int results = 0;
128#define CHECK_GOTO(a) do { \ 128#define CHECK_GOTO(a) do { \
129 if (!(a)) { \ 129 if (!(a)) { \
130 PRINT_ERROR; \ 130 PRINT_ERROR; \
131 rc = 0; \
132 goto err; \ 131 goto err; \
133 } \ 132 } \
134} while (0) 133} while (0)
@@ -360,7 +359,7 @@ test_add(BIO *bp)
360{ 359{
361 BIGNUM *a = NULL, *b = NULL, *c = NULL; 360 BIGNUM *a = NULL, *b = NULL, *c = NULL;
362 int i; 361 int i;
363 int rc = 1; 362 int rc = 0;
364 363
365 if ((a = BN_new()) == NULL) 364 if ((a = BN_new()) == NULL)
366 goto err; 365 goto err;
@@ -391,11 +390,11 @@ test_add(BIO *bp)
391 CHECK_GOTO(BN_add(c, c, a)); 390 CHECK_GOTO(BN_add(c, c, a));
392 if (!BN_is_zero(c)) { 391 if (!BN_is_zero(c)) {
393 fprintf(stderr, "Add test failed!\n"); 392 fprintf(stderr, "Add test failed!\n");
394 rc = 0; 393 goto err;
395 break;
396 } 394 }
397 } 395 }
398 396
397 rc = 1;
399 err: 398 err:
400 BN_free(a); 399 BN_free(a);
401 BN_free(b); 400 BN_free(b);
@@ -409,7 +408,7 @@ test_sub(BIO *bp)
409{ 408{
410 BIGNUM *a = NULL, *b = NULL, *c = NULL; 409 BIGNUM *a = NULL, *b = NULL, *c = NULL;
411 int i; 410 int i;
412 int rc = 1; 411 int rc = 0;
413 412
414 if ((a = BN_new()) == NULL) 413 if ((a = BN_new()) == NULL)
415 goto err; 414 goto err;
@@ -423,8 +422,7 @@ test_sub(BIO *bp)
423 CHECK_GOTO(BN_bntest_rand(a, 512, 0, 0)); 422 CHECK_GOTO(BN_bntest_rand(a, 512, 0, 0));
424 CHECK_GOTO(bn_copy(b, a)); 423 CHECK_GOTO(bn_copy(b, a));
425 if (BN_set_bit(a, i) == 0) { 424 if (BN_set_bit(a, i) == 0) {
426 rc = 0; 425 goto err;
427 break;
428 } 426 }
429 CHECK_GOTO(BN_add_word(b, i)); 427 CHECK_GOTO(BN_add_word(b, i));
430 } else { 428 } else {
@@ -447,15 +445,17 @@ test_sub(BIO *bp)
447 CHECK_GOTO(BN_sub(c, c, a)); 445 CHECK_GOTO(BN_sub(c, c, a));
448 if (!BN_is_zero(c)) { 446 if (!BN_is_zero(c)) {
449 fprintf(stderr, "Subtract test failed!\n"); 447 fprintf(stderr, "Subtract test failed!\n");
450 rc = 0; 448 goto err;
451 break;
452 } 449 }
453 } 450 }
451
452 rc = 1;
454 err: 453 err:
455 BN_free(a); 454 BN_free(a);
456 BN_free(b); 455 BN_free(b);
457 BN_free(c); 456 BN_free(c);
458 return (rc); 457
458 return rc;
459} 459}
460 460
461int 461int
@@ -463,7 +463,7 @@ test_div(BIO *bp, BN_CTX *ctx)
463{ 463{
464 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 464 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
465 int i; 465 int i;
466 int rc = 1; 466 int rc = 0;
467 467
468 if ((a = BN_new()) == NULL) 468 if ((a = BN_new()) == NULL)
469 goto err; 469 goto err;
@@ -519,17 +519,19 @@ test_div(BIO *bp, BN_CTX *ctx)
519 CHECK_GOTO(BN_sub(d, d, a)); 519 CHECK_GOTO(BN_sub(d, d, a));
520 if (!BN_is_zero(d)) { 520 if (!BN_is_zero(d)) {
521 fprintf(stderr, "Division test failed!\n"); 521 fprintf(stderr, "Division test failed!\n");
522 rc = 0; 522 goto err;
523 break;
524 } 523 }
525 } 524 }
525
526 rc = 1;
526 err: 527 err:
527 BN_free(a); 528 BN_free(a);
528 BN_free(b); 529 BN_free(b);
529 BN_free(c); 530 BN_free(c);
530 BN_free(d); 531 BN_free(d);
531 BN_free(e); 532 BN_free(e);
532 return (rc); 533
534 return rc;
533} 535}
534 536
535static void 537static void
@@ -555,7 +557,7 @@ test_div_word(BIO *bp)
555 BIGNUM *a = NULL, *b = NULL; 557 BIGNUM *a = NULL, *b = NULL;
556 BN_ULONG r, rmod, s = 0; 558 BN_ULONG r, rmod, s = 0;
557 int i; 559 int i;
558 int rc = 1; 560 int rc = 0;
559 561
560 if ((a = BN_new()) == NULL) 562 if ((a = BN_new()) == NULL)
561 goto err; 563 goto err;
@@ -566,29 +568,25 @@ test_div_word(BIO *bp)
566 do { 568 do {
567 if (!BN_bntest_rand(a, 512, -1, 0) || 569 if (!BN_bntest_rand(a, 512, -1, 0) ||
568 !BN_bntest_rand(b, BN_BITS2, -1, 0)) { 570 !BN_bntest_rand(b, BN_BITS2, -1, 0)) {
569 rc = 0; 571 goto err;
570 break;
571 } 572 }
572 s = BN_get_word(b); 573 s = BN_get_word(b);
573 } while (!s); 574 } while (!s);
574 575
575 if (!bn_copy(b, a)) { 576 if (!bn_copy(b, a)) {
576 rc = 0; 577 goto err;
577 break;
578 } 578 }
579 579
580 rmod = BN_mod_word(b, s); 580 rmod = BN_mod_word(b, s);
581 r = BN_div_word(b, s); 581 r = BN_div_word(b, s);
582 582
583 if (r == (BN_ULONG)-1 || rmod == (BN_ULONG)-1) { 583 if (r == (BN_ULONG)-1 || rmod == (BN_ULONG)-1) {
584 rc = 0; 584 goto err;
585 break;
586 } 585 }
587 586
588 if (rmod != r) { 587 if (rmod != r) {
589 fprintf(stderr, "Mod (word) test failed!\n"); 588 fprintf(stderr, "Mod (word) test failed!\n");
590 rc = 0; 589 goto err;
591 break;
592 } 590 }
593 591
594 if (bp != NULL) { 592 if (bp != NULL) {
@@ -615,10 +613,11 @@ test_div_word(BIO *bp)
615 CHECK_GOTO(BN_sub(b, a, b)); 613 CHECK_GOTO(BN_sub(b, a, b));
616 if (!BN_is_zero(b)) { 614 if (!BN_is_zero(b)) {
617 fprintf(stderr, "Division (word) test failed!\n"); 615 fprintf(stderr, "Division (word) test failed!\n");
618 rc = 0; 616 goto err;
619 break;
620 } 617 }
621 } 618 }
619
620 rc = 1;
622 err: 621 err:
623 BN_free(a); 622 BN_free(a);
624 BN_free(b); 623 BN_free(b);
@@ -632,7 +631,7 @@ test_div_recp(BIO *bp, BN_CTX *ctx)
632 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 631 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
633 BN_RECP_CTX *recp = NULL; 632 BN_RECP_CTX *recp = NULL;
634 int i; 633 int i;
635 int rc = 1; 634 int rc = 0;
636 635
637 if ((a = BN_new()) == NULL) 636 if ((a = BN_new()) == NULL)
638 goto err; 637 goto err;
@@ -689,10 +688,11 @@ test_div_recp(BIO *bp, BN_CTX *ctx)
689 fprintf(stderr, "\nb="); 688 fprintf(stderr, "\nb=");
690 CHECK_GOTO(BN_print_fp(stderr, b)); 689 CHECK_GOTO(BN_print_fp(stderr, b));
691 fprintf(stderr, "\n"); 690 fprintf(stderr, "\n");
692 rc = 0; 691 goto err;
693 break;
694 } 692 }
695 } 693 }
694
695 rc = 1;
696 err: 696 err:
697 BN_free(a); 697 BN_free(a);
698 BN_free(b); 698 BN_free(b);
@@ -700,7 +700,8 @@ test_div_recp(BIO *bp, BN_CTX *ctx)
700 BN_free(d); 700 BN_free(d);
701 BN_free(e); 701 BN_free(e);
702 BN_RECP_CTX_free(recp); 702 BN_RECP_CTX_free(recp);
703 return (rc); 703
704 return rc;
704} 705}
705 706
706int 707int
@@ -708,7 +709,7 @@ test_mul(BIO *bp)
708{ 709{
709 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 710 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
710 int i; 711 int i;
711 int rc = 1; 712 int rc = 0;
712 BN_CTX *ctx; 713 BN_CTX *ctx;
713 714
714 ctx = BN_CTX_new(); 715 ctx = BN_CTX_new();
@@ -749,10 +750,11 @@ test_mul(BIO *bp)
749 CHECK_GOTO(BN_sub(d, d, b)); 750 CHECK_GOTO(BN_sub(d, d, b));
750 if (!BN_is_zero(d) || !BN_is_zero(e)) { 751 if (!BN_is_zero(d) || !BN_is_zero(e)) {
751 fprintf(stderr, "Multiplication test failed!\n"); 752 fprintf(stderr, "Multiplication test failed!\n");
752 rc = 0; 753 goto err;
753 break;
754 } 754 }
755 } 755 }
756
757 rc = 1;
756 err: 758 err:
757 BN_free(a); 759 BN_free(a);
758 BN_free(b); 760 BN_free(b);
@@ -760,7 +762,8 @@ test_mul(BIO *bp)
760 BN_free(d); 762 BN_free(d);
761 BN_free(e); 763 BN_free(e);
762 BN_CTX_free(ctx); 764 BN_CTX_free(ctx);
763 return (rc); 765
766 return rc;
764} 767}
765 768
766int 769int
@@ -848,12 +851,14 @@ test_sqr(BIO *bp, BN_CTX *ctx)
848 "different results!\n"); 851 "different results!\n");
849 goto err; 852 goto err;
850 } 853 }
854
851 rc = 1; 855 rc = 1;
852 err: 856 err:
853 BN_free(a); 857 BN_free(a);
854 BN_free(c); 858 BN_free(c);
855 BN_free(d); 859 BN_free(d);
856 BN_free(e); 860 BN_free(e);
861
857 return rc; 862 return rc;
858} 863}
859 864
@@ -863,7 +868,7 @@ test_mont(BIO *bp, BN_CTX *ctx)
863 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *A = NULL, *B = NULL; 868 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *A = NULL, *B = NULL;
864 BIGNUM *n = NULL; 869 BIGNUM *n = NULL;
865 int i; 870 int i;
866 int rc = 1; 871 int rc = 0;
867 BN_MONT_CTX *mont; 872 BN_MONT_CTX *mont;
868 873
869 mont = BN_MONT_CTX_new(); 874 mont = BN_MONT_CTX_new();
@@ -932,10 +937,11 @@ test_mont(BIO *bp, BN_CTX *ctx)
932 CHECK_GOTO(BN_sub(d, d, A)); 937 CHECK_GOTO(BN_sub(d, d, A));
933 if (!BN_is_zero(d)) { 938 if (!BN_is_zero(d)) {
934 fprintf(stderr, "Montgomery multiplication test failed!\n"); 939 fprintf(stderr, "Montgomery multiplication test failed!\n");
935 rc = 0; 940 goto err;
936 break;
937 } 941 }
938 } 942 }
943
944 rc = 1;
939 err: 945 err:
940 BN_MONT_CTX_free(mont); 946 BN_MONT_CTX_free(mont);
941 BN_free(a); 947 BN_free(a);
@@ -945,7 +951,8 @@ test_mont(BIO *bp, BN_CTX *ctx)
945 BN_free(A); 951 BN_free(A);
946 BN_free(B); 952 BN_free(B);
947 BN_free(n); 953 BN_free(n);
948 return (rc); 954
955 return rc;
949} 956}
950 957
951int 958int
@@ -953,7 +960,7 @@ test_mod(BIO *bp, BN_CTX *ctx)
953{ 960{
954 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 961 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
955 int i; 962 int i;
956 int rc = 1; 963 int rc = 0;
957 964
958 if ((a = BN_new()) == NULL) 965 if ((a = BN_new()) == NULL)
959 goto err; 966 goto err;
@@ -986,17 +993,19 @@ test_mod(BIO *bp, BN_CTX *ctx)
986 CHECK_GOTO(BN_sub(e, e, c)); 993 CHECK_GOTO(BN_sub(e, e, c));
987 if (!BN_is_zero(e)) { 994 if (!BN_is_zero(e)) {
988 fprintf(stderr, "Modulo test failed!\n"); 995 fprintf(stderr, "Modulo test failed!\n");
989 rc = 0; 996 goto err;
990 break;
991 } 997 }
992 } 998 }
999
1000 rc = 1;
993 err: 1001 err:
994 BN_free(a); 1002 BN_free(a);
995 BN_free(b); 1003 BN_free(b);
996 BN_free(c); 1004 BN_free(c);
997 BN_free(d); 1005 BN_free(d);
998 BN_free(e); 1006 BN_free(e);
999 return (rc); 1007
1008 return rc;
1000} 1009}
1001 1010
1002int 1011int
@@ -1004,7 +1013,7 @@ test_mod_mul(BIO *bp, BN_CTX *ctx)
1004{ 1013{
1005 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 1014 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
1006 int i, j; 1015 int i, j;
1007 int rc = 1; 1016 int rc = 0;
1008 1017
1009 if ((a = BN_new()) == NULL) 1018 if ((a = BN_new()) == NULL)
1010 goto err; 1019 goto err;
@@ -1068,18 +1077,20 @@ test_mod_mul(BIO *bp, BN_CTX *ctx)
1068 if (!BN_is_zero(b)) { 1077 if (!BN_is_zero(b)) {
1069 fprintf(stderr, "Modulo multiply test failed!\n"); 1078 fprintf(stderr, "Modulo multiply test failed!\n");
1070 ERR_print_errors_fp(stderr); 1079 ERR_print_errors_fp(stderr);
1071 rc = 0;
1072 goto err; 1080 goto err;
1073 } 1081 }
1074 } 1082 }
1075 } 1083 }
1084
1085 rc = 1;
1076 err: 1086 err:
1077 BN_free(a); 1087 BN_free(a);
1078 BN_free(b); 1088 BN_free(b);
1079 BN_free(c); 1089 BN_free(c);
1080 BN_free(d); 1090 BN_free(d);
1081 BN_free(e); 1091 BN_free(e);
1082 return (rc); 1092
1093 return rc;
1083} 1094}
1084 1095
1085int 1096int
@@ -1087,7 +1098,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1087{ 1098{
1088 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 1099 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
1089 int i; 1100 int i;
1090 int rc = 1; 1101 int rc = 0;
1091 1102
1092 if ((a = BN_new()) == NULL) 1103 if ((a = BN_new()) == NULL)
1093 goto err; 1104 goto err;
@@ -1105,17 +1116,14 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1105 CHECK_GOTO(BN_zero(c)); 1116 CHECK_GOTO(BN_zero(c));
1106 if (BN_mod_exp(d, a, b, c, ctx)) { 1117 if (BN_mod_exp(d, a, b, c, ctx)) {
1107 fprintf(stderr, "BN_mod_exp with zero modulus succeeded!\n"); 1118 fprintf(stderr, "BN_mod_exp with zero modulus succeeded!\n");
1108 rc = 0;
1109 goto err; 1119 goto err;
1110 } 1120 }
1111 if (BN_mod_exp_ct(d, a, b, c, ctx)) { 1121 if (BN_mod_exp_ct(d, a, b, c, ctx)) {
1112 fprintf(stderr, "BN_mod_exp_ct with zero modulus succeeded!\n"); 1122 fprintf(stderr, "BN_mod_exp_ct with zero modulus succeeded!\n");
1113 rc = 0;
1114 goto err; 1123 goto err;
1115 } 1124 }
1116 if (BN_mod_exp_nonct(d, a, b, c, ctx)) { 1125 if (BN_mod_exp_nonct(d, a, b, c, ctx)) {
1117 fprintf(stderr, "BN_mod_exp_nonct with zero modulus succeeded!\n"); 1126 fprintf(stderr, "BN_mod_exp_nonct with zero modulus succeeded!\n");
1118 rc = 0;
1119 goto err; 1127 goto err;
1120 } 1128 }
1121 1129
@@ -1125,8 +1133,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1125 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0)); 1133 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0));
1126 1134
1127 if (!BN_mod_exp(d, a, b, c, ctx)) { 1135 if (!BN_mod_exp(d, a, b, c, ctx)) {
1128 rc = 0; 1136 goto err;
1129 break;
1130 } 1137 }
1131 1138
1132 if (bp != NULL) { 1139 if (bp != NULL) {
@@ -1146,8 +1153,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1146 CHECK_GOTO(BN_div(a, b, e, c, ctx)); 1153 CHECK_GOTO(BN_div(a, b, e, c, ctx));
1147 if (!BN_is_zero(b)) { 1154 if (!BN_is_zero(b)) {
1148 fprintf(stderr, "Modulo exponentiation test failed!\n"); 1155 fprintf(stderr, "Modulo exponentiation test failed!\n");
1149 rc = 0; 1156 goto err;
1150 break;
1151 } 1157 }
1152 } 1158 }
1153 1159
@@ -1157,8 +1163,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1157 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0)); 1163 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0));
1158 1164
1159 if (!BN_mod_exp_ct(d, a, b, c, ctx)) { 1165 if (!BN_mod_exp_ct(d, a, b, c, ctx)) {
1160 rc = 0; 1166 goto err;
1161 break;
1162 } 1167 }
1163 1168
1164 if (bp != NULL) { 1169 if (bp != NULL) {
@@ -1178,8 +1183,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1178 CHECK_GOTO(BN_div(a, b, e, c, ctx)); 1183 CHECK_GOTO(BN_div(a, b, e, c, ctx));
1179 if (!BN_is_zero(b)) { 1184 if (!BN_is_zero(b)) {
1180 fprintf(stderr, "Modulo exponentiation test failed!\n"); 1185 fprintf(stderr, "Modulo exponentiation test failed!\n");
1181 rc = 0; 1186 goto err;
1182 break;
1183 } 1187 }
1184 } 1188 }
1185 1189
@@ -1189,8 +1193,7 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1189 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0)); 1193 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0));
1190 1194
1191 if (!BN_mod_exp_nonct(d, a, b, c, ctx)) { 1195 if (!BN_mod_exp_nonct(d, a, b, c, ctx)) {
1192 rc = 0; 1196 goto err;
1193 break;
1194 } 1197 }
1195 1198
1196 if (bp != NULL) { 1199 if (bp != NULL) {
@@ -1210,17 +1213,19 @@ test_mod_exp(BIO *bp, BN_CTX *ctx)
1210 CHECK_GOTO(BN_div(a, b, e, c, ctx)); 1213 CHECK_GOTO(BN_div(a, b, e, c, ctx));
1211 if (!BN_is_zero(b)) { 1214 if (!BN_is_zero(b)) {
1212 fprintf(stderr, "Modulo exponentiation test failed!\n"); 1215 fprintf(stderr, "Modulo exponentiation test failed!\n");
1213 rc = 0; 1216 goto err;
1214 break;
1215 } 1217 }
1216 } 1218 }
1219
1220 rc = 1;
1217 err: 1221 err:
1218 BN_free(a); 1222 BN_free(a);
1219 BN_free(b); 1223 BN_free(b);
1220 BN_free(c); 1224 BN_free(c);
1221 BN_free(d); 1225 BN_free(d);
1222 BN_free(e); 1226 BN_free(e);
1223 return (rc); 1227
1228 return rc;
1224} 1229}
1225 1230
1226int 1231int
@@ -1228,7 +1233,7 @@ test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
1228{ 1233{
1229 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 1234 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
1230 int i; 1235 int i;
1231 int rc = 1; 1236 int rc = 0;
1232 1237
1233 if ((a = BN_new()) == NULL) 1238 if ((a = BN_new()) == NULL)
1234 goto err; 1239 goto err;
@@ -1247,7 +1252,6 @@ test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
1247 if (BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) { 1252 if (BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) {
1248 fprintf(stderr, "BN_mod_exp_mont_consttime with zero modulus " 1253 fprintf(stderr, "BN_mod_exp_mont_consttime with zero modulus "
1249 "succeeded\n"); 1254 "succeeded\n");
1250 rc = 0;
1251 goto err; 1255 goto err;
1252 } 1256 }
1253 1257
@@ -1255,7 +1259,6 @@ test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
1255 if (BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) { 1259 if (BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) {
1256 fprintf(stderr, "BN_mod_exp_mont_consttime with even modulus " 1260 fprintf(stderr, "BN_mod_exp_mont_consttime with even modulus "
1257 "succeeded\n"); 1261 "succeeded\n");
1258 rc = 0;
1259 goto err; 1262 goto err;
1260 } 1263 }
1261 1264
@@ -1265,8 +1268,7 @@ test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
1265 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0)); 1268 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0));
1266 1269
1267 if (!BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) { 1270 if (!BN_mod_exp_mont_consttime(d, a, b, c, ctx, NULL)) {
1268 rc = 0; 1271 goto err;
1269 break;
1270 } 1272 }
1271 1273
1272 if (bp != NULL) { 1274 if (bp != NULL) {
@@ -1286,17 +1288,19 @@ test_mod_exp_mont_consttime(BIO *bp, BN_CTX *ctx)
1286 CHECK_GOTO(BN_div(a, b, e, c, ctx)); 1288 CHECK_GOTO(BN_div(a, b, e, c, ctx));
1287 if (!BN_is_zero(b)) { 1289 if (!BN_is_zero(b)) {
1288 fprintf(stderr, "Modulo exponentiation test failed!\n"); 1290 fprintf(stderr, "Modulo exponentiation test failed!\n");
1289 rc = 0; 1291 goto err;
1290 break;
1291 } 1292 }
1292 } 1293 }
1294
1295 rc = 1;
1293 err: 1296 err:
1294 BN_free(a); 1297 BN_free(a);
1295 BN_free(b); 1298 BN_free(b);
1296 BN_free(c); 1299 BN_free(c);
1297 BN_free(d); 1300 BN_free(d);
1298 BN_free(e); 1301 BN_free(e);
1299 return (rc); 1302
1303 return rc;
1300} 1304}
1301 1305
1302/* 1306/*
@@ -1310,7 +1314,7 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1310 BIGNUM *b = NULL, *n = NULL, *c = NULL; 1314 BIGNUM *b = NULL, *n = NULL, *c = NULL;
1311 BN_MONT_CTX *mont = NULL; 1315 BN_MONT_CTX *mont = NULL;
1312 int len; 1316 int len;
1313 int rc = 1; 1317 int rc = 0;
1314 1318
1315 if ((a = BN_new()) == NULL) 1319 if ((a = BN_new()) == NULL)
1316 goto err; 1320 goto err;
@@ -1336,12 +1340,10 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1336 CHECK_GOTO(BN_bntest_rand(a, 1024, 0, 0)); 1340 CHECK_GOTO(BN_bntest_rand(a, 1024, 0, 0));
1337 CHECK_GOTO(BN_zero(p)); 1341 CHECK_GOTO(BN_zero(p));
1338 if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)) { 1342 if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)) {
1339 rc = 0;
1340 goto err; 1343 goto err;
1341 } 1344 }
1342 if (!BN_is_one(d)) { 1345 if (!BN_is_one(d)) {
1343 fprintf(stderr, "Modular exponentiation test failed!\n"); 1346 fprintf(stderr, "Modular exponentiation test failed!\n");
1344 rc = 0;
1345 goto err; 1347 goto err;
1346 } 1348 }
1347 /* Regression test for carry bug in mulx4x_mont */ 1349 /* Regression test for carry bug in mulx4x_mont */
@@ -1369,7 +1371,6 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1369 if (BN_cmp(c, d)) { 1371 if (BN_cmp(c, d)) {
1370 fprintf(stderr, "Montgomery multiplication test failed:" 1372 fprintf(stderr, "Montgomery multiplication test failed:"
1371 " a*b != b*a.\n"); 1373 " a*b != b*a.\n");
1372 rc = 0;
1373 goto err; 1374 goto err;
1374 } 1375 }
1375 /* Regression test for carry bug in sqr[x]8x_mont */ 1376 /* Regression test for carry bug in sqr[x]8x_mont */
@@ -1417,19 +1418,16 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1417 if (BN_cmp(c, d)) { 1418 if (BN_cmp(c, d)) {
1418 fprintf(stderr, "Montgomery multiplication test failed:" 1419 fprintf(stderr, "Montgomery multiplication test failed:"
1419 " a**2 != a*a.\n"); 1420 " a**2 != a*a.\n");
1420 rc = 0;
1421 goto err; 1421 goto err;
1422 } 1422 }
1423 /* Zero input */ 1423 /* Zero input */
1424 CHECK_GOTO(BN_bntest_rand(p, 1024, 0, 0)); 1424 CHECK_GOTO(BN_bntest_rand(p, 1024, 0, 0));
1425 CHECK_GOTO(BN_zero(a)); 1425 CHECK_GOTO(BN_zero(a));
1426 if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)) { 1426 if (!BN_mod_exp_mont_consttime(d, a, p, m, ctx, NULL)) {
1427 rc = 0;
1428 goto err; 1427 goto err;
1429 } 1428 }
1430 if (!BN_is_zero(d)) { 1429 if (!BN_is_zero(d)) {
1431 fprintf(stderr, "Modular exponentiation test failed!\n"); 1430 fprintf(stderr, "Modular exponentiation test failed!\n");
1432 rc = 0;
1433 goto err; 1431 goto err;
1434 } 1432 }
1435 /* 1433 /*
@@ -1440,37 +1438,32 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1440 CHECK_GOTO(BN_one(a)); 1438 CHECK_GOTO(BN_one(a));
1441 CHECK_GOTO(BN_MONT_CTX_set(mont, m, ctx)); 1439 CHECK_GOTO(BN_MONT_CTX_set(mont, m, ctx));
1442 if (!BN_from_montgomery(e, a, mont, ctx)) { 1440 if (!BN_from_montgomery(e, a, mont, ctx)) {
1443 rc = 0;
1444 goto err; 1441 goto err;
1445 } 1442 }
1446 if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL)) { 1443 if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL)) {
1447 rc = 0;
1448 goto err; 1444 goto err;
1449 } 1445 }
1450 if (!BN_mod_exp_simple(a, e, p, m, ctx)) { 1446 if (!BN_mod_exp_simple(a, e, p, m, ctx)) {
1451 rc = 0;
1452 goto err; 1447 goto err;
1453 } 1448 }
1454 if (BN_cmp(a, d) != 0) { 1449 if (BN_cmp(a, d) != 0) {
1455 fprintf(stderr, "Modular exponentiation test failed!\n"); 1450 fprintf(stderr, "Modular exponentiation test failed!\n");
1456 rc = 0;
1457 goto err; 1451 goto err;
1458 } 1452 }
1459 /* Finally, some regular test vectors. */ 1453 /* Finally, some regular test vectors. */
1460 CHECK_GOTO(BN_bntest_rand(e, 1024, 0, 0)); 1454 CHECK_GOTO(BN_bntest_rand(e, 1024, 0, 0));
1461 if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL)) { 1455 if (!BN_mod_exp_mont_consttime(d, e, p, m, ctx, NULL)) {
1462 rc = 0;
1463 goto err; 1456 goto err;
1464 } 1457 }
1465 if (!BN_mod_exp_simple(a, e, p, m, ctx)) { 1458 if (!BN_mod_exp_simple(a, e, p, m, ctx)) {
1466 rc = 0;
1467 goto err; 1459 goto err;
1468 } 1460 }
1469 if (BN_cmp(a, d) != 0) { 1461 if (BN_cmp(a, d) != 0) {
1470 fprintf(stderr, "Modular exponentiation test failed!\n"); 1462 fprintf(stderr, "Modular exponentiation test failed!\n");
1471 rc = 0;
1472 goto err; 1463 goto err;
1473 } 1464 }
1465
1466 rc = 1;
1474 err: 1467 err:
1475 BN_free(a); 1468 BN_free(a);
1476 BN_free(p); 1469 BN_free(p);
@@ -1481,7 +1474,8 @@ test_mod_exp_mont5(BIO *bp, BN_CTX *ctx)
1481 BN_free(n); 1474 BN_free(n);
1482 BN_free(c); 1475 BN_free(c);
1483 BN_MONT_CTX_free(mont); 1476 BN_MONT_CTX_free(mont);
1484 return (rc); 1477
1478 return rc;
1485} 1479}
1486 1480
1487int 1481int
@@ -1489,7 +1483,7 @@ test_exp(BIO *bp, BN_CTX *ctx)
1489{ 1483{
1490 BIGNUM *a = NULL, *b = NULL, *d = NULL, *e = NULL, *one = NULL; 1484 BIGNUM *a = NULL, *b = NULL, *d = NULL, *e = NULL, *one = NULL;
1491 int i; 1485 int i;
1492 int rc = 1; 1486 int rc = 0;
1493 1487
1494 if ((a = BN_new()) == NULL) 1488 if ((a = BN_new()) == NULL)
1495 goto err; 1489 goto err;
@@ -1508,8 +1502,7 @@ test_exp(BIO *bp, BN_CTX *ctx)
1508 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0)); 1502 CHECK_GOTO(BN_bntest_rand(b, 2 + i, 0, 0));
1509 1503
1510 if (BN_exp(d, a, b, ctx) <= 0) { 1504 if (BN_exp(d, a, b, ctx) <= 0) {
1511 rc = 0; 1505 goto err;
1512 break;
1513 } 1506 }
1514 1507
1515 if (bp != NULL) { 1508 if (bp != NULL) {
@@ -1528,17 +1521,19 @@ test_exp(BIO *bp, BN_CTX *ctx)
1528 CHECK_GOTO(BN_sub(e, e, d)); 1521 CHECK_GOTO(BN_sub(e, e, d));
1529 if (!BN_is_zero(e)) { 1522 if (!BN_is_zero(e)) {
1530 fprintf(stderr, "Exponentiation test failed!\n"); 1523 fprintf(stderr, "Exponentiation test failed!\n");
1531 rc = 0; 1524 goto err;
1532 break;
1533 } 1525 }
1534 } 1526 }
1527
1528 rc = 1;
1535 err: 1529 err:
1536 BN_free(a); 1530 BN_free(a);
1537 BN_free(b); 1531 BN_free(b);
1538 BN_free(d); 1532 BN_free(d);
1539 BN_free(e); 1533 BN_free(e);
1540 BN_free(one); 1534 BN_free(one);
1541 return (rc); 1535
1536 return rc;
1542} 1537}
1543 1538
1544#ifndef OPENSSL_NO_EC2M 1539#ifndef OPENSSL_NO_EC2M
@@ -1586,11 +1581,13 @@ test_gf2m_add(BIO *bp)
1586 goto err; 1581 goto err;
1587 } 1582 }
1588 } 1583 }
1584
1589 rc = 1; 1585 rc = 1;
1590 err: 1586 err:
1591 BN_free(a); 1587 BN_free(a);
1592 BN_free(b); 1588 BN_free(b);
1593 BN_free(c); 1589 BN_free(c);
1590
1594 return rc; 1591 return rc;
1595} 1592}
1596 1593
@@ -1644,6 +1641,7 @@ test_gf2m_mod(BIO *bp)
1644 } 1641 }
1645 } 1642 }
1646 } 1643 }
1644
1647 rc = 1; 1645 rc = 1;
1648 err: 1646 err:
1649 BN_free(a); 1647 BN_free(a);
@@ -1652,6 +1650,7 @@ test_gf2m_mod(BIO *bp)
1652 BN_free(c); 1650 BN_free(c);
1653 BN_free(d); 1651 BN_free(d);
1654 BN_free(e); 1652 BN_free(e);
1653
1655 return rc; 1654 return rc;
1656} 1655}
1657 1656
@@ -1719,6 +1718,7 @@ test_gf2m_mod_mul(BIO *bp, BN_CTX *ctx)
1719 } 1718 }
1720 } 1719 }
1721 } 1720 }
1721
1722 rc = 1; 1722 rc = 1;
1723 err: 1723 err:
1724 BN_free(a); 1724 BN_free(a);
@@ -1730,6 +1730,7 @@ test_gf2m_mod_mul(BIO *bp, BN_CTX *ctx)
1730 BN_free(f); 1730 BN_free(f);
1731 BN_free(g); 1731 BN_free(g);
1732 BN_free(h); 1732 BN_free(h);
1733
1733 return rc; 1734 return rc;
1734} 1735}
1735 1736
@@ -1783,6 +1784,7 @@ test_gf2m_mod_sqr(BIO *bp, BN_CTX *ctx)
1783 } 1784 }
1784 } 1785 }
1785 } 1786 }
1787
1786 rc = 1; 1788 rc = 1;
1787 err: 1789 err:
1788 BN_free(a); 1790 BN_free(a);
@@ -1790,6 +1792,7 @@ test_gf2m_mod_sqr(BIO *bp, BN_CTX *ctx)
1790 BN_free(b[1]); 1792 BN_free(b[1]);
1791 BN_free(c); 1793 BN_free(c);
1792 BN_free(d); 1794 BN_free(d);
1795
1793 return rc; 1796 return rc;
1794} 1797}
1795 1798
@@ -1839,6 +1842,7 @@ test_gf2m_mod_inv(BIO *bp, BN_CTX *ctx)
1839 } 1842 }
1840 } 1843 }
1841 } 1844 }
1845
1842 rc = 1; 1846 rc = 1;
1843 err: 1847 err:
1844 BN_free(a); 1848 BN_free(a);
@@ -1846,6 +1850,7 @@ test_gf2m_mod_inv(BIO *bp, BN_CTX *ctx)
1846 BN_free(b[1]); 1850 BN_free(b[1]);
1847 BN_free(c); 1851 BN_free(c);
1848 BN_free(d); 1852 BN_free(d);
1853
1849 return rc; 1854 return rc;
1850} 1855}
1851 1856
@@ -1903,6 +1908,7 @@ test_gf2m_mod_div(BIO *bp, BN_CTX *ctx)
1903 } 1908 }
1904 } 1909 }
1905 } 1910 }
1911
1906 rc = 1; 1912 rc = 1;
1907 err: 1913 err:
1908 BN_free(a); 1914 BN_free(a);
@@ -1912,6 +1918,7 @@ test_gf2m_mod_div(BIO *bp, BN_CTX *ctx)
1912 BN_free(d); 1918 BN_free(d);
1913 BN_free(e); 1919 BN_free(e);
1914 BN_free(f); 1920 BN_free(f);
1921
1915 return rc; 1922 return rc;
1916} 1923}
1917 1924
@@ -1977,6 +1984,7 @@ test_gf2m_mod_exp(BIO *bp, BN_CTX *ctx)
1977 } 1984 }
1978 } 1985 }
1979 } 1986 }
1987
1980 rc = 1; 1988 rc = 1;
1981 err: 1989 err:
1982 BN_free(a); 1990 BN_free(a);
@@ -1986,6 +1994,7 @@ test_gf2m_mod_exp(BIO *bp, BN_CTX *ctx)
1986 BN_free(d); 1994 BN_free(d);
1987 BN_free(e); 1995 BN_free(e);
1988 BN_free(f); 1996 BN_free(f);
1997
1989 return rc; 1998 return rc;
1990} 1999}
1991 2000
@@ -2039,6 +2048,7 @@ test_gf2m_mod_sqrt(BIO *bp, BN_CTX *ctx)
2039 } 2048 }
2040 } 2049 }
2041 } 2050 }
2051
2042 rc = 1; 2052 rc = 1;
2043 err: 2053 err:
2044 BN_free(a); 2054 BN_free(a);
@@ -2048,6 +2058,7 @@ test_gf2m_mod_sqrt(BIO *bp, BN_CTX *ctx)
2048 BN_free(d); 2058 BN_free(d);
2049 BN_free(e); 2059 BN_free(e);
2050 BN_free(f); 2060 BN_free(f);
2061
2051 return rc; 2062 return rc;
2052} 2063}
2053 2064
@@ -2123,6 +2134,7 @@ test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx)
2123 fprintf(stderr, "this is very unlikely and probably indicates an error.\n"); 2134 fprintf(stderr, "this is very unlikely and probably indicates an error.\n");
2124 goto err; 2135 goto err;
2125 } 2136 }
2137
2126 rc = 1; 2138 rc = 1;
2127 err: 2139 err:
2128 BN_free(a); 2140 BN_free(a);
@@ -2131,6 +2143,7 @@ test_gf2m_mod_solve_quad(BIO *bp, BN_CTX *ctx)
2131 BN_free(c); 2143 BN_free(c);
2132 BN_free(d); 2144 BN_free(d);
2133 BN_free(e); 2145 BN_free(e);
2146
2134 return rc; 2147 return rc;
2135} 2148}
2136#endif 2149#endif
@@ -2148,7 +2161,7 @@ genprime_cb(int p, int n, BN_GENCB *arg)
2148 if (p == 3) 2161 if (p == 3)
2149 c = '\n'; 2162 c = '\n';
2150 putc(c, stderr); 2163 putc(c, stderr);
2151 return (1); 2164 return 1;
2152} 2165}
2153 2166
2154int 2167int
@@ -2243,14 +2256,15 @@ test_kron(BIO *bp, BN_CTX *ctx)
2243 } 2256 }
2244 2257
2245 putc('\n', stderr); 2258 putc('\n', stderr);
2246 rc = 1;
2247 2259
2260 rc = 1;
2248 err: 2261 err:
2249 BN_GENCB_free(cb); 2262 BN_GENCB_free(cb);
2250 BN_free(a); 2263 BN_free(a);
2251 BN_free(b); 2264 BN_free(b);
2252 BN_free(r); 2265 BN_free(r);
2253 BN_free(t); 2266 BN_free(t);
2267
2254 return rc; 2268 return rc;
2255} 2269}
2256 2270
@@ -2339,13 +2353,14 @@ test_sqrt(BIO *bp, BN_CTX *ctx)
2339 2353
2340 putc('\n', stderr); 2354 putc('\n', stderr);
2341 } 2355 }
2342 rc = 1;
2343 2356
2357 rc = 1;
2344 err: 2358 err:
2345 BN_GENCB_free(cb); 2359 BN_GENCB_free(cb);
2346 BN_free(a); 2360 BN_free(a);
2347 BN_free(p); 2361 BN_free(p);
2348 BN_free(r); 2362 BN_free(r);
2363
2349 return rc; 2364 return rc;
2350} 2365}
2351 2366
@@ -2354,7 +2369,7 @@ test_lshift(BIO *bp, BN_CTX *ctx, int use_lst)
2354{ 2369{
2355 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL; 2370 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL;
2356 int i; 2371 int i;
2357 int rc = 1; 2372 int rc = 0;
2358 2373
2359 if ((a = BN_new()) == NULL) 2374 if ((a = BN_new()) == NULL)
2360 goto err; 2375 goto err;
@@ -2400,16 +2415,18 @@ test_lshift(BIO *bp, BN_CTX *ctx, int use_lst)
2400 fprintf(stderr, "\nd="); 2415 fprintf(stderr, "\nd=");
2401 CHECK_GOTO(BN_print_fp(stderr, d)); 2416 CHECK_GOTO(BN_print_fp(stderr, d));
2402 fprintf(stderr, "\n"); 2417 fprintf(stderr, "\n");
2403 rc = 0; 2418 goto err;
2404 break;
2405 } 2419 }
2406 } 2420 }
2421
2422 rc = 1;
2407 err: 2423 err:
2408 BN_free(a); 2424 BN_free(a);
2409 BN_free(b); 2425 BN_free(b);
2410 BN_free(c); 2426 BN_free(c);
2411 BN_free(d); 2427 BN_free(d);
2412 return (rc); 2428
2429 return rc;
2413} 2430}
2414 2431
2415int 2432int
@@ -2417,7 +2434,7 @@ test_lshift1(BIO *bp)
2417{ 2434{
2418 BIGNUM *a = NULL, *b = NULL, *c = NULL; 2435 BIGNUM *a = NULL, *b = NULL, *c = NULL;
2419 int i; 2436 int i;
2420 int rc = 1; 2437 int rc = 0;
2421 2438
2422 if ((a = BN_new()) == NULL) 2439 if ((a = BN_new()) == NULL)
2423 goto err; 2440 goto err;
@@ -2443,17 +2460,19 @@ test_lshift1(BIO *bp)
2443 CHECK_GOTO(BN_sub(a, b, c)); 2460 CHECK_GOTO(BN_sub(a, b, c));
2444 if (!BN_is_zero(a)) { 2461 if (!BN_is_zero(a)) {
2445 fprintf(stderr, "Left shift one test failed!\n"); 2462 fprintf(stderr, "Left shift one test failed!\n");
2446 rc = 0; 2463 goto err;
2447 break;
2448 } 2464 }
2449 2465
2450 CHECK_GOTO(bn_copy(a, b)); 2466 CHECK_GOTO(bn_copy(a, b));
2451 } 2467 }
2468
2469 rc = 1;
2452 err: 2470 err:
2453 BN_free(a); 2471 BN_free(a);
2454 BN_free(b); 2472 BN_free(b);
2455 BN_free(c); 2473 BN_free(c);
2456 return (rc); 2474
2475 return rc;
2457} 2476}
2458 2477
2459int 2478int
@@ -2461,7 +2480,7 @@ test_rshift(BIO *bp, BN_CTX *ctx)
2461{ 2480{
2462 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; 2481 BIGNUM *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL;
2463 int i; 2482 int i;
2464 int rc = 1; 2483 int rc = 0;
2465 2484
2466 if ((a = BN_new()) == NULL) 2485 if ((a = BN_new()) == NULL)
2467 goto err; 2486 goto err;
@@ -2494,17 +2513,19 @@ test_rshift(BIO *bp, BN_CTX *ctx)
2494 CHECK_GOTO(BN_sub(d, d, b)); 2513 CHECK_GOTO(BN_sub(d, d, b));
2495 if (!BN_is_zero(d)) { 2514 if (!BN_is_zero(d)) {
2496 fprintf(stderr, "Right shift test failed!\n"); 2515 fprintf(stderr, "Right shift test failed!\n");
2497 rc = 0; 2516 goto err;
2498 break;
2499 } 2517 }
2500 } 2518 }
2519
2520 rc = 1;
2501 err: 2521 err:
2502 BN_free(a); 2522 BN_free(a);
2503 BN_free(b); 2523 BN_free(b);
2504 BN_free(c); 2524 BN_free(c);
2505 BN_free(d); 2525 BN_free(d);
2506 BN_free(e); 2526 BN_free(e);
2507 return (rc); 2527
2528 return rc;
2508} 2529}
2509 2530
2510int 2531int
@@ -2512,7 +2533,7 @@ test_rshift1(BIO *bp)
2512{ 2533{
2513 BIGNUM *a = NULL, *b = NULL, *c = NULL; 2534 BIGNUM *a = NULL, *b = NULL, *c = NULL;
2514 int i; 2535 int i;
2515 int rc = 1; 2536 int rc = 0;
2516 2537
2517 if ((a = BN_new()) == NULL) 2538 if ((a = BN_new()) == NULL)
2518 goto err; 2539 goto err;
@@ -2538,16 +2559,18 @@ test_rshift1(BIO *bp)
2538 CHECK_GOTO(BN_sub(c, c, b)); 2559 CHECK_GOTO(BN_sub(c, c, b));
2539 if (!BN_is_zero(c) && !BN_abs_is_word(c, 1)) { 2560 if (!BN_is_zero(c) && !BN_abs_is_word(c, 1)) {
2540 fprintf(stderr, "Right shift one test failed!\n"); 2561 fprintf(stderr, "Right shift one test failed!\n");
2541 rc = 0; 2562 goto err;
2542 break;
2543 } 2563 }
2544 CHECK_GOTO(bn_copy(a, b)); 2564 CHECK_GOTO(bn_copy(a, b));
2545 } 2565 }
2566
2567 rc = 1;
2546 err: 2568 err:
2547 BN_free(a); 2569 BN_free(a);
2548 BN_free(b); 2570 BN_free(b);
2549 BN_free(c); 2571 BN_free(c);
2550 return (rc); 2572
2573 return rc;
2551} 2574}
2552 2575
2553int 2576int
@@ -2604,9 +2627,9 @@ test_mod_exp_sizes(BIO *bp, BN_CTX *ctx)
2604 } 2627 }
2605 2628
2606 rc = 1; 2629 rc = 1;
2607
2608 err: 2630 err:
2609 BN_MONT_CTX_free(mont_ctx); 2631 BN_MONT_CTX_free(mont_ctx);
2610 BN_CTX_end(ctx); 2632 BN_CTX_end(ctx);
2633
2611 return rc; 2634 return rc;
2612} 2635}