~ubuntu-branches/ubuntu/maverick/openssl/maverick

« back to all changes in this revision

Viewing changes to apps/dhparam.c

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2005-12-13 21:37:42 UTC
  • mto: (11.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20051213213742-d0ydaylf80l16bj1
Tags: upstream-0.9.8a
ImportĀ upstreamĀ versionĀ 0.9.8a

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
 *
110
110
 */
111
111
 
 
112
#include <openssl/opensslconf.h>        /* for OPENSSL_NO_DH */
112
113
#ifndef OPENSSL_NO_DH
113
114
#include <stdio.h>
114
115
#include <stdlib.h>
142
143
 * -C
143
144
 */
144
145
 
145
 
static void MS_CALLBACK dh_cb(int p, int n, void *arg);
 
146
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb);
146
147
 
147
148
int MAIN(int, char **);
148
149
 
294
295
 
295
296
        if(num) {
296
297
 
 
298
                BN_GENCB cb;
 
299
                BN_GENCB_set(&cb, dh_cb, bio_err);
297
300
                if (!app_RAND_load_file(NULL, bio_err, 1) && inrand == NULL)
298
301
                        {
299
302
                        BIO_printf(bio_err,"warning, not much extra random data, consider using the -rand option\n");
305
308
#ifndef OPENSSL_NO_DSA
306
309
                if (dsaparam)
307
310
                        {
308
 
                        DSA *dsa;
 
311
                        DSA *dsa = DSA_new();
309
312
                        
310
313
                        BIO_printf(bio_err,"Generating DSA parameters, %d bit long prime\n",num);
311
 
                        dsa = DSA_generate_parameters(num, NULL, 0, NULL, NULL, dh_cb, bio_err);
312
 
                        if (dsa == NULL)
 
314
                        if(!dsa || !DSA_generate_parameters_ex(dsa, num,
 
315
                                                NULL, 0, NULL, NULL, &cb))
313
316
                                {
 
317
                                if(dsa) DSA_free(dsa);
314
318
                                ERR_print_errors(bio_err);
315
319
                                goto end;
316
320
                                }
326
330
                else
327
331
#endif
328
332
                        {
 
333
                        dh = DH_new();
329
334
                        BIO_printf(bio_err,"Generating DH parameters, %d bit long safe prime, generator %d\n",num,g);
330
335
                        BIO_printf(bio_err,"This is going to take a long time\n");
331
 
                        dh=DH_generate_parameters(num,g,dh_cb,bio_err);
332
 
                        
333
 
                        if (dh == NULL)
 
336
                        if(!dh || !DH_generate_parameters_ex(dh, num, g, &cb))
334
337
                                {
 
338
                                if(dh) DH_free(dh);
335
339
                                ERR_print_errors(bio_err);
336
340
                                goto end;
337
341
                                }
534
538
        }
535
539
 
536
540
/* dh_cb is identical to dsa_cb in apps/dsaparam.c */
537
 
static void MS_CALLBACK dh_cb(int p, int n, void *arg)
 
541
static int MS_CALLBACK dh_cb(int p, int n, BN_GENCB *cb)
538
542
        {
539
543
        char c='*';
540
544
 
542
546
        if (p == 1) c='+';
543
547
        if (p == 2) c='*';
544
548
        if (p == 3) c='\n';
545
 
        BIO_write((BIO *)arg,&c,1);
546
 
        (void)BIO_flush((BIO *)arg);
 
549
        BIO_write(cb->arg,&c,1);
 
550
        (void)BIO_flush(cb->arg);
547
551
#ifdef LINT
548
552
        p=n;
549
553
#endif
 
554
        return 1;
550
555
        }
551
556
 
552
557
#endif