diff options
Diffstat (limited to 'src/lib/libcrypto/dsa/dsatest.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsatest.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/libcrypto/dsa/dsatest.c b/src/lib/libcrypto/dsa/dsatest.c index fc25c9a1b7..309a7cda89 100644 --- a/src/lib/libcrypto/dsa/dsatest.c +++ b/src/lib/libcrypto/dsa/dsatest.c | |||
@@ -84,7 +84,10 @@ int main(int argc, char *argv[]) | |||
84 | #define MS_CALLBACK | 84 | #define MS_CALLBACK |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | static void MS_CALLBACK dsa_cb(int p, int n, char *arg); | 87 | static void MS_CALLBACK dsa_cb(int p, int n, void *arg); |
88 | |||
89 | /* 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 */ | ||
88 | static unsigned char seed[20]={ | 91 | static unsigned char seed[20]={ |
89 | 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, | 92 | 0xd5,0x01,0x4e,0x4b,0x60,0xef,0x2b,0xa8,0xb6,0x21,0x1b,0x40, |
90 | 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, | 93 | 0x62,0xba,0x32,0x24,0xe0,0x42,0x7d,0xd3, |
@@ -120,6 +123,8 @@ static unsigned char out_g[]={ | |||
120 | 123 | ||
121 | static const unsigned char str1[]="12345678901234567890"; | 124 | static const unsigned char str1[]="12345678901234567890"; |
122 | 125 | ||
126 | static const char rnd_seed[] = "string to make the random number generator think it has entropy"; | ||
127 | |||
123 | static BIO *bio_err=NULL; | 128 | static BIO *bio_err=NULL; |
124 | 129 | ||
125 | int main(int argc, char **argv) | 130 | int main(int argc, char **argv) |
@@ -131,15 +136,17 @@ int main(int argc, char **argv) | |||
131 | unsigned char sig[256]; | 136 | unsigned char sig[256]; |
132 | unsigned int siglen; | 137 | unsigned int siglen; |
133 | 138 | ||
139 | ERR_load_crypto_strings(); | ||
140 | RAND_seed(rnd_seed, sizeof rnd_seed); | ||
141 | |||
134 | if (bio_err == NULL) | 142 | if (bio_err == NULL) |
135 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); | 143 | bio_err=BIO_new_fp(stderr,BIO_NOCLOSE); |
136 | 144 | ||
137 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); | 145 | CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON); |
138 | 146 | ||
139 | BIO_printf(bio_err,"test generation of DSA parameters\n"); | 147 | BIO_printf(bio_err,"test generation of DSA parameters\n"); |
140 | BIO_printf(bio_err,"expect '.*' followed by 5 lines of '.'s and '+'s\n"); | 148 | |
141 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb, | 149 | dsa=DSA_generate_parameters(512,seed,20,&counter,&h,dsa_cb,bio_err); |
142 | (char *)bio_err); | ||
143 | 150 | ||
144 | BIO_printf(bio_err,"seed\n"); | 151 | BIO_printf(bio_err,"seed\n"); |
145 | for (i=0; i<20; i+=4) | 152 | for (i=0; i<20; i+=4) |
@@ -193,13 +200,18 @@ end: | |||
193 | if (!ret) | 200 | if (!ret) |
194 | ERR_print_errors(bio_err); | 201 | ERR_print_errors(bio_err); |
195 | if (dsa != NULL) DSA_free(dsa); | 202 | if (dsa != NULL) DSA_free(dsa); |
203 | ERR_remove_state(0); | ||
196 | CRYPTO_mem_leaks(bio_err); | 204 | CRYPTO_mem_leaks(bio_err); |
197 | if (bio_err != NULL) BIO_free(bio_err); | 205 | if (bio_err != NULL) |
206 | { | ||
207 | BIO_free(bio_err); | ||
208 | bio_err = NULL; | ||
209 | } | ||
198 | exit(!ret); | 210 | exit(!ret); |
199 | return(0); | 211 | return(0); |
200 | } | 212 | } |
201 | 213 | ||
202 | static void MS_CALLBACK dsa_cb(int p, int n, char *arg) | 214 | static void MS_CALLBACK dsa_cb(int p, int n, void *arg) |
203 | { | 215 | { |
204 | char c='*'; | 216 | char c='*'; |
205 | static int ok=0,num=0; | 217 | static int ok=0,num=0; |
@@ -208,8 +220,8 @@ static void MS_CALLBACK dsa_cb(int p, int n, char *arg) | |||
208 | if (p == 1) c='+'; | 220 | if (p == 1) c='+'; |
209 | if (p == 2) { c='*'; ok++; } | 221 | if (p == 2) { c='*'; ok++; } |
210 | if (p == 3) c='\n'; | 222 | if (p == 3) c='\n'; |
211 | BIO_write((BIO *)arg,&c,1); | 223 | BIO_write(arg,&c,1); |
212 | (void)BIO_flush((BIO *)arg); | 224 | (void)BIO_flush(arg); |
213 | 225 | ||
214 | if (!ok && (p == 0) && (num > 1)) | 226 | if (!ok && (p == 0) && (num > 1)) |
215 | { | 227 | { |