1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ssl/libcrypto/src/crypto/evp/m_ecdsa.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,148 @@
1.4 +/* crypto/evp/m_ecdsa.c */
1.5 +/* ====================================================================
1.6 + * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved.
1.7 + *
1.8 + * Redistribution and use in source and binary forms, with or without
1.9 + * modification, are permitted provided that the following conditions
1.10 + * are met:
1.11 + *
1.12 + * 1. Redistributions of source code must retain the above copyright
1.13 + * notice, this list of conditions and the following disclaimer.
1.14 + *
1.15 + * 2. Redistributions in binary form must reproduce the above copyright
1.16 + * notice, this list of conditions and the following disclaimer in
1.17 + * the documentation and/or other materials provided with the
1.18 + * distribution.
1.19 + *
1.20 + * 3. All advertising materials mentioning features or use of this
1.21 + * software must display the following acknowledgment:
1.22 + * "This product includes software developed by the OpenSSL Project
1.23 + * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
1.24 + *
1.25 + * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
1.26 + * endorse or promote products derived from this software without
1.27 + * prior written permission. For written permission, please contact
1.28 + * openssl-core@openssl.org.
1.29 + *
1.30 + * 5. Products derived from this software may not be called "OpenSSL"
1.31 + * nor may "OpenSSL" appear in their names without prior written
1.32 + * permission of the OpenSSL Project.
1.33 + *
1.34 + * 6. Redistributions of any form whatsoever must retain the following
1.35 + * acknowledgment:
1.36 + * "This product includes software developed by the OpenSSL Project
1.37 + * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
1.38 + *
1.39 + * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
1.40 + * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.41 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1.42 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
1.43 + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1.44 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
1.45 + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1.46 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.47 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
1.48 + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1.49 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
1.50 + * OF THE POSSIBILITY OF SUCH DAMAGE.
1.51 + * ====================================================================
1.52 + *
1.53 + * This product includes cryptographic software written by Eric Young
1.54 + * (eay@cryptsoft.com). This product includes software written by Tim
1.55 + * Hudson (tjh@cryptsoft.com).
1.56 + *
1.57 + */
1.58 +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
1.59 + * All rights reserved.
1.60 + *
1.61 + * This package is an SSL implementation written
1.62 + * by Eric Young (eay@cryptsoft.com).
1.63 + * The implementation was written so as to conform with Netscapes SSL.
1.64 + *
1.65 + * This library is free for commercial and non-commercial use as long as
1.66 + * the following conditions are aheared to. The following conditions
1.67 + * apply to all code found in this distribution, be it the RC4, RSA,
1.68 + * lhash, DES, etc., code; not just the SSL code. The SSL documentation
1.69 + * included with this distribution is covered by the same copyright terms
1.70 + * except that the holder is Tim Hudson (tjh@cryptsoft.com).
1.71 + *
1.72 + * Copyright remains Eric Young's, and as such any Copyright notices in
1.73 + * the code are not to be removed.
1.74 + * If this package is used in a product, Eric Young should be given attribution
1.75 + * as the author of the parts of the library used.
1.76 + * This can be in the form of a textual message at program startup or
1.77 + * in documentation (online or textual) provided with the package.
1.78 + *
1.79 + * Redistribution and use in source and binary forms, with or without
1.80 + * modification, are permitted provided that the following conditions
1.81 + * are met:
1.82 + * 1. Redistributions of source code must retain the copyright
1.83 + * notice, this list of conditions and the following disclaimer.
1.84 + * 2. Redistributions in binary form must reproduce the above copyright
1.85 + * notice, this list of conditions and the following disclaimer in the
1.86 + * documentation and/or other materials provided with the distribution.
1.87 + * 3. All advertising materials mentioning features or use of this software
1.88 + * must display the following acknowledgement:
1.89 + * "This product includes cryptographic software written by
1.90 + * Eric Young (eay@cryptsoft.com)"
1.91 + * The word 'cryptographic' can be left out if the rouines from the library
1.92 + * being used are not cryptographic related :-).
1.93 + * 4. If you include any Windows specific code (or a derivative thereof) from
1.94 + * the apps directory (application code) you must include an acknowledgement:
1.95 + * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
1.96 + *
1.97 + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
1.98 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.99 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1.100 + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1.101 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.102 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1.103 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
1.104 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
1.105 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
1.106 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
1.107 + * SUCH DAMAGE.
1.108 + *
1.109 + * The licence and distribution terms for any publically available version or
1.110 + * derivative of this code cannot be changed. i.e. this code cannot simply be
1.111 + * copied and put under another distribution licence
1.112 + * [including the GNU Public Licence.]
1.113 + */
1.114 +
1.115 +#include <stdio.h>
1.116 +#include "cryptlib.h"
1.117 +#include <openssl/evp.h>
1.118 +#include <openssl/objects.h>
1.119 +#include <openssl/x509.h>
1.120 +
1.121 +#ifndef OPENSSL_NO_SHA
1.122 +static int init(EVP_MD_CTX *ctx)
1.123 + { return SHA1_Init(ctx->md_data); }
1.124 +
1.125 +static int update(EVP_MD_CTX *ctx,const void *data,size_t count)
1.126 + { return SHA1_Update(ctx->md_data,data,count); }
1.127 +
1.128 +static int final(EVP_MD_CTX *ctx,unsigned char *md)
1.129 + { return SHA1_Final(md,ctx->md_data); }
1.130 +
1.131 +static const EVP_MD ecdsa_md=
1.132 + {
1.133 + NID_ecdsa_with_SHA1,
1.134 + NID_ecdsa_with_SHA1,
1.135 + SHA_DIGEST_LENGTH,
1.136 + 0,
1.137 + init,
1.138 + update,
1.139 + final,
1.140 + NULL,
1.141 + NULL,
1.142 + EVP_PKEY_ECDSA_method,
1.143 + SHA_CBLOCK,
1.144 + sizeof(EVP_MD *)+sizeof(SHA_CTX),
1.145 + };
1.146 +
1.147 +EXPORT_C const EVP_MD *EVP_ecdsa(void)
1.148 + {
1.149 + return(&ecdsa_md);
1.150 + }
1.151 +#endif