blob: f9725ab09501f85e6f5e5071fdc31a696a8212a4 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/**
2 * \file dhm.h
Paul Bakkere0ccd0a2009-01-04 16:27:10 +00003 *
Paul Bakker37ca75d2011-01-06 12:28:03 +00004 * \brief Diffie-Hellman-Merkle key exchange
5 *
Manuel Pégourié-Gonnard6fb81872015-07-27 11:11:48 +02006 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02007 * SPDX-License-Identifier: Apache-2.0
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
10 * not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
Paul Bakkerb96f1542010-07-18 20:36:00 +000020 *
Manuel Pégourié-Gonnardfe446432015-03-06 13:17:10 +000021 * This file is part of mbed TLS (https://tls.mbed.org)
Paul Bakker5121ce52009-01-03 21:22:43 +000022 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#ifndef MBEDTLS_DHM_H
24#define MBEDTLS_DHM_H
Paul Bakker5121ce52009-01-03 21:22:43 +000025
Reuven Levin1f35ca92017-12-07 10:09:32 +000026#if !defined(MBEDTLS_CONFIG_FILE)
27#include "config.h"
28#else
29#include MBEDTLS_CONFIG_FILE
30#endif
Paul Bakker314052f2011-08-15 09:07:52 +000031#include "bignum.h"
Reuven Levin1f35ca92017-12-07 10:09:32 +000032#if !defined(MBEDTLS_DHM_ALT)
33
Paul Bakkerf3b86c12011-01-27 15:24:17 +000034/*
35 * DHM Error codes
36 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037#define MBEDTLS_ERR_DHM_BAD_INPUT_DATA -0x3080 /**< Bad input parameters to function. */
38#define MBEDTLS_ERR_DHM_READ_PARAMS_FAILED -0x3100 /**< Reading of the DHM parameters failed. */
39#define MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED -0x3180 /**< Making of the DHM parameters failed. */
40#define MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED -0x3200 /**< Reading of the public values failed. */
41#define MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED -0x3280 /**< Making of the public value failed. */
42#define MBEDTLS_ERR_DHM_CALC_SECRET_FAILED -0x3300 /**< Calculation of the DHM secret failed. */
43#define MBEDTLS_ERR_DHM_INVALID_FORMAT -0x3380 /**< The ASN.1 data is not formatted correctly. */
Manuel Pégourié-Gonnard6a8ca332015-05-28 09:33:39 +020044#define MBEDTLS_ERR_DHM_ALLOC_FAILED -0x3400 /**< Allocation of memory failed. */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020045#define MBEDTLS_ERR_DHM_FILE_IO_ERROR -0x3480 /**< Read/write of file failed. */
Paul Bakker5121ce52009-01-03 21:22:43 +000046
Paul Bakkerf3b86c12011-01-27 15:24:17 +000047/**
Paul Bakkerda7e3f22012-09-28 07:18:17 +000048 * RFC 3526 defines a number of standardized Diffie-Hellman groups
49 * for IKE.
Paul Bakker29b64762012-09-25 09:36:44 +000050 * RFC 5114 defines a number of standardized Diffie-Hellman groups
Paul Bakkerda7e3f22012-09-28 07:18:17 +000051 * that can be used.
52 *
53 * Some are included here for convenience.
Paul Bakker29b64762012-09-25 09:36:44 +000054 *
55 * Included are:
Paul Bakkerda7e3f22012-09-28 07:18:17 +000056 * RFC 3526 3. 2048-bit MODP Group
57 * RFC 3526 4. 3072-bit MODP Group
Manuel Pégourié-Gonnard78931032015-07-03 17:06:39 +020058 * RFC 3526 5. 4096-bit MODP Group
Paul Bakkerda7e3f22012-09-28 07:18:17 +000059 * RFC 5114 2.2. 2048-bit MODP Group with 224-bit Prime Order Subgroup
Paul Bakker29b64762012-09-25 09:36:44 +000060 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020061#define MBEDTLS_DHM_RFC3526_MODP_2048_P \
Paul Bakkerda7e3f22012-09-28 07:18:17 +000062 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
63 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
64 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
65 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
66 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
67 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
68 "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
69 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
70 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
71 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
72 "15728E5A8AACAA68FFFFFFFFFFFFFFFF"
73
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020074#define MBEDTLS_DHM_RFC3526_MODP_2048_G "02"
Paul Bakkerda7e3f22012-09-28 07:18:17 +000075
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020076#define MBEDTLS_DHM_RFC3526_MODP_3072_P \
Paul Bakkerda7e3f22012-09-28 07:18:17 +000077 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
78 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
79 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
80 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
81 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
82 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
83 "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
84 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
85 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
86 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
87 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
88 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
89 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
90 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
91 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
92 "43DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF"
93
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020094#define MBEDTLS_DHM_RFC3526_MODP_3072_G "02"
Paul Bakkerda7e3f22012-09-28 07:18:17 +000095
Manuel Pégourié-Gonnard78931032015-07-03 17:06:39 +020096#define MBEDTLS_DHM_RFC3526_MODP_4096_P \
97 "FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD1" \
98 "29024E088A67CC74020BBEA63B139B22514A08798E3404DD" \
99 "EF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245" \
100 "E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED" \
101 "EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3D" \
102 "C2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F" \
103 "83655D23DCA3AD961C62F356208552BB9ED529077096966D" \
104 "670C354E4ABC9804F1746C08CA18217C32905E462E36CE3B" \
105 "E39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9" \
106 "DE2BCBF6955817183995497CEA956AE515D2261898FA0510" \
107 "15728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64" \
108 "ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7" \
109 "ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6B" \
110 "F12FFA06D98A0864D87602733EC86A64521F2B18177B200C" \
111 "BBE117577A615D6C770988C0BAD946E208E24FA074E5AB31" \
112 "43DB5BFCE0FD108E4B82D120A92108011A723C12A787E6D7" \
113 "88719A10BDBA5B2699C327186AF4E23C1A946834B6150BDA" \
114 "2583E9CA2AD44CE8DBBBC2DB04DE8EF92E8EFC141FBECAA6" \
115 "287C59474E6BC05D99B2964FA090C3A2233BA186515BE7ED" \
116 "1F612970CEE2D7AFB81BDD762170481CD0069127D5B05AA9" \
117 "93B4EA988D8FDDC186FFB7DC90A6C08F4DF435C934063199" \
118 "FFFFFFFFFFFFFFFF"
Paul Bakker29b64762012-09-25 09:36:44 +0000119
Manuel Pégourié-Gonnard78931032015-07-03 17:06:39 +0200120#define MBEDTLS_DHM_RFC3526_MODP_4096_G "02"
Paul Bakker29b64762012-09-25 09:36:44 +0000121
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200122#define MBEDTLS_DHM_RFC5114_MODP_2048_P \
Paul Bakker29b64762012-09-25 09:36:44 +0000123 "AD107E1E9123A9D0D660FAA79559C51FA20D64E5683B9FD1" \
124 "B54B1597B61D0A75E6FA141DF95A56DBAF9A3C407BA1DF15" \
125 "EB3D688A309C180E1DE6B85A1274A0A66D3F8152AD6AC212" \
126 "9037C9EDEFDA4DF8D91E8FEF55B7394B7AD5B7D0B6C12207" \
127 "C9F98D11ED34DBF6C6BA0B2C8BBC27BE6A00E0A0B9C49708" \
128 "B3BF8A317091883681286130BC8985DB1602E714415D9330" \
129 "278273C7DE31EFDC7310F7121FD5A07415987D9ADC0A486D" \
130 "CDF93ACC44328387315D75E198C641A480CD86A1B9E587E8" \
131 "BE60E69CC928B2B9C52172E413042E9B23F10B0E16E79763" \
132 "C9B53DCF4BA80A29E3FB73C16B8E75B97EF363E2FFA31F71" \
Paul Bakkera864f2e2012-09-26 08:29:20 +0000133 "CF9DE5384E71B81C0AC4DFFE0C10E64F"
Paul Bakker29b64762012-09-25 09:36:44 +0000134
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200135#define MBEDTLS_DHM_RFC5114_MODP_2048_G \
Paul Bakker29b64762012-09-25 09:36:44 +0000136 "AC4032EF4F2D9AE39DF30B5C8FFDAC506CDEBE7B89998CAF"\
137 "74866A08CFE4FFE3A6824A4E10B9A6F0DD921F01A70C4AFA"\
138 "AB739D7700C29F52C57DB17C620A8652BE5E9001A8D66AD7"\
139 "C17669101999024AF4D027275AC1348BB8A762D0521BC98A"\
140 "E247150422EA1ED409939D54DA7460CDB5F6C6B250717CBE"\
141 "F180EB34118E98D119529A45D6F834566E3025E316A330EF"\
142 "BB77A86F0C1AB15B051AE3D428C8F8ACB70A8137150B8EEB"\
143 "10E183EDD19963DDD9E263E4770589EF6AA21E7F5F2FF381"\
144 "B539CCE3409D13CD566AFBB48D6C019181E1BCFE94B30269"\
145 "EDFE72FE9B6AA4BD7B5A0F1C71CFFF4C19C418E1F6EC0179"\
Paul Bakkera864f2e2012-09-26 08:29:20 +0000146 "81BC087F2A7065B384B890D3191F2BFA"
Paul Bakker29b64762012-09-25 09:36:44 +0000147
Paul Bakker407a0da2013-06-27 14:29:21 +0200148#ifdef __cplusplus
149extern "C" {
150#endif
151
Paul Bakker29b64762012-09-25 09:36:44 +0000152/**
Paul Bakkerf3b86c12011-01-27 15:24:17 +0000153 * \brief DHM context structure
154 */
Paul Bakker5121ce52009-01-03 21:22:43 +0000155typedef struct
156{
Paul Bakker23986e52011-04-24 08:57:21 +0000157 size_t len; /*!< size(P) in chars */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200158 mbedtls_mpi P; /*!< prime modulus */
159 mbedtls_mpi G; /*!< generator */
160 mbedtls_mpi X; /*!< secret value */
161 mbedtls_mpi GX; /*!< self = G^X mod P */
162 mbedtls_mpi GY; /*!< peer = G^Y mod P */
163 mbedtls_mpi K; /*!< key = GY^X mod P */
164 mbedtls_mpi RP; /*!< cached R^2 mod P */
165 mbedtls_mpi Vi; /*!< blinding value */
166 mbedtls_mpi Vf; /*!< un-blinding value */
167 mbedtls_mpi pX; /*!< previous X */
Paul Bakker5121ce52009-01-03 21:22:43 +0000168}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200169mbedtls_dhm_context;
Paul Bakker5121ce52009-01-03 21:22:43 +0000170
Paul Bakker5121ce52009-01-03 21:22:43 +0000171/**
Paul Bakker8f870b02014-06-20 13:32:38 +0200172 * \brief Initialize DHM context
173 *
174 * \param ctx DHM context to be initialized
175 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200176void mbedtls_dhm_init( mbedtls_dhm_context *ctx );
Paul Bakker8f870b02014-06-20 13:32:38 +0200177
178/**
Paul Bakker5121ce52009-01-03 21:22:43 +0000179 * \brief Parse the ServerKeyExchange parameters
180 *
181 * \param ctx DHM context
182 * \param p &(start of input buffer)
183 * \param end end of buffer
184 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200185 * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000186 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200187int mbedtls_dhm_read_params( mbedtls_dhm_context *ctx,
Paul Bakker5121ce52009-01-03 21:22:43 +0000188 unsigned char **p,
Paul Bakkerff60ee62010-03-16 21:09:09 +0000189 const unsigned char *end );
Paul Bakker5121ce52009-01-03 21:22:43 +0000190
191/**
192 * \brief Setup and write the ServerKeyExchange parameters
193 *
194 * \param ctx DHM context
Paul Bakkerff7fe672010-07-18 09:45:05 +0000195 * \param x_size private value size in bytes
Paul Bakker5121ce52009-01-03 21:22:43 +0000196 * \param output destination buffer
197 * \param olen number of chars written
198 * \param f_rng RNG function
199 * \param p_rng RNG parameter
200 *
201 * \note This function assumes that ctx->P and ctx->G
202 * have already been properly set (for example
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200203 * using mbedtls_mpi_read_string or mbedtls_mpi_read_binary).
Paul Bakker5121ce52009-01-03 21:22:43 +0000204 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200205 * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000206 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200207int mbedtls_dhm_make_params( mbedtls_dhm_context *ctx, int x_size,
Paul Bakker23986e52011-04-24 08:57:21 +0000208 unsigned char *output, size_t *olen,
Paul Bakkera3d195c2011-11-27 21:07:34 +0000209 int (*f_rng)(void *, unsigned char *, size_t),
210 void *p_rng );
Paul Bakker5121ce52009-01-03 21:22:43 +0000211
212/**
213 * \brief Import the peer's public value G^Y
214 *
215 * \param ctx DHM context
216 * \param input input buffer
217 * \param ilen size of buffer
218 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200219 * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000220 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200221int mbedtls_dhm_read_public( mbedtls_dhm_context *ctx,
Paul Bakker23986e52011-04-24 08:57:21 +0000222 const unsigned char *input, size_t ilen );
Paul Bakker5121ce52009-01-03 21:22:43 +0000223
224/**
225 * \brief Create own private value X and export G^X
226 *
227 * \param ctx DHM context
Paul Bakker84bef1d2012-04-20 13:42:02 +0000228 * \param x_size private value size in bytes
Paul Bakker5121ce52009-01-03 21:22:43 +0000229 * \param output destination buffer
Simon Butcher2917b9e2016-05-25 00:59:37 +0100230 * \param olen must be at least equal to the size of P, ctx->len
Paul Bakker5121ce52009-01-03 21:22:43 +0000231 * \param f_rng RNG function
232 * \param p_rng RNG parameter
233 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200234 * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Paul Bakker5121ce52009-01-03 21:22:43 +0000235 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236int mbedtls_dhm_make_public( mbedtls_dhm_context *ctx, int x_size,
Paul Bakker23986e52011-04-24 08:57:21 +0000237 unsigned char *output, size_t olen,
Paul Bakkera3d195c2011-11-27 21:07:34 +0000238 int (*f_rng)(void *, unsigned char *, size_t),
239 void *p_rng );
Paul Bakker5121ce52009-01-03 21:22:43 +0000240
241/**
242 * \brief Derive and export the shared secret (G^Y)^X mod P
243 *
244 * \param ctx DHM context
245 * \param output destination buffer
Manuel Pégourié-Gonnard33352052015-06-02 16:17:08 +0100246 * \param output_size size of the destination buffer
247 * \param olen on exit, holds the actual number of bytes written
Manuel Pégourié-Gonnard2d627642013-09-04 14:22:07 +0200248 * \param f_rng RNG function, for blinding purposes
249 * \param p_rng RNG parameter
Paul Bakker5121ce52009-01-03 21:22:43 +0000250 *
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200251 * \return 0 if successful, or an MBEDTLS_ERR_DHM_XXX error code
Manuel Pégourié-Gonnard143b5022013-09-04 16:29:59 +0200252 *
Manuel Pégourié-Gonnard15d5de12013-09-17 11:34:11 +0200253 * \note If non-NULL, f_rng is used to blind the input as
254 * countermeasure against timing attacks. Blinding is
255 * automatically used if and only if our secret value X is
256 * re-used and costs nothing otherwise, so it is recommended
257 * to always pass a non-NULL f_rng argument.
Paul Bakker5121ce52009-01-03 21:22:43 +0000258 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200259int mbedtls_dhm_calc_secret( mbedtls_dhm_context *ctx,
Manuel Pégourié-Gonnard33352052015-06-02 16:17:08 +0100260 unsigned char *output, size_t output_size, size_t *olen,
Manuel Pégourié-Gonnard2d627642013-09-04 14:22:07 +0200261 int (*f_rng)(void *, unsigned char *, size_t),
262 void *p_rng );
Paul Bakker5121ce52009-01-03 21:22:43 +0000263
Paul Bakker9a736322012-11-14 12:39:52 +0000264/**
Paul Bakker8f870b02014-06-20 13:32:38 +0200265 * \brief Free and clear the components of a DHM key
266 *
267 * \param ctx DHM context to free and clear
Paul Bakker5121ce52009-01-03 21:22:43 +0000268 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200269void mbedtls_dhm_free( mbedtls_dhm_context *ctx );
Paul Bakker5121ce52009-01-03 21:22:43 +0000270
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200271#if defined(MBEDTLS_ASN1_PARSE_C)
Paul Bakker40ce79f2013-09-15 17:43:54 +0200272/** \ingroup x509_module */
273/**
Manuel Pégourié-Gonnard43b37cb2015-05-12 11:20:10 +0200274 * \brief Parse DHM parameters in PEM or DER format
Paul Bakker40ce79f2013-09-15 17:43:54 +0200275 *
276 * \param dhm DHM context to be initialized
277 * \param dhmin input buffer
278 * \param dhminlen size of the buffer
Manuel Pégourié-Gonnard43b37cb2015-05-12 11:20:10 +0200279 * (including the terminating null byte for PEM data)
Paul Bakker40ce79f2013-09-15 17:43:54 +0200280 *
281 * \return 0 if successful, or a specific DHM or PEM error code
282 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200283int mbedtls_dhm_parse_dhm( mbedtls_dhm_context *dhm, const unsigned char *dhmin,
Paul Bakker40ce79f2013-09-15 17:43:54 +0200284 size_t dhminlen );
285
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200286#if defined(MBEDTLS_FS_IO)
Paul Bakker40ce79f2013-09-15 17:43:54 +0200287/** \ingroup x509_module */
288/**
289 * \brief Load and parse DHM parameters
290 *
291 * \param dhm DHM context to be initialized
292 * \param path filename to read the DHM Parameters from
293 *
294 * \return 0 if successful, or a specific DHM or PEM error code
295 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296int mbedtls_dhm_parse_dhmfile( mbedtls_dhm_context *dhm, const char *path );
297#endif /* MBEDTLS_FS_IO */
298#endif /* MBEDTLS_ASN1_PARSE_C */
nirekh01d569ecf2018-01-09 16:43:21 +0000299
300#ifdef __cplusplus
301}
302#endif
303
304#else /* MBEDTLS_DHM_ALT */
Reuven Levin1f35ca92017-12-07 10:09:32 +0000305#include "dhm_alt.h"
306#endif /* MBEDTLS_DHM_ALT */
Paul Bakker40ce79f2013-09-15 17:43:54 +0200307
nirekh01d569ecf2018-01-09 16:43:21 +0000308#ifdef __cplusplus
309extern "C" {
310#endif
311
Paul Bakker5121ce52009-01-03 21:22:43 +0000312/**
313 * \brief Checkup routine
314 *
315 * \return 0 if successful, or 1 if the test failed
316 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200317int mbedtls_dhm_self_test( int verbose );
Paul Bakker5121ce52009-01-03 21:22:43 +0000318
319#ifdef __cplusplus
320}
321#endif
322
Paul Bakker9af723c2014-05-01 13:03:14 +0200323#endif /* dhm.h */