Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Certificate generation and signing |
| 3 | * |
| 4 | * Copyright (C) 2006-2013, Brainspark B.V. |
| 5 | * |
| 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
| 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
| 8 | * |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License along |
| 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 24 | */ |
| 25 | |
Manuel Pégourié-Gonnard | abd6e02 | 2013-09-20 13:30:43 +0200 | [diff] [blame] | 26 | #include "polarssl/config.h" |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 27 | |
| 28 | #include <string.h> |
| 29 | #include <stdlib.h> |
| 30 | #include <stdio.h> |
| 31 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 32 | #if !defined(POLARSSL_X509_CRT_WRITE_C) || \ |
| 33 | !defined(POLARSSL_X509_CRT_PARSE_C) || !defined(POLARSSL_FS_IO) || \ |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 34 | !defined(POLARSSL_ENTROPY_C) || !defined(POLARSSL_CTR_DRBG_C) || \ |
Paul Bakker | 4122f3e | 2013-09-09 16:01:46 +0200 | [diff] [blame] | 35 | !defined(POLARSSL_ERROR_C) |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 36 | int main( int argc, char *argv[] ) |
| 37 | { |
| 38 | ((void) argc); |
| 39 | ((void) argv); |
| 40 | |
Paul Bakker | 7c6b2c3 | 2013-09-16 13:49:26 +0200 | [diff] [blame] | 41 | printf( "POLARSSL_X509_CRT_WRITE_C and/or POLARSSL_X509_CRT_PARSE_C and/or " |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 42 | "POLARSSL_FS_IO and/or " |
| 43 | "POLARSSL_ENTROPY_C and/or POLARSSL_CTR_DRBG_C and/or " |
| 44 | "POLARSSL_ERROR_C not defined.\n"); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 45 | return( 0 ); |
| 46 | } |
| 47 | #else |
| 48 | |
Manuel Pégourié-Gonnard | 7831b0c | 2013-09-20 12:29:56 +0200 | [diff] [blame] | 49 | #include "polarssl/x509_crt.h" |
| 50 | #include "polarssl/x509_csr.h" |
| 51 | #include "polarssl/entropy.h" |
| 52 | #include "polarssl/ctr_drbg.h" |
| 53 | #include "polarssl/error.h" |
| 54 | |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 55 | #define DFL_ISSUER_CRT "" |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 56 | #define DFL_REQUEST_FILE "" |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 57 | #define DFL_SUBJECT_KEY "subject.key" |
| 58 | #define DFL_ISSUER_KEY "ca.key" |
| 59 | #define DFL_SUBJECT_PWD "" |
| 60 | #define DFL_ISSUER_PWD "" |
| 61 | #define DFL_OUTPUT_FILENAME "cert.crt" |
| 62 | #define DFL_SUBJECT_NAME "CN=Cert,O=PolarSSL,C=NL" |
| 63 | #define DFL_ISSUER_NAME "CN=CA,O=PolarSSL,C=NL" |
| 64 | #define DFL_NOT_BEFORE "20010101000000" |
| 65 | #define DFL_NOT_AFTER "20301231235959" |
| 66 | #define DFL_SERIAL "1" |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 67 | #define DFL_SELFSIGN 0 |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 68 | #define DFL_IS_CA 0 |
| 69 | #define DFL_MAX_PATHLEN -1 |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 70 | #define DFL_KEY_USAGE 0 |
| 71 | #define DFL_NS_CERT_TYPE 0 |
| 72 | |
| 73 | /* |
| 74 | * global options |
| 75 | */ |
| 76 | struct options |
| 77 | { |
Paul Bakker | 8fc30b1 | 2013-11-25 13:29:43 +0100 | [diff] [blame] | 78 | const char *issuer_crt; /* filename of the issuer certificate */ |
| 79 | const char *request_file; /* filename of the certificate request */ |
| 80 | const char *subject_key; /* filename of the subject key file */ |
| 81 | const char *issuer_key; /* filename of the issuer key file */ |
| 82 | const char *subject_pwd; /* password for the subject key file */ |
| 83 | const char *issuer_pwd; /* password for the issuer key file */ |
| 84 | const char *output_file; /* where to store the constructed key file */ |
| 85 | const char *subject_name; /* subject name for certificate */ |
| 86 | const char *issuer_name; /* issuer name for certificate */ |
| 87 | const char *not_before; /* validity period not before */ |
| 88 | const char *not_after; /* validity period not after */ |
| 89 | const char *serial; /* serial number string */ |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 90 | int selfsign; /* selfsign the certificate */ |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 91 | int is_ca; /* is a CA certificate */ |
| 92 | int max_pathlen; /* maximum CA path length */ |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 93 | unsigned char key_usage; /* key usage flags */ |
| 94 | unsigned char ns_cert_type; /* NS cert type */ |
| 95 | } opt; |
| 96 | |
Paul Bakker | 8fc30b1 | 2013-11-25 13:29:43 +0100 | [diff] [blame] | 97 | int write_certificate( x509write_cert *crt, const char *output_file, |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 98 | int (*f_rng)(void *, unsigned char *, size_t), |
| 99 | void *p_rng ) |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 100 | { |
| 101 | int ret; |
| 102 | FILE *f; |
| 103 | unsigned char output_buf[4096]; |
| 104 | size_t len = 0; |
| 105 | |
| 106 | memset( output_buf, 0, 4096 ); |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 107 | if( ( ret = x509write_crt_pem( crt, output_buf, 4096, f_rng, p_rng ) ) < 0 ) |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 108 | return( ret ); |
| 109 | |
| 110 | len = strlen( (char *) output_buf ); |
| 111 | |
| 112 | if( ( f = fopen( output_file, "w" ) ) == NULL ) |
| 113 | return( -1 ); |
| 114 | |
| 115 | if( fwrite( output_buf, 1, len, f ) != len ) |
| 116 | return( -1 ); |
| 117 | |
| 118 | fclose(f); |
| 119 | |
| 120 | return( 0 ); |
| 121 | } |
| 122 | |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 123 | #if defined(POLARSSL_X509_CSR_PARSE_C) |
| 124 | #define USAGE_CSR \ |
| 125 | " request_file=%%s default: (empty)\n" \ |
| 126 | " If request_file is specified, subject_key,\n" \ |
| 127 | " subject_pwd and subject_name are ignored!\n" |
| 128 | #else |
| 129 | #define USAGE_CSR "" |
| 130 | #endif /* POLARSSL_X509_CSR_PARSE_C */ |
| 131 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 132 | #define USAGE \ |
| 133 | "\n usage: cert_write param=<>...\n" \ |
| 134 | "\n acceptable parameters:\n" \ |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 135 | USAGE_CSR \ |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 136 | " subject_key=%%s default: subject.key\n" \ |
| 137 | " subject_pwd=%%s default: (empty)\n" \ |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 138 | " subject_name=%%s default: CN=Cert,O=PolarSSL,C=NL\n" \ |
| 139 | "\n" \ |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 140 | " issuer_crt=%%s default: (empty)\n" \ |
| 141 | " If issuer_crt is specified, issuer_name is\n" \ |
| 142 | " ignored!\n" \ |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 143 | " issuer_name=%%s default: CN=CA,O=PolarSSL,C=NL\n" \ |
| 144 | "\n" \ |
| 145 | " selfsign=%%d default: 0 (false)\n" \ |
| 146 | " If selfsign is enabled, issuer_name and\n" \ |
| 147 | " issuer_key are required (issuer_crt and\n" \ |
| 148 | " subject_* are ignored\n" \ |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 149 | " issuer_key=%%s default: ca.key\n" \ |
| 150 | " issuer_pwd=%%s default: (empty)\n" \ |
| 151 | " output_file=%%s default: cert.crt\n" \ |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 152 | " serial=%%s default: 1\n" \ |
| 153 | " not_before=%%s default: 20010101000000\n"\ |
| 154 | " not_after=%%s default: 20301231235959\n"\ |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 155 | " is_ca=%%d default: 0 (disabled)\n" \ |
| 156 | " max_pathlen=%%d default: -1 (none)\n" \ |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 157 | " key_usage=%%s default: (empty)\n" \ |
| 158 | " Comma-separated-list of values:\n" \ |
| 159 | " digital_signature\n" \ |
| 160 | " non_repudiation\n" \ |
| 161 | " key_encipherment\n" \ |
| 162 | " data_encipherment\n" \ |
| 163 | " key_agreement\n" \ |
| 164 | " key_certificate_sign\n" \ |
| 165 | " crl_sign\n" \ |
| 166 | " ns_cert_type=%%s default: (empty)\n" \ |
| 167 | " Comma-separated-list of values:\n" \ |
| 168 | " ssl_client\n" \ |
| 169 | " ssl_server\n" \ |
| 170 | " email\n" \ |
| 171 | " object_signing\n" \ |
| 172 | " ssl_ca\n" \ |
| 173 | " email_ca\n" \ |
| 174 | " object_signing_ca\n" \ |
| 175 | "\n" |
| 176 | |
| 177 | int main( int argc, char *argv[] ) |
| 178 | { |
| 179 | int ret = 0; |
Paul Bakker | c559c7a | 2013-09-18 14:13:26 +0200 | [diff] [blame] | 180 | x509_crt issuer_crt; |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 181 | pk_context loaded_issuer_key, loaded_subject_key; |
| 182 | pk_context *issuer_key = &loaded_issuer_key, |
| 183 | *subject_key = &loaded_subject_key; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 184 | char buf[1024]; |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 185 | char issuer_name[128]; |
Paul Bakker | c97f9f6 | 2013-11-30 15:13:02 +0100 | [diff] [blame^] | 186 | int i; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 187 | char *p, *q, *r; |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 188 | #if defined(POLARSSL_X509_CSR_PARSE_C) |
| 189 | char subject_name[128]; |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 190 | x509_csr csr; |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 191 | #endif |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 192 | x509write_cert crt; |
| 193 | mpi serial; |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 194 | entropy_context entropy; |
| 195 | ctr_drbg_context ctr_drbg; |
| 196 | const char *pers = "crt example app"; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 197 | |
| 198 | /* |
| 199 | * Set to sane values |
| 200 | */ |
| 201 | x509write_crt_init( &crt ); |
| 202 | x509write_crt_set_md_alg( &crt, POLARSSL_MD_SHA1 ); |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 203 | pk_init( &loaded_issuer_key ); |
| 204 | pk_init( &loaded_subject_key ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 205 | mpi_init( &serial ); |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 206 | #if defined(POLARSSL_X509_CSR_PARSE_C) |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 207 | x509_csr_init( &csr ); |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 208 | #endif |
Paul Bakker | 369d2eb | 2013-09-18 11:58:25 +0200 | [diff] [blame] | 209 | x509_crt_init( &issuer_crt ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 210 | memset( buf, 0, 1024 ); |
| 211 | |
| 212 | if( argc == 0 ) |
| 213 | { |
| 214 | usage: |
| 215 | printf( USAGE ); |
| 216 | ret = 1; |
| 217 | goto exit; |
| 218 | } |
| 219 | |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 220 | opt.issuer_crt = DFL_ISSUER_CRT; |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 221 | opt.request_file = DFL_REQUEST_FILE; |
| 222 | opt.request_file = DFL_REQUEST_FILE; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 223 | opt.subject_key = DFL_SUBJECT_KEY; |
| 224 | opt.issuer_key = DFL_ISSUER_KEY; |
| 225 | opt.subject_pwd = DFL_SUBJECT_PWD; |
| 226 | opt.issuer_pwd = DFL_ISSUER_PWD; |
| 227 | opt.output_file = DFL_OUTPUT_FILENAME; |
| 228 | opt.subject_name = DFL_SUBJECT_NAME; |
| 229 | opt.issuer_name = DFL_ISSUER_NAME; |
| 230 | opt.not_before = DFL_NOT_BEFORE; |
| 231 | opt.not_after = DFL_NOT_AFTER; |
| 232 | opt.serial = DFL_SERIAL; |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 233 | opt.selfsign = DFL_SELFSIGN; |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 234 | opt.is_ca = DFL_IS_CA; |
| 235 | opt.max_pathlen = DFL_MAX_PATHLEN; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 236 | opt.key_usage = DFL_KEY_USAGE; |
| 237 | opt.ns_cert_type = DFL_NS_CERT_TYPE; |
| 238 | |
| 239 | for( i = 1; i < argc; i++ ) |
| 240 | { |
| 241 | |
| 242 | p = argv[i]; |
| 243 | if( ( q = strchr( p, '=' ) ) == NULL ) |
| 244 | goto usage; |
| 245 | *q++ = '\0'; |
| 246 | |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 247 | if( strcmp( p, "request_file" ) == 0 ) |
| 248 | opt.request_file = q; |
| 249 | else if( strcmp( p, "subject_key" ) == 0 ) |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 250 | opt.subject_key = q; |
| 251 | else if( strcmp( p, "issuer_key" ) == 0 ) |
| 252 | opt.issuer_key = q; |
| 253 | else if( strcmp( p, "subject_pwd" ) == 0 ) |
| 254 | opt.subject_pwd = q; |
| 255 | else if( strcmp( p, "issuer_pwd" ) == 0 ) |
| 256 | opt.issuer_pwd = q; |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 257 | else if( strcmp( p, "issuer_crt" ) == 0 ) |
| 258 | opt.issuer_crt = q; |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 259 | else if( strcmp( p, "output_file" ) == 0 ) |
| 260 | opt.output_file = q; |
| 261 | else if( strcmp( p, "subject_name" ) == 0 ) |
| 262 | { |
| 263 | opt.subject_name = q; |
| 264 | } |
| 265 | else if( strcmp( p, "issuer_name" ) == 0 ) |
| 266 | { |
| 267 | opt.issuer_name = q; |
| 268 | } |
| 269 | else if( strcmp( p, "not_before" ) == 0 ) |
| 270 | { |
| 271 | opt.not_before = q; |
| 272 | } |
| 273 | else if( strcmp( p, "not_after" ) == 0 ) |
| 274 | { |
| 275 | opt.not_after = q; |
| 276 | } |
| 277 | else if( strcmp( p, "serial" ) == 0 ) |
| 278 | { |
| 279 | opt.serial = q; |
| 280 | } |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 281 | else if( strcmp( p, "selfsign" ) == 0 ) |
| 282 | { |
| 283 | opt.selfsign = atoi( q ); |
| 284 | if( opt.selfsign < 0 || opt.selfsign > 1 ) |
| 285 | goto usage; |
| 286 | } |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 287 | else if( strcmp( p, "is_ca" ) == 0 ) |
| 288 | { |
| 289 | opt.is_ca = atoi( q ); |
| 290 | if( opt.is_ca < 0 || opt.is_ca > 1 ) |
| 291 | goto usage; |
| 292 | } |
| 293 | else if( strcmp( p, "max_pathlen" ) == 0 ) |
| 294 | { |
| 295 | opt.max_pathlen = atoi( q ); |
| 296 | if( opt.max_pathlen < -1 || opt.max_pathlen > 127 ) |
| 297 | goto usage; |
| 298 | } |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 299 | else if( strcmp( p, "key_usage" ) == 0 ) |
| 300 | { |
| 301 | while( q != NULL ) |
| 302 | { |
| 303 | if( ( r = strchr( q, ',' ) ) != NULL ) |
| 304 | *r++ = '\0'; |
| 305 | |
| 306 | if( strcmp( q, "digital_signature" ) == 0 ) |
| 307 | opt.key_usage |= KU_DIGITAL_SIGNATURE; |
| 308 | else if( strcmp( q, "non_repudiation" ) == 0 ) |
| 309 | opt.key_usage |= KU_NON_REPUDIATION; |
| 310 | else if( strcmp( q, "key_encipherment" ) == 0 ) |
| 311 | opt.key_usage |= KU_KEY_ENCIPHERMENT; |
| 312 | else if( strcmp( q, "data_encipherment" ) == 0 ) |
| 313 | opt.key_usage |= KU_DATA_ENCIPHERMENT; |
| 314 | else if( strcmp( q, "key_agreement" ) == 0 ) |
| 315 | opt.key_usage |= KU_KEY_AGREEMENT; |
| 316 | else if( strcmp( q, "key_cert_sign" ) == 0 ) |
| 317 | opt.key_usage |= KU_KEY_CERT_SIGN; |
| 318 | else if( strcmp( q, "crl_sign" ) == 0 ) |
| 319 | opt.key_usage |= KU_CRL_SIGN; |
| 320 | else |
| 321 | goto usage; |
| 322 | |
| 323 | q = r; |
| 324 | } |
| 325 | } |
| 326 | else if( strcmp( p, "ns_cert_type" ) == 0 ) |
| 327 | { |
| 328 | while( q != NULL ) |
| 329 | { |
| 330 | if( ( r = strchr( q, ',' ) ) != NULL ) |
| 331 | *r++ = '\0'; |
| 332 | |
| 333 | if( strcmp( q, "ssl_client" ) == 0 ) |
| 334 | opt.ns_cert_type |= NS_CERT_TYPE_SSL_CLIENT; |
| 335 | else if( strcmp( q, "ssl_server" ) == 0 ) |
| 336 | opt.ns_cert_type |= NS_CERT_TYPE_SSL_SERVER; |
| 337 | else if( strcmp( q, "email" ) == 0 ) |
| 338 | opt.ns_cert_type |= NS_CERT_TYPE_EMAIL; |
| 339 | else if( strcmp( q, "object_signing" ) == 0 ) |
| 340 | opt.ns_cert_type |= NS_CERT_TYPE_OBJECT_SIGNING; |
| 341 | else if( strcmp( q, "ssl_ca" ) == 0 ) |
| 342 | opt.ns_cert_type |= NS_CERT_TYPE_SSL_CA; |
| 343 | else if( strcmp( q, "email_ca" ) == 0 ) |
| 344 | opt.ns_cert_type |= NS_CERT_TYPE_EMAIL_CA; |
| 345 | else if( strcmp( q, "object_signing_ca" ) == 0 ) |
| 346 | opt.ns_cert_type |= NS_CERT_TYPE_OBJECT_SIGNING_CA; |
| 347 | else |
| 348 | goto usage; |
| 349 | |
| 350 | q = r; |
| 351 | } |
| 352 | } |
| 353 | else |
| 354 | goto usage; |
| 355 | } |
| 356 | |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 357 | printf("\n"); |
| 358 | |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 359 | /* |
| 360 | * 0. Seed the PRNG |
| 361 | */ |
| 362 | printf( " . Seeding the random number generator..." ); |
| 363 | fflush( stdout ); |
| 364 | |
| 365 | entropy_init( &entropy ); |
| 366 | if( ( ret = ctr_drbg_init( &ctr_drbg, entropy_func, &entropy, |
| 367 | (const unsigned char *) pers, |
| 368 | strlen( pers ) ) ) != 0 ) |
| 369 | { |
| 370 | error_strerror( ret, buf, 1024 ); |
| 371 | printf( " failed\n ! ctr_drbg_init returned %d - %s\n", ret, buf ); |
| 372 | goto exit; |
| 373 | } |
| 374 | |
| 375 | printf( " ok\n" ); |
| 376 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 377 | // Parse serial to MPI |
| 378 | // |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 379 | printf( " . Reading serial number..." ); |
| 380 | fflush( stdout ); |
| 381 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 382 | if( ( ret = mpi_read_string( &serial, 10, opt.serial ) ) != 0 ) |
| 383 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 384 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 385 | printf( " failed\n ! mpi_read_string returned -0x%02x - %s\n\n", -ret, buf ); |
| 386 | goto exit; |
| 387 | } |
| 388 | |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 389 | printf( " ok\n" ); |
| 390 | |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 391 | // Parse issuer certificate if present |
| 392 | // |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 393 | if( !opt.selfsign && strlen( opt.issuer_crt ) ) |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 394 | { |
| 395 | /* |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 396 | * 1.0.a. Load the certificates |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 397 | */ |
| 398 | printf( " . Loading the issuer certificate ..." ); |
| 399 | fflush( stdout ); |
| 400 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 401 | if( ( ret = x509_crt_parse_file( &issuer_crt, opt.issuer_crt ) ) != 0 ) |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 402 | { |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 403 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 404 | printf( " failed\n ! x509_crt_parse_file returned -0x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 405 | goto exit; |
| 406 | } |
| 407 | |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 408 | ret = x509_dn_gets( issuer_name, sizeof(issuer_name), |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 409 | &issuer_crt.issuer ); |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 410 | if( ret < 0 ) |
| 411 | { |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 412 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 413 | printf( " failed\n ! x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 414 | goto exit; |
| 415 | } |
| 416 | |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 417 | opt.issuer_name = issuer_name; |
| 418 | |
| 419 | printf( " ok\n" ); |
| 420 | } |
| 421 | |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 422 | #if defined(POLARSSL_X509_CSR_PARSE_C) |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 423 | // Parse certificate request if present |
| 424 | // |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 425 | if( !opt.selfsign && strlen( opt.request_file ) ) |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 426 | { |
| 427 | /* |
| 428 | * 1.0.b. Load the CSR |
| 429 | */ |
| 430 | printf( " . Loading the certificate request ..." ); |
| 431 | fflush( stdout ); |
| 432 | |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 433 | if( ( ret = x509_csr_parse_file( &csr, opt.request_file ) ) != 0 ) |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 434 | { |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 435 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | ddf26b4 | 2013-09-18 13:46:23 +0200 | [diff] [blame] | 436 | printf( " failed\n ! x509_csr_parse_file returned -0x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 437 | goto exit; |
| 438 | } |
| 439 | |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 440 | ret = x509_dn_gets( subject_name, sizeof(subject_name), |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 441 | &csr.subject ); |
| 442 | if( ret < 0 ) |
| 443 | { |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 444 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 86d0c19 | 2013-09-18 11:11:02 +0200 | [diff] [blame] | 445 | printf( " failed\n ! x509_dn_gets returned -0x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 446 | goto exit; |
| 447 | } |
| 448 | |
| 449 | opt.subject_name = subject_name; |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 450 | subject_key = &csr.pk; |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 451 | |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 452 | printf( " ok\n" ); |
| 453 | } |
Paul Bakker | 7fc7fa6 | 2013-09-17 14:44:00 +0200 | [diff] [blame] | 454 | #endif /* POLARSSL_X509_CSR_PARSE_C */ |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 455 | |
| 456 | /* |
| 457 | * 1.1. Load the keys |
| 458 | */ |
| 459 | if( !opt.selfsign && !strlen( opt.request_file ) ) |
| 460 | { |
| 461 | printf( " . Loading the subject key ..." ); |
| 462 | fflush( stdout ); |
| 463 | |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 464 | ret = pk_parse_keyfile( &loaded_subject_key, opt.subject_key, |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 465 | opt.subject_pwd ); |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 466 | if( ret != 0 ) |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 467 | { |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 468 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 469 | printf( " failed\n ! pk_parse_keyfile returned -0x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | e2673fb | 2013-09-09 15:52:07 +0200 | [diff] [blame] | 470 | goto exit; |
| 471 | } |
Paul Bakker | 1014e95 | 2013-09-09 13:59:42 +0200 | [diff] [blame] | 472 | |
| 473 | printf( " ok\n" ); |
| 474 | } |
| 475 | |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 476 | printf( " . Loading the issuer key ..." ); |
| 477 | fflush( stdout ); |
| 478 | |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 479 | ret = pk_parse_keyfile( &loaded_issuer_key, opt.issuer_key, |
| 480 | opt.issuer_pwd ); |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 481 | if( ret != 0 ) |
| 482 | { |
| 483 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 1a7550a | 2013-09-15 13:01:22 +0200 | [diff] [blame] | 484 | printf( " failed\n ! pk_parse_keyfile returned -x%02x - %s\n\n", -ret, buf ); |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 485 | goto exit; |
| 486 | } |
| 487 | |
| 488 | // Check if key and issuer certificate match |
| 489 | // |
| 490 | if( strlen( opt.issuer_crt ) ) |
| 491 | { |
| 492 | if( !pk_can_do( &issuer_crt.pk, POLARSSL_PK_RSA ) || |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 493 | mpi_cmp_mpi( &pk_rsa( issuer_crt.pk )->N, |
| 494 | &pk_rsa( *issuer_key )->N ) != 0 || |
| 495 | mpi_cmp_mpi( &pk_rsa( issuer_crt.pk )->E, |
| 496 | &pk_rsa( *issuer_key )->E ) != 0 ) |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 497 | { |
| 498 | printf( " failed\n ! issuer_key does not match issuer certificate\n\n" ); |
| 499 | ret = -1; |
| 500 | goto exit; |
| 501 | } |
| 502 | } |
| 503 | |
| 504 | printf( " ok\n" ); |
| 505 | |
| 506 | if( opt.selfsign ) |
| 507 | { |
Paul Bakker | 93c6aa4 | 2013-10-28 22:28:09 +0100 | [diff] [blame] | 508 | opt.subject_name = opt.issuer_name; |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 509 | subject_key = issuer_key; |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 510 | } |
| 511 | |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 512 | x509write_crt_set_subject_key( &crt, subject_key ); |
| 513 | x509write_crt_set_issuer_key( &crt, issuer_key ); |
Paul Bakker | b2d7f23 | 2013-09-09 16:24:18 +0200 | [diff] [blame] | 514 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 515 | /* |
| 516 | * 1.0. Check the names for validity |
| 517 | */ |
| 518 | if( ( ret = x509write_crt_set_subject_name( &crt, opt.subject_name ) ) != 0 ) |
| 519 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 520 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 521 | printf( " failed\n ! x509write_crt_set_subject_name returned -0x%02x - %s\n\n", -ret, buf ); |
| 522 | goto exit; |
| 523 | } |
| 524 | |
| 525 | if( ( ret = x509write_crt_set_issuer_name( &crt, opt.issuer_name ) ) != 0 ) |
| 526 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 527 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 528 | printf( " failed\n ! x509write_crt_set_issuer_name returned -0x%02x - %s\n\n", -ret, buf ); |
| 529 | goto exit; |
| 530 | } |
| 531 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 532 | printf( " . Setting certificate values ..." ); |
| 533 | fflush( stdout ); |
| 534 | |
| 535 | ret = x509write_crt_set_serial( &crt, &serial ); |
| 536 | if( ret != 0 ) |
| 537 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 538 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 539 | printf( " failed\n ! x509write_crt_set_serial returned -0x%02x - %s\n\n", -ret, buf ); |
| 540 | goto exit; |
| 541 | } |
| 542 | |
| 543 | ret = x509write_crt_set_validity( &crt, opt.not_before, opt.not_after ); |
| 544 | if( ret != 0 ) |
| 545 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 546 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 547 | printf( " failed\n ! x509write_crt_set_validity returned -0x%02x - %s\n\n", -ret, buf ); |
| 548 | goto exit; |
| 549 | } |
| 550 | |
| 551 | printf( " ok\n" ); |
| 552 | |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 553 | printf( " . Adding the Basic Constraints extension ..." ); |
| 554 | fflush( stdout ); |
| 555 | |
| 556 | ret = x509write_crt_set_basic_constraints( &crt, opt.is_ca, |
| 557 | opt.max_pathlen ); |
| 558 | if( ret != 0 ) |
| 559 | { |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 560 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 561 | printf( " failed\n ! x509write_crt_set_basic_contraints returned -0x%02x - %s\n\n", -ret, buf ); |
| 562 | goto exit; |
| 563 | } |
| 564 | |
| 565 | printf( " ok\n" ); |
| 566 | |
Manuel Pégourié-Gonnard | 3daaf3d | 2013-10-27 14:22:02 +0100 | [diff] [blame] | 567 | #if defined(POLARSSL_SHA1_C) |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 568 | printf( " . Adding the Subject Key Identifier ..." ); |
| 569 | fflush( stdout ); |
| 570 | |
| 571 | ret = x509write_crt_set_subject_key_identifier( &crt ); |
| 572 | if( ret != 0 ) |
| 573 | { |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 574 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 575 | printf( " failed\n ! x509write_crt_set_subject_key_identifier returned -0x%02x - %s\n\n", -ret, buf ); |
| 576 | goto exit; |
| 577 | } |
| 578 | |
| 579 | printf( " ok\n" ); |
| 580 | |
| 581 | printf( " . Adding the Authority Key Identifier ..." ); |
| 582 | fflush( stdout ); |
| 583 | |
| 584 | ret = x509write_crt_set_authority_key_identifier( &crt ); |
| 585 | if( ret != 0 ) |
| 586 | { |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 587 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 588 | printf( " failed\n ! x509write_crt_set_authority_key_identifier returned -0x%02x - %s\n\n", -ret, buf ); |
| 589 | goto exit; |
| 590 | } |
| 591 | |
| 592 | printf( " ok\n" ); |
Manuel Pégourié-Gonnard | 3daaf3d | 2013-10-27 14:22:02 +0100 | [diff] [blame] | 593 | #endif /* POLARSSL_SHA1_C */ |
Paul Bakker | 15162a0 | 2013-09-06 19:27:21 +0200 | [diff] [blame] | 594 | |
Paul Bakker | 52be08c | 2013-09-09 12:37:54 +0200 | [diff] [blame] | 595 | if( opt.key_usage ) |
| 596 | { |
| 597 | printf( " . Adding the Key Usage extension ..." ); |
| 598 | fflush( stdout ); |
| 599 | |
| 600 | ret = x509write_crt_set_key_usage( &crt, opt.key_usage ); |
| 601 | if( ret != 0 ) |
| 602 | { |
Paul Bakker | 52be08c | 2013-09-09 12:37:54 +0200 | [diff] [blame] | 603 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 52be08c | 2013-09-09 12:37:54 +0200 | [diff] [blame] | 604 | printf( " failed\n ! x509write_crt_set_key_usage returned -0x%02x - %s\n\n", -ret, buf ); |
| 605 | goto exit; |
| 606 | } |
| 607 | |
| 608 | printf( " ok\n" ); |
| 609 | } |
| 610 | |
| 611 | if( opt.ns_cert_type ) |
| 612 | { |
| 613 | printf( " . Adding the NS Cert Type extension ..." ); |
| 614 | fflush( stdout ); |
| 615 | |
| 616 | ret = x509write_crt_set_ns_cert_type( &crt, opt.ns_cert_type ); |
| 617 | if( ret != 0 ) |
| 618 | { |
Paul Bakker | 52be08c | 2013-09-09 12:37:54 +0200 | [diff] [blame] | 619 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 52be08c | 2013-09-09 12:37:54 +0200 | [diff] [blame] | 620 | printf( " failed\n ! x509write_crt_set_ns_cert_type returned -0x%02x - %s\n\n", -ret, buf ); |
| 621 | goto exit; |
| 622 | } |
| 623 | |
| 624 | printf( " ok\n" ); |
| 625 | } |
| 626 | |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 627 | /* |
| 628 | * 1.2. Writing the request |
| 629 | */ |
| 630 | printf( " . Writing the certificate..." ); |
| 631 | fflush( stdout ); |
| 632 | |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 633 | if( ( ret = write_certificate( &crt, opt.output_file, |
| 634 | ctr_drbg_random, &ctr_drbg ) ) != 0 ) |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 635 | { |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 636 | error_strerror( ret, buf, 1024 ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 637 | printf( " failed\n ! write_certifcate -0x%02x - %s\n\n", -ret, buf ); |
| 638 | goto exit; |
| 639 | } |
| 640 | |
| 641 | printf( " ok\n" ); |
| 642 | |
| 643 | exit: |
| 644 | x509write_crt_free( &crt ); |
Manuel Pégourié-Gonnard | f38e71a | 2013-09-12 05:21:54 +0200 | [diff] [blame] | 645 | pk_free( &loaded_subject_key ); |
| 646 | pk_free( &loaded_issuer_key ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 647 | mpi_free( &serial ); |
Paul Bakker | 1ffefac | 2013-09-28 15:23:03 +0200 | [diff] [blame] | 648 | entropy_free( &entropy ); |
Paul Bakker | 9397dcb | 2013-09-06 09:55:26 +0200 | [diff] [blame] | 649 | |
| 650 | #if defined(_WIN32) |
| 651 | printf( " + Press Enter to exit this program.\n" ); |
| 652 | fflush( stdout ); getchar(); |
| 653 | #endif |
| 654 | |
| 655 | return( ret ); |
| 656 | } |
Paul Bakker | 36713e8 | 2013-09-17 13:25:29 +0200 | [diff] [blame] | 657 | #endif /* POLARSSL_X509_CRT_WRITE_C && POLARSSL_X509_CRT_PARSE_C && |
| 658 | POLARSSL_FS_IO && POLARSSL_ENTROPY_C && POLARSSL_CTR_DRBG_C && |
Manuel Pégourié-Gonnard | 31e5940 | 2013-09-12 05:59:05 +0200 | [diff] [blame] | 659 | POLARSSL_ERROR_C */ |