Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 1 | /** |
| 2 | * \file ecjpake.h |
| 3 | * |
| 4 | * \brief Elliptic curve J-PAKE |
Darryl Green | a40a101 | 2018-01-05 15:33:17 +0000 | [diff] [blame] | 5 | */ |
| 6 | /* |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 7 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 7ff7965 | 2023-11-03 12:04:52 +0000 | [diff] [blame] | 8 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 9 | */ |
| 10 | #ifndef MBEDTLS_ECJPAKE_H |
| 11 | #define MBEDTLS_ECJPAKE_H |
| 12 | |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 13 | /* |
Manuel Pégourié-Gonnard | d8204a7 | 2015-08-14 13:36:55 +0200 | [diff] [blame] | 14 | * J-PAKE is a password-authenticated key exchange that allows deriving a |
| 15 | * strong shared secret from a (potentially low entropy) pre-shared |
| 16 | * passphrase, with forward secrecy and mutual authentication. |
| 17 | * https://en.wikipedia.org/wiki/Password_Authenticated_Key_Exchange_by_Juggling |
| 18 | * |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 19 | * This file implements the Elliptic Curve variant of J-PAKE, |
| 20 | * as defined in Chapter 7.4 of the Thread v1.0 Specification, |
| 21 | * available to members of the Thread Group http://threadgroup.org/ |
Manuel Pégourié-Gonnard | d8204a7 | 2015-08-14 13:36:55 +0200 | [diff] [blame] | 22 | * |
| 23 | * As the J-PAKE algorithm is inherently symmetric, so is our API. |
| 24 | * Each party needs to send its first round message, in any order, to the |
| 25 | * other party, then each sends its second round message, in any order. |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 26 | * The payloads are serialized in a way suitable for use in TLS, but could |
| 27 | * also be use outside TLS. |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 28 | */ |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 29 | #if !defined(MBEDTLS_CONFIG_FILE) |
Jaeden Amero | c49fbbf | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 30 | #include "mbedtls/config.h" |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 31 | #else |
| 32 | #include MBEDTLS_CONFIG_FILE |
| 33 | #endif |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 34 | |
Jaeden Amero | c49fbbf | 2019-07-04 20:01:14 +0100 | [diff] [blame] | 35 | #include "mbedtls/ecp.h" |
| 36 | #include "mbedtls/md.h" |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 37 | |
| 38 | #ifdef __cplusplus |
| 39 | extern "C" { |
| 40 | #endif |
| 41 | |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 42 | /** |
| 43 | * Roles in the EC J-PAKE exchange |
| 44 | */ |
Manuel Pégourié-Gonnard | 6449391 | 2015-08-13 20:19:51 +0200 | [diff] [blame] | 45 | typedef enum { |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 46 | MBEDTLS_ECJPAKE_CLIENT = 0, /**< Client */ |
| 47 | MBEDTLS_ECJPAKE_SERVER, /**< Server */ |
Manuel Pégourié-Gonnard | 6449391 | 2015-08-13 20:19:51 +0200 | [diff] [blame] | 48 | } mbedtls_ecjpake_role; |
| 49 | |
Ron Eldor | 4e6d55d | 2018-02-07 16:36:15 +0200 | [diff] [blame] | 50 | #if !defined(MBEDTLS_ECJPAKE_ALT) |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 51 | /** |
Manuel Pégourié-Gonnard | ce45676 | 2015-08-14 11:54:35 +0200 | [diff] [blame] | 52 | * EC J-PAKE context structure. |
| 53 | * |
| 54 | * J-PAKE is a symmetric protocol, except for the identifiers used in |
| 55 | * Zero-Knowledge Proofs, and the serialization of the second message |
| 56 | * (KeyExchange) as defined by the Thread spec. |
| 57 | * |
| 58 | * In order to benefit from this symmetry, we choose a different naming |
Shaun Case | 0e7791f | 2021-12-20 21:14:10 -0800 | [diff] [blame] | 59 | * convention from the Thread v1.0 spec. Correspondence is indicated in the |
Simon Butcher | 5b331b9 | 2016-01-03 16:14:14 +0000 | [diff] [blame] | 60 | * description as a pair C: client name, S: server name |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 61 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 62 | typedef struct mbedtls_ecjpake_context { |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 63 | const mbedtls_md_info_t *md_info; /**< Hash to use */ |
| 64 | mbedtls_ecp_group grp; /**< Elliptic curve */ |
Manuel Pégourié-Gonnard | 6449391 | 2015-08-13 20:19:51 +0200 | [diff] [blame] | 65 | mbedtls_ecjpake_role role; /**< Are we client or server? */ |
Robert Cragie | 7cdad77 | 2015-10-02 13:31:41 +0100 | [diff] [blame] | 66 | int point_format; /**< Format for point export */ |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 67 | |
Manuel Pégourié-Gonnard | ce45676 | 2015-08-14 11:54:35 +0200 | [diff] [blame] | 68 | mbedtls_ecp_point Xm1; /**< My public key 1 C: X1, S: X3 */ |
| 69 | mbedtls_ecp_point Xm2; /**< My public key 2 C: X2, S: X4 */ |
| 70 | mbedtls_ecp_point Xp1; /**< Peer public key 1 C: X3, S: X1 */ |
| 71 | mbedtls_ecp_point Xp2; /**< Peer public key 2 C: X4, S: X2 */ |
| 72 | mbedtls_ecp_point Xp; /**< Peer public key C: Xs, S: Xc */ |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 73 | |
Manuel Pégourié-Gonnard | ce45676 | 2015-08-14 11:54:35 +0200 | [diff] [blame] | 74 | mbedtls_mpi xm1; /**< My private key 1 C: x1, S: x3 */ |
| 75 | mbedtls_mpi xm2; /**< My private key 2 C: x2, S: x4 */ |
Manuel Pégourié-Gonnard | 23dcbe3 | 2015-08-13 09:37:00 +0200 | [diff] [blame] | 76 | |
Manuel Pégourié-Gonnard | 6b798b9 | 2015-08-14 11:18:30 +0200 | [diff] [blame] | 77 | mbedtls_mpi s; /**< Pre-shared secret (passphrase) */ |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 78 | } mbedtls_ecjpake_context; |
| 79 | |
Ron Eldor | 4e6d55d | 2018-02-07 16:36:15 +0200 | [diff] [blame] | 80 | #else /* MBEDTLS_ECJPAKE_ALT */ |
| 81 | #include "ecjpake_alt.h" |
| 82 | #endif /* MBEDTLS_ECJPAKE_ALT */ |
| 83 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 84 | /** |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 85 | * \brief Initialize an ECJPAKE context. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 86 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 87 | * \param ctx The ECJPAKE context to initialize. |
| 88 | * This must not be \c NULL. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 89 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 90 | void mbedtls_ecjpake_init(mbedtls_ecjpake_context *ctx); |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 91 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 92 | /** |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 93 | * \brief Set up an ECJPAKE context for use. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 94 | * |
| 95 | * \note Currently the only values for hash/curve allowed by the |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 96 | * standard are #MBEDTLS_MD_SHA256/#MBEDTLS_ECP_DP_SECP256R1. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 97 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 98 | * \param ctx The ECJPAKE context to set up. This must be initialized. |
| 99 | * \param role The role of the caller. This must be either |
| 100 | * #MBEDTLS_ECJPAKE_CLIENT or #MBEDTLS_ECJPAKE_SERVER. |
| 101 | * \param hash The identifier of the hash function to use, |
| 102 | * for example #MBEDTLS_MD_SHA256. |
| 103 | * \param curve The identifier of the elliptic curve to use, |
| 104 | * for example #MBEDTLS_ECP_DP_SECP256R1. |
| 105 | * \param secret The pre-shared secret (passphrase). This must be |
| 106 | * a readable buffer of length \p len Bytes. It need |
| 107 | * only be valid for the duration of this call. |
| 108 | * \param len The length of the pre-shared secret \p secret. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 109 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 110 | * \return \c 0 if successful. |
| 111 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 112 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 113 | int mbedtls_ecjpake_setup(mbedtls_ecjpake_context *ctx, |
| 114 | mbedtls_ecjpake_role role, |
| 115 | mbedtls_md_type_t hash, |
| 116 | mbedtls_ecp_group_id curve, |
| 117 | const unsigned char *secret, |
| 118 | size_t len); |
Manuel Pégourié-Gonnard | 7af8bc1 | 2015-08-12 16:58:50 +0200 | [diff] [blame] | 119 | |
Andres Amaya Garcia | af610a0 | 2016-12-14 10:13:43 +0000 | [diff] [blame] | 120 | /** |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 121 | * \brief Check if an ECJPAKE context is ready for use. |
Manuel Pégourié-Gonnard | b813acc | 2015-09-15 15:34:09 +0200 | [diff] [blame] | 122 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 123 | * \param ctx The ECJPAKE context to check. This must be |
| 124 | * initialized. |
Manuel Pégourié-Gonnard | b813acc | 2015-09-15 15:34:09 +0200 | [diff] [blame] | 125 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 126 | * \return \c 0 if the context is ready for use. |
| 127 | * \return #MBEDTLS_ERR_ECP_BAD_INPUT_DATA otherwise. |
Manuel Pégourié-Gonnard | b813acc | 2015-09-15 15:34:09 +0200 | [diff] [blame] | 128 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 129 | int mbedtls_ecjpake_check(const mbedtls_ecjpake_context *ctx); |
Manuel Pégourié-Gonnard | b813acc | 2015-09-15 15:34:09 +0200 | [diff] [blame] | 130 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 131 | /** |
Manuel Pégourié-Gonnard | d8204a7 | 2015-08-14 13:36:55 +0200 | [diff] [blame] | 132 | * \brief Generate and write the first round message |
| 133 | * (TLS: contents of the Client/ServerHello extension, |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 134 | * excluding extension type and length bytes). |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 135 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 136 | * \param ctx The ECJPAKE context to use. This must be |
| 137 | * initialized and set up. |
| 138 | * \param buf The buffer to write the contents to. This must be a |
| 139 | * writable buffer of length \p len Bytes. |
| 140 | * \param len The length of \p buf in Bytes. |
| 141 | * \param olen The address at which to store the total number |
| 142 | * of Bytes written to \p buf. This must not be \c NULL. |
| 143 | * \param f_rng The RNG function to use. This must not be \c NULL. |
| 144 | * \param p_rng The RNG parameter to be passed to \p f_rng. This |
| 145 | * may be \c NULL if \p f_rng doesn't use a context. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 146 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 147 | * \return \c 0 if successful. |
| 148 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 149 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 150 | int mbedtls_ecjpake_write_round_one(mbedtls_ecjpake_context *ctx, |
| 151 | unsigned char *buf, size_t len, size_t *olen, |
| 152 | int (*f_rng)(void *, unsigned char *, size_t), |
| 153 | void *p_rng); |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 154 | |
| 155 | /** |
| 156 | * \brief Read and process the first round message |
Manuel Pégourié-Gonnard | d8204a7 | 2015-08-14 13:36:55 +0200 | [diff] [blame] | 157 | * (TLS: contents of the Client/ServerHello extension, |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 158 | * excluding extension type and length bytes). |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 159 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 160 | * \param ctx The ECJPAKE context to use. This must be initialized |
| 161 | * and set up. |
| 162 | * \param buf The buffer holding the first round message. This must |
| 163 | * be a readable buffer of length \p len Bytes. |
| 164 | * \param len The length in Bytes of \p buf. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 165 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 166 | * \return \c 0 if successful. |
| 167 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 168 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 169 | int mbedtls_ecjpake_read_round_one(mbedtls_ecjpake_context *ctx, |
| 170 | const unsigned char *buf, |
| 171 | size_t len); |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 172 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 173 | /** |
| 174 | * \brief Generate and write the second round message |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 175 | * (TLS: contents of the Client/ServerKeyExchange). |
Manuel Pégourié-Gonnard | 614bd5e | 2015-08-13 20:19:16 +0200 | [diff] [blame] | 176 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 177 | * \param ctx The ECJPAKE context to use. This must be initialized, |
| 178 | * set up, and already have performed round one. |
| 179 | * \param buf The buffer to write the round two contents to. |
| 180 | * This must be a writable buffer of length \p len Bytes. |
| 181 | * \param len The size of \p buf in Bytes. |
| 182 | * \param olen The address at which to store the total number of Bytes |
| 183 | * written to \p buf. This must not be \c NULL. |
| 184 | * \param f_rng The RNG function to use. This must not be \c NULL. |
| 185 | * \param p_rng The RNG parameter to be passed to \p f_rng. This |
| 186 | * may be \c NULL if \p f_rng doesn't use a context. |
Manuel Pégourié-Gonnard | 614bd5e | 2015-08-13 20:19:16 +0200 | [diff] [blame] | 187 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 188 | * \return \c 0 if successful. |
| 189 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | 614bd5e | 2015-08-13 20:19:16 +0200 | [diff] [blame] | 190 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 191 | int mbedtls_ecjpake_write_round_two(mbedtls_ecjpake_context *ctx, |
| 192 | unsigned char *buf, size_t len, size_t *olen, |
| 193 | int (*f_rng)(void *, unsigned char *, size_t), |
| 194 | void *p_rng); |
Manuel Pégourié-Gonnard | 614bd5e | 2015-08-13 20:19:16 +0200 | [diff] [blame] | 195 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 196 | /** |
| 197 | * \brief Read and process the second round message |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 198 | * (TLS: contents of the Client/ServerKeyExchange). |
Manuel Pégourié-Gonnard | ec0eece | 2015-08-13 19:13:20 +0200 | [diff] [blame] | 199 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 200 | * \param ctx The ECJPAKE context to use. This must be initialized |
| 201 | * and set up and already have performed round one. |
| 202 | * \param buf The buffer holding the second round message. This must |
| 203 | * be a readable buffer of length \p len Bytes. |
| 204 | * \param len The length in Bytes of \p buf. |
Manuel Pégourié-Gonnard | ec0eece | 2015-08-13 19:13:20 +0200 | [diff] [blame] | 205 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 206 | * \return \c 0 if successful. |
| 207 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | ec0eece | 2015-08-13 19:13:20 +0200 | [diff] [blame] | 208 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 209 | int mbedtls_ecjpake_read_round_two(mbedtls_ecjpake_context *ctx, |
| 210 | const unsigned char *buf, |
| 211 | size_t len); |
Manuel Pégourié-Gonnard | ec0eece | 2015-08-13 19:13:20 +0200 | [diff] [blame] | 212 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 213 | /** |
| 214 | * \brief Derive the shared secret |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 215 | * (TLS: Pre-Master Secret). |
Manuel Pégourié-Gonnard | 5f18829 | 2015-08-14 10:52:39 +0200 | [diff] [blame] | 216 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 217 | * \param ctx The ECJPAKE context to use. This must be initialized, |
| 218 | * set up and have performed both round one and two. |
| 219 | * \param buf The buffer to write the derived secret to. This must |
| 220 | * be a writable buffer of length \p len Bytes. |
| 221 | * \param len The length of \p buf in Bytes. |
| 222 | * \param olen The address at which to store the total number of Bytes |
| 223 | * written to \p buf. This must not be \c NULL. |
| 224 | * \param f_rng The RNG function to use. This must not be \c NULL. |
| 225 | * \param p_rng The RNG parameter to be passed to \p f_rng. This |
| 226 | * may be \c NULL if \p f_rng doesn't use a context. |
Manuel Pégourié-Gonnard | 5f18829 | 2015-08-14 10:52:39 +0200 | [diff] [blame] | 227 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 228 | * \return \c 0 if successful. |
| 229 | * \return A negative error code on failure. |
Manuel Pégourié-Gonnard | 5f18829 | 2015-08-14 10:52:39 +0200 | [diff] [blame] | 230 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 231 | int mbedtls_ecjpake_derive_secret(mbedtls_ecjpake_context *ctx, |
| 232 | unsigned char *buf, size_t len, size_t *olen, |
| 233 | int (*f_rng)(void *, unsigned char *, size_t), |
| 234 | void *p_rng); |
Manuel Pégourié-Gonnard | 5f18829 | 2015-08-14 10:52:39 +0200 | [diff] [blame] | 235 | |
Manuel Pégourié-Gonnard | f7368c9 | 2015-08-14 14:33:05 +0200 | [diff] [blame] | 236 | /** |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 237 | * \brief This clears an ECJPAKE context and frees any |
| 238 | * embedded data structure. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 239 | * |
Andrzej Kurek | c470b6b | 2019-01-31 08:20:20 -0500 | [diff] [blame] | 240 | * \param ctx The ECJPAKE context to free. This may be \c NULL, |
| 241 | * in which case this function does nothing. If it is not |
| 242 | * \c NULL, it must point to an initialized ECJPAKE context. |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 243 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 244 | void mbedtls_ecjpake_free(mbedtls_ecjpake_context *ctx); |
Manuel Pégourié-Gonnard | 4e8bc78 | 2015-08-12 20:50:31 +0200 | [diff] [blame] | 245 | |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 246 | #if defined(MBEDTLS_SELF_TEST) |
Hanno Becker | 616d1ca | 2018-01-24 10:25:05 +0000 | [diff] [blame] | 247 | |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 248 | /** |
| 249 | * \brief Checkup routine |
| 250 | * |
| 251 | * \return 0 if successful, or 1 if a test failed |
| 252 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 253 | int mbedtls_ecjpake_self_test(int verbose); |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 254 | |
Ron Eldor | 4e6d55d | 2018-02-07 16:36:15 +0200 | [diff] [blame] | 255 | #endif /* MBEDTLS_SELF_TEST */ |
| 256 | |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 257 | #ifdef __cplusplus |
| 258 | } |
| 259 | #endif |
| 260 | |
Hanno Becker | 616d1ca | 2018-01-24 10:25:05 +0000 | [diff] [blame] | 261 | |
Manuel Pégourié-Gonnard | 4d8685b | 2015-08-05 15:44:42 +0200 | [diff] [blame] | 262 | #endif /* ecjpake.h */ |