blob: 6ad00d6abb90585fb40a53f36efffecb87363ed9 [file] [log] [blame]
Paul Bakker5121ce52009-01-03 21:22:43 +00001/*
2 * Diffie-Hellman-Merkle key exchange (server side)
3 *
Bence Szépkúti1e148272020-08-07 13:07:28 +02004 * Copyright The Mbed TLS Contributors
Manuel Pégourié-Gonnard37ff1402015-09-04 14:21:07 +02005 * SPDX-License-Identifier: Apache-2.0
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may
8 * not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
Paul Bakker5121ce52009-01-03 21:22:43 +000018 */
19
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020020#if !defined(MBEDTLS_CONFIG_FILE)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000021#include "mbedtls/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020022#else
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020023#include MBEDTLS_CONFIG_FILE
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020024#endif
Paul Bakker5121ce52009-01-03 21:22:43 +000025
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000026#include "mbedtls/platform.h"
Rich Evansf90016a2015-01-19 14:26:37 +000027
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020028#if defined(MBEDTLS_AES_C) && defined(MBEDTLS_DHM_C) && \
29 defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_NET_C) && \
30 defined(MBEDTLS_RSA_C) && defined(MBEDTLS_SHA256_C) && \
Janos Follath9fe6f922016-10-07 14:17:56 +010031 defined(MBEDTLS_FS_IO) && defined(MBEDTLS_CTR_DRBG_C) && \
32 defined(MBEDTLS_SHA1_C)
Andres AG788aa4a2016-09-14 14:32:09 +010033#include "mbedtls/net_sockets.h"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000034#include "mbedtls/aes.h"
35#include "mbedtls/dhm.h"
36#include "mbedtls/rsa.h"
37#include "mbedtls/sha1.h"
38#include "mbedtls/entropy.h"
39#include "mbedtls/ctr_drbg.h"
Paul Bakker5121ce52009-01-03 21:22:43 +000040
Rich Evans18b78c72015-02-11 14:06:19 +000041#include <stdio.h>
42#include <string.h>
43#endif
44
Manuel Pégourié-Gonnardc0d74942015-06-23 12:30:57 +020045#define SERVER_PORT "11999"
Paul Bakker5121ce52009-01-03 21:22:43 +000046#define PLAINTEXT "==Hello there!=="
47
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020048#if !defined(MBEDTLS_AES_C) || !defined(MBEDTLS_DHM_C) || \
49 !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_NET_C) || \
50 !defined(MBEDTLS_RSA_C) || !defined(MBEDTLS_SHA256_C) || \
Janos Follath9fe6f922016-10-07 14:17:56 +010051 !defined(MBEDTLS_FS_IO) || !defined(MBEDTLS_CTR_DRBG_C) || \
52 !defined(MBEDTLS_SHA1_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000053int main( void )
Paul Bakker5690efc2011-05-26 13:16:06 +000054{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020055 mbedtls_printf("MBEDTLS_AES_C and/or MBEDTLS_DHM_C and/or MBEDTLS_ENTROPY_C "
56 "and/or MBEDTLS_NET_C and/or MBEDTLS_RSA_C and/or "
57 "MBEDTLS_SHA256_C and/or MBEDTLS_FS_IO and/or "
58 "MBEDTLS_CTR_DRBG_C not defined.\n");
Krzysztof Stachowiak5e1b1952019-04-24 14:24:46 +020059 mbedtls_exit( 0 );
Paul Bakker5690efc2011-05-26 13:16:06 +000060}
61#else
Simon Butcher63cb97e2018-12-06 17:43:31 +000062
Simon Butcher63cb97e2018-12-06 17:43:31 +000063
Rich Evans85b05ec2015-02-12 11:37:29 +000064int main( void )
Paul Bakker5121ce52009-01-03 21:22:43 +000065{
66 FILE *f;
67
Andres Amaya Garcia03a992c2018-04-29 19:40:45 +010068 int ret = 1;
69 int exit_code = MBEDTLS_EXIT_FAILURE;
Paul Bakker23986e52011-04-24 08:57:21 +000070 size_t n, buflen;
Manuel Pégourié-Gonnard5db64322015-06-30 15:40:39 +020071 mbedtls_net_context listen_fd, client_fd;
Paul Bakker5121ce52009-01-03 21:22:43 +000072
Paul Bakker520ea912012-10-24 14:17:01 +000073 unsigned char buf[2048];
Manuel Pégourié-Gonnard102a6202015-08-27 21:51:44 +020074 unsigned char hash[32];
Paul Bakker5121ce52009-01-03 21:22:43 +000075 unsigned char buf2[2];
Paul Bakkeref3f8c72013-06-24 13:01:08 +020076 const char *pers = "dh_server";
Paul Bakker5121ce52009-01-03 21:22:43 +000077
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020078 mbedtls_entropy_context entropy;
79 mbedtls_ctr_drbg_context ctr_drbg;
80 mbedtls_rsa_context rsa;
81 mbedtls_dhm_context dhm;
82 mbedtls_aes_context aes;
Paul Bakker5121ce52009-01-03 21:22:43 +000083
Hanno Beckerc95fad32017-08-23 06:44:30 +010084 mbedtls_mpi N, P, Q, D, E;
85
Manuel Pégourié-Gonnard5db64322015-06-30 15:40:39 +020086 mbedtls_net_init( &listen_fd );
87 mbedtls_net_init( &client_fd );
88 mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, MBEDTLS_MD_SHA256 );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020089 mbedtls_dhm_init( &dhm );
90 mbedtls_aes_init( &aes );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +020091 mbedtls_ctr_drbg_init( &ctr_drbg );
Paul Bakker5121ce52009-01-03 21:22:43 +000092
Hanno Beckerc95fad32017-08-23 06:44:30 +010093 mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
94 mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
95
Paul Bakker5121ce52009-01-03 21:22:43 +000096 /*
97 * 1. Setup the RNG
98 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020099 mbedtls_printf( "\n . Seeding the random number generator" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000100 fflush( stdout );
101
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200102 mbedtls_entropy_init( &entropy );
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200103 if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
Paul Bakkeref3f8c72013-06-24 13:01:08 +0200104 (const unsigned char *) pers,
105 strlen( pers ) ) ) != 0 )
Paul Bakker508ad5a2011-12-04 17:09:26 +0000106 {
Manuel Pégourié-Gonnardec160c02015-04-28 22:52:30 +0200107 mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned %d\n", ret );
Paul Bakker508ad5a2011-12-04 17:09:26 +0000108 goto exit;
109 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000110
111 /*
112 * 2a. Read the server's private RSA key
113 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200114 mbedtls_printf( "\n . Reading private key from rsa_priv.txt" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000115 fflush( stdout );
116
117 if( ( f = fopen( "rsa_priv.txt", "rb" ) ) == NULL )
118 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200119 mbedtls_printf( " failed\n ! Could not open rsa_priv.txt\n" \
Paul Bakker5121ce52009-01-03 21:22:43 +0000120 " ! Please run rsa_genkey first\n\n" );
121 goto exit;
122 }
123
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200124 mbedtls_rsa_init( &rsa, MBEDTLS_RSA_PKCS_V15, 0 );
Paul Bakker5121ce52009-01-03 21:22:43 +0000125
Hanno Beckerc95fad32017-08-23 06:44:30 +0100126 if( ( ret = mbedtls_mpi_read_file( &N , 16, f ) ) != 0 ||
127 ( ret = mbedtls_mpi_read_file( &E , 16, f ) ) != 0 ||
128 ( ret = mbedtls_mpi_read_file( &D , 16, f ) ) != 0 ||
129 ( ret = mbedtls_mpi_read_file( &P , 16, f ) ) != 0 ||
130 ( ret = mbedtls_mpi_read_file( &Q , 16, f ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000131 {
Hanno Beckerc95fad32017-08-23 06:44:30 +0100132 mbedtls_printf( " failed\n ! mbedtls_mpi_read_file returned %d\n\n",
133 ret );
Janos Follath98e28a72016-05-31 14:03:54 +0100134 fclose( f );
Paul Bakker5121ce52009-01-03 21:22:43 +0000135 goto exit;
136 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000137 fclose( f );
138
Hanno Beckerc95fad32017-08-23 06:44:30 +0100139 if( ( ret = mbedtls_rsa_import( &rsa, &N, &P, &Q, &D, &E ) ) != 0 )
140 {
141 mbedtls_printf( " failed\n ! mbedtls_rsa_import returned %d\n\n",
142 ret );
143 goto exit;
144 }
145
Hanno Becker7f25f852017-10-10 16:56:22 +0100146 if( ( ret = mbedtls_rsa_complete( &rsa ) ) != 0 )
Hanno Beckerc95fad32017-08-23 06:44:30 +0100147 {
148 mbedtls_printf( " failed\n ! mbedtls_rsa_complete returned %d\n\n",
149 ret );
150 goto exit;
151 }
152
Paul Bakker5121ce52009-01-03 21:22:43 +0000153 /*
154 * 2b. Get the DHM modulus and generator
155 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200156 mbedtls_printf( "\n . Reading DH parameters from dh_prime.txt" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000157 fflush( stdout );
158
159 if( ( f = fopen( "dh_prime.txt", "rb" ) ) == NULL )
160 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200161 mbedtls_printf( " failed\n ! Could not open dh_prime.txt\n" \
Paul Bakker5121ce52009-01-03 21:22:43 +0000162 " ! Please run dh_genprime first\n\n" );
163 goto exit;
164 }
165
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200166 if( mbedtls_mpi_read_file( &dhm.P, 16, f ) != 0 ||
167 mbedtls_mpi_read_file( &dhm.G, 16, f ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000168 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200169 mbedtls_printf( " failed\n ! Invalid DH parameter file\n\n" );
Janos Follath98e28a72016-05-31 14:03:54 +0100170 fclose( f );
Paul Bakker5121ce52009-01-03 21:22:43 +0000171 goto exit;
172 }
173
174 fclose( f );
175
176 /*
177 * 3. Wait for a client to connect
178 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200179 mbedtls_printf( "\n . Waiting for a remote connection" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000180 fflush( stdout );
181
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200182 if( ( ret = mbedtls_net_bind( &listen_fd, NULL, SERVER_PORT, MBEDTLS_NET_PROTO_TCP ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000183 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200184 mbedtls_printf( " failed\n ! mbedtls_net_bind returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000185 goto exit;
186 }
187
Manuel Pégourié-Gonnard5db64322015-06-30 15:40:39 +0200188 if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd,
Manuel Pégourié-Gonnard0b104b02015-05-14 21:52:40 +0200189 NULL, 0, NULL ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000190 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200191 mbedtls_printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000192 goto exit;
193 }
194
195 /*
196 * 4. Setup the DH parameters (P,G,Ys)
197 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200198 mbedtls_printf( "\n . Sending the server's DH parameters" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000199 fflush( stdout );
200
201 memset( buf, 0, sizeof( buf ) );
202
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200203 if( ( ret = mbedtls_dhm_make_params( &dhm, (int) mbedtls_mpi_size( &dhm.P ), buf, &n,
204 mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000205 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200206 mbedtls_printf( " failed\n ! mbedtls_dhm_make_params returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000207 goto exit;
208 }
209
210 /*
211 * 5. Sign the parameters and send them
212 */
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100213 if( ( ret = mbedtls_sha1_ret( buf, n, hash ) ) != 0 )
Andres Amaya Garcia1ff60f42017-06-28 13:26:36 +0100214 {
Gilles Peskine9e4f77c2018-01-22 11:48:08 +0100215 mbedtls_printf( " failed\n ! mbedtls_sha1_ret returned %d\n\n", ret );
Andres Amaya Garcia1ff60f42017-06-28 13:26:36 +0100216 goto exit;
217 }
Paul Bakker5121ce52009-01-03 21:22:43 +0000218
219 buf[n ] = (unsigned char)( rsa.len >> 8 );
220 buf[n + 1] = (unsigned char)( rsa.len );
221
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200222 if( ( ret = mbedtls_rsa_pkcs1_sign( &rsa, NULL, NULL, MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_SHA256,
Paul Bakker5121ce52009-01-03 21:22:43 +0000223 0, hash, buf + n + 2 ) ) != 0 )
224 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200225 mbedtls_printf( " failed\n ! mbedtls_rsa_pkcs1_sign returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000226 goto exit;
227 }
228
229 buflen = n + 2 + rsa.len;
230 buf2[0] = (unsigned char)( buflen >> 8 );
231 buf2[1] = (unsigned char)( buflen );
232
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200233 if( ( ret = mbedtls_net_send( &client_fd, buf2, 2 ) ) != 2 ||
234 ( ret = mbedtls_net_send( &client_fd, buf, buflen ) ) != (int) buflen )
Paul Bakker5121ce52009-01-03 21:22:43 +0000235 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200236 mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000237 goto exit;
238 }
239
240 /*
241 * 6. Get the client's public value: Yc = G ^ Xc mod P
242 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200243 mbedtls_printf( "\n . Receiving the client's public value" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000244 fflush( stdout );
245
246 memset( buf, 0, sizeof( buf ) );
Paul Bakker5121ce52009-01-03 21:22:43 +0000247
Martijn de Millianob194a282017-07-06 23:55:59 +0200248 n = dhm.len;
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200249 if( ( ret = mbedtls_net_recv( &client_fd, buf, n ) ) != (int) n )
Paul Bakker5121ce52009-01-03 21:22:43 +0000250 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200251 mbedtls_printf( " failed\n ! mbedtls_net_recv returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000252 goto exit;
253 }
254
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200255 if( ( ret = mbedtls_dhm_read_public( &dhm, buf, dhm.len ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000256 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200257 mbedtls_printf( " failed\n ! mbedtls_dhm_read_public returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000258 goto exit;
259 }
260
261 /*
262 * 7. Derive the shared secret: K = Ys ^ Xc mod P
263 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200264 mbedtls_printf( "\n . Shared secret: " );
Paul Bakker5121ce52009-01-03 21:22:43 +0000265 fflush( stdout );
266
Manuel Pégourié-Gonnard33352052015-06-02 16:17:08 +0100267 if( ( ret = mbedtls_dhm_calc_secret( &dhm, buf, sizeof( buf ), &n,
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200268 mbedtls_ctr_drbg_random, &ctr_drbg ) ) != 0 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000269 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200270 mbedtls_printf( " failed\n ! mbedtls_dhm_calc_secret returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000271 goto exit;
272 }
273
274 for( n = 0; n < 16; n++ )
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200275 mbedtls_printf( "%02x", buf[n] );
Paul Bakker5121ce52009-01-03 21:22:43 +0000276
277 /*
278 * 8. Setup the AES-256 encryption key
279 *
280 * This is an overly simplified example; best practice is
281 * to hash the shared secret with a random value to derive
282 * the keying material for the encryption/decryption keys
283 * and MACs.
284 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200285 mbedtls_printf( "...\n . Encrypting and sending the ciphertext" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000286 fflush( stdout );
287
Gilles Peskine377a3102021-07-07 21:08:28 +0200288 ret = mbedtls_aes_setkey_enc( &aes, buf, 256 );
289 if( ret != 0 )
290 goto exit;
Paul Bakker5121ce52009-01-03 21:22:43 +0000291 memcpy( buf, PLAINTEXT, 16 );
Gilles Peskine377a3102021-07-07 21:08:28 +0200292 ret = mbedtls_aes_crypt_ecb( &aes, MBEDTLS_AES_ENCRYPT, buf, buf );
293 if( ret != 0 )
294 goto exit;
Paul Bakker5121ce52009-01-03 21:22:43 +0000295
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296 if( ( ret = mbedtls_net_send( &client_fd, buf, 16 ) ) != 16 )
Paul Bakker5121ce52009-01-03 21:22:43 +0000297 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200298 mbedtls_printf( " failed\n ! mbedtls_net_send returned %d\n\n", ret );
Paul Bakker5121ce52009-01-03 21:22:43 +0000299 goto exit;
300 }
301
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200302 mbedtls_printf( "\n\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000303
Andres Amaya Garcia03a992c2018-04-29 19:40:45 +0100304 exit_code = MBEDTLS_EXIT_SUCCESS;
305
Paul Bakker5121ce52009-01-03 21:22:43 +0000306exit:
307
Hanno Beckerc95fad32017-08-23 06:44:30 +0100308 mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
309 mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
310
Manuel Pégourié-Gonnard3d7d00a2015-06-30 15:55:03 +0200311 mbedtls_net_free( &client_fd );
312 mbedtls_net_free( &listen_fd );
Paul Bakker0c226102014-04-17 16:02:36 +0200313
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200314 mbedtls_aes_free( &aes );
315 mbedtls_rsa_free( &rsa );
316 mbedtls_dhm_free( &dhm );
317 mbedtls_ctr_drbg_free( &ctr_drbg );
318 mbedtls_entropy_free( &entropy );
Paul Bakker5121ce52009-01-03 21:22:43 +0000319
Paul Bakkercce9d772011-11-18 14:26:47 +0000320#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200321 mbedtls_printf( " + Press Enter to exit this program.\n" );
Paul Bakker5121ce52009-01-03 21:22:43 +0000322 fflush( stdout ); getchar();
323#endif
324
Krzysztof Stachowiak5e1b1952019-04-24 14:24:46 +0200325 mbedtls_exit( exit_code );
Paul Bakker5121ce52009-01-03 21:22:43 +0000326}
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200327#endif /* MBEDTLS_AES_C && MBEDTLS_DHM_C && MBEDTLS_ENTROPY_C &&
328 MBEDTLS_NET_C && MBEDTLS_RSA_C && MBEDTLS_SHA256_C &&
329 MBEDTLS_FS_IO && MBEDTLS_CTR_DRBG_C */