summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/dsa/dsatest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/dsa/dsatest.c')
-rw-r--r--src/lib/libcrypto/dsa/dsatest.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c
index 55a3756aff..912317bb44 100644
--- a/src/lib/libcrypto/dsa/dsatest.c
+++ b/src/lib/libcrypto/dsa/dsatest.c
@@ -56,6 +56,12 @@
56 * [including the GNU Public Licence.] 56 * [including the GNU Public Licence.]
57 */ 57 */
58 58
59/* Until the key-gen callbacks are modified to use newer prototypes, we allow
60 * deprecated functions for openssl-internal code */
61#ifdef OPENSSL_NO_DEPRECATED
62#undef OPENSSL_NO_DEPRECATED
63#endif
64
59#include <stdio.h> 65#include <stdio.h>
60#include <stdlib.h> 66#include <stdlib.h>
61#include <string.h> 67#include <string.h>
@@ -68,6 +74,7 @@
68#include <openssl/rand.h> 74#include <openssl/rand.h>
69#include <openssl/bio.h> 75#include <openssl/bio.h>
70#include <openssl/err.h> 76#include <openssl/err.h>
77#include <openssl/bn.h>
71 78
72#ifdef OPENSSL_NO_DSA 79#ifdef OPENSSL_NO_DSA
73int main(int argc, char *argv[]) 80int main(int argc, char *argv[])
@@ -84,7 +91,7 @@ int main(int argc, char *argv[])
84#define MS_CALLBACK 91#define MS_CALLBACK
85#endif 92#endif
86 93
87static void MS_CALLBACK dsa_cb(int p, int n, void *arg); 94static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *arg);
88 95
89/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to 96/* seed, out_p, out_q, out_g are taken from the updated Appendix 5 to
90 * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */ 97 * FIPS PUB 186 and also appear in Appendix 5 to FIPS PIB 186-1 */
@@ -129,6 +136,7 @@ static BIO *bio_err=NULL;
129 136
130int main(int argc, char **argv) 137int main(int argc, char **argv)
131 { 138 {
139 BN_GENCB cb;
132 DSA *dsa=NULL; 140 DSA *dsa=NULL;
133 int counter,ret=0,i,j; 141 int counter,ret=0,i,j;
134 unsigned char buf[256]; 142 unsigned char buf[256];
@@ -148,7 +156,10 @@ int main(int argc, char **argv)
148 156
149 BIO_printf(bio_err,"test generation of DSA parameters\n"); 157 BIO_printf(bio_err,"test generation of DSA parameters\n");
150 158
151 dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); 159 BN_GENCB_set(&cb, dsa_cb, bio_err);
160 if(((dsa = DSA_new()) == NULL) || !DSA_generate_parameters_ex(dsa, 512,
161 seed, 20, &counter, &h, &cb))
162 goto end;
152 163
153 BIO_printf(bio_err,"seed\n"); 164 BIO_printf(bio_err,"seed\n");
154 for (i=0; i<20; i+=4) 165 for (i=0; i<20; i+=4)
@@ -156,7 +167,7 @@ int main(int argc, char **argv)
156 BIO_printf(bio_err,"%02X%02X%02X%02X ", 167 BIO_printf(bio_err,"%02X%02X%02X%02X ",
157 seed[i],seed[i+1],seed[i+2],seed[i+3]); 168 seed[i],seed[i+1],seed[i+2],seed[i+3]);
158 } 169 }
159 BIO_printf(bio_err,"\ncounter=%d h=%d\n",counter,h); 170 BIO_printf(bio_err,"\ncounter=%d h=%ld\n",counter,h);
160 171
161 if (dsa == NULL) goto end; 172 if (dsa == NULL) goto end;
162 DSA_print(bio_err,dsa,0); 173 DSA_print(bio_err,dsa,0);
@@ -220,17 +231,14 @@ end:
220 BIO_free(bio_err); 231 BIO_free(bio_err);
221 bio_err = NULL; 232 bio_err = NULL;
222 } 233 }
234#ifdef OPENSSL_SYS_NETWARE
235 if (!ret) printf("ERROR\n");
236#endif
223 EXIT(!ret); 237 EXIT(!ret);
224 return(0); 238 return(0);
225 } 239 }
226 240
227static int cb_exit(int ec) 241static int MS_CALLBACK dsa_cb(int p, int n, BN_GENCB *arg)
228 {
229 EXIT(ec);
230 return(0); /* To keep some compilers quiet */
231 }
232
233static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
234 { 242 {
235 char c='*'; 243 char c='*';
236 static int ok=0,num=0; 244 static int ok=0,num=0;
@@ -239,13 +247,14 @@ static void MS_CALLBACK dsa_cb(int p, int n, void *arg)
239 if (p == 1) c='+'; 247 if (p == 1) c='+';
240 if (p == 2) { c='*'; ok++; } 248 if (p == 2) { c='*'; ok++; }
241 if (p == 3) c='\n'; 249 if (p == 3) c='\n';
242 BIO_write(arg,&c,1); 250 BIO_write(arg->arg,&c,1);
243 (void)BIO_flush(arg); 251 (void)BIO_flush(arg->arg);
244 252
245 if (!ok && (p == 0) && (num > 1)) 253 if (!ok && (p == 0) && (num > 1))
246 { 254 {
247 BIO_printf((BIO *)arg,"error in dsatest\n"); 255 BIO_printf((BIO *)arg,"error in dsatest\n");
248 cb_exit(1); 256 return 0;
249 } 257 }
258 return 1;
250 } 259 }
251#endif 260#endif