1160814Ssimon/* crypto/ecdh/ecdh.h */
2160814Ssimon/* ====================================================================
3160814Ssimon * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED.
4160814Ssimon *
5160814Ssimon * The Elliptic Curve Public-Key Crypto Library (ECC Code) included
6160814Ssimon * herein is developed by SUN MICROSYSTEMS, INC., and is contributed
7160814Ssimon * to the OpenSSL project.
8160814Ssimon *
9160814Ssimon * The ECC Code is licensed pursuant to the OpenSSL open source
10160814Ssimon * license provided below.
11160814Ssimon *
12160814Ssimon * The ECDH software is originally written by Douglas Stebila of
13160814Ssimon * Sun Microsystems Laboratories.
14160814Ssimon *
15160814Ssimon */
16160814Ssimon/* ====================================================================
17160814Ssimon * Copyright (c) 2000-2002 The OpenSSL Project.  All rights reserved.
18160814Ssimon *
19160814Ssimon * Redistribution and use in source and binary forms, with or without
20160814Ssimon * modification, are permitted provided that the following conditions
21160814Ssimon * are met:
22160814Ssimon *
23160814Ssimon * 1. Redistributions of source code must retain the above copyright
24280304Sjkim *    notice, this list of conditions and the following disclaimer.
25160814Ssimon *
26160814Ssimon * 2. Redistributions in binary form must reproduce the above copyright
27160814Ssimon *    notice, this list of conditions and the following disclaimer in
28160814Ssimon *    the documentation and/or other materials provided with the
29160814Ssimon *    distribution.
30160814Ssimon *
31160814Ssimon * 3. All advertising materials mentioning features or use of this
32160814Ssimon *    software must display the following acknowledgment:
33160814Ssimon *    "This product includes software developed by the OpenSSL Project
34160814Ssimon *    for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
35160814Ssimon *
36160814Ssimon * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
37160814Ssimon *    endorse or promote products derived from this software without
38160814Ssimon *    prior written permission. For written permission, please contact
39160814Ssimon *    licensing@OpenSSL.org.
40160814Ssimon *
41160814Ssimon * 5. Products derived from this software may not be called "OpenSSL"
42160814Ssimon *    nor may "OpenSSL" appear in their names without prior written
43160814Ssimon *    permission of the OpenSSL Project.
44160814Ssimon *
45160814Ssimon * 6. Redistributions of any form whatsoever must retain the following
46160814Ssimon *    acknowledgment:
47160814Ssimon *    "This product includes software developed by the OpenSSL Project
48160814Ssimon *    for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
49160814Ssimon *
50160814Ssimon * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
51160814Ssimon * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52160814Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
53160814Ssimon * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
54160814Ssimon * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55160814Ssimon * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
56160814Ssimon * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
57160814Ssimon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58160814Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
59160814Ssimon * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
60160814Ssimon * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
61160814Ssimon * OF THE POSSIBILITY OF SUCH DAMAGE.
62160814Ssimon * ====================================================================
63160814Ssimon *
64160814Ssimon * This product includes cryptographic software written by Eric Young
65160814Ssimon * (eay@cryptsoft.com).  This product includes software written by Tim
66160814Ssimon * Hudson (tjh@cryptsoft.com).
67160814Ssimon *
68160814Ssimon */
69160814Ssimon#ifndef HEADER_ECDH_H
70280304Sjkim# define HEADER_ECDH_H
71160814Ssimon
72280304Sjkim# include <openssl/opensslconf.h>
73160814Ssimon
74280304Sjkim# ifdef OPENSSL_NO_ECDH
75280304Sjkim#  error ECDH is disabled.
76280304Sjkim# endif
77160814Ssimon
78280304Sjkim# include <openssl/ec.h>
79280304Sjkim# include <openssl/ossl_typ.h>
80280304Sjkim# ifndef OPENSSL_NO_DEPRECATED
81280304Sjkim#  include <openssl/bn.h>
82280304Sjkim# endif
83160814Ssimon
84160814Ssimon#ifdef __cplusplus
85160814Ssimonextern "C" {
86160814Ssimon#endif
87160814Ssimon
88160814Ssimonconst ECDH_METHOD *ECDH_OpenSSL(void);
89160814Ssimon
90280304Sjkimvoid ECDH_set_default_method(const ECDH_METHOD *);
91160814Ssimonconst ECDH_METHOD *ECDH_get_default_method(void);
92280304Sjkimint ECDH_set_method(EC_KEY *, const ECDH_METHOD *);
93160814Ssimon
94280304Sjkimint ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key,
95280304Sjkim                     EC_KEY *ecdh, void *(*KDF) (const void *in, size_t inlen,
96280304Sjkim                                                 void *out, size_t *outlen));
97160814Ssimon
98280304Sjkimint ECDH_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new
99280304Sjkim                          *new_func, CRYPTO_EX_dup *dup_func,
100280304Sjkim                          CRYPTO_EX_free *free_func);
101280304Sjkimint ECDH_set_ex_data(EC_KEY *d, int idx, void *arg);
102280304Sjkimvoid *ECDH_get_ex_data(EC_KEY *d, int idx);
103160814Ssimon
104160814Ssimon/* BEGIN ERROR CODES */
105280304Sjkim/*
106280304Sjkim * The following lines are auto generated by the script mkerr.pl. Any changes
107160814Ssimon * made after this point may be overwritten when the script is next run.
108160814Ssimon */
109160814Ssimonvoid ERR_load_ECDH_strings(void);
110160814Ssimon
111160814Ssimon/* Error codes for the ECDH functions. */
112160814Ssimon
113160814Ssimon/* Function codes. */
114280304Sjkim# define ECDH_F_ECDH_CHECK                                102
115280304Sjkim# define ECDH_F_ECDH_COMPUTE_KEY                          100
116280304Sjkim# define ECDH_F_ECDH_DATA_NEW_METHOD                      101
117160814Ssimon
118160814Ssimon/* Reason codes. */
119280304Sjkim# define ECDH_R_KDF_FAILED                                102
120280304Sjkim# define ECDH_R_NON_FIPS_METHOD                           103
121280304Sjkim# define ECDH_R_NO_PRIVATE_VALUE                          100
122280304Sjkim# define ECDH_R_POINT_ARITHMETIC_FAILURE                  101
123160814Ssimon
124160814Ssimon#ifdef  __cplusplus
125160814Ssimon}
126160814Ssimon#endif
127160814Ssimon#endif
128