1ebfedea0SLionel Sambuc /* apps/genrsa.c */
2ebfedea0SLionel Sambuc /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3ebfedea0SLionel Sambuc * All rights reserved.
4ebfedea0SLionel Sambuc *
5ebfedea0SLionel Sambuc * This package is an SSL implementation written
6ebfedea0SLionel Sambuc * by Eric Young (eay@cryptsoft.com).
7ebfedea0SLionel Sambuc * The implementation was written so as to conform with Netscapes SSL.
8ebfedea0SLionel Sambuc *
9ebfedea0SLionel Sambuc * This library is free for commercial and non-commercial use as long as
10ebfedea0SLionel Sambuc * the following conditions are aheared to. The following conditions
11ebfedea0SLionel Sambuc * apply to all code found in this distribution, be it the RC4, RSA,
12ebfedea0SLionel Sambuc * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13ebfedea0SLionel Sambuc * included with this distribution is covered by the same copyright terms
14ebfedea0SLionel Sambuc * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15ebfedea0SLionel Sambuc *
16ebfedea0SLionel Sambuc * Copyright remains Eric Young's, and as such any Copyright notices in
17ebfedea0SLionel Sambuc * the code are not to be removed.
18ebfedea0SLionel Sambuc * If this package is used in a product, Eric Young should be given attribution
19ebfedea0SLionel Sambuc * as the author of the parts of the library used.
20ebfedea0SLionel Sambuc * This can be in the form of a textual message at program startup or
21ebfedea0SLionel Sambuc * in documentation (online or textual) provided with the package.
22ebfedea0SLionel Sambuc *
23ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
24ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
25ebfedea0SLionel Sambuc * are met:
26ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the copyright
27ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer.
28ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
29ebfedea0SLionel Sambuc * notice, this list of conditions and the following disclaimer in the
30ebfedea0SLionel Sambuc * documentation and/or other materials provided with the distribution.
31ebfedea0SLionel Sambuc * 3. All advertising materials mentioning features or use of this software
32ebfedea0SLionel Sambuc * must display the following acknowledgement:
33ebfedea0SLionel Sambuc * "This product includes cryptographic software written by
34ebfedea0SLionel Sambuc * Eric Young (eay@cryptsoft.com)"
35ebfedea0SLionel Sambuc * The word 'cryptographic' can be left out if the rouines from the library
36ebfedea0SLionel Sambuc * being used are not cryptographic related :-).
37ebfedea0SLionel Sambuc * 4. If you include any Windows specific code (or a derivative thereof) from
38ebfedea0SLionel Sambuc * the apps directory (application code) you must include an acknowledgement:
39ebfedea0SLionel Sambuc * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40ebfedea0SLionel Sambuc *
41ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44ebfedea0SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51ebfedea0SLionel Sambuc * SUCH DAMAGE.
52ebfedea0SLionel Sambuc *
53ebfedea0SLionel Sambuc * The licence and distribution terms for any publically available version or
54ebfedea0SLionel Sambuc * derivative of this code cannot be changed. i.e. this code cannot simply be
55ebfedea0SLionel Sambuc * copied and put under another distribution licence
56ebfedea0SLionel Sambuc * [including the GNU Public Licence.]
57ebfedea0SLionel Sambuc */
58ebfedea0SLionel Sambuc
59ebfedea0SLionel Sambuc #include <openssl/opensslconf.h>
60*0a6a1f1dSLionel Sambuc /*
61*0a6a1f1dSLionel Sambuc * Until the key-gen callbacks are modified to use newer prototypes, we allow
62*0a6a1f1dSLionel Sambuc * deprecated functions for openssl-internal code
63*0a6a1f1dSLionel Sambuc */
64ebfedea0SLionel Sambuc #ifdef OPENSSL_NO_DEPRECATED
65ebfedea0SLionel Sambuc # undef OPENSSL_NO_DEPRECATED
66ebfedea0SLionel Sambuc #endif
67ebfedea0SLionel Sambuc
68ebfedea0SLionel Sambuc #ifndef OPENSSL_NO_RSA
69ebfedea0SLionel Sambuc # include <stdio.h>
70ebfedea0SLionel Sambuc # include <string.h>
71ebfedea0SLionel Sambuc # include <sys/types.h>
72ebfedea0SLionel Sambuc # include <sys/stat.h>
73ebfedea0SLionel Sambuc # include "apps.h"
74ebfedea0SLionel Sambuc # include <openssl/bio.h>
75ebfedea0SLionel Sambuc # include <openssl/err.h>
76ebfedea0SLionel Sambuc # include <openssl/bn.h>
77ebfedea0SLionel Sambuc # include <openssl/rsa.h>
78ebfedea0SLionel Sambuc # include <openssl/evp.h>
79ebfedea0SLionel Sambuc # include <openssl/x509.h>
80ebfedea0SLionel Sambuc # include <openssl/pem.h>
81ebfedea0SLionel Sambuc # include <openssl/rand.h>
82ebfedea0SLionel Sambuc
83ebfedea0SLionel Sambuc # define DEFBITS 1024
84ebfedea0SLionel Sambuc # undef PROG
85ebfedea0SLionel Sambuc # define PROG genrsa_main
86ebfedea0SLionel Sambuc
87ebfedea0SLionel Sambuc static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb);
88ebfedea0SLionel Sambuc
89ebfedea0SLionel Sambuc int MAIN(int, char **);
90ebfedea0SLionel Sambuc
MAIN(int argc,char ** argv)91ebfedea0SLionel Sambuc int MAIN(int argc, char **argv)
92ebfedea0SLionel Sambuc {
93ebfedea0SLionel Sambuc BN_GENCB cb;
94ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
95ebfedea0SLionel Sambuc ENGINE *e = NULL;
96ebfedea0SLionel Sambuc # endif
97ebfedea0SLionel Sambuc int ret = 1;
98ebfedea0SLionel Sambuc int i, num = DEFBITS;
99ebfedea0SLionel Sambuc long l;
100ebfedea0SLionel Sambuc const EVP_CIPHER *enc = NULL;
101ebfedea0SLionel Sambuc unsigned long f4 = RSA_F4;
102ebfedea0SLionel Sambuc char *outfile = NULL;
103ebfedea0SLionel Sambuc char *passargout = NULL, *passout = NULL;
104ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
105ebfedea0SLionel Sambuc char *engine = NULL;
106ebfedea0SLionel Sambuc # endif
107ebfedea0SLionel Sambuc char *inrand = NULL;
108ebfedea0SLionel Sambuc BIO *out = NULL;
109ebfedea0SLionel Sambuc BIGNUM *bn = BN_new();
110ebfedea0SLionel Sambuc RSA *rsa = NULL;
111ebfedea0SLionel Sambuc
112*0a6a1f1dSLionel Sambuc if (!bn)
113*0a6a1f1dSLionel Sambuc goto err;
114ebfedea0SLionel Sambuc
115ebfedea0SLionel Sambuc apps_startup();
116ebfedea0SLionel Sambuc BN_GENCB_set(&cb, genrsa_cb, bio_err);
117ebfedea0SLionel Sambuc
118ebfedea0SLionel Sambuc if (bio_err == NULL)
119ebfedea0SLionel Sambuc if ((bio_err = BIO_new(BIO_s_file())) != NULL)
120ebfedea0SLionel Sambuc BIO_set_fp(bio_err, stderr, BIO_NOCLOSE | BIO_FP_TEXT);
121ebfedea0SLionel Sambuc
122ebfedea0SLionel Sambuc if (!load_config(bio_err, NULL))
123ebfedea0SLionel Sambuc goto err;
124*0a6a1f1dSLionel Sambuc if ((out = BIO_new(BIO_s_file())) == NULL) {
125ebfedea0SLionel Sambuc BIO_printf(bio_err, "unable to create BIO for output\n");
126ebfedea0SLionel Sambuc goto err;
127ebfedea0SLionel Sambuc }
128ebfedea0SLionel Sambuc
129ebfedea0SLionel Sambuc argv++;
130ebfedea0SLionel Sambuc argc--;
131*0a6a1f1dSLionel Sambuc for (;;) {
132*0a6a1f1dSLionel Sambuc if (argc <= 0)
133*0a6a1f1dSLionel Sambuc break;
134*0a6a1f1dSLionel Sambuc if (strcmp(*argv, "-out") == 0) {
135*0a6a1f1dSLionel Sambuc if (--argc < 1)
136*0a6a1f1dSLionel Sambuc goto bad;
137ebfedea0SLionel Sambuc outfile = *(++argv);
138*0a6a1f1dSLionel Sambuc } else if (strcmp(*argv, "-3") == 0)
139ebfedea0SLionel Sambuc f4 = 3;
140ebfedea0SLionel Sambuc else if (strcmp(*argv, "-F4") == 0 || strcmp(*argv, "-f4") == 0)
141ebfedea0SLionel Sambuc f4 = RSA_F4;
142ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
143*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-engine") == 0) {
144*0a6a1f1dSLionel Sambuc if (--argc < 1)
145*0a6a1f1dSLionel Sambuc goto bad;
146ebfedea0SLionel Sambuc engine = *(++argv);
147ebfedea0SLionel Sambuc }
148ebfedea0SLionel Sambuc # endif
149*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-rand") == 0) {
150*0a6a1f1dSLionel Sambuc if (--argc < 1)
151*0a6a1f1dSLionel Sambuc goto bad;
152ebfedea0SLionel Sambuc inrand = *(++argv);
153ebfedea0SLionel Sambuc }
154ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_DES
155ebfedea0SLionel Sambuc else if (strcmp(*argv, "-des") == 0)
156ebfedea0SLionel Sambuc enc = EVP_des_cbc();
157ebfedea0SLionel Sambuc else if (strcmp(*argv, "-des3") == 0)
158ebfedea0SLionel Sambuc enc = EVP_des_ede3_cbc();
159ebfedea0SLionel Sambuc # endif
160ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
161ebfedea0SLionel Sambuc else if (strcmp(*argv, "-idea") == 0)
162ebfedea0SLionel Sambuc enc = EVP_idea_cbc();
163ebfedea0SLionel Sambuc # endif
164ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
165ebfedea0SLionel Sambuc else if (strcmp(*argv, "-seed") == 0)
166ebfedea0SLionel Sambuc enc = EVP_seed_cbc();
167ebfedea0SLionel Sambuc # endif
168ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
169ebfedea0SLionel Sambuc else if (strcmp(*argv, "-aes128") == 0)
170ebfedea0SLionel Sambuc enc = EVP_aes_128_cbc();
171ebfedea0SLionel Sambuc else if (strcmp(*argv, "-aes192") == 0)
172ebfedea0SLionel Sambuc enc = EVP_aes_192_cbc();
173ebfedea0SLionel Sambuc else if (strcmp(*argv, "-aes256") == 0)
174ebfedea0SLionel Sambuc enc = EVP_aes_256_cbc();
175ebfedea0SLionel Sambuc # endif
176ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
177ebfedea0SLionel Sambuc else if (strcmp(*argv, "-camellia128") == 0)
178ebfedea0SLionel Sambuc enc = EVP_camellia_128_cbc();
179ebfedea0SLionel Sambuc else if (strcmp(*argv, "-camellia192") == 0)
180ebfedea0SLionel Sambuc enc = EVP_camellia_192_cbc();
181ebfedea0SLionel Sambuc else if (strcmp(*argv, "-camellia256") == 0)
182ebfedea0SLionel Sambuc enc = EVP_camellia_256_cbc();
183ebfedea0SLionel Sambuc # endif
184*0a6a1f1dSLionel Sambuc else if (strcmp(*argv, "-passout") == 0) {
185*0a6a1f1dSLionel Sambuc if (--argc < 1)
186*0a6a1f1dSLionel Sambuc goto bad;
187ebfedea0SLionel Sambuc passargout = *(++argv);
188*0a6a1f1dSLionel Sambuc } else
189ebfedea0SLionel Sambuc break;
190ebfedea0SLionel Sambuc argv++;
191ebfedea0SLionel Sambuc argc--;
192ebfedea0SLionel Sambuc }
193*0a6a1f1dSLionel Sambuc if ((argc >= 1) && ((sscanf(*argv, "%d", &num) == 0) || (num < 0))) {
194ebfedea0SLionel Sambuc bad:
195ebfedea0SLionel Sambuc BIO_printf(bio_err, "usage: genrsa [args] [numbits]\n");
196*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
197*0a6a1f1dSLionel Sambuc " -des encrypt the generated key with DES in cbc mode\n");
198*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
199*0a6a1f1dSLionel Sambuc " -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)\n");
200ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_IDEA
201*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
202*0a6a1f1dSLionel Sambuc " -idea encrypt the generated key with IDEA in cbc mode\n");
203ebfedea0SLionel Sambuc # endif
204ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_SEED
205ebfedea0SLionel Sambuc BIO_printf(bio_err, " -seed\n");
206*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
207*0a6a1f1dSLionel Sambuc " encrypt PEM output with cbc seed\n");
208ebfedea0SLionel Sambuc # endif
209ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_AES
210ebfedea0SLionel Sambuc BIO_printf(bio_err, " -aes128, -aes192, -aes256\n");
211*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
212*0a6a1f1dSLionel Sambuc " encrypt PEM output with cbc aes\n");
213ebfedea0SLionel Sambuc # endif
214ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_CAMELLIA
215ebfedea0SLionel Sambuc BIO_printf(bio_err, " -camellia128, -camellia192, -camellia256\n");
216*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
217*0a6a1f1dSLionel Sambuc " encrypt PEM output with cbc camellia\n");
218ebfedea0SLionel Sambuc # endif
219ebfedea0SLionel Sambuc BIO_printf(bio_err, " -out file output the key to 'file\n");
220*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
221*0a6a1f1dSLionel Sambuc " -passout arg output file pass phrase source\n");
222*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
223*0a6a1f1dSLionel Sambuc " -f4 use F4 (0x10001) for the E value\n");
224ebfedea0SLionel Sambuc BIO_printf(bio_err, " -3 use 3 for the E value\n");
225ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
226*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
227*0a6a1f1dSLionel Sambuc " -engine e use engine e, possibly a hardware device.\n");
228ebfedea0SLionel Sambuc # endif
229*0a6a1f1dSLionel Sambuc BIO_printf(bio_err, " -rand file%cfile%c...\n", LIST_SEPARATOR_CHAR,
230*0a6a1f1dSLionel Sambuc LIST_SEPARATOR_CHAR);
231*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
232*0a6a1f1dSLionel Sambuc " load the file (or the files in the directory) into\n");
233ebfedea0SLionel Sambuc BIO_printf(bio_err, " the random number generator\n");
234ebfedea0SLionel Sambuc goto err;
235ebfedea0SLionel Sambuc }
236ebfedea0SLionel Sambuc
237ebfedea0SLionel Sambuc ERR_load_crypto_strings();
238ebfedea0SLionel Sambuc
239ebfedea0SLionel Sambuc if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) {
240ebfedea0SLionel Sambuc BIO_printf(bio_err, "Error getting password\n");
241ebfedea0SLionel Sambuc goto err;
242ebfedea0SLionel Sambuc }
243ebfedea0SLionel Sambuc # ifndef OPENSSL_NO_ENGINE
244ebfedea0SLionel Sambuc e = setup_engine(bio_err, engine, 0);
245ebfedea0SLionel Sambuc # endif
246ebfedea0SLionel Sambuc
247*0a6a1f1dSLionel Sambuc if (outfile == NULL) {
248ebfedea0SLionel Sambuc BIO_set_fp(out, stdout, BIO_NOCLOSE);
249ebfedea0SLionel Sambuc # ifdef OPENSSL_SYS_VMS
250ebfedea0SLionel Sambuc {
251ebfedea0SLionel Sambuc BIO *tmpbio = BIO_new(BIO_f_linebuffer());
252ebfedea0SLionel Sambuc out = BIO_push(tmpbio, out);
253ebfedea0SLionel Sambuc }
254ebfedea0SLionel Sambuc # endif
255*0a6a1f1dSLionel Sambuc } else {
256*0a6a1f1dSLionel Sambuc if (BIO_write_filename(out, outfile) <= 0) {
257ebfedea0SLionel Sambuc perror(outfile);
258ebfedea0SLionel Sambuc goto err;
259ebfedea0SLionel Sambuc }
260ebfedea0SLionel Sambuc }
261ebfedea0SLionel Sambuc
262ebfedea0SLionel Sambuc if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL
263*0a6a1f1dSLionel Sambuc && !RAND_status()) {
264*0a6a1f1dSLionel Sambuc BIO_printf(bio_err,
265*0a6a1f1dSLionel Sambuc "warning, not much extra random data, consider using the -rand option\n");
266ebfedea0SLionel Sambuc }
267ebfedea0SLionel Sambuc if (inrand != NULL)
268ebfedea0SLionel Sambuc BIO_printf(bio_err, "%ld semi-random bytes loaded\n",
269ebfedea0SLionel Sambuc app_RAND_load_files(inrand));
270ebfedea0SLionel Sambuc
271ebfedea0SLionel Sambuc BIO_printf(bio_err, "Generating RSA private key, %d bit long modulus\n",
272ebfedea0SLionel Sambuc num);
273ebfedea0SLionel Sambuc # ifdef OPENSSL_NO_ENGINE
274ebfedea0SLionel Sambuc rsa = RSA_new();
275ebfedea0SLionel Sambuc # else
276ebfedea0SLionel Sambuc rsa = RSA_new_method(e);
277ebfedea0SLionel Sambuc # endif
278ebfedea0SLionel Sambuc if (!rsa)
279ebfedea0SLionel Sambuc goto err;
280ebfedea0SLionel Sambuc
281ebfedea0SLionel Sambuc if (!BN_set_word(bn, f4) || !RSA_generate_key_ex(rsa, num, bn, &cb))
282ebfedea0SLionel Sambuc goto err;
283ebfedea0SLionel Sambuc
284ebfedea0SLionel Sambuc app_RAND_write_file(NULL, bio_err);
285ebfedea0SLionel Sambuc
286*0a6a1f1dSLionel Sambuc /*
287*0a6a1f1dSLionel Sambuc * We need to do the following for when the base number size is < long,
288*0a6a1f1dSLionel Sambuc * esp windows 3.1 :-(.
289*0a6a1f1dSLionel Sambuc */
290ebfedea0SLionel Sambuc l = 0L;
291*0a6a1f1dSLionel Sambuc for (i = 0; i < rsa->e->top; i++) {
292ebfedea0SLionel Sambuc # ifndef SIXTY_FOUR_BIT
293ebfedea0SLionel Sambuc l <<= BN_BITS4;
294ebfedea0SLionel Sambuc l <<= BN_BITS4;
295ebfedea0SLionel Sambuc # endif
296ebfedea0SLionel Sambuc l += rsa->e->d[i];
297ebfedea0SLionel Sambuc }
298ebfedea0SLionel Sambuc BIO_printf(bio_err, "e is %ld (0x%lX)\n", l, l);
299ebfedea0SLionel Sambuc {
300ebfedea0SLionel Sambuc PW_CB_DATA cb_data;
301ebfedea0SLionel Sambuc cb_data.password = passout;
302ebfedea0SLionel Sambuc cb_data.prompt_info = outfile;
303ebfedea0SLionel Sambuc if (!PEM_write_bio_RSAPrivateKey(out, rsa, enc, NULL, 0,
304*0a6a1f1dSLionel Sambuc (pem_password_cb *)password_callback,
305*0a6a1f1dSLionel Sambuc &cb_data))
306ebfedea0SLionel Sambuc goto err;
307ebfedea0SLionel Sambuc }
308ebfedea0SLionel Sambuc
309ebfedea0SLionel Sambuc ret = 0;
310ebfedea0SLionel Sambuc err:
311*0a6a1f1dSLionel Sambuc if (bn)
312*0a6a1f1dSLionel Sambuc BN_free(bn);
313*0a6a1f1dSLionel Sambuc if (rsa)
314*0a6a1f1dSLionel Sambuc RSA_free(rsa);
315*0a6a1f1dSLionel Sambuc if (out)
316*0a6a1f1dSLionel Sambuc BIO_free_all(out);
317*0a6a1f1dSLionel Sambuc if (passout)
318*0a6a1f1dSLionel Sambuc OPENSSL_free(passout);
319ebfedea0SLionel Sambuc if (ret != 0)
320ebfedea0SLionel Sambuc ERR_print_errors(bio_err);
321ebfedea0SLionel Sambuc apps_shutdown();
322ebfedea0SLionel Sambuc OPENSSL_EXIT(ret);
323ebfedea0SLionel Sambuc }
324ebfedea0SLionel Sambuc
genrsa_cb(int p,int n,BN_GENCB * cb)325ebfedea0SLionel Sambuc static int MS_CALLBACK genrsa_cb(int p, int n, BN_GENCB *cb)
326ebfedea0SLionel Sambuc {
327ebfedea0SLionel Sambuc char c = '*';
328ebfedea0SLionel Sambuc
329*0a6a1f1dSLionel Sambuc if (p == 0)
330*0a6a1f1dSLionel Sambuc c = '.';
331*0a6a1f1dSLionel Sambuc if (p == 1)
332*0a6a1f1dSLionel Sambuc c = '+';
333*0a6a1f1dSLionel Sambuc if (p == 2)
334*0a6a1f1dSLionel Sambuc c = '*';
335*0a6a1f1dSLionel Sambuc if (p == 3)
336*0a6a1f1dSLionel Sambuc c = '\n';
337ebfedea0SLionel Sambuc BIO_write(cb->arg, &c, 1);
338ebfedea0SLionel Sambuc (void)BIO_flush(cb->arg);
339ebfedea0SLionel Sambuc # ifdef LINT
340ebfedea0SLionel Sambuc p = n;
341ebfedea0SLionel Sambuc # endif
342ebfedea0SLionel Sambuc return 1;
343ebfedea0SLionel Sambuc }
344ebfedea0SLionel Sambuc #else /* !OPENSSL_NO_RSA */
345ebfedea0SLionel Sambuc
346ebfedea0SLionel Sambuc # if PEDANTIC
347ebfedea0SLionel Sambuc static void *dummy = &dummy;
348ebfedea0SLionel Sambuc # endif
349ebfedea0SLionel Sambuc
350ebfedea0SLionel Sambuc #endif
351