1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant/* crypto/evp/m_ecdsa.c */ 2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant/* ==================================================================== 3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. 4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant * Redistribution and use in source and binary forms, with or without 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant * modification, are permitted provided that the following conditions 7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * are met: 8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 1. Redistributions of source code must retain the above copyright 10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * notice, this list of conditions and the following disclaimer. 11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 12bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 2. Redistributions in binary form must reproduce the above copyright 13bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * notice, this list of conditions and the following disclaimer in 14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * the documentation and/or other materials provided with the 15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * distribution. 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 3. All advertising materials mentioning features or use of this 18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * software must display the following acknowledgment: 19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * "This product includes software developed by the OpenSSL Project 20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * for use in the OpenSSL Toolkit. (http://www.openssl.org/)" 21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to 23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * endorse or promote products derived from this software without 24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * prior written permission. For written permission, please contact 25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * openssl-core@openssl.org. 26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 5. Products derived from this software may not be called "OpenSSL" 28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * nor may "OpenSSL" appear in their names without prior written 29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * permission of the OpenSSL Project. 30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 31f8f852138f86e4588916021e1afedfcab25298c0Howard Hinnant * 6. Redistributions of any form whatsoever must retain the following 32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * acknowledgment: 33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * "This product includes software developed by the OpenSSL Project 34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * for use in the OpenSSL Toolkit (http://www.openssl.org/)" 35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY 37f8f852138f86e4588916021e1afedfcab25298c0Howard Hinnant * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR 40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * OF THE POSSIBILITY OF SUCH DAMAGE. 48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * ==================================================================== 49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * This product includes cryptographic software written by Eric Young 51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * (eay@cryptsoft.com). This product includes software written by Tim 52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * Hudson (tjh@cryptsoft.com). 53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant */ 55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * All rights reserved. 57bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 58bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * This package is an SSL implementation written 59bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * by Eric Young (eay@cryptsoft.com). 60bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * The implementation was written so as to conform with Netscapes SSL. 61bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * This library is free for commercial and non-commercial use as long as 63bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * the following conditions are aheared to. The following conditions 64bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * apply to all code found in this distribution, be it the RC4, RSA, 65bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * lhash, DES, etc., code; not just the SSL code. The SSL documentation 66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * included with this distribution is covered by the same copyright terms 67bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * except that the holder is Tim Hudson (tjh@cryptsoft.com). 688eba41324c5519557e76092fe8fe98ebb8aa5f5bDaniel Dunbar * 69bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * Copyright remains Eric Young's, and as such any Copyright notices in 70bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * the code are not to be removed. 71bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * If this package is used in a product, Eric Young should be given attribution 72bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * as the author of the parts of the library used. 73bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * This can be in the form of a textual message at program startup or 74bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * in documentation (online or textual) provided with the package. 75bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 76bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * Redistribution and use in source and binary forms, with or without 77bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * modification, are permitted provided that the following conditions 78bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * are met: 79bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 1. Redistributions of source code must retain the copyright 80bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * notice, this list of conditions and the following disclaimer. 81bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 2. Redistributions in binary form must reproduce the above copyright 82bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * notice, this list of conditions and the following disclaimer in the 83bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * documentation and/or other materials provided with the distribution. 84bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 3. All advertising materials mentioning features or use of this software 85bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * must display the following acknowledgement: 86bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * "This product includes cryptographic software written by 87bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * Eric Young (eay@cryptsoft.com)" 88bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * The word 'cryptographic' can be left out if the rouines from the library 89bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * being used are not cryptographic related :-). 90bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 4. If you include any Windows specific code (or a derivative thereof) from 91bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * the apps directory (application code) you must include an acknowledgement: 92bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 93bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * 94bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 95bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 96bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 97bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 98bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 99bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 100bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 104 * SUCH DAMAGE. 105 * 106 * The licence and distribution terms for any publically available version or 107 * derivative of this code cannot be changed. i.e. this code cannot simply be 108 * copied and put under another distribution licence 109 * [including the GNU Public Licence.] 110 */ 111 112#include <stdio.h> 113#include "cryptlib.h" 114#include <openssl/evp.h> 115#include <openssl/objects.h> 116#include <openssl/x509.h> 117 118#ifndef OPENSSL_NO_SHA 119#ifndef OPENSSL_FIPS 120 121static int init(EVP_MD_CTX *ctx) 122 { return SHA1_Init(ctx->md_data); } 123 124static int update(EVP_MD_CTX *ctx,const void *data,size_t count) 125 { return SHA1_Update(ctx->md_data,data,count); } 126 127static int final(EVP_MD_CTX *ctx,unsigned char *md) 128 { return SHA1_Final(md,ctx->md_data); } 129 130static const EVP_MD ecdsa_md= 131 { 132 NID_ecdsa_with_SHA1, 133 NID_ecdsa_with_SHA1, 134 SHA_DIGEST_LENGTH, 135 EVP_MD_FLAG_PKEY_DIGEST, 136 init, 137 update, 138 final, 139 NULL, 140 NULL, 141 EVP_PKEY_ECDSA_method, 142 SHA_CBLOCK, 143 sizeof(EVP_MD *)+sizeof(SHA_CTX), 144 }; 145 146const EVP_MD *EVP_ecdsa(void) 147 { 148 return(&ecdsa_md); 149 } 150#endif 151#endif 152