summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/exptest.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/libcrypto/bn/exptest.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/exptest.c b/src/lib/libcrypto/bn/exptest.c
index b09cf88705..28aaac2ac1 100644
--- a/src/lib/libcrypto/bn/exptest.c
+++ b/src/lib/libcrypto/bn/exptest.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
77 BIO *out=NULL; 77 BIO *out=NULL;
78 int i,ret; 78 int i,ret;
79 unsigned char c; 79 unsigned char c;
80 BIGNUM *r_mont,*r_recp,*r_simple,*a,*b,*m; 80 BIGNUM *r_mont,*r_mont_const,*r_recp,*r_simple,*a,*b,*m;
81 81
82 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't 82 RAND_seed(rnd_seed, sizeof rnd_seed); /* or BN_rand may fail, and we don't
83 * even check its return value 83 * even check its return value
@@ -88,6 +88,7 @@ int main(int argc, char *argv[])
88 ctx=BN_CTX_new(); 88 ctx=BN_CTX_new();
89 if (ctx == NULL) EXIT(1); 89 if (ctx == NULL) EXIT(1);
90 r_mont=BN_new(); 90 r_mont=BN_new();
91 r_mont_const=BN_new();
91 r_recp=BN_new(); 92 r_recp=BN_new();
92 r_simple=BN_new(); 93 r_simple=BN_new();
93 a=BN_new(); 94 a=BN_new();
@@ -143,8 +144,17 @@ int main(int argc, char *argv[])
143 EXIT(1); 144 EXIT(1);
144 } 145 }
145 146
147 ret=BN_mod_exp_mont_consttime(r_mont_const,a,b,m,ctx,NULL);
148 if (ret <= 0)
149 {
150 printf("BN_mod_exp_mont_consttime() problems\n");
151 ERR_print_errors(out);
152 EXIT(1);
153 }
154
146 if (BN_cmp(r_simple, r_mont) == 0 155 if (BN_cmp(r_simple, r_mont) == 0
147 && BN_cmp(r_simple,r_recp) == 0) 156 && BN_cmp(r_simple,r_recp) == 0
157 && BN_cmp(r_simple,r_mont_const) == 0)
148 { 158 {
149 printf("."); 159 printf(".");
150 fflush(stdout); 160 fflush(stdout);
@@ -153,6 +163,8 @@ int main(int argc, char *argv[])
153 { 163 {
154 if (BN_cmp(r_simple,r_mont) != 0) 164 if (BN_cmp(r_simple,r_mont) != 0)
155 printf("\nsimple and mont results differ\n"); 165 printf("\nsimple and mont results differ\n");
166 if (BN_cmp(r_simple,r_mont) != 0)
167 printf("\nsimple and mont const time results differ\n");
156 if (BN_cmp(r_simple,r_recp) != 0) 168 if (BN_cmp(r_simple,r_recp) != 0)
157 printf("\nsimple and recp results differ\n"); 169 printf("\nsimple and recp results differ\n");
158 170
@@ -162,11 +174,13 @@ int main(int argc, char *argv[])
162 printf("\nsimple ="); BN_print(out,r_simple); 174 printf("\nsimple ="); BN_print(out,r_simple);
163 printf("\nrecp ="); BN_print(out,r_recp); 175 printf("\nrecp ="); BN_print(out,r_recp);
164 printf("\nmont ="); BN_print(out,r_mont); 176 printf("\nmont ="); BN_print(out,r_mont);
177 printf("\nmont_ct ="); BN_print(out,r_mont_const);
165 printf("\n"); 178 printf("\n");
166 EXIT(1); 179 EXIT(1);
167 } 180 }
168 } 181 }
169 BN_free(r_mont); 182 BN_free(r_mont);
183 BN_free(r_mont_const);
170 BN_free(r_recp); 184 BN_free(r_recp);
171 BN_free(r_simple); 185 BN_free(r_simple);
172 BN_free(a); 186 BN_free(a);