Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Simple DTLS client demonstration program |
| 3 | * |
| 4 | * Copyright (C) 2014, Brainspark B.V. |
| 5 | * |
Manuel Pégourié-Gonnard | e4d4890 | 2015-03-06 13:40:52 +0000 | [diff] [blame^] | 6 | * This file is part of mbed TLS (https://tls.mbed.org) |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along |
| 19 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 20 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | */ |
| 22 | |
| 23 | #if !defined(POLARSSL_CONFIG_FILE) |
| 24 | #include "polarssl/config.h" |
| 25 | #else |
| 26 | #include POLARSSL_CONFIG_FILE |
| 27 | #endif |
| 28 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 29 | #if defined(POLARSSL_PLATFORM_C) |
| 30 | #include "polarssl/platform.h" |
| 31 | #else |
| 32 | #define polarssl_printf printf |
| 33 | #define polarssl_fprintf fprintf |
| 34 | #endif |
| 35 | |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 36 | #if !defined(POLARSSL_SSL_CLI_C) || !defined(POLARSSL_SSL_PROTO_DTLS) || \ |
| 37 | !defined(POLARSSL_NET_C) || \ |
| 38 | !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) || \ |
| 39 | !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_RSA_C) || \ |
| 40 | !defined(POLARSSL_CERTS_C) |
| 41 | |
| 42 | #include <stdio.h> |
| 43 | int main( int argc, char *argv[] ) |
| 44 | { |
| 45 | ((void) argc); |
| 46 | ((void) argv); |
| 47 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 48 | polarssl_printf( "POLARSSL_SSL_CLI_C and/or POLARSSL_SSL_PROTO_DTLS and/or " |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 49 | "POLARSSL_NET_C and/or " |
| 50 | "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or " |
| 51 | "POLARSSL_X509_CRT_PARSE_C and/or POLARSSL_RSA_C and/or " |
| 52 | "POLARSSL_CERTS_C not defined.\n" ); |
| 53 | return( 0 ); |
| 54 | } |
| 55 | #else |
| 56 | |
| 57 | #include <string.h> |
| 58 | #include <stdio.h> |
| 59 | |
| 60 | #include "polarssl/net.h" |
| 61 | #include "polarssl/debug.h" |
| 62 | #include "polarssl/ssl.h" |
| 63 | #include "polarssl/entropy.h" |
| 64 | #include "polarssl/ctr_drbg.h" |
| 65 | #include "polarssl/error.h" |
| 66 | #include "polarssl/certs.h" |
| 67 | |
| 68 | #define SERVER_PORT 4433 |
| 69 | #define SERVER_NAME "localhost" |
| 70 | #define SERVER_ADDR "127.0.0.1" /* forces IPv4 */ |
| 71 | #define MESSAGE "Echo this" |
| 72 | |
| 73 | #define READ_TIMEOUT_MS 1000 |
| 74 | #define MAX_RETRY 5 |
| 75 | |
| 76 | #define DEBUG_LEVEL 0 |
| 77 | |
| 78 | static void my_debug( void *ctx, int level, const char *str ) |
| 79 | { |
| 80 | ((void) level); |
| 81 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 82 | polarssl_fprintf( (FILE *) ctx, "%s", str ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 83 | fflush( (FILE *) ctx ); |
| 84 | } |
| 85 | |
| 86 | int main( int argc, char *argv[] ) |
| 87 | { |
| 88 | int ret, len, server_fd = -1; |
| 89 | unsigned char buf[1024]; |
| 90 | const char *pers = "dtls_client"; |
| 91 | int retry_left = MAX_RETRY; |
| 92 | |
| 93 | entropy_context entropy; |
| 94 | ctr_drbg_context ctr_drbg; |
| 95 | ssl_context ssl; |
| 96 | x509_crt cacert; |
| 97 | |
| 98 | ((void) argc); |
| 99 | ((void) argv); |
| 100 | |
| 101 | #if defined(POLARSSL_DEBUG_C) |
| 102 | debug_set_threshold( DEBUG_LEVEL ); |
| 103 | #endif |
| 104 | |
| 105 | /* |
| 106 | * 0. Initialize the RNG and the session data |
| 107 | */ |
| 108 | memset( &ssl, 0, sizeof( ssl_context ) ); |
| 109 | x509_crt_init( &cacert ); |
| 110 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 111 | polarssl_printf( "\n . Seeding the random number generator..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 112 | fflush( stdout ); |
| 113 | |
| 114 | entropy_init( &entropy ); |
| 115 | if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy, |
| 116 | (const unsigned char *) pers, |
| 117 | strlen( pers ) ) ) != 0 ) |
| 118 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 119 | polarssl_printf( " failed\n ! ctr_drbg_init returned %d\n", ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 120 | goto exit; |
| 121 | } |
| 122 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 123 | polarssl_printf( " ok\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 124 | |
| 125 | /* |
| 126 | * 0. Initialize certificates |
| 127 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 128 | polarssl_printf( " . Loading the CA root certificate ..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 129 | fflush( stdout ); |
| 130 | |
| 131 | #if defined(POLARSSL_CERTS_C) |
| 132 | ret = x509_crt_parse( &cacert, (const unsigned char *) test_ca_list, |
| 133 | strlen( test_ca_list ) ); |
| 134 | #else |
| 135 | ret = 1; |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 136 | polarssl_printf("POLARSSL_CERTS_C not defined."); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 137 | #endif |
| 138 | |
| 139 | if( ret < 0 ) |
| 140 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 141 | polarssl_printf( " failed\n ! x509_crt_parse returned -0x%x\n\n", -ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 142 | goto exit; |
| 143 | } |
| 144 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 145 | polarssl_printf( " ok (%d skipped)\n", ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 146 | |
| 147 | /* |
| 148 | * 1. Start the connection |
| 149 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 150 | polarssl_printf( " . Connecting to udp/%s/%4d...", SERVER_NAME, |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 151 | SERVER_PORT ); |
| 152 | fflush( stdout ); |
| 153 | |
| 154 | if( ( ret = net_connect( &server_fd, SERVER_ADDR, |
| 155 | SERVER_PORT, NET_PROTO_UDP ) ) != 0 ) |
| 156 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 157 | polarssl_printf( " failed\n ! net_connect returned %d\n\n", ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 158 | goto exit; |
| 159 | } |
| 160 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 161 | polarssl_printf( " ok\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 162 | |
| 163 | /* |
| 164 | * 2. Setup stuff |
| 165 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 166 | polarssl_printf( " . Setting up the DTLS structure..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 167 | fflush( stdout ); |
| 168 | |
| 169 | if( ( ret = ssl_init( &ssl ) ) != 0 ) |
| 170 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 171 | polarssl_printf( " failed\n ! ssl_init returned %d\n\n", ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 172 | goto exit; |
| 173 | } |
| 174 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 175 | polarssl_printf( " ok\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 176 | |
| 177 | ssl_set_endpoint( &ssl, SSL_IS_CLIENT ); |
| 178 | ssl_set_transport( &ssl, SSL_TRANSPORT_DATAGRAM ); |
| 179 | |
| 180 | /* OPTIONAL is usually a bad choice for security, but makes interop easier |
| 181 | * in this simplified example, in which the ca chain is hardcoded. |
| 182 | * Production code should set a proper ca chain and use REQUIRED. */ |
| 183 | ssl_set_authmode( &ssl, SSL_VERIFY_OPTIONAL ); |
| 184 | ssl_set_ca_chain( &ssl, &cacert, NULL, SERVER_NAME ); |
| 185 | |
| 186 | ssl_set_rng( &ssl, ctr_drbg_random, &ctr_drbg ); |
| 187 | ssl_set_dbg( &ssl, my_debug, stdout ); |
| 188 | |
| 189 | ssl_set_bio_timeout( &ssl, &server_fd, |
| 190 | net_send, net_recv, net_recv_timeout, |
| 191 | READ_TIMEOUT_MS ); |
| 192 | |
| 193 | /* |
| 194 | * 4. Handshake |
| 195 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 196 | polarssl_printf( " . Performing the SSL/TLS handshake..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 197 | fflush( stdout ); |
| 198 | |
| 199 | do ret = ssl_handshake( &ssl ); |
| 200 | while( ret == POLARSSL_ERR_NET_WANT_READ || |
| 201 | ret == POLARSSL_ERR_NET_WANT_WRITE ); |
| 202 | |
| 203 | if( ret != 0 ) |
| 204 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 205 | polarssl_printf( " failed\n ! ssl_handshake returned -0x%x\n\n", -ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 206 | goto exit; |
| 207 | } |
| 208 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 209 | polarssl_printf( " ok\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 210 | |
| 211 | /* |
| 212 | * 5. Verify the server certificate |
| 213 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 214 | polarssl_printf( " . Verifying peer X.509 certificate..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 215 | |
| 216 | /* In real life, we would have used SSL_VERIFY_REQUIRED so that the |
| 217 | * handshake would not succeed if the peer's cert is bad. Even if we used |
| 218 | * SSL_VERIFY_OPTIONAL, we would bail out here if ret != 0 */ |
| 219 | if( ( ret = ssl_get_verify_result( &ssl ) ) != 0 ) |
| 220 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 221 | polarssl_printf( " failed\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 222 | |
| 223 | if( ( ret & BADCERT_EXPIRED ) != 0 ) |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 224 | polarssl_printf( " ! server certificate has expired\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 225 | |
| 226 | if( ( ret & BADCERT_REVOKED ) != 0 ) |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 227 | polarssl_printf( " ! server certificate has been revoked\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 228 | |
| 229 | if( ( ret & BADCERT_CN_MISMATCH ) != 0 ) |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 230 | polarssl_printf( " ! CN mismatch (expected CN=%s)\n", SERVER_NAME ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 231 | |
| 232 | if( ( ret & BADCERT_NOT_TRUSTED ) != 0 ) |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 233 | polarssl_printf( " ! self-signed or not signed by a trusted CA\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 234 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 235 | polarssl_printf( "\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 236 | } |
| 237 | else |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 238 | polarssl_printf( " ok\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 239 | |
| 240 | /* |
| 241 | * 6. Write the echo request |
| 242 | */ |
| 243 | send_request: |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 244 | polarssl_printf( " > Write to server:" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 245 | fflush( stdout ); |
| 246 | |
| 247 | len = sizeof( MESSAGE ) - 1; |
| 248 | |
| 249 | do ret = ssl_write( &ssl, (unsigned char *) MESSAGE, len ); |
| 250 | while( ret == POLARSSL_ERR_NET_WANT_READ || |
| 251 | ret == POLARSSL_ERR_NET_WANT_WRITE ); |
| 252 | |
| 253 | if( ret < 0 ) |
| 254 | { |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 255 | polarssl_printf( " failed\n ! ssl_write returned %d\n\n", ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 256 | goto exit; |
| 257 | } |
| 258 | |
| 259 | len = ret; |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 260 | polarssl_printf( " %d bytes written\n\n%s\n\n", len, MESSAGE ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * 7. Read the echo response |
| 264 | */ |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 265 | polarssl_printf( " < Read from server:" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 266 | fflush( stdout ); |
| 267 | |
| 268 | len = sizeof( buf ) - 1; |
| 269 | memset( buf, 0, sizeof( buf ) ); |
| 270 | |
| 271 | do ret = ssl_read( &ssl, buf, len ); |
| 272 | while( ret == POLARSSL_ERR_NET_WANT_READ || |
| 273 | ret == POLARSSL_ERR_NET_WANT_WRITE ); |
| 274 | |
| 275 | if( ret <= 0 ) |
| 276 | { |
| 277 | switch( ret ) |
| 278 | { |
| 279 | case POLARSSL_ERR_NET_TIMEOUT: |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 280 | polarssl_printf( " timeout\n\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 281 | if( retry_left-- > 0 ) |
| 282 | goto send_request; |
| 283 | goto exit; |
| 284 | |
| 285 | case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY: |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 286 | polarssl_printf( " connection was closed gracefully\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 287 | ret = 0; |
| 288 | goto close_notify; |
| 289 | |
| 290 | default: |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 291 | polarssl_printf( " ssl_read returned -0x%x\n\n", -ret ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 292 | goto exit; |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | len = ret; |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 297 | polarssl_printf( " %d bytes read\n\n%s\n\n", len, buf ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 298 | |
| 299 | /* |
| 300 | * 8. Done, cleanly close the connection |
| 301 | */ |
| 302 | close_notify: |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 303 | polarssl_printf( " . Closing the connection..." ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 304 | |
| 305 | /* No error checking, the connection might be closed already */ |
| 306 | do ret = ssl_close_notify( &ssl ); |
| 307 | while( ret == POLARSSL_ERR_NET_WANT_WRITE ); |
| 308 | ret = 0; |
| 309 | |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 310 | polarssl_printf( " done\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 311 | |
| 312 | /* |
| 313 | * 9. Final clean-ups and exit |
| 314 | */ |
| 315 | exit: |
| 316 | |
| 317 | #ifdef POLARSSL_ERROR_C |
| 318 | if( ret != 0 ) |
| 319 | { |
| 320 | char error_buf[100]; |
| 321 | polarssl_strerror( ret, error_buf, 100 ); |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 322 | polarssl_printf( "Last error was: %d - %s\n\n", ret, error_buf ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 323 | } |
| 324 | #endif |
| 325 | |
| 326 | if( server_fd != -1 ) |
| 327 | net_close( server_fd ); |
| 328 | |
| 329 | x509_crt_free( &cacert ); |
| 330 | ssl_free( &ssl ); |
| 331 | ctr_drbg_free( &ctr_drbg ); |
| 332 | entropy_free( &entropy ); |
| 333 | |
| 334 | #if defined(_WIN32) |
Manuel Pégourié-Gonnard | f224678 | 2015-01-29 13:29:20 +0000 | [diff] [blame] | 335 | polarssl_printf( " + Press Enter to exit this program.\n" ); |
Manuel Pégourié-Gonnard | e63582a | 2014-10-14 11:47:21 +0200 | [diff] [blame] | 336 | fflush( stdout ); getchar(); |
| 337 | #endif |
| 338 | |
| 339 | /* Shell can not handle large exit numbers -> 1 for errors */ |
| 340 | if( ret < 0 ) |
| 341 | ret = 1; |
| 342 | |
| 343 | return( ret ); |
| 344 | } |
| 345 | #endif /* POLARSSL_SSL_CLI_C && POLARSSL_SSL_PROTO_DTLS && POLARSSL_NET_C && |
| 346 | POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C && |
| 347 | POLARSSL_X509_CRT_PARSE_C && POLARSSL_RSA_C && POLARSSL_CERTS_C */ |