blob: 6862835e6a2deb5e14d7b8c927eaa5f427f763df [file] [log] [blame]
Paul Bakkerbdb912d2012-02-13 23:11:30 +00001/*
Paul Bakkerf3df61a2013-08-26 17:22:23 +02002 * Key writing application
Paul Bakkerbdb912d2012-02-13 23:11:30 +00003 *
Manuel Pégourié-Gonnarda658a402015-01-23 09:45:19 +00004 * Copyright (C) 2006-2013, ARM Limited, All Rights Reserved
Paul Bakkerbdb912d2012-02-13 23:11:30 +00005 *
Manuel Pégourié-Gonnard085ab042015-01-23 11:06:27 +00006 * This file is part of mbed TLS (https://www.polarssl.org)
Paul Bakkerbdb912d2012-02-13 23:11:30 +00007 *
Paul Bakkerbdb912d2012-02-13 23:11:30 +00008 * 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
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020023#if !defined(POLARSSL_CONFIG_FILE)
Manuel Pégourié-Gonnardabd6e022013-09-20 13:30:43 +020024#include "polarssl/config.h"
Manuel Pégourié-Gonnardcef4ad22014-04-29 12:39:06 +020025#else
26#include POLARSSL_CONFIG_FILE
27#endif
Paul Bakkerbdb912d2012-02-13 23:11:30 +000028
Rich Evansf90016a2015-01-19 14:26:37 +000029#if defined(POLARSSL_PLATFORM_C)
30#include "polarssl/platform.h"
31#else
32#define polarssl_printf printf
33#define polarssl_fprintf fprintf
34#define polarssl_malloc malloc
35#define polarssl_free free
36#endif
37
Paul Bakkerbdb912d2012-02-13 23:11:30 +000038#include <string.h>
39#include <stdlib.h>
40#include <stdio.h>
41
Paul Bakker2e24ca72013-09-18 15:21:27 +020042#include "polarssl/error.h"
Paul Bakker7c6b2c32013-09-16 13:49:26 +020043#include "polarssl/pk.h"
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +020044#include "polarssl/error.h"
Paul Bakkerbdb912d2012-02-13 23:11:30 +000045
Paul Bakker7c6b2c32013-09-16 13:49:26 +020046#if !defined(POLARSSL_PK_WRITE_C) || !defined(POLARSSL_FS_IO)
Paul Bakkered27a042013-04-18 22:46:23 +020047int main( int argc, char *argv[] )
48{
49 ((void) argc);
50 ((void) argv);
51
Rich Evansf90016a2015-01-19 14:26:37 +000052 polarssl_printf( "POLARSSL_PK_WRITE_C and/or POLARSSL_FS_IO not defined.\n" );
Paul Bakkered27a042013-04-18 22:46:23 +020053 return( 0 );
54}
55#else
56
Paul Bakkerbdb912d2012-02-13 23:11:30 +000057#define MODE_NONE 0
58#define MODE_PRIVATE 1
59#define MODE_PUBLIC 2
60
61#define OUTPUT_MODE_NONE 0
62#define OUTPUT_MODE_PRIVATE 1
63#define OUTPUT_MODE_PUBLIC 2
64
Paul Bakkerf3df61a2013-08-26 17:22:23 +020065#define OUTPUT_FORMAT_PEM 0
66#define OUTPUT_FORMAT_DER 1
67
Paul Bakkerbdb912d2012-02-13 23:11:30 +000068#define DFL_MODE MODE_NONE
69#define DFL_FILENAME "keyfile.key"
70#define DFL_DEBUG_LEVEL 0
Paul Bakkerf3df61a2013-08-26 17:22:23 +020071#define DFL_OUTPUT_MODE OUTPUT_MODE_NONE
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +020072#if defined(POLARSSL_PEM_WRITE_C)
Paul Bakkerbdb912d2012-02-13 23:11:30 +000073#define DFL_OUTPUT_FILENAME "keyfile.pem"
Paul Bakkerf3df61a2013-08-26 17:22:23 +020074#define DFL_OUTPUT_FORMAT OUTPUT_FORMAT_PEM
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +020075#else
76#define DFL_OUTPUT_FILENAME "keyfile.der"
77#define DFL_OUTPUT_FORMAT OUTPUT_FORMAT_DER
78#endif
Paul Bakkerbdb912d2012-02-13 23:11:30 +000079
80/*
81 * global options
82 */
83struct options
84{
85 int mode; /* the mode to run the application in */
Paul Bakkeref3f8c72013-06-24 13:01:08 +020086 const char *filename; /* filename of the key file */
Paul Bakkerbdb912d2012-02-13 23:11:30 +000087 int output_mode; /* the output mode to use */
Paul Bakkeref3f8c72013-06-24 13:01:08 +020088 const char *output_file; /* where to store the constructed key file */
Paul Bakkerf3df61a2013-08-26 17:22:23 +020089 int output_format; /* the output format to use */
Paul Bakkerbdb912d2012-02-13 23:11:30 +000090} opt;
91
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +020092static int write_public_key( pk_context *key, const char *output_file )
Paul Bakkerbdb912d2012-02-13 23:11:30 +000093{
Paul Bakkerf3df61a2013-08-26 17:22:23 +020094 int ret;
Paul Bakkerbdb912d2012-02-13 23:11:30 +000095 FILE *f;
Paul Bakker1d569582012-10-03 20:35:44 +000096 unsigned char output_buf[16000];
Paul Bakkerf3df61a2013-08-26 17:22:23 +020097 unsigned char *c = output_buf;
98 size_t len = 0;
Paul Bakkerbdb912d2012-02-13 23:11:30 +000099
Paul Bakker1d569582012-10-03 20:35:44 +0000100 memset(output_buf, 0, 16000);
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000101
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200102#if defined(POLARSSL_PEM_WRITE_C)
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200103 if( opt.output_format == OUTPUT_FORMAT_PEM )
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000104 {
Paul Bakkerc7bb02b2013-09-15 14:54:56 +0200105 if( ( ret = pk_write_pubkey_pem( key, output_buf, 16000 ) ) != 0 )
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200106 return( ret );
107
108 len = strlen( (char *) output_buf );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000109 }
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200110 else
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200111#endif
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200112 {
Paul Bakkerc7bb02b2013-09-15 14:54:56 +0200113 if( ( ret = pk_write_pubkey_der( key, output_buf, 16000 ) ) < 0 )
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200114 return( ret );
115
116 len = ret;
117 c = output_buf + sizeof(output_buf) - len - 1;
118 }
119
120 if( ( f = fopen( output_file, "w" ) ) == NULL )
121 return( -1 );
122
123 if( fwrite( c, 1, len, f ) != len )
Paul Bakker0c226102014-04-17 16:02:36 +0200124 {
125 fclose( f );
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200126 return( -1 );
Paul Bakker0c226102014-04-17 16:02:36 +0200127 }
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200128
Paul Bakker0c226102014-04-17 16:02:36 +0200129 fclose( f );
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200130
131 return( 0 );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000132}
133
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200134static int write_private_key( pk_context *key, const char *output_file )
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000135{
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200136 int ret;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000137 FILE *f;
Paul Bakker1d569582012-10-03 20:35:44 +0000138 unsigned char output_buf[16000];
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200139 unsigned char *c = output_buf;
140 size_t len = 0;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000141
Paul Bakker1d569582012-10-03 20:35:44 +0000142 memset(output_buf, 0, 16000);
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200143
144#if defined(POLARSSL_PEM_WRITE_C)
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200145 if( opt.output_format == OUTPUT_FORMAT_PEM )
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000146 {
Paul Bakkerc7bb02b2013-09-15 14:54:56 +0200147 if( ( ret = pk_write_key_pem( key, output_buf, 16000 ) ) != 0 )
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200148 return( ret );
149
150 len = strlen( (char *) output_buf );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000151 }
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200152 else
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200153#endif
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200154 {
Paul Bakkerc7bb02b2013-09-15 14:54:56 +0200155 if( ( ret = pk_write_key_der( key, output_buf, 16000 ) ) < 0 )
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200156 return( ret );
157
158 len = ret;
159 c = output_buf + sizeof(output_buf) - len - 1;
160 }
161
162 if( ( f = fopen( output_file, "w" ) ) == NULL )
163 return( -1 );
164
165 if( fwrite( c, 1, len, f ) != len )
Paul Bakker0c226102014-04-17 16:02:36 +0200166 {
167 fclose( f );
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200168 return( -1 );
Paul Bakker0c226102014-04-17 16:02:36 +0200169 }
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200170
Paul Bakker0c226102014-04-17 16:02:36 +0200171 fclose( f );
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200172
173 return( 0 );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000174}
175
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200176#if defined(POLARSSL_PEM_WRITE_C)
177#define USAGE_OUT \
178 " output_file=%%s default: keyfile.pem\n" \
179 " output_format=pem|der default: pem\n"
180#else
181#define USAGE_OUT \
182 " output_file=%%s default: keyfile.der\n" \
183 " output_format=der default: der\n"
184#endif
185
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000186#define USAGE \
187 "\n usage: key_app param=<>...\n" \
188 "\n acceptable parameters:\n" \
189 " mode=private|public default: none\n" \
190 " filename=%%s default: keyfile.key\n" \
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000191 " output_mode=private|public default: none\n" \
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200192 USAGE_OUT \
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000193 "\n"
194
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000195int main( int argc, char *argv[] )
196{
197 int ret = 0;
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200198 pk_context key;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000199 char buf[1024];
Paul Bakker1d569582012-10-03 20:35:44 +0000200 int i;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000201 char *p, *q;
202
203 /*
204 * Set to sane values
205 */
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200206 pk_init( &key );
207 memset( buf, 0, sizeof( buf ) );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000208
209 if( argc == 0 )
210 {
211 usage:
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200212 ret = 1;
Rich Evansf90016a2015-01-19 14:26:37 +0000213 polarssl_printf( USAGE );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000214 goto exit;
215 }
216
217 opt.mode = DFL_MODE;
218 opt.filename = DFL_FILENAME;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000219 opt.output_mode = DFL_OUTPUT_MODE;
220 opt.output_file = DFL_OUTPUT_FILENAME;
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200221 opt.output_format = DFL_OUTPUT_FORMAT;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000222
223 for( i = 1; i < argc; i++ )
224 {
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000225 p = argv[i];
226 if( ( q = strchr( p, '=' ) ) == NULL )
227 goto usage;
228 *q++ = '\0';
229
230 if( strcmp( p, "mode" ) == 0 )
231 {
232 if( strcmp( q, "private" ) == 0 )
233 opt.mode = MODE_PRIVATE;
234 else if( strcmp( q, "public" ) == 0 )
235 opt.mode = MODE_PUBLIC;
236 else
237 goto usage;
238 }
239 else if( strcmp( p, "output_mode" ) == 0 )
240 {
241 if( strcmp( q, "private" ) == 0 )
242 opt.output_mode = OUTPUT_MODE_PRIVATE;
243 else if( strcmp( q, "public" ) == 0 )
244 opt.output_mode = OUTPUT_MODE_PUBLIC;
245 else
246 goto usage;
247 }
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200248 else if( strcmp( p, "output_format" ) == 0 )
249 {
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200250#if defined(POLARSSL_PEM_WRITE_C)
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200251 if( strcmp( q, "pem" ) == 0 )
252 opt.output_format = OUTPUT_FORMAT_PEM;
Manuel Pégourié-Gonnardf9378d82014-06-24 13:11:25 +0200253 else
254#endif
255 if( strcmp( q, "der" ) == 0 )
Paul Bakkerf3df61a2013-08-26 17:22:23 +0200256 opt.output_format = OUTPUT_FORMAT_DER;
257 else
258 goto usage;
259 }
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000260 else if( strcmp( p, "filename" ) == 0 )
261 opt.filename = q;
262 else if( strcmp( p, "output_file" ) == 0 )
263 opt.output_file = q;
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000264 else
265 goto usage;
266 }
267
268 if( opt.mode == MODE_NONE && opt.output_mode != OUTPUT_MODE_NONE )
269 {
Rich Evansf90016a2015-01-19 14:26:37 +0000270 polarssl_printf( "\nCannot output a key without reading one.\n");
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000271 goto exit;
272 }
273
274 if( opt.mode == MODE_PUBLIC && opt.output_mode == OUTPUT_MODE_PRIVATE )
275 {
Rich Evansf90016a2015-01-19 14:26:37 +0000276 polarssl_printf( "\nCannot output a private key from a public key.\n");
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000277 goto exit;
278 }
279
280 if( opt.mode == MODE_PRIVATE )
281 {
282 /*
283 * 1.1. Load the key
284 */
Rich Evansf90016a2015-01-19 14:26:37 +0000285 polarssl_printf( "\n . Loading the private key ..." );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000286 fflush( stdout );
287
Paul Bakker1a7550a2013-09-15 13:01:22 +0200288 ret = pk_parse_keyfile( &key, opt.filename, NULL );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000289
290 if( ret != 0 )
291 {
Paul Bakker2e24ca72013-09-18 15:21:27 +0200292 polarssl_strerror( ret, (char *) buf, sizeof(buf) );
Rich Evansf90016a2015-01-19 14:26:37 +0000293 polarssl_printf( " failed\n ! pk_parse_keyfile returned -0x%04x - %s\n\n", -ret, buf );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000294 goto exit;
295 }
296
Rich Evansf90016a2015-01-19 14:26:37 +0000297 polarssl_printf( " ok\n" );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000298
299 /*
300 * 1.2 Print the key
301 */
Rich Evansf90016a2015-01-19 14:26:37 +0000302 polarssl_printf( " . Key information ...\n" );
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200303
304#if defined(POLARSSL_RSA_C)
305 if( pk_get_type( &key ) == POLARSSL_PK_RSA )
306 {
307 rsa_context *rsa = pk_rsa( key );
308 mpi_write_file( "N: ", &rsa->N, 16, NULL );
309 mpi_write_file( "E: ", &rsa->E, 16, NULL );
310 mpi_write_file( "D: ", &rsa->D, 16, NULL );
311 mpi_write_file( "P: ", &rsa->P, 16, NULL );
312 mpi_write_file( "Q: ", &rsa->Q, 16, NULL );
313 mpi_write_file( "DP: ", &rsa->DP, 16, NULL );
314 mpi_write_file( "DQ: ", &rsa->DQ, 16, NULL );
315 mpi_write_file( "QP: ", &rsa->QP, 16, NULL );
316 }
317 else
318#endif
Paul Bakker2e24ca72013-09-18 15:21:27 +0200319#if defined(POLARSSL_ECP_C)
320 if( pk_get_type( &key ) == POLARSSL_PK_ECKEY )
321 {
322 ecp_keypair *ecp = pk_ec( key );
323 mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
324 mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
325 mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
326 mpi_write_file( "D : ", &ecp->d , 16, NULL );
327 }
328 else
329#endif
Rich Evansf90016a2015-01-19 14:26:37 +0000330 polarssl_printf("key type not supported yet\n");
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000331
332 }
333 else if( opt.mode == MODE_PUBLIC )
334 {
335 /*
336 * 1.1. Load the key
337 */
Rich Evansf90016a2015-01-19 14:26:37 +0000338 polarssl_printf( "\n . Loading the public key ..." );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000339 fflush( stdout );
340
Paul Bakker1a7550a2013-09-15 13:01:22 +0200341 ret = pk_parse_public_keyfile( &key, opt.filename );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000342
343 if( ret != 0 )
344 {
Paul Bakker2e24ca72013-09-18 15:21:27 +0200345 polarssl_strerror( ret, (char *) buf, sizeof(buf) );
Rich Evansf90016a2015-01-19 14:26:37 +0000346 polarssl_printf( " failed\n ! pk_parse_public_key returned -0x%04x - %s\n\n", -ret, buf );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000347 goto exit;
348 }
349
Rich Evansf90016a2015-01-19 14:26:37 +0000350 polarssl_printf( " ok\n" );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000351
352 /*
353 * 1.2 Print the key
354 */
Rich Evansf90016a2015-01-19 14:26:37 +0000355 polarssl_printf( " . Key information ...\n" );
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200356
357#if defined(POLARSSL_RSA_C)
358 if( pk_get_type( &key ) == POLARSSL_PK_RSA )
359 {
360 rsa_context *rsa = pk_rsa( key );
361 mpi_write_file( "N: ", &rsa->N, 16, NULL );
362 mpi_write_file( "E: ", &rsa->E, 16, NULL );
363 }
364 else
365#endif
Paul Bakker2e24ca72013-09-18 15:21:27 +0200366#if defined(POLARSSL_ECP_C)
367 if( pk_get_type( &key ) == POLARSSL_PK_ECKEY )
368 {
369 ecp_keypair *ecp = pk_ec( key );
370 mpi_write_file( "Q(X): ", &ecp->Q.X, 16, NULL );
371 mpi_write_file( "Q(Y): ", &ecp->Q.Y, 16, NULL );
372 mpi_write_file( "Q(Z): ", &ecp->Q.Z, 16, NULL );
373 }
374 else
375#endif
Rich Evansf90016a2015-01-19 14:26:37 +0000376 polarssl_printf("key type not supported yet\n");
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000377 }
378 else
379 goto usage;
380
381 if( opt.output_mode == OUTPUT_MODE_PUBLIC )
382 {
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200383 write_public_key( &key, opt.output_file );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000384 }
385 if( opt.output_mode == OUTPUT_MODE_PRIVATE )
386 {
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200387 write_private_key( &key, opt.output_file );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000388 }
389
390exit:
391
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200392 if( ret != 0 && ret != 1)
393 {
394#ifdef POLARSSL_ERROR_C
395 polarssl_strerror( ret, buf, sizeof( buf ) );
Rich Evansf90016a2015-01-19 14:26:37 +0000396 polarssl_printf( " - %s\n", buf );
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200397#else
Rich Evansf90016a2015-01-19 14:26:37 +0000398 polarssl_printf("\n");
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200399#endif
400 }
401
402 pk_free( &key );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000403
404#if defined(_WIN32)
Rich Evansf90016a2015-01-19 14:26:37 +0000405 polarssl_printf( " + Press Enter to exit this program.\n" );
Paul Bakkerbdb912d2012-02-13 23:11:30 +0000406 fflush( stdout ); getchar();
407#endif
408
409 return( ret );
410}
Manuel Pégourié-Gonnard26b4d452013-09-12 06:56:06 +0200411#endif /* POLARSSL_X509_WRITE_C && POLARSSL_FS_IO */