5c8f9af2b9913c6d619e3253414a64f31e053b16
[openssl.git] / crypto / dsa / dsa_depr.c
1 /*
2  * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License 2.0 (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 /*
11  * This file contains deprecated function(s) that are now wrappers to the new
12  * version(s).
13  */
14
15 /*
16  * DSA low level APIs are deprecated for public use, but still ok for
17  * internal use.
18  */
19 #include "internal/deprecated.h"
20
21 /*
22  * Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186,
23  * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in FIPS PUB
24  * 180-1)
25  */
26 #define xxxHASH    EVP_sha1()
27
28 #include <openssl/opensslconf.h>
29 #ifdef OPENSSL_NO_DEPRECATED_0_9_8
30 NON_EMPTY_TRANSLATION_UNIT
31 #else
32
33 # include <stdio.h>
34 # include <time.h>
35 # include "internal/cryptlib.h"
36 # include <openssl/evp.h>
37 # include <openssl/bn.h>
38 # include <openssl/dsa.h>
39 # include <openssl/sha.h>
40
41 DSA *DSA_generate_parameters(int bits,
42                              unsigned char *seed_in, int seed_len,
43                              int *counter_ret, unsigned long *h_ret,
44                              void (*callback) (int, int, void *),
45                              void *cb_arg)
46 {
47     BN_GENCB *cb;
48     DSA *ret;
49
50     if ((ret = DSA_new()) == NULL)
51         return NULL;
52     cb = BN_GENCB_new();
53     if (cb == NULL)
54         goto err;
55
56     BN_GENCB_set_old(cb, callback, cb_arg);
57
58     if (DSA_generate_parameters_ex(ret, bits, seed_in, seed_len,
59                                    counter_ret, h_ret, cb)) {
60         BN_GENCB_free(cb);
61         return ret;
62     }
63     BN_GENCB_free(cb);
64 err:
65     DSA_free(ret);
66     return NULL;
67 }
68 #endif