1160814Ssimon/* crypto/dsa/dsa_depr.c */ 2160814Ssimon/* ==================================================================== 3160814Ssimon * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4160814Ssimon * 5160814Ssimon * Redistribution and use in source and binary forms, with or without 6160814Ssimon * modification, are permitted provided that the following conditions 7160814Ssimon * are met: 8160814Ssimon * 9160814Ssimon * 1. Redistributions of source code must retain the above copyright 10160814Ssimon * notice, this list of conditions and the following disclaimer. 11160814Ssimon * 12160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 13160814Ssimon * notice, this list of conditions and the following disclaimer in 14160814Ssimon * the documentation and/or other materials provided with the 15160814Ssimon * distribution. 16160814Ssimon * 17160814Ssimon * 3. All advertising materials mentioning features or use of this 18160814Ssimon * software must display the following acknowledgment: 19160814Ssimon * "This product includes software developed by the OpenSSL Project 20160814Ssimon * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21160814Ssimon * 22160814Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23160814Ssimon * endorse or promote products derived from this software without 24160814Ssimon * prior written permission. For written permission, please contact 25160814Ssimon * openssl-core@openssl.org. 26160814Ssimon * 27160814Ssimon * 5. Products derived from this software may not be called "OpenSSL" 28160814Ssimon * nor may "OpenSSL" appear in their names without prior written 29160814Ssimon * permission of the OpenSSL Project. 30160814Ssimon * 31160814Ssimon * 6. Redistributions of any form whatsoever must retain the following 32160814Ssimon * acknowledgment: 33160814Ssimon * "This product includes software developed by the OpenSSL Project 34160814Ssimon * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35160814Ssimon * 36160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37160814Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39160814Ssimon * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40160814Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41160814Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42160814Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43160814Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45160814Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46160814Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47160814Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE. 48160814Ssimon * ==================================================================== 49160814Ssimon * 50160814Ssimon * This product includes cryptographic software written by Eric Young 51160814Ssimon * (eay@cryptsoft.com). This product includes software written by Tim 52160814Ssimon * Hudson (tjh@cryptsoft.com). 53160814Ssimon * 54160814Ssimon */ 55160814Ssimon 56160814Ssimon/* This file contains deprecated function(s) that are now wrappers to the new 57160814Ssimon * version(s). */ 58160814Ssimon 59160814Ssimon#undef GENUINE_DSA 60160814Ssimon 61160814Ssimon#ifdef GENUINE_DSA 62160814Ssimon/* Parameter generation follows the original release of FIPS PUB 186, 63160814Ssimon * Appendix 2.2 (i.e. use SHA as defined in FIPS PUB 180) */ 64160814Ssimon#define HASH EVP_sha() 65160814Ssimon#else 66160814Ssimon/* Parameter generation follows the updated Appendix 2.2 for FIPS PUB 186, 67160814Ssimon * also Appendix 2.2 of FIPS PUB 186-1 (i.e. use SHA as defined in 68160814Ssimon * FIPS PUB 180-1) */ 69160814Ssimon#define HASH EVP_sha1() 70160814Ssimon#endif 71160814Ssimon 72160814Ssimonstatic void *dummy=&dummy; 73160814Ssimon 74160814Ssimon#ifndef OPENSSL_NO_SHA 75160814Ssimon 76160814Ssimon#include <stdio.h> 77160814Ssimon#include <time.h> 78160814Ssimon#include "cryptlib.h" 79160814Ssimon#include <openssl/evp.h> 80160814Ssimon#include <openssl/bn.h> 81160814Ssimon#include <openssl/dsa.h> 82160814Ssimon#include <openssl/rand.h> 83160814Ssimon#include <openssl/sha.h> 84160814Ssimon 85160814Ssimon#ifndef OPENSSL_NO_DEPRECATED 86160814SsimonDSA *DSA_generate_parameters(int bits, 87160814Ssimon unsigned char *seed_in, int seed_len, 88160814Ssimon int *counter_ret, unsigned long *h_ret, 89160814Ssimon void (*callback)(int, int, void *), 90160814Ssimon void *cb_arg) 91160814Ssimon { 92160814Ssimon BN_GENCB cb; 93160814Ssimon DSA *ret; 94160814Ssimon 95160814Ssimon if ((ret=DSA_new()) == NULL) return NULL; 96160814Ssimon 97160814Ssimon BN_GENCB_set_old(&cb, callback, cb_arg); 98160814Ssimon 99160814Ssimon if(DSA_generate_parameters_ex(ret, bits, seed_in, seed_len, 100160814Ssimon counter_ret, h_ret, &cb)) 101160814Ssimon return ret; 102160814Ssimon DSA_free(ret); 103160814Ssimon return NULL; 104160814Ssimon } 105160814Ssimon#endif 106160814Ssimon#endif 107