Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 1 | /** |
| 2 | * \file ecdh.h |
| 3 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 4 | * \brief The Elliptic Curve Diffie-Hellman (ECDH) protocol APIs. |
| 5 | * |
| 6 | * ECDH is an anonymous key agreement protocol allowing two parties to |
| 7 | * establish a shared secret over an insecure channel. Each party must have an |
| 8 | * elliptic-curve public–private key pair. |
| 9 | * |
| 10 | * For more information, see <em>NIST SP 800-56A Rev. 2: Recommendation for |
| 11 | * Pair-Wise Key Establishment Schemes Using Discrete Logarithm |
| 12 | * Cryptography</em>. |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 13 | */ |
| 14 | /* |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 15 | * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 16 | * SPDX-License-Identifier: Apache-2.0 |
| 17 | * |
| 18 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 19 | * not use this file except in compliance with the License. |
| 20 | * You may obtain a copy of the License at |
| 21 | * |
| 22 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 23 | * |
| 24 | * Unless required by applicable law or agreed to in writing, software |
| 25 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 26 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 27 | * See the License for the specific language governing permissions and |
| 28 | * limitations under the License. |
Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 29 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 30 | * This file is part of Mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 31 | */ |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 32 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 33 | #ifndef MBEDTLS_ECDH_H |
| 34 | #define MBEDTLS_ECDH_H |
Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 35 | |
Ron Eldor | 3625e56 | 2018-12-16 12:14:37 +0200 | [diff] [blame^] | 36 | #if !defined(MBEDTLS_CONFIG_FILE) |
| 37 | #include "config.h" |
| 38 | #else |
| 39 | #include MBEDTLS_CONFIG_FILE |
| 40 | #endif |
| 41 | |
Manuel Pégourié-Gonnard | bdc9676 | 2013-10-03 11:50:39 +0200 | [diff] [blame] | 42 | #include "ecp.h" |
Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 43 | |
Paul Bakker | 407a0da | 2013-06-27 14:29:21 +0200 | [diff] [blame] | 44 | #ifdef __cplusplus |
| 45 | extern "C" { |
| 46 | #endif |
| 47 | |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 48 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 49 | * Defines the source of the imported EC key: |
| 50 | * <ul><li>Our key.</li> |
| 51 | * <li>The key of the peer.</li></ul> |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 52 | */ |
| 53 | typedef enum |
| 54 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 55 | MBEDTLS_ECDH_OURS, |
| 56 | MBEDTLS_ECDH_THEIRS, |
| 57 | } mbedtls_ecdh_side; |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 58 | |
| 59 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 60 | * \brief The ECDH context structure. |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 61 | */ |
| 62 | typedef struct |
| 63 | { |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 64 | mbedtls_ecp_group grp; /*!< The elliptic curve used. */ |
| 65 | mbedtls_mpi d; /*!< The private key. */ |
| 66 | mbedtls_ecp_point Q; /*!< The public key. */ |
| 67 | mbedtls_ecp_point Qp; /*!< The value of the public key of the peer. */ |
| 68 | mbedtls_mpi z; /*!< The shared secret. */ |
| 69 | int point_format; /*!< The format of point export in TLS messages. */ |
| 70 | mbedtls_ecp_point Vi; /*!< The blinding value. */ |
| 71 | mbedtls_ecp_point Vf; /*!< The unblinding value. */ |
| 72 | mbedtls_mpi _d; /*!< The previous \p d. */ |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 73 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 74 | mbedtls_ecdh_context; |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 75 | |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 76 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 77 | * \brief This function generates an ECDH keypair on an elliptic |
| 78 | * curve. |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 79 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 80 | * This function performs the first of two core computations |
| 81 | * implemented during the ECDH key exchange. The second core |
| 82 | * computation is performed by mbedtls_ecdh_compute_shared(). |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 83 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 84 | * \param grp The ECP group. |
| 85 | * \param d The destination MPI (private key). |
| 86 | * \param Q The destination point (public key). |
| 87 | * \param f_rng The RNG function. |
| 88 | * \param p_rng The RNG parameter. |
| 89 | * |
| 90 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or |
| 91 | * \c MBEDTLS_MPI_XXX error code on failure. |
| 92 | * |
| 93 | * \see ecp.h |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 94 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 95 | int mbedtls_ecdh_gen_public( mbedtls_ecp_group *grp, mbedtls_mpi *d, mbedtls_ecp_point *Q, |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 96 | int (*f_rng)(void *, unsigned char *, size_t), |
| 97 | void *p_rng ); |
| 98 | |
| 99 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 100 | * \brief This function computes the shared secret. |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 101 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 102 | * This function performs the second of two core computations |
| 103 | * implemented during the ECDH key exchange. The first core |
| 104 | * computation is performed by mbedtls_ecdh_gen_public(). |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 105 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 106 | * \param grp The ECP group. |
| 107 | * \param z The destination MPI (shared secret). |
| 108 | * \param Q The public key from another party. |
| 109 | * \param d Our secret exponent (private key). |
| 110 | * \param f_rng The RNG function. |
| 111 | * \param p_rng The RNG parameter. |
Manuel Pégourié-Gonnard | e09d2f8 | 2013-09-02 14:29:09 +0200 | [diff] [blame] | 112 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 113 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX or |
| 114 | * \c MBEDTLS_MPI_XXX error code on failure. |
| 115 | * |
| 116 | * \see ecp.h |
| 117 | * |
| 118 | * \note If \p f_rng is not NULL, it is used to implement |
Manuel Pégourié-Gonnard | e09d2f8 | 2013-09-02 14:29:09 +0200 | [diff] [blame] | 119 | * countermeasures against potential elaborate timing |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 120 | * attacks. For more information, see mbedtls_ecp_mul(). |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 121 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 122 | int mbedtls_ecdh_compute_shared( mbedtls_ecp_group *grp, mbedtls_mpi *z, |
| 123 | const mbedtls_ecp_point *Q, const mbedtls_mpi *d, |
Manuel Pégourié-Gonnard | e09d2f8 | 2013-09-02 14:29:09 +0200 | [diff] [blame] | 124 | int (*f_rng)(void *, unsigned char *, size_t), |
| 125 | void *p_rng ); |
Manuel Pégourié-Gonnard | 0bad5c2 | 2013-01-26 15:30:46 +0100 | [diff] [blame] | 126 | |
| 127 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 128 | * \brief This function initializes an ECDH context. |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 129 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 130 | * \param ctx The ECDH context to initialize. |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 131 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 132 | void mbedtls_ecdh_init( mbedtls_ecdh_context *ctx ); |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 133 | |
| 134 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 135 | * \brief This function frees a context. |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 136 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 137 | * \param ctx The context to free. |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 138 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 139 | void mbedtls_ecdh_free( mbedtls_ecdh_context *ctx ); |
Manuel Pégourié-Gonnard | 63533e4 | 2013-02-10 14:21:04 +0100 | [diff] [blame] | 140 | |
| 141 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 142 | * \brief This function generates a public key and a TLS |
| 143 | * ServerKeyExchange payload. |
Manuel Pégourié-Gonnard | 1372476 | 2013-02-10 15:01:54 +0100 | [diff] [blame] | 144 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 145 | * This is the first function used by a TLS server for ECDHE |
| 146 | * ciphersuites. |
Manuel Pégourié-Gonnard | 1372476 | 2013-02-10 15:01:54 +0100 | [diff] [blame] | 147 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 148 | * \param ctx The ECDH context. |
| 149 | * \param olen The number of characters written. |
| 150 | * \param buf The destination buffer. |
| 151 | * \param blen The length of the destination buffer. |
| 152 | * \param f_rng The RNG function. |
| 153 | * \param p_rng The RNG parameter. |
Manuel Pégourié-Gonnard | 1372476 | 2013-02-10 15:01:54 +0100 | [diff] [blame] | 154 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 155 | * \note This function assumes that the ECP group (grp) of the |
| 156 | * \p ctx context has already been properly set, |
| 157 | * for example, using mbedtls_ecp_group_load(). |
| 158 | * |
| 159 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 160 | * on failure. |
| 161 | * |
| 162 | * \see ecp.h |
Manuel Pégourié-Gonnard | 1372476 | 2013-02-10 15:01:54 +0100 | [diff] [blame] | 163 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 164 | int mbedtls_ecdh_make_params( mbedtls_ecdh_context *ctx, size_t *olen, |
Manuel Pégourié-Gonnard | 854fbd7 | 2013-02-11 20:28:55 +0100 | [diff] [blame] | 165 | unsigned char *buf, size_t blen, |
| 166 | int (*f_rng)(void *, unsigned char *, size_t), |
| 167 | void *p_rng ); |
| 168 | |
| 169 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 170 | * \brief This function parses and processes a TLS ServerKeyExhange |
| 171 | * payload. |
Manuel Pégourié-Gonnard | 854fbd7 | 2013-02-11 20:28:55 +0100 | [diff] [blame] | 172 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 173 | * This is the first function used by a TLS client for ECDHE |
| 174 | * ciphersuites. |
Manuel Pégourié-Gonnard | 854fbd7 | 2013-02-11 20:28:55 +0100 | [diff] [blame] | 175 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 176 | * \param ctx The ECDH context. |
| 177 | * \param buf The pointer to the start of the input buffer. |
| 178 | * \param end The address for one Byte past the end of the buffer. |
| 179 | * |
| 180 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 181 | * on failure. |
| 182 | * |
| 183 | * \see ecp.h |
Manuel Pégourié-Gonnard | 854fbd7 | 2013-02-11 20:28:55 +0100 | [diff] [blame] | 184 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 185 | int mbedtls_ecdh_read_params( mbedtls_ecdh_context *ctx, |
Manuel Pégourié-Gonnard | 854fbd7 | 2013-02-11 20:28:55 +0100 | [diff] [blame] | 186 | const unsigned char **buf, const unsigned char *end ); |
Manuel Pégourié-Gonnard | 1372476 | 2013-02-10 15:01:54 +0100 | [diff] [blame] | 187 | |
| 188 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 189 | * \brief This function sets up an ECDH context from an EC key. |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 190 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 191 | * It is used by clients and servers in place of the |
| 192 | * ServerKeyEchange for static ECDH, and imports ECDH |
| 193 | * parameters from the EC key information of a certificate. |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 194 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 195 | * \param ctx The ECDH context to set up. |
| 196 | * \param key The EC key to use. |
| 197 | * \param side Defines the source of the key: |
| 198 | * <ul><li>1: Our key.</li> |
| 199 | <li>0: The key of the peer.</li></ul> |
| 200 | * |
| 201 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 202 | * on failure. |
| 203 | * |
| 204 | * \see ecp.h |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 205 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 206 | int mbedtls_ecdh_get_params( mbedtls_ecdh_context *ctx, const mbedtls_ecp_keypair *key, |
| 207 | mbedtls_ecdh_side side ); |
Manuel Pégourié-Gonnard | cdff3cf | 2013-12-12 09:55:52 +0100 | [diff] [blame] | 208 | |
| 209 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 210 | * \brief This function generates a public key and a TLS |
| 211 | * ClientKeyExchange payload. |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 212 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 213 | * This is the second function used by a TLS client for ECDH(E) |
| 214 | * ciphersuites. |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 215 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 216 | * \param ctx The ECDH context. |
| 217 | * \param olen The number of Bytes written. |
| 218 | * \param buf The destination buffer. |
| 219 | * \param blen The size of the destination buffer. |
| 220 | * \param f_rng The RNG function. |
| 221 | * \param p_rng The RNG parameter. |
| 222 | * |
| 223 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 224 | * on failure. |
| 225 | * |
| 226 | * \see ecp.h |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 227 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 228 | int mbedtls_ecdh_make_public( mbedtls_ecdh_context *ctx, size_t *olen, |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 229 | unsigned char *buf, size_t blen, |
| 230 | int (*f_rng)(void *, unsigned char *, size_t), |
| 231 | void *p_rng ); |
| 232 | |
| 233 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 234 | * \brief This function parses and processes a TLS ClientKeyExchange |
| 235 | * payload. |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 236 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 237 | * This is the second function used by a TLS server for ECDH(E) |
| 238 | * ciphersuites. |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 239 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 240 | * \param ctx The ECDH context. |
| 241 | * \param buf The start of the input buffer. |
| 242 | * \param blen The length of the input buffer. |
| 243 | * |
| 244 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 245 | * on failure. |
| 246 | * |
| 247 | * \see ecp.h |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 248 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 249 | int mbedtls_ecdh_read_public( mbedtls_ecdh_context *ctx, |
Manuel Pégourié-Gonnard | 5cceb41 | 2013-02-11 21:51:45 +0100 | [diff] [blame] | 250 | const unsigned char *buf, size_t blen ); |
| 251 | |
| 252 | /** |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 253 | * \brief This function derives and exports the shared secret. |
Manuel Pégourié-Gonnard | 424fda5 | 2013-02-11 22:05:42 +0100 | [diff] [blame] | 254 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 255 | * This is the last function used by both TLS client |
| 256 | * and servers. |
Manuel Pégourié-Gonnard | 424fda5 | 2013-02-11 22:05:42 +0100 | [diff] [blame] | 257 | * |
Rose Zadik | de2d622 | 2018-01-25 21:57:43 +0000 | [diff] [blame] | 258 | * \param ctx The ECDH context. |
| 259 | * \param olen The number of Bytes written. |
| 260 | * \param buf The destination buffer. |
| 261 | * \param blen The length of the destination buffer. |
| 262 | * \param f_rng The RNG function. |
| 263 | * \param p_rng The RNG parameter. |
| 264 | * |
| 265 | * \return \c 0 on success, or an \c MBEDTLS_ERR_ECP_XXX error code |
| 266 | * on failure. |
| 267 | * |
| 268 | * \see ecp.h |
| 269 | * |
| 270 | * \note If \p f_rng is not NULL, it is used to implement |
| 271 | * countermeasures against potential elaborate timing |
| 272 | * attacks. For more information, see mbedtls_ecp_mul(). |
Manuel Pégourié-Gonnard | 424fda5 | 2013-02-11 22:05:42 +0100 | [diff] [blame] | 273 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 274 | int mbedtls_ecdh_calc_secret( mbedtls_ecdh_context *ctx, size_t *olen, |
Manuel Pégourié-Gonnard | e09d2f8 | 2013-09-02 14:29:09 +0200 | [diff] [blame] | 275 | unsigned char *buf, size_t blen, |
| 276 | int (*f_rng)(void *, unsigned char *, size_t), |
| 277 | void *p_rng ); |
Manuel Pégourié-Gonnard | 424fda5 | 2013-02-11 22:05:42 +0100 | [diff] [blame] | 278 | |
Manuel Pégourié-Gonnard | 6545ca7 | 2013-01-26 16:05:22 +0100 | [diff] [blame] | 279 | #ifdef __cplusplus |
| 280 | } |
| 281 | #endif |
| 282 | |
Paul Bakker | 9af723c | 2014-05-01 13:03:14 +0200 | [diff] [blame] | 283 | #endif /* ecdh.h */ |