Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Convert PEM to DER |
| 3 | * |
Bence Szépkúti | 1e14827 | 2020-08-07 13:07:28 +0200 | [diff] [blame] | 4 | * Copyright The Mbed TLS Contributors |
Dave Rodgman | 7ff7965 | 2023-11-03 12:04:52 +0000 | [diff] [blame] | 5 | * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 6 | */ |
| 7 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 8 | #if !defined(MBEDTLS_CONFIG_FILE) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 9 | #include "mbedtls/config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 10 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 11 | #include MBEDTLS_CONFIG_FILE |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 12 | #endif |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 13 | |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 14 | #include "mbedtls/platform.h" |
Rich Evans | f90016a | 2015-01-19 14:26:37 +0000 | [diff] [blame] | 15 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 16 | #if defined(MBEDTLS_BASE64_C) && defined(MBEDTLS_FS_IO) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 17 | #include "mbedtls/error.h" |
| 18 | #include "mbedtls/base64.h" |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 19 | |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 20 | #include <stdio.h> |
| 21 | #include <stdlib.h> |
| 22 | #include <string.h> |
| 23 | #endif |
| 24 | |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 25 | #define DFL_FILENAME "file.pem" |
| 26 | #define DFL_OUTPUT_FILENAME "file.der" |
| 27 | |
Rich Evans | 18b78c7 | 2015-02-11 14:06:19 +0000 | [diff] [blame] | 28 | #define USAGE \ |
| 29 | "\n usage: pem2der param=<>...\n" \ |
| 30 | "\n acceptable parameters:\n" \ |
| 31 | " filename=%%s default: file.pem\n" \ |
| 32 | " output_file=%%s default: file.der\n" \ |
| 33 | "\n" |
| 34 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 35 | #if !defined(MBEDTLS_BASE64_C) || !defined(MBEDTLS_FS_IO) |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 36 | int main(void) |
Manuel Pégourié-Gonnard | 7831b0c | 2013-09-20 12:29:56 +0200 | [diff] [blame] | 37 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 38 | mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n"); |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 39 | mbedtls_exit(0); |
Manuel Pégourié-Gonnard | 7831b0c | 2013-09-20 12:29:56 +0200 | [diff] [blame] | 40 | } |
| 41 | #else |
Manuel Pégourié-Gonnard | 3ef6a6d | 2018-12-10 14:31:45 +0100 | [diff] [blame] | 42 | |
Manuel Pégourié-Gonnard | 3ef6a6d | 2018-12-10 14:31:45 +0100 | [diff] [blame] | 43 | |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 44 | /* |
| 45 | * global options |
| 46 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 47 | struct options { |
Paul Bakker | 8fc30b1 | 2013-11-25 13:29:43 +0100 | [diff] [blame] | 48 | const char *filename; /* filename of the input file */ |
| 49 | const char *output_file; /* where to store the output */ |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 50 | } opt; |
| 51 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 52 | int convert_pem_to_der(const unsigned char *input, size_t ilen, |
| 53 | unsigned char *output, size_t *olen) |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 54 | { |
| 55 | int ret; |
| 56 | const unsigned char *s1, *s2, *end = input + ilen; |
| 57 | size_t len = 0; |
| 58 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 59 | s1 = (unsigned char *) strstr((const char *) input, "-----BEGIN"); |
| 60 | if (s1 == NULL) { |
| 61 | return -1; |
| 62 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 63 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 64 | s2 = (unsigned char *) strstr((const char *) input, "-----END"); |
| 65 | if (s2 == NULL) { |
| 66 | return -1; |
| 67 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 68 | |
| 69 | s1 += 10; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 70 | while (s1 < end && *s1 != '-') { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 71 | s1++; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 72 | } |
| 73 | while (s1 < end && *s1 == '-') { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 74 | s1++; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 75 | } |
| 76 | if (*s1 == '\r') { |
| 77 | s1++; |
| 78 | } |
| 79 | if (*s1 == '\n') { |
| 80 | s1++; |
| 81 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 82 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 83 | if (s2 <= s1 || s2 > end) { |
| 84 | return -1; |
| 85 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 86 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 87 | ret = mbedtls_base64_decode(NULL, 0, &len, (const unsigned char *) s1, s2 - s1); |
| 88 | if (ret == MBEDTLS_ERR_BASE64_INVALID_CHARACTER) { |
| 89 | return ret; |
| 90 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 91 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 92 | if (len > *olen) { |
| 93 | return -1; |
| 94 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 95 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 96 | if ((ret = mbedtls_base64_decode(output, len, &len, (const unsigned char *) s1, |
| 97 | s2 - s1)) != 0) { |
| 98 | return ret; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | *olen = len; |
| 102 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 103 | return 0; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | /* |
| 107 | * Load all data from a file into a given buffer. |
| 108 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 109 | static int load_file(const char *path, unsigned char **buf, size_t *n) |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 110 | { |
| 111 | FILE *f; |
| 112 | long size; |
| 113 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 114 | if ((f = fopen(path, "rb")) == NULL) { |
| 115 | return -1; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 116 | } |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 117 | |
| 118 | fseek(f, 0, SEEK_END); |
| 119 | if ((size = ftell(f)) == -1) { |
| 120 | fclose(f); |
| 121 | return -1; |
| 122 | } |
| 123 | fseek(f, 0, SEEK_SET); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 124 | |
| 125 | *n = (size_t) size; |
| 126 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 127 | if (*n + 1 == 0 || |
| 128 | (*buf = mbedtls_calloc(1, *n + 1)) == NULL) { |
| 129 | fclose(f); |
| 130 | return -1; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 131 | } |
| 132 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 133 | if (fread(*buf, 1, *n, f) != *n) { |
| 134 | fclose(f); |
| 135 | free(*buf); |
Alfred Klomp | 1d42b3e | 2014-07-14 22:09:21 +0200 | [diff] [blame] | 136 | *buf = NULL; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 137 | return -1; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 138 | } |
| 139 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 140 | fclose(f); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 141 | |
| 142 | (*buf)[*n] = '\0'; |
| 143 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 144 | return 0; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | /* |
| 148 | * Write buffer to a file |
| 149 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 150 | static int write_file(const char *path, unsigned char *buf, size_t n) |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 151 | { |
| 152 | FILE *f; |
| 153 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 154 | if ((f = fopen(path, "wb")) == NULL) { |
| 155 | return -1; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 156 | } |
| 157 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 158 | if (fwrite(buf, 1, n, f) != n) { |
| 159 | fclose(f); |
| 160 | return -1; |
| 161 | } |
| 162 | |
| 163 | fclose(f); |
| 164 | return 0; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 165 | } |
| 166 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 167 | int main(int argc, char *argv[]) |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 168 | { |
Andres Amaya Garcia | 78dabe0 | 2018-04-29 22:08:41 +0100 | [diff] [blame] | 169 | int ret = 1; |
| 170 | int exit_code = MBEDTLS_EXIT_FAILURE; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 171 | unsigned char *pem_buffer = NULL; |
| 172 | unsigned char der_buffer[4096]; |
| 173 | char buf[1024]; |
| 174 | size_t pem_size, der_size = sizeof(der_buffer); |
Paul Bakker | c97f9f6 | 2013-11-30 15:13:02 +0100 | [diff] [blame] | 175 | int i; |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 176 | char *p, *q; |
| 177 | |
| 178 | /* |
| 179 | * Set to sane values |
| 180 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 181 | memset(buf, 0, sizeof(buf)); |
| 182 | memset(der_buffer, 0, sizeof(der_buffer)); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 183 | |
Aditya Deshpande | 0504ac2 | 2023-01-30 15:58:50 +0000 | [diff] [blame] | 184 | if (argc < 2) { |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 185 | usage: |
| 186 | mbedtls_printf(USAGE); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 187 | goto exit; |
| 188 | } |
| 189 | |
| 190 | opt.filename = DFL_FILENAME; |
| 191 | opt.output_file = DFL_OUTPUT_FILENAME; |
| 192 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 193 | for (i = 1; i < argc; i++) { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 194 | |
| 195 | p = argv[i]; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 196 | if ((q = strchr(p, '=')) == NULL) { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 197 | goto usage; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 198 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 199 | *q++ = '\0'; |
| 200 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 201 | if (strcmp(p, "filename") == 0) { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 202 | opt.filename = q; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 203 | } else if (strcmp(p, "output_file") == 0) { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 204 | opt.output_file = q; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 205 | } else { |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 206 | goto usage; |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 207 | } |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | /* |
| 211 | * 1.1. Load the PEM file |
| 212 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 213 | mbedtls_printf("\n . Loading the PEM file ..."); |
| 214 | fflush(stdout); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 215 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 216 | ret = load_file(opt.filename, &pem_buffer, &pem_size); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 217 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 218 | if (ret != 0) { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 219 | #ifdef MBEDTLS_ERROR_C |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 220 | mbedtls_strerror(ret, buf, 1024); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 221 | #endif |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 222 | mbedtls_printf(" failed\n ! load_file returned %d - %s\n\n", ret, buf); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 223 | goto exit; |
| 224 | } |
| 225 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 226 | mbedtls_printf(" ok\n"); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 227 | |
| 228 | /* |
| 229 | * 1.2. Convert from PEM to DER |
| 230 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 231 | mbedtls_printf(" . Converting from PEM to DER ..."); |
| 232 | fflush(stdout); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 233 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 234 | if ((ret = convert_pem_to_der(pem_buffer, pem_size, der_buffer, &der_size)) != 0) { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 235 | #ifdef MBEDTLS_ERROR_C |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 236 | mbedtls_strerror(ret, buf, 1024); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 237 | #endif |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 238 | mbedtls_printf(" failed\n ! convert_pem_to_der %d - %s\n\n", ret, buf); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 239 | goto exit; |
| 240 | } |
| 241 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 242 | mbedtls_printf(" ok\n"); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 243 | |
| 244 | /* |
| 245 | * 1.3. Write the DER file |
| 246 | */ |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 247 | mbedtls_printf(" . Writing the DER file ..."); |
| 248 | fflush(stdout); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 249 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 250 | ret = write_file(opt.output_file, der_buffer, der_size); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 251 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 252 | if (ret != 0) { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 253 | #ifdef MBEDTLS_ERROR_C |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 254 | mbedtls_strerror(ret, buf, 1024); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 255 | #endif |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 256 | mbedtls_printf(" failed\n ! write_file returned %d - %s\n\n", ret, buf); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 257 | goto exit; |
| 258 | } |
| 259 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 260 | mbedtls_printf(" ok\n"); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 261 | |
Andres Amaya Garcia | 78dabe0 | 2018-04-29 22:08:41 +0100 | [diff] [blame] | 262 | exit_code = MBEDTLS_EXIT_SUCCESS; |
| 263 | |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 264 | exit: |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 265 | free(pem_buffer); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 266 | |
| 267 | #if defined(_WIN32) |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 268 | mbedtls_printf(" + Press Enter to exit this program.\n"); |
| 269 | fflush(stdout); getchar(); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 270 | #endif |
| 271 | |
Gilles Peskine | 1b6c09a | 2023-01-11 14:52:35 +0100 | [diff] [blame] | 272 | mbedtls_exit(exit_code); |
Paul Bakker | 8adf13b | 2013-08-25 14:50:09 +0200 | [diff] [blame] | 273 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 274 | #endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */ |