blob: ad131061cede8e8bcc99dc69125ab23eae183339 [file] [log] [blame]
Manuel Pégourié-Gonnard0bad5c22013-01-26 15:30:46 +01001/**
2 * \file ecdh.h
3 *
4 * \brief Elliptic curve Diffie-Hellman
5 *
6 * Copyright (C) 2006-2013, Brainspark B.V.
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 */
27#ifndef POLARSSL_ECDH_H
28#define POLARSSL_ECDH_H
29
30#include "polarssl/ecp.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
Manuel Pégourié-Gonnard6545ca72013-01-26 16:05:22 +010036/**
37 * \brief Generate a public key
38 *
39 * \param grp ECP group
40 * \param d Destination MPI (secret exponent)
41 * \param Q Destination point (public key)
42 * \param f_rng RNG function
43 * \param p_rng RNG parameter
44 *
45 * \return 0 if successful,
46 * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code
47 */
48int ecdh_gen_public( const ecp_group *grp, mpi *d, ecp_point *Q,
49 int (*f_rng)(void *, unsigned char *, size_t),
50 void *p_rng );
51
52/**
53 * \brief Compute shared secret
54 *
55 * \param grp ECP group
56 * \param z Destination MPI (shared secret)
57 * \param Q Public key from other party
58 * \param d Our secret exponent
59 *
60 * \return 0 if successful,
61 * or a POLARSSL_ERR_ECP_XXX or POLARSSL_MPI_XXX error code
62 */
63int ecdh_compute_shared( const ecp_group *grp, mpi *z,
64 const ecp_point *Q, const mpi *d );
Manuel Pégourié-Gonnard0bad5c22013-01-26 15:30:46 +010065
66/**
67 * \brief Checkup routine
68 *
69 * \return 0 if successful, or 1 if the test failed
70 */
71int ecdh_self_test( int verbose );
72
Manuel Pégourié-Gonnard6545ca72013-01-26 16:05:22 +010073#ifdef __cplusplus
74}
75#endif
76
Manuel Pégourié-Gonnard0bad5c22013-01-26 15:30:46 +010077#endif