1219181Snwhitehorn/* crypto/dsa/dsa_lib.c */ 2219181Snwhitehorn/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 3219181Snwhitehorn * All rights reserved. 4219181Snwhitehorn * 5219181Snwhitehorn * This package is an SSL implementation written 6219181Snwhitehorn * by Eric Young (eay@cryptsoft.com). 7219181Snwhitehorn * The implementation was written so as to conform with Netscapes SSL. 8219181Snwhitehorn * 9219181Snwhitehorn * This library is free for commercial and non-commercial use as long as 10219181Snwhitehorn * the following conditions are aheared to. The following conditions 11231758Snyan * apply to all code found in this distribution, be it the RC4, RSA, 12231758Snyan * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13225637Snwhitehorn * included with this distribution is covered by the same copyright terms 14225637Snwhitehorn * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15232427Snwhitehorn * 16231758Snyan * Copyright remains Eric Young's, and as such any Copyright notices in 17231758Snyan * the code are not to be removed. 18231758Snyan * If this package is used in a product, Eric Young should be given attribution 19231758Snyan * as the author of the parts of the library used. 20231758Snyan * This can be in the form of a textual message at program startup or 21232427Snwhitehorn * in documentation (online or textual) provided with the package. 22232427Snwhitehorn * 23232427Snwhitehorn * Redistribution and use in source and binary forms, with or without 24232427Snwhitehorn * modification, are permitted provided that the following conditions 25232427Snwhitehorn * are met: 26232427Snwhitehorn * 1. Redistributions of source code must retain the copyright 27232427Snwhitehorn * notice, this list of conditions and the following disclaimer. 28232427Snwhitehorn * 2. Redistributions in binary form must reproduce the above copyright 29232427Snwhitehorn * notice, this list of conditions and the following disclaimer in the 30225637Snwhitehorn * documentation and/or other materials provided with the distribution. 31225637Snwhitehorn * 3. All advertising materials mentioning features or use of this software 32225637Snwhitehorn * must display the following acknowledgement: 33225637Snwhitehorn * "This product includes cryptographic software written by 34225637Snwhitehorn * Eric Young (eay@cryptsoft.com)" 35225637Snwhitehorn * The word 'cryptographic' can be left out if the rouines from the library 36225637Snwhitehorn * being used are not cryptographic related :-). 37225637Snwhitehorn * 4. If you include any Windows specific code (or a derivative thereof) from 38225637Snwhitehorn * the apps directory (application code) you must include an acknowledgement: 39225637Snwhitehorn * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40231758Snyan * 41225637Snwhitehorn * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42225637Snwhitehorn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43225637Snwhitehorn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44225637Snwhitehorn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45225637Snwhitehorn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46225637Snwhitehorn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47219181Snwhitehorn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48219181Snwhitehorn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49219181Snwhitehorn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50219181Snwhitehorn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51219181Snwhitehorn * SUCH DAMAGE. 52225637Snwhitehorn * 53225637Snwhitehorn * The licence and distribution terms for any publically available version or 54225637Snwhitehorn * derivative of this code cannot be changed. i.e. this code cannot simply be 55225637Snwhitehorn * copied and put under another distribution licence 56225637Snwhitehorn * [including the GNU Public Licence.] 57225637Snwhitehorn */ 58219181Snwhitehorn 59219181Snwhitehorn/* Original version from Steven Schoch <schoch@sheba.arc.nasa.gov> */ 60220500Snwhitehorn 61220500Snwhitehorn#include <stdio.h> 62220500Snwhitehorn#include "cryptlib.h" 63220500Snwhitehorn#include <openssl/bn.h> 64220500Snwhitehorn#include <openssl/dsa.h> 65219181Snwhitehorn#include <openssl/asn1.h> 66219181Snwhitehorn#ifndef OPENSSL_NO_ENGINE 67219181Snwhitehorn# include <openssl/engine.h> 68219181Snwhitehorn#endif 69219181Snwhitehorn#ifndef OPENSSL_NO_DH 70219181Snwhitehorn# include <openssl/dh.h> 71219181Snwhitehorn#endif 72219181Snwhitehorn 73219181SnwhitehornDSA_SIG *DSA_SIG_new(void) 74219181Snwhitehorn{ 75219181Snwhitehorn DSA_SIG *sig; 76219181Snwhitehorn sig = OPENSSL_malloc(sizeof(DSA_SIG)); 77 if (!sig) 78 return NULL; 79 sig->r = NULL; 80 sig->s = NULL; 81 return sig; 82} 83 84void DSA_SIG_free(DSA_SIG *sig) 85{ 86 if (sig) { 87 if (sig->r) 88 BN_free(sig->r); 89 if (sig->s) 90 BN_free(sig->s); 91 OPENSSL_free(sig); 92 } 93} 94