blob: 2145e072adc162bcceef7664900b8ab085a22a35 [file] [log] [blame]
Paul Bakkered56b222011-07-13 11:26:43 +00001/*
2 * Key reading application
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 Bakkered56b222011-07-13 11:26: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 Bakkered56b222011-07-13 11:26:43 +000025
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020026#if defined(MBEDTLS_PLATFORM_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000027#include "mbedtls/platform.h"
Rich Evansf90016a2015-01-19 14:26:37 +000028#else
Rich Evans18b78c72015-02-11 14:06:19 +000029#include <stdio.h>
Andres Amaya Garcia0faf1a52018-04-29 20:02:18 +010030#include <stdlib.h>
31#define mbedtls_printf printf
Manuel Pégourié-Gonnard3ef6a6d2018-12-10 14:31:45 +010032#define mbedtls_exit exit
Andres Amaya Garcia7d429652018-04-30 22:42:33 +010033#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
Andres Amaya Garcia0faf1a52018-04-29 20:02:18 +010034#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
35#endif /* MBEDTLS_PLATFORM_C */
Rich Evansf90016a2015-01-19 14:26:37 +000036
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020037#if defined(MBEDTLS_BIGNUM_C) && \
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +020038 defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO) && \
39 defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_CTR_DRBG_C)
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000040#include "mbedtls/error.h"
41#include "mbedtls/rsa.h"
Jaeden Ameroed736992018-10-26 16:55:14 +010042#include "mbedtls/pk.h"
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +020043#include "mbedtls/entropy.h"
44#include "mbedtls/ctr_drbg.h"
Manuel Pégourié-Gonnard84dea012021-06-15 11:29:26 +020045
Rich Evans18b78c72015-02-11 14:06:19 +000046#include <string.h>
47#endif
48
49#define MODE_NONE 0
50#define MODE_PRIVATE 1
51#define MODE_PUBLIC 2
52
53#define DFL_MODE MODE_NONE
54#define DFL_FILENAME "keyfile.key"
55#define DFL_PASSWORD ""
56#define DFL_PASSWORD_FILE ""
57#define DFL_DEBUG_LEVEL 0
Manuel Pégourié-Gonnard6c5abfa2015-02-13 14:12:07 +000058
Rich Evans18b78c72015-02-11 14:06:19 +000059#define USAGE \
60 "\n usage: key_app param=<>...\n" \
61 "\n acceptable parameters:\n" \
62 " mode=private|public default: none\n" \
63 " filename=%%s default: keyfile.key\n" \
64 " password=%%s default: \"\"\n" \
65 " password_file=%%s default: \"\"\n" \
66 "\n"
67
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020068#if !defined(MBEDTLS_BIGNUM_C) || \
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +020069 !defined(MBEDTLS_PK_PARSE_C) || !defined(MBEDTLS_FS_IO) || \
70 !defined(MBEDTLS_ENTROPY_C) || !defined(MBEDTLS_CTR_DRBG_C)
Rich Evans85b05ec2015-02-12 11:37:29 +000071int main( void )
Paul Bakker15254952013-09-17 11:24:56 +020072{
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +020073 mbedtls_printf("MBEDTLS_BIGNUM_C and/or "
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +020074 "MBEDTLS_PK_PARSE_C and/or MBEDTLS_FS_IO and/or "
75 "MBEDTLS_ENTROPY_C and/or MBEDTLS_CTR_DRBG_C not defined.\n");
Krzysztof Stachowiak5e1b1952019-04-24 14:24:46 +020076 mbedtls_exit( 0 );
Paul Bakker15254952013-09-17 11:24:56 +020077}
78#else
Simon Butcher63cb97e2018-12-06 17:43:31 +000079
Simon Butcher63cb97e2018-12-06 17:43:31 +000080
Paul Bakkered56b222011-07-13 11:26:43 +000081/*
82 * global options
83 */
84struct options
85{
86 int mode; /* the mode to run the application in */
Paul Bakkeref3f8c72013-06-24 13:01:08 +020087 const char *filename; /* filename of the key file */
88 const char *password; /* password for the private key */
89 const char *password_file; /* password_file for the private key */
Paul Bakkered56b222011-07-13 11:26:43 +000090} opt;
91
Paul Bakkered56b222011-07-13 11:26:43 +000092int main( int argc, char *argv[] )
93{
Andres Amaya Garcia0faf1a52018-04-29 20:02:18 +010094 int ret = 1;
95 int exit_code = MBEDTLS_EXIT_FAILURE;
Paul Bakkered56b222011-07-13 11:26:43 +000096 char buf[1024];
Paul Bakkerdb2509c2012-09-27 12:44:31 +000097 int i;
Paul Bakkered56b222011-07-13 11:26:43 +000098 char *p, *q;
99
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200100 const char *pers = "pkey/key_app";
101 mbedtls_entropy_context entropy;
102 mbedtls_ctr_drbg_context ctr_drbg;
103
Hanno Becker54ebf992017-08-23 06:45:38 +0100104 mbedtls_pk_context pk;
105 mbedtls_mpi N, P, Q, D, E, DP, DQ, QP;
106
Paul Bakkered56b222011-07-13 11:26:43 +0000107 /*
108 * Set to sane values
109 */
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200110 mbedtls_entropy_init( &entropy );
111 mbedtls_ctr_drbg_init( &ctr_drbg );
112
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200113 mbedtls_pk_init( &pk );
Paul Bakker2e24ca72013-09-18 15:21:27 +0200114 memset( buf, 0, sizeof(buf) );
Paul Bakkered56b222011-07-13 11:26:43 +0000115
Hanno Becker54ebf992017-08-23 06:45:38 +0100116 mbedtls_mpi_init( &N ); mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
117 mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &DP );
118 mbedtls_mpi_init( &DQ ); mbedtls_mpi_init( &QP );
119
Paul Bakkered56b222011-07-13 11:26:43 +0000120 if( argc == 0 )
121 {
122 usage:
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200123 mbedtls_printf( USAGE );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300124 goto cleanup;
Paul Bakkered56b222011-07-13 11:26:43 +0000125 }
126
127 opt.mode = DFL_MODE;
128 opt.filename = DFL_FILENAME;
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000129 opt.password = DFL_PASSWORD;
130 opt.password_file = DFL_PASSWORD_FILE;
Paul Bakkered56b222011-07-13 11:26:43 +0000131
132 for( i = 1; i < argc; i++ )
133 {
Paul Bakkered56b222011-07-13 11:26:43 +0000134 p = argv[i];
135 if( ( q = strchr( p, '=' ) ) == NULL )
136 goto usage;
137 *q++ = '\0';
138
139 if( strcmp( p, "mode" ) == 0 )
140 {
141 if( strcmp( q, "private" ) == 0 )
142 opt.mode = MODE_PRIVATE;
143 else if( strcmp( q, "public" ) == 0 )
144 opt.mode = MODE_PUBLIC;
145 else
146 goto usage;
147 }
148 else if( strcmp( p, "filename" ) == 0 )
149 opt.filename = q;
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000150 else if( strcmp( p, "password" ) == 0 )
151 opt.password = q;
152 else if( strcmp( p, "password_file" ) == 0 )
153 opt.password_file = q;
Paul Bakkered56b222011-07-13 11:26:43 +0000154 else
155 goto usage;
156 }
157
158 if( opt.mode == MODE_PRIVATE )
159 {
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000160 if( strlen( opt.password ) && strlen( opt.password_file ) )
161 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200162 mbedtls_printf( "Error: cannot have both password and password_file\n" );
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000163 goto usage;
164 }
165
166 if( strlen( opt.password_file ) )
167 {
168 FILE *f;
169
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200170 mbedtls_printf( "\n . Loading the password file ..." );
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000171 if( ( f = fopen( opt.password_file, "rb" ) ) == NULL )
172 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200173 mbedtls_printf( " failed\n ! fopen returned NULL\n" );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300174 goto cleanup;
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000175 }
Paul Bakker8a0c0a92014-04-17 16:08:20 +0200176 if( fgets( buf, sizeof(buf), f ) == NULL )
177 {
178 fclose( f );
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200179 mbedtls_printf( "Error: fgets() failed to retrieve password\n" );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300180 goto cleanup;
Paul Bakker8a0c0a92014-04-17 16:08:20 +0200181 }
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000182 fclose( f );
183
Paul Bakker840ab202013-11-30 15:14:38 +0100184 i = (int) strlen( buf );
Paul Bakkerdb2509c2012-09-27 12:44:31 +0000185 if( buf[i - 1] == '\n' ) buf[i - 1] = '\0';
186 if( buf[i - 2] == '\r' ) buf[i - 2] = '\0';
187 opt.password = buf;
188 }
189
Paul Bakkered56b222011-07-13 11:26:43 +0000190 /*
191 * 1.1. Load the key
192 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200193 mbedtls_printf( "\n . Loading the private key ..." );
Paul Bakkered56b222011-07-13 11:26:43 +0000194 fflush( stdout );
195
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200196 if( ( ret = mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
197 (const unsigned char *) pers,
198 strlen( pers ) ) ) != 0 )
199 {
200 mbedtls_printf( " failed\n ! mbedtls_ctr_drbg_seed returned -0x%04x\n", (unsigned int) -ret );
201 goto cleanup;
202 }
203
Manuel Pégourié-Gonnard84dea012021-06-15 11:29:26 +0200204 ret = mbedtls_pk_parse_keyfile( &pk, opt.filename, opt.password,
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200205 mbedtls_ctr_drbg_random, &ctr_drbg );
Paul Bakkered56b222011-07-13 11:26:43 +0000206
207 if( ret != 0 )
208 {
Kenneth Soerensen518d4352020-04-01 17:22:45 +0200209 mbedtls_printf( " failed\n ! mbedtls_pk_parse_keyfile returned -0x%04x\n", (unsigned int) -ret );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300210 goto cleanup;
Paul Bakkered56b222011-07-13 11:26:43 +0000211 }
212
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200213 mbedtls_printf( " ok\n" );
Paul Bakkered56b222011-07-13 11:26:43 +0000214
215 /*
216 * 1.2 Print the key
217 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200218 mbedtls_printf( " . Key information ...\n" );
219#if defined(MBEDTLS_RSA_C)
220 if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
Paul Bakker15254952013-09-17 11:24:56 +0200221 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200222 mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
Hanno Becker54ebf992017-08-23 06:45:38 +0100223
224 if( ( ret = mbedtls_rsa_export ( rsa, &N, &P, &Q, &D, &E ) ) != 0 ||
225 ( ret = mbedtls_rsa_export_crt( rsa, &DP, &DQ, &QP ) ) != 0 )
226 {
227 mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
Ron Eldora5221472018-06-27 08:49:00 +0300228 goto cleanup;
Hanno Becker54ebf992017-08-23 06:45:38 +0100229 }
230
Ron Eldorbf470992018-06-27 11:51:46 +0300231 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "N: ", &N, 16, NULL ) );
232 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "E: ", &E, 16, NULL ) );
233 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D: ", &D, 16, NULL ) );
234 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "P: ", &P, 16, NULL ) );
235 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q: ", &Q, 16, NULL ) );
236 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "DP: ", &DP, 16, NULL ) );
237 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "DQ: ", &DQ, 16, NULL ) );
238 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "QP: ", &QP, 16, NULL ) );
Paul Bakker15254952013-09-17 11:24:56 +0200239 }
240 else
241#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200242#if defined(MBEDTLS_ECP_C)
243 if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
Paul Bakker15254952013-09-17 11:24:56 +0200244 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200245 mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
Mateusz Starzyk5dd4f6e2021-05-19 19:35:35 +0200246 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ) );
247 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ) );
248 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ) );
249 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "D : ", &ecp->MBEDTLS_PRIVATE(d) , 16, NULL ) );
Paul Bakker15254952013-09-17 11:24:56 +0200250 }
251 else
252#endif
253 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200254 mbedtls_printf("Do not know how to print key information for this type\n" );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300255 goto cleanup;
Paul Bakker15254952013-09-17 11:24:56 +0200256 }
Paul Bakkered56b222011-07-13 11:26:43 +0000257 }
258 else if( opt.mode == MODE_PUBLIC )
259 {
260 /*
261 * 1.1. Load the key
262 */
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200263 mbedtls_printf( "\n . Loading the public key ..." );
Paul Bakkered56b222011-07-13 11:26:43 +0000264 fflush( stdout );
265
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200266 ret = mbedtls_pk_parse_public_keyfile( &pk, opt.filename );
Paul Bakkered56b222011-07-13 11:26:43 +0000267
268 if( ret != 0 )
269 {
Kenneth Soerensen518d4352020-04-01 17:22:45 +0200270 mbedtls_printf( " failed\n ! mbedtls_pk_parse_public_keyfile returned -0x%04x\n", (unsigned int) -ret );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300271 goto cleanup;
Paul Bakkered56b222011-07-13 11:26:43 +0000272 }
273
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200274 mbedtls_printf( " ok\n" );
Paul Bakkered56b222011-07-13 11:26:43 +0000275
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200276 mbedtls_printf( " . Key information ...\n" );
277#if defined(MBEDTLS_RSA_C)
278 if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_RSA )
Paul Bakker15254952013-09-17 11:24:56 +0200279 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200280 mbedtls_rsa_context *rsa = mbedtls_pk_rsa( pk );
Hanno Becker54ebf992017-08-23 06:45:38 +0100281
282 if( ( ret = mbedtls_rsa_export( rsa, &N, NULL, NULL,
283 NULL, &E ) ) != 0 )
284 {
285 mbedtls_printf( " failed\n ! could not export RSA parameters\n\n" );
Ron Eldora5221472018-06-27 08:49:00 +0300286 goto cleanup;
Hanno Becker54ebf992017-08-23 06:45:38 +0100287 }
Ron Eldorbf470992018-06-27 11:51:46 +0300288 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "N: ", &N, 16, NULL ) );
289 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "E: ", &E, 16, NULL ) );
Paul Bakker15254952013-09-17 11:24:56 +0200290 }
291 else
292#endif
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200293#if defined(MBEDTLS_ECP_C)
294 if( mbedtls_pk_get_type( &pk ) == MBEDTLS_PK_ECKEY )
Paul Bakker15254952013-09-17 11:24:56 +0200295 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200296 mbedtls_ecp_keypair *ecp = mbedtls_pk_ec( pk );
Mateusz Starzyk5dd4f6e2021-05-19 19:35:35 +0200297 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(X): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(X), 16, NULL ) );
298 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Y): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Y), 16, NULL ) );
299 MBEDTLS_MPI_CHK( mbedtls_mpi_write_file( "Q(Z): ", &ecp->MBEDTLS_PRIVATE(Q).MBEDTLS_PRIVATE(Z), 16, NULL ) );
Paul Bakker15254952013-09-17 11:24:56 +0200300 }
301 else
302#endif
303 {
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200304 mbedtls_printf("Do not know how to print key information for this type\n" );
Ron Eldor6a9257b2017-08-24 14:20:17 +0300305 goto cleanup;
Paul Bakker15254952013-09-17 11:24:56 +0200306 }
Paul Bakkered56b222011-07-13 11:26:43 +0000307 }
308 else
309 goto usage;
310
Andres Amaya Garcia0faf1a52018-04-29 20:02:18 +0100311 exit_code = MBEDTLS_EXIT_SUCCESS;
312
Ron Eldor6a9257b2017-08-24 14:20:17 +0300313cleanup:
Paul Bakkered56b222011-07-13 11:26:43 +0000314
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200315#if defined(MBEDTLS_ERROR_C)
Andres Amaya Garcia0faf1a52018-04-29 20:02:18 +0100316 if( exit_code != MBEDTLS_EXIT_SUCCESS )
Hanno Becker54ebf992017-08-23 06:45:38 +0100317 {
Ron Eldor7a814262018-06-24 16:34:15 +0300318 mbedtls_strerror( ret, buf, sizeof( buf ) );
Hanno Becker54ebf992017-08-23 06:45:38 +0100319 mbedtls_printf( " ! Last error was: %s\n", buf );
320 }
Manuel Pégourié-Gonnard92e5b592013-09-18 18:57:10 +0200321#endif
322
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200323 mbedtls_ctr_drbg_free( &ctr_drbg );
324 mbedtls_entropy_free( &entropy );
325
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200326 mbedtls_pk_free( &pk );
Hanno Becker54ebf992017-08-23 06:45:38 +0100327 mbedtls_mpi_free( &N ); mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
328 mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &DP );
329 mbedtls_mpi_free( &DQ ); mbedtls_mpi_free( &QP );
Paul Bakkered56b222011-07-13 11:26:43 +0000330
Paul Bakkercce9d772011-11-18 14:26:47 +0000331#if defined(_WIN32)
Manuel Pégourié-Gonnard2cf5a7c2015-04-08 12:49:31 +0200332 mbedtls_printf( " + Press Enter to exit this program.\n" );
Paul Bakkered56b222011-07-13 11:26:43 +0000333 fflush( stdout ); getchar();
334#endif
335
Krzysztof Stachowiak5e1b1952019-04-24 14:24:46 +0200336 mbedtls_exit( exit_code );
Paul Bakkered56b222011-07-13 11:26:43 +0000337}
Manuel Pégourié-Gonnard1503a9a2021-06-16 10:35:56 +0200338#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO &&
339 MBEDTLS_ENTROPY_C && MBEDTLS_CTR_DRBG_C */