* tar xzf utvpn-src-unix-v101-7101-public-2010.06.27.tar.gz
[lab.git] / utvpn / utvpn-unix-v101-7101-public / src / Mayaqua / openssl / ecdsa.h
diff --git a/utvpn/utvpn-unix-v101-7101-public/src/Mayaqua/openssl/ecdsa.h b/utvpn/utvpn-unix-v101-7101-public/src/Mayaqua/openssl/ecdsa.h
new file mode 100644 (file)
index 0000000..749d332
--- /dev/null
@@ -0,0 +1,270 @@
+/* crypto/ecdsa/ecdsa.h */\r
+/**\r
+ * \file   crypto/ecdsa/ecdsa.h Include file for the OpenSSL ECDSA functions\r
+ * \author Written by Nils Larsch for the OpenSSL project\r
+ */\r
+/* ====================================================================\r
+ * Copyright (c) 2000-2003 The OpenSSL Project.  All rights reserved.\r
+ *\r
+ * Redistribution and use in source and binary forms, with or without\r
+ * modification, are permitted provided that the following conditions\r
+ * are met:\r
+ *\r
+ * 1. Redistributions of source code must retain the above copyright\r
+ *    notice, this list of conditions and the following disclaimer. \r
+ *\r
+ * 2. Redistributions in binary form must reproduce the above copyright\r
+ *    notice, this list of conditions and the following disclaimer in\r
+ *    the documentation and/or other materials provided with the\r
+ *    distribution.\r
+ *\r
+ * 3. All advertising materials mentioning features or use of this\r
+ *    software must display the following acknowledgment:\r
+ *    "This product includes software developed by the OpenSSL Project\r
+ *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"\r
+ *\r
+ * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to\r
+ *    endorse or promote products derived from this software without\r
+ *    prior written permission. For written permission, please contact\r
+ *    licensing@OpenSSL.org.\r
+ *\r
+ * 5. Products derived from this software may not be called "OpenSSL"\r
+ *    nor may "OpenSSL" appear in their names without prior written\r
+ *    permission of the OpenSSL Project.\r
+ *\r
+ * 6. Redistributions of any form whatsoever must retain the following\r
+ *    acknowledgment:\r
+ *    "This product includes software developed by the OpenSSL Project\r
+ *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"\r
+ *\r
+ * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\r
+ * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR\r
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\r
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\r
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\r
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\r
+ * OF THE POSSIBILITY OF SUCH DAMAGE.\r
+ * ====================================================================\r
+ *\r
+ * This product includes cryptographic software written by Eric Young\r
+ * (eay@cryptsoft.com).  This product includes software written by Tim\r
+ * Hudson (tjh@cryptsoft.com).\r
+ *\r
+ */\r
+#ifndef HEADER_ECDSA_H\r
+#define HEADER_ECDSA_H\r
+\r
+#include <openssl/opensslconf.h>\r
+\r
+#ifdef OPENSSL_NO_ECDSA\r
+#error ECDSA is disabled.\r
+#endif\r
+\r
+#include <openssl/ec.h>\r
+#include <openssl/ossl_typ.h>\r
+#ifndef OPENSSL_NO_DEPRECATED\r
+#include <openssl/bn.h>\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+typedef struct ECDSA_SIG_st\r
+       {\r
+       BIGNUM *r;\r
+       BIGNUM *s;\r
+       } ECDSA_SIG;\r
+\r
+/** ECDSA_SIG *ECDSA_SIG_new(void)\r
+ * allocates and initialize a ECDSA_SIG structure\r
+ * \return pointer to a ECDSA_SIG structure or NULL if an error occurred\r
+ */\r
+ECDSA_SIG *ECDSA_SIG_new(void);\r
+\r
+/** ECDSA_SIG_free\r
+ * frees a ECDSA_SIG structure\r
+ * \param a pointer to the ECDSA_SIG structure\r
+ */\r
+void     ECDSA_SIG_free(ECDSA_SIG *a);\r
+\r
+/** i2d_ECDSA_SIG\r
+ * DER encode content of ECDSA_SIG object (note: this function modifies *pp\r
+ * (*pp += length of the DER encoded signature)).\r
+ * \param a  pointer to the ECDSA_SIG object\r
+ * \param pp pointer to a unsigned char pointer for the output or NULL\r
+ * \return the length of the DER encoded ECDSA_SIG object or 0 \r
+ */\r
+int      i2d_ECDSA_SIG(const ECDSA_SIG *a, unsigned char **pp);\r
+\r
+/** d2i_ECDSA_SIG\r
+ * decodes a DER encoded ECDSA signature (note: this function changes *pp\r
+ * (*pp += len)). \r
+ * \param v pointer to ECDSA_SIG pointer (may be NULL)\r
+ * \param pp buffer with the DER encoded signature\r
+ * \param len bufferlength\r
+ * \return pointer to the decoded ECDSA_SIG structure (or NULL)\r
+ */\r
+ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **v, const unsigned char **pp, long len);\r
+\r
+/** ECDSA_do_sign\r
+ * computes the ECDSA signature of the given hash value using\r
+ * the supplied private key and returns the created signature.\r
+ * \param dgst pointer to the hash value\r
+ * \param dgst_len length of the hash value\r
+ * \param eckey pointer to the EC_KEY object containing a private EC key\r
+ * \return pointer to a ECDSA_SIG structure or NULL\r
+ */\r
+ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst,int dgst_len,EC_KEY *eckey);\r
+\r
+/** ECDSA_do_sign_ex\r
+ * computes ECDSA signature of a given hash value using the supplied\r
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\r
+ * \param dgst pointer to the hash value to sign\r
+ * \param dgstlen length of the hash value\r
+ * \param kinv optional pointer to a pre-computed inverse k\r
+ * \param rp optional pointer to the pre-computed rp value (see \r
+ *        ECDSA_sign_setup\r
+ * \param eckey pointer to the EC_KEY object containing a private EC key\r
+ * \return pointer to a ECDSA_SIG structure or NULL\r
+ */\r
+ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, \r
+               const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey);\r
+\r
+/** ECDSA_do_verify\r
+ * verifies that the supplied signature is a valid ECDSA\r
+ * signature of the supplied hash value using the supplied public key.\r
+ * \param dgst pointer to the hash value\r
+ * \param dgst_len length of the hash value\r
+ * \param sig  pointer to the ECDSA_SIG structure\r
+ * \param eckey pointer to the EC_KEY object containing a public EC key\r
+ * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error\r
+ */\r
+int      ECDSA_do_verify(const unsigned char *dgst, int dgst_len,\r
+               const ECDSA_SIG *sig, EC_KEY* eckey);\r
+\r
+const ECDSA_METHOD *ECDSA_OpenSSL(void);\r
+\r
+/** ECDSA_set_default_method\r
+ * sets the default ECDSA method\r
+ * \param meth the new default ECDSA_METHOD\r
+ */\r
+void     ECDSA_set_default_method(const ECDSA_METHOD *meth);\r
+\r
+/** ECDSA_get_default_method\r
+ * returns the default ECDSA method\r
+ * \return pointer to ECDSA_METHOD structure containing the default method\r
+ */\r
+const ECDSA_METHOD *ECDSA_get_default_method(void);\r
+\r
+/** ECDSA_set_method\r
+ * sets method to be used for the ECDSA operations\r
+ * \param eckey pointer to the EC_KEY object\r
+ * \param meth  pointer to the new method\r
+ * \return 1 on success and 0 otherwise \r
+ */\r
+int      ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth);\r
+\r
+/** ECDSA_size\r
+ * returns the maximum length of the DER encoded signature\r
+ * \param  eckey pointer to a EC_KEY object\r
+ * \return numbers of bytes required for the DER encoded signature\r
+ */\r
+int      ECDSA_size(const EC_KEY *eckey);\r
+\r
+/** ECDSA_sign_setup\r
+ * precompute parts of the signing operation. \r
+ * \param eckey pointer to the EC_KEY object containing a private EC key\r
+ * \param ctx  pointer to a BN_CTX object (may be NULL)\r
+ * \param kinv pointer to a BIGNUM pointer for the inverse of k\r
+ * \param rp   pointer to a BIGNUM pointer for x coordinate of k * generator\r
+ * \return 1 on success and 0 otherwise\r
+ */\r
+int      ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, \r
+               BIGNUM **rp);\r
+\r
+/** ECDSA_sign\r
+ * computes ECDSA signature of a given hash value using the supplied\r
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\r
+ * \param type this parameter is ignored\r
+ * \param dgst pointer to the hash value to sign\r
+ * \param dgstlen length of the hash value\r
+ * \param sig buffer to hold the DER encoded signature\r
+ * \param siglen pointer to the length of the returned signature\r
+ * \param eckey pointer to the EC_KEY object containing a private EC key\r
+ * \return 1 on success and 0 otherwise\r
+ */\r
+int      ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, \r
+               unsigned char *sig, unsigned int *siglen, EC_KEY *eckey);\r
+\r
+\r
+/** ECDSA_sign_ex\r
+ * computes ECDSA signature of a given hash value using the supplied\r
+ * private key (note: sig must point to ECDSA_size(eckey) bytes of memory).\r
+ * \param type this parameter is ignored\r
+ * \param dgst pointer to the hash value to sign\r
+ * \param dgstlen length of the hash value\r
+ * \param sig buffer to hold the DER encoded signature\r
+ * \param siglen pointer to the length of the returned signature\r
+ * \param kinv optional pointer to a pre-computed inverse k\r
+ * \param rp optional pointer to the pre-computed rp value (see \r
+ *        ECDSA_sign_setup\r
+ * \param eckey pointer to the EC_KEY object containing a private EC key\r
+ * \return 1 on success and 0 otherwise\r
+ */\r
+int      ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, \r
+               unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv,\r
+               const BIGNUM *rp, EC_KEY *eckey);\r
+\r
+/** ECDSA_verify\r
+ * verifies that the given signature is valid ECDSA signature\r
+ * of the supplied hash value using the specified public key.\r
+ * \param type this parameter is ignored\r
+ * \param dgst pointer to the hash value \r
+ * \param dgstlen length of the hash value\r
+ * \param sig  pointer to the DER encoded signature\r
+ * \param siglen length of the DER encoded signature\r
+ * \param eckey pointer to the EC_KEY object containing a public EC key\r
+ * \return 1 if the signature is valid, 0 if the signature is invalid and -1 on error\r
+ */\r
+int      ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, \r
+               const unsigned char *sig, int siglen, EC_KEY *eckey);\r
+\r
+/* the standard ex_data functions */\r
+int      ECDSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new \r
+               *new_func, CRYPTO_EX_dup *dup_func, CRYPTO_EX_free *free_func);\r
+int      ECDSA_set_ex_data(EC_KEY *d, int idx, void *arg);\r
+void     *ECDSA_get_ex_data(EC_KEY *d, int idx);\r
+\r
+\r
+/* BEGIN ERROR CODES */\r
+/* The following lines are auto generated by the script mkerr.pl. Any changes\r
+ * made after this point may be overwritten when the script is next run.\r
+ */\r
+void ERR_load_ECDSA_strings(void);\r
+\r
+/* Error codes for the ECDSA functions. */\r
+\r
+/* Function codes. */\r
+#define ECDSA_F_ECDSA_DATA_NEW_METHOD                   100\r
+#define ECDSA_F_ECDSA_DO_SIGN                           101\r
+#define ECDSA_F_ECDSA_DO_VERIFY                                 102\r
+#define ECDSA_F_ECDSA_SIGN_SETUP                        103\r
+\r
+/* Reason codes. */\r
+#define ECDSA_R_BAD_SIGNATURE                           100\r
+#define ECDSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE             101\r
+#define ECDSA_R_ERR_EC_LIB                              102\r
+#define ECDSA_R_MISSING_PARAMETERS                      103\r
+#define ECDSA_R_RANDOM_NUMBER_GENERATION_FAILED                 104\r
+#define ECDSA_R_SIGNATURE_MALLOC_FAILED                         105\r
+\r
+#ifdef  __cplusplus\r
+}\r
+#endif\r
+#endif\r