m_ecdsa.c revision 160814
1160814Ssimon/* crypto/evp/m_ecdsa.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/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 56160814Ssimon * All rights reserved. 57160814Ssimon * 58160814Ssimon * This package is an SSL implementation written 59160814Ssimon * by Eric Young (eay@cryptsoft.com). 60160814Ssimon * The implementation was written so as to conform with Netscapes SSL. 61160814Ssimon * 62160814Ssimon * This library is free for commercial and non-commercial use as long as 63160814Ssimon * the following conditions are aheared to. The following conditions 64160814Ssimon * apply to all code found in this distribution, be it the RC4, RSA, 65160814Ssimon * lhash, DES, etc., code; not just the SSL code. The SSL documentation 66160814Ssimon * included with this distribution is covered by the same copyright terms 67160814Ssimon * except that the holder is Tim Hudson (tjh@cryptsoft.com). 68160814Ssimon * 69160814Ssimon * Copyright remains Eric Young's, and as such any Copyright notices in 70160814Ssimon * the code are not to be removed. 71160814Ssimon * If this package is used in a product, Eric Young should be given attribution 72160814Ssimon * as the author of the parts of the library used. 73160814Ssimon * This can be in the form of a textual message at program startup or 74160814Ssimon * in documentation (online or textual) provided with the package. 75160814Ssimon * 76160814Ssimon * Redistribution and use in source and binary forms, with or without 77160814Ssimon * modification, are permitted provided that the following conditions 78160814Ssimon * are met: 79160814Ssimon * 1. Redistributions of source code must retain the copyright 80160814Ssimon * notice, this list of conditions and the following disclaimer. 81160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright 82160814Ssimon * notice, this list of conditions and the following disclaimer in the 83160814Ssimon * documentation and/or other materials provided with the distribution. 84160814Ssimon * 3. All advertising materials mentioning features or use of this software 85160814Ssimon * must display the following acknowledgement: 86160814Ssimon * "This product includes cryptographic software written by 87160814Ssimon * Eric Young (eay@cryptsoft.com)" 88160814Ssimon * The word 'cryptographic' can be left out if the rouines from the library 89160814Ssimon * being used are not cryptographic related :-). 90160814Ssimon * 4. If you include any Windows specific code (or a derivative thereof) from 91160814Ssimon * the apps directory (application code) you must include an acknowledgement: 92160814Ssimon * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 93160814Ssimon * 94160814Ssimon * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 95160814Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 96160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 97160814Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 98160814Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 99160814Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 100160814Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 101160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 102160814Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 103160814Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 104160814Ssimon * SUCH DAMAGE. 105160814Ssimon * 106160814Ssimon * The licence and distribution terms for any publically available version or 107160814Ssimon * derivative of this code cannot be changed. i.e. this code cannot simply be 108160814Ssimon * copied and put under another distribution licence 109160814Ssimon * [including the GNU Public Licence.] 110160814Ssimon */ 111160814Ssimon 112160814Ssimon#include <stdio.h> 113160814Ssimon#include "cryptlib.h" 114160814Ssimon#include <openssl/evp.h> 115160814Ssimon#include <openssl/objects.h> 116160814Ssimon#include <openssl/x509.h> 117160814Ssimon 118160814Ssimon#ifndef OPENSSL_NO_SHA 119160814Ssimonstatic int init(EVP_MD_CTX *ctx) 120160814Ssimon { return SHA1_Init(ctx->md_data); } 121160814Ssimon 122160814Ssimonstatic int update(EVP_MD_CTX *ctx,const void *data,size_t count) 123160814Ssimon { return SHA1_Update(ctx->md_data,data,count); } 124160814Ssimon 125160814Ssimonstatic int final(EVP_MD_CTX *ctx,unsigned char *md) 126160814Ssimon { return SHA1_Final(md,ctx->md_data); } 127160814Ssimon 128160814Ssimonstatic const EVP_MD ecdsa_md= 129160814Ssimon { 130160814Ssimon NID_ecdsa_with_SHA1, 131160814Ssimon NID_ecdsa_with_SHA1, 132160814Ssimon SHA_DIGEST_LENGTH, 133160814Ssimon 0, 134160814Ssimon init, 135160814Ssimon update, 136160814Ssimon final, 137160814Ssimon NULL, 138160814Ssimon NULL, 139160814Ssimon EVP_PKEY_ECDSA_method, 140160814Ssimon SHA_CBLOCK, 141160814Ssimon sizeof(EVP_MD *)+sizeof(SHA_CTX), 142160814Ssimon }; 143160814Ssimon 144160814Ssimonconst EVP_MD *EVP_ecdsa(void) 145160814Ssimon { 146160814Ssimon return(&ecdsa_md); 147160814Ssimon } 148160814Ssimon#endif 149