Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Error message information |
| 3 | * |
Manuel Pégourié-Gonnard | 6fb8187 | 2015-07-27 11:11:48 +0200 | [diff] [blame] | 4 | * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved |
Manuel Pégourié-Gonnard | 37ff140 | 2015-09-04 14:21:07 +0200 | [diff] [blame] | 5 | * 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 Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 18 | * |
Manuel Pégourié-Gonnard | fe44643 | 2015-03-06 13:17:10 +0000 | [diff] [blame] | 19 | * This file is part of mbed TLS (https://tls.mbed.org) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 22 | #if !defined(MBEDTLS_CONFIG_FILE) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 23 | #include "mbedtls/config.h" |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 24 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 25 | #include MBEDTLS_CONFIG_FILE |
Manuel Pégourié-Gonnard | cef4ad2 | 2014-04-29 12:39:06 +0200 | [diff] [blame] | 26 | #endif |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 27 | |
Janos Follath | df587ee | 2019-12-18 13:16:46 +0000 | [diff] [blame] | 28 | #if defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 29 | #include <string.h> |
Manuel Pégourié-Gonnard | bee8ded | 2014-06-25 12:22:59 +0200 | [diff] [blame] | 30 | #endif |
| 31 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 32 | #if defined(MBEDTLS_PLATFORM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 33 | #include "mbedtls/platform.h" |
Manuel Pégourié-Gonnard | 0928640 | 2015-02-13 15:18:33 +0000 | [diff] [blame] | 34 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 35 | #define mbedtls_snprintf snprintf |
-~- redtangent ~-~ | 9fa2e86 | 2016-05-26 10:07:49 +0100 | [diff] [blame] | 36 | #define mbedtls_time_t time_t |
Manuel Pégourié-Gonnard | bee8ded | 2014-06-25 12:22:59 +0200 | [diff] [blame] | 37 | #endif |
| 38 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 39 | #if defined(MBEDTLS_ERROR_C) |
Paul Bakker | 3c2122f | 2013-06-24 19:03:14 +0200 | [diff] [blame] | 40 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 41 | #include <stdio.h> |
| 42 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 43 | #if defined(MBEDTLS_AES_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 44 | #include "mbedtls/aes.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 45 | #endif |
| 46 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 47 | #if defined(MBEDTLS_ARC4_C) |
| 48 | #include "mbedtls/arc4.h" |
| 49 | #endif |
| 50 | |
Markku-Juhani O. Saarinen | 07478d6 | 2017-12-01 16:20:15 +0000 | [diff] [blame] | 51 | #if defined(MBEDTLS_ARIA_C) |
| 52 | #include "mbedtls/aria.h" |
| 53 | #endif |
| 54 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 55 | #if defined(MBEDTLS_BASE64_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 56 | #include "mbedtls/base64.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 59 | #if defined(MBEDTLS_BIGNUM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 60 | #include "mbedtls/bignum.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 61 | #endif |
| 62 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 63 | #if defined(MBEDTLS_BLOWFISH_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 64 | #include "mbedtls/blowfish.h" |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 65 | #endif |
| 66 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 67 | #if defined(MBEDTLS_CAMELLIA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 68 | #include "mbedtls/camellia.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 69 | #endif |
| 70 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 71 | #if defined(MBEDTLS_CCM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 72 | #include "mbedtls/ccm.h" |
Manuel Pégourié-Gonnard | a6916fa | 2014-05-02 15:17:29 +0200 | [diff] [blame] | 73 | #endif |
| 74 | |
Daniel King | 34b822c | 2016-05-15 17:28:08 -0300 | [diff] [blame] | 75 | #if defined(MBEDTLS_CHACHA20_C) |
| 76 | #include "mbedtls/chacha20.h" |
| 77 | #endif |
| 78 | |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 79 | #if defined(MBEDTLS_CHACHAPOLY_C) |
| 80 | #include "mbedtls/chachapoly.h" |
| 81 | #endif |
| 82 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 83 | #if defined(MBEDTLS_CIPHER_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 84 | #include "mbedtls/cipher.h" |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 85 | #endif |
| 86 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 87 | #if defined(MBEDTLS_CMAC_C) |
| 88 | #include "mbedtls/cmac.h" |
| 89 | #endif |
| 90 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 91 | #if defined(MBEDTLS_CTR_DRBG_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 92 | #include "mbedtls/ctr_drbg.h" |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 93 | #endif |
| 94 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 95 | #if defined(MBEDTLS_DES_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 96 | #include "mbedtls/des.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 97 | #endif |
| 98 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 99 | #if defined(MBEDTLS_DHM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 100 | #include "mbedtls/dhm.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 101 | #endif |
| 102 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 103 | #if defined(MBEDTLS_ECP_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 104 | #include "mbedtls/ecp.h" |
Paul Bakker | cf4365f | 2013-01-16 17:00:43 +0100 | [diff] [blame] | 105 | #endif |
| 106 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 107 | #if defined(MBEDTLS_ENTROPY_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 108 | #include "mbedtls/entropy.h" |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 109 | #endif |
| 110 | |
Janos Follath | 60f6b64 | 2019-12-03 15:55:56 +0000 | [diff] [blame] | 111 | #if defined(MBEDTLS_ERROR_C) |
| 112 | #include "mbedtls/error.h" |
| 113 | #endif |
| 114 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 115 | #if defined(MBEDTLS_GCM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 116 | #include "mbedtls/gcm.h" |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 117 | #endif |
| 118 | |
Thomas Fossati | 656864b | 2016-07-17 08:51:22 +0100 | [diff] [blame] | 119 | #if defined(MBEDTLS_HKDF_C) |
| 120 | #include "mbedtls/hkdf.h" |
| 121 | #endif |
| 122 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 123 | #if defined(MBEDTLS_HMAC_DRBG_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 124 | #include "mbedtls/hmac_drbg.h" |
Manuel Pégourié-Gonnard | cf38367 | 2014-02-01 10:22:21 +0100 | [diff] [blame] | 125 | #endif |
| 126 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 127 | #if defined(MBEDTLS_MD_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 128 | #include "mbedtls/md.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 129 | #endif |
| 130 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 131 | #if defined(MBEDTLS_MD2_C) |
| 132 | #include "mbedtls/md2.h" |
| 133 | #endif |
| 134 | |
| 135 | #if defined(MBEDTLS_MD4_C) |
| 136 | #include "mbedtls/md4.h" |
| 137 | #endif |
| 138 | |
| 139 | #if defined(MBEDTLS_MD5_C) |
| 140 | #include "mbedtls/md5.h" |
| 141 | #endif |
| 142 | |
Gilles Peskine | 458b8f2 | 2020-02-26 18:28:28 +0100 | [diff] [blame] | 143 | #if defined(MBEDTLS_NET_C) |
| 144 | #include "mbedtls/net_sockets.h" |
| 145 | #endif |
| 146 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 147 | #if defined(MBEDTLS_OID_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 148 | #include "mbedtls/oid.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 149 | #endif |
| 150 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 151 | #if defined(MBEDTLS_PADLOCK_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 152 | #include "mbedtls/padlock.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 153 | #endif |
| 154 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 155 | #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 156 | #include "mbedtls/pem.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 157 | #endif |
| 158 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 159 | #if defined(MBEDTLS_PK_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 160 | #include "mbedtls/pk.h" |
Manuel Pégourié-Gonnard | 7a6c946 | 2013-07-09 10:04:07 +0200 | [diff] [blame] | 161 | #endif |
| 162 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 163 | #if defined(MBEDTLS_PKCS12_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 164 | #include "mbedtls/pkcs12.h" |
Paul Bakker | f1f21fe | 2013-06-24 19:17:19 +0200 | [diff] [blame] | 165 | #endif |
| 166 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 167 | #if defined(MBEDTLS_PKCS5_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 168 | #include "mbedtls/pkcs5.h" |
Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 169 | #endif |
| 170 | |
Ron Eldor | 0ff4e0b | 2018-08-29 18:53:20 +0300 | [diff] [blame] | 171 | #if defined(MBEDTLS_PLATFORM_C) |
| 172 | #include "mbedtls/platform.h" |
| 173 | #endif |
| 174 | |
Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame] | 175 | #if defined(MBEDTLS_POLY1305_C) |
| 176 | #include "mbedtls/poly1305.h" |
| 177 | #endif |
| 178 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 179 | #if defined(MBEDTLS_RIPEMD160_C) |
| 180 | #include "mbedtls/ripemd160.h" |
| 181 | #endif |
| 182 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 183 | #if defined(MBEDTLS_RSA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 184 | #include "mbedtls/rsa.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 185 | #endif |
| 186 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 187 | #if defined(MBEDTLS_SHA1_C) |
| 188 | #include "mbedtls/sha1.h" |
| 189 | #endif |
| 190 | |
| 191 | #if defined(MBEDTLS_SHA256_C) |
| 192 | #include "mbedtls/sha256.h" |
| 193 | #endif |
| 194 | |
| 195 | #if defined(MBEDTLS_SHA512_C) |
| 196 | #include "mbedtls/sha512.h" |
| 197 | #endif |
| 198 | |
Gilles Peskine | 458b8f2 | 2020-02-26 18:28:28 +0100 | [diff] [blame] | 199 | #if defined(MBEDTLS_SSL_TLS_C) |
| 200 | #include "mbedtls/ssl.h" |
| 201 | #endif |
| 202 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 203 | #if defined(MBEDTLS_THREADING_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 204 | #include "mbedtls/threading.h" |
Paul Bakker | 2466d93 | 2013-09-28 14:40:38 +0200 | [diff] [blame] | 205 | #endif |
| 206 | |
Gilles Peskine | 458b8f2 | 2020-02-26 18:28:28 +0100 | [diff] [blame] | 207 | #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) |
| 208 | #include "mbedtls/x509.h" |
| 209 | #endif |
| 210 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 211 | #if defined(MBEDTLS_XTEA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 212 | #include "mbedtls/xtea.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 213 | #endif |
| 214 | |
Paul Bakker | dceecd8 | 2011-11-15 16:38:34 +0000 | [diff] [blame] | 215 | |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 216 | const char * mbedtls_high_level_strerr( int error_code ) |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 217 | { |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 218 | const char *error_description = NULL; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 219 | |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 220 | switch( error_code ) |
| 221 | { |
Gaurav Aggarwal | 3d02db2 | 2020-04-11 17:14:03 -0700 | [diff] [blame^] | 222 | /* Begin Auto-Generated Code. */ |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 223 | #if defined(MBEDTLS_CIPHER_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 224 | case -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE): |
| 225 | error_description = "CIPHER - The selected feature is not available"; |
| 226 | break; |
| 227 | case -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA): |
| 228 | error_description = "CIPHER - Bad input parameters"; |
| 229 | break; |
| 230 | case -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED): |
| 231 | error_description = "CIPHER - Failed to allocate memory"; |
| 232 | break; |
| 233 | case -(MBEDTLS_ERR_CIPHER_INVALID_PADDING): |
| 234 | error_description = "CIPHER - Input data contains invalid padding and is rejected"; |
| 235 | break; |
| 236 | case -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED): |
| 237 | error_description = "CIPHER - Decryption of block requires a full block"; |
| 238 | break; |
| 239 | case -(MBEDTLS_ERR_CIPHER_AUTH_FAILED): |
| 240 | error_description = "CIPHER - Authentication failed (for AEAD modes)"; |
| 241 | break; |
| 242 | case -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT): |
| 243 | error_description = "CIPHER - The context is invalid. For example, because it was freed"; |
| 244 | break; |
| 245 | case -(MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED): |
| 246 | error_description = "CIPHER - Cipher hardware accelerator failed"; |
| 247 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 248 | #endif /* MBEDTLS_CIPHER_C */ |
| 249 | |
| 250 | #if defined(MBEDTLS_DHM_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 251 | case -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA): |
| 252 | error_description = "DHM - Bad input parameters"; |
| 253 | break; |
| 254 | case -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED): |
| 255 | error_description = "DHM - Reading of the DHM parameters failed"; |
| 256 | break; |
| 257 | case -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED): |
| 258 | error_description = "DHM - Making of the DHM parameters failed"; |
| 259 | break; |
| 260 | case -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED): |
| 261 | error_description = "DHM - Reading of the public values failed"; |
| 262 | break; |
| 263 | case -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED): |
| 264 | error_description = "DHM - Making of the public value failed"; |
| 265 | break; |
| 266 | case -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED): |
| 267 | error_description = "DHM - Calculation of the DHM secret failed"; |
| 268 | break; |
| 269 | case -(MBEDTLS_ERR_DHM_INVALID_FORMAT): |
| 270 | error_description = "DHM - The ASN.1 data is not formatted correctly"; |
| 271 | break; |
| 272 | case -(MBEDTLS_ERR_DHM_ALLOC_FAILED): |
| 273 | error_description = "DHM - Allocation of memory failed"; |
| 274 | break; |
| 275 | case -(MBEDTLS_ERR_DHM_FILE_IO_ERROR): |
| 276 | error_description = "DHM - Read or write of file failed"; |
| 277 | break; |
| 278 | case -(MBEDTLS_ERR_DHM_HW_ACCEL_FAILED): |
| 279 | error_description = "DHM - DHM hardware accelerator failed"; |
| 280 | break; |
| 281 | case -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED): |
| 282 | error_description = "DHM - Setting the modulus and generator failed"; |
| 283 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 284 | #endif /* MBEDTLS_DHM_C */ |
| 285 | |
| 286 | #if defined(MBEDTLS_ECP_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 287 | case -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA): |
| 288 | error_description = "ECP - Bad input parameters to function"; |
| 289 | break; |
| 290 | case -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL): |
| 291 | error_description = "ECP - The buffer is too small to write to"; |
| 292 | break; |
| 293 | case -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE): |
| 294 | error_description = "ECP - The requested feature is not available, for example, the requested curve is not supported"; |
| 295 | break; |
| 296 | case -(MBEDTLS_ERR_ECP_VERIFY_FAILED): |
| 297 | error_description = "ECP - The signature is not valid"; |
| 298 | break; |
| 299 | case -(MBEDTLS_ERR_ECP_ALLOC_FAILED): |
| 300 | error_description = "ECP - Memory allocation failed"; |
| 301 | break; |
| 302 | case -(MBEDTLS_ERR_ECP_RANDOM_FAILED): |
| 303 | error_description = "ECP - Generation of random value, such as ephemeral key, failed"; |
| 304 | break; |
| 305 | case -(MBEDTLS_ERR_ECP_INVALID_KEY): |
| 306 | error_description = "ECP - Invalid private or public key"; |
| 307 | break; |
| 308 | case -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH): |
| 309 | error_description = "ECP - The buffer contains a valid signature followed by more data"; |
| 310 | break; |
| 311 | case -(MBEDTLS_ERR_ECP_HW_ACCEL_FAILED): |
| 312 | error_description = "ECP - The ECP hardware accelerator failed"; |
| 313 | break; |
| 314 | case -(MBEDTLS_ERR_ECP_IN_PROGRESS): |
| 315 | error_description = "ECP - Operation in progress, call again with the same parameters to continue"; |
| 316 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 317 | #endif /* MBEDTLS_ECP_C */ |
| 318 | |
| 319 | #if defined(MBEDTLS_MD_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 320 | case -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE): |
| 321 | error_description = "MD - The selected feature is not available"; |
| 322 | break; |
| 323 | case -(MBEDTLS_ERR_MD_BAD_INPUT_DATA): |
| 324 | error_description = "MD - Bad input parameters to function"; |
| 325 | break; |
| 326 | case -(MBEDTLS_ERR_MD_ALLOC_FAILED): |
| 327 | error_description = "MD - Failed to allocate memory"; |
| 328 | break; |
| 329 | case -(MBEDTLS_ERR_MD_FILE_IO_ERROR): |
| 330 | error_description = "MD - Opening or reading of file failed"; |
| 331 | break; |
| 332 | case -(MBEDTLS_ERR_MD_HW_ACCEL_FAILED): |
| 333 | error_description = "MD - MD hardware accelerator failed"; |
| 334 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 335 | #endif /* MBEDTLS_MD_C */ |
| 336 | |
| 337 | #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 338 | case -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT): |
| 339 | error_description = "PEM - No PEM header or footer found"; |
| 340 | break; |
| 341 | case -(MBEDTLS_ERR_PEM_INVALID_DATA): |
| 342 | error_description = "PEM - PEM string is not as expected"; |
| 343 | break; |
| 344 | case -(MBEDTLS_ERR_PEM_ALLOC_FAILED): |
| 345 | error_description = "PEM - Failed to allocate memory"; |
| 346 | break; |
| 347 | case -(MBEDTLS_ERR_PEM_INVALID_ENC_IV): |
| 348 | error_description = "PEM - RSA IV is not in hex-format"; |
| 349 | break; |
| 350 | case -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG): |
| 351 | error_description = "PEM - Unsupported key encryption algorithm"; |
| 352 | break; |
| 353 | case -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED): |
| 354 | error_description = "PEM - Private key password can't be empty"; |
| 355 | break; |
| 356 | case -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH): |
| 357 | error_description = "PEM - Given private key password does not allow for correct decryption"; |
| 358 | break; |
| 359 | case -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE): |
| 360 | error_description = "PEM - Unavailable feature, e.g. hashing/encryption combination"; |
| 361 | break; |
| 362 | case -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA): |
| 363 | error_description = "PEM - Bad input parameters to function"; |
| 364 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 365 | #endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */ |
| 366 | |
| 367 | #if defined(MBEDTLS_PK_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 368 | case -(MBEDTLS_ERR_PK_ALLOC_FAILED): |
| 369 | error_description = "PK - Memory allocation failed"; |
| 370 | break; |
| 371 | case -(MBEDTLS_ERR_PK_TYPE_MISMATCH): |
| 372 | error_description = "PK - Type mismatch, eg attempt to encrypt with an ECDSA key"; |
| 373 | break; |
| 374 | case -(MBEDTLS_ERR_PK_BAD_INPUT_DATA): |
| 375 | error_description = "PK - Bad input parameters to function"; |
| 376 | break; |
| 377 | case -(MBEDTLS_ERR_PK_FILE_IO_ERROR): |
| 378 | error_description = "PK - Read/write of file failed"; |
| 379 | break; |
| 380 | case -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION): |
| 381 | error_description = "PK - Unsupported key version"; |
| 382 | break; |
| 383 | case -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT): |
| 384 | error_description = "PK - Invalid key tag or value"; |
| 385 | break; |
| 386 | case -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG): |
| 387 | error_description = "PK - Key algorithm is unsupported (only RSA and EC are supported)"; |
| 388 | break; |
| 389 | case -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED): |
| 390 | error_description = "PK - Private key password can't be empty"; |
| 391 | break; |
| 392 | case -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH): |
| 393 | error_description = "PK - Given private key password does not allow for correct decryption"; |
| 394 | break; |
| 395 | case -(MBEDTLS_ERR_PK_INVALID_PUBKEY): |
| 396 | error_description = "PK - The pubkey tag or value is invalid (only RSA and EC are supported)"; |
| 397 | break; |
| 398 | case -(MBEDTLS_ERR_PK_INVALID_ALG): |
| 399 | error_description = "PK - The algorithm tag or value is invalid"; |
| 400 | break; |
| 401 | case -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE): |
| 402 | error_description = "PK - Elliptic curve is unsupported (only NIST curves are supported)"; |
| 403 | break; |
| 404 | case -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE): |
| 405 | error_description = "PK - Unavailable feature, e.g. RSA disabled for RSA key"; |
| 406 | break; |
| 407 | case -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH): |
| 408 | error_description = "PK - The buffer contains a valid signature followed by more data"; |
| 409 | break; |
| 410 | case -(MBEDTLS_ERR_PK_HW_ACCEL_FAILED): |
| 411 | error_description = "PK - PK hardware accelerator failed"; |
| 412 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 413 | #endif /* MBEDTLS_PK_C */ |
| 414 | |
| 415 | #if defined(MBEDTLS_PKCS12_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 416 | case -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA): |
| 417 | error_description = "PKCS12 - Bad input parameters to function"; |
| 418 | break; |
| 419 | case -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE): |
| 420 | error_description = "PKCS12 - Feature not available, e.g. unsupported encryption scheme"; |
| 421 | break; |
| 422 | case -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT): |
| 423 | error_description = "PKCS12 - PBE ASN.1 data not as expected"; |
| 424 | break; |
| 425 | case -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH): |
| 426 | error_description = "PKCS12 - Given private key password does not allow for correct decryption"; |
| 427 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 428 | #endif /* MBEDTLS_PKCS12_C */ |
| 429 | |
| 430 | #if defined(MBEDTLS_PKCS5_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 431 | case -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA): |
| 432 | error_description = "PKCS5 - Bad input parameters to function"; |
| 433 | break; |
| 434 | case -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT): |
| 435 | error_description = "PKCS5 - Unexpected ASN.1 data"; |
| 436 | break; |
| 437 | case -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE): |
| 438 | error_description = "PKCS5 - Requested encryption or digest alg not available"; |
| 439 | break; |
| 440 | case -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH): |
| 441 | error_description = "PKCS5 - Given private key password does not allow for correct decryption"; |
| 442 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 443 | #endif /* MBEDTLS_PKCS5_C */ |
| 444 | |
| 445 | #if defined(MBEDTLS_RSA_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 446 | case -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA): |
| 447 | error_description = "RSA - Bad input parameters to function"; |
| 448 | break; |
| 449 | case -(MBEDTLS_ERR_RSA_INVALID_PADDING): |
| 450 | error_description = "RSA - Input data contains invalid padding and is rejected"; |
| 451 | break; |
| 452 | case -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED): |
| 453 | error_description = "RSA - Something failed during generation of a key"; |
| 454 | break; |
| 455 | case -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED): |
| 456 | error_description = "RSA - Key failed to pass the validity check of the library"; |
| 457 | break; |
| 458 | case -(MBEDTLS_ERR_RSA_PUBLIC_FAILED): |
| 459 | error_description = "RSA - The public key operation failed"; |
| 460 | break; |
| 461 | case -(MBEDTLS_ERR_RSA_PRIVATE_FAILED): |
| 462 | error_description = "RSA - The private key operation failed"; |
| 463 | break; |
| 464 | case -(MBEDTLS_ERR_RSA_VERIFY_FAILED): |
| 465 | error_description = "RSA - The PKCS#1 verification failed"; |
| 466 | break; |
| 467 | case -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE): |
| 468 | error_description = "RSA - The output buffer for decryption is not large enough"; |
| 469 | break; |
| 470 | case -(MBEDTLS_ERR_RSA_RNG_FAILED): |
| 471 | error_description = "RSA - The random generator failed to generate non-zeros"; |
| 472 | break; |
| 473 | case -(MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION): |
| 474 | error_description = "RSA - The implementation does not offer the requested operation, for example, because of security violations or lack of functionality"; |
| 475 | break; |
| 476 | case -(MBEDTLS_ERR_RSA_HW_ACCEL_FAILED): |
| 477 | error_description = "RSA - RSA hardware accelerator failed"; |
| 478 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 479 | #endif /* MBEDTLS_RSA_C */ |
| 480 | |
| 481 | #if defined(MBEDTLS_SSL_TLS_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 482 | case -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE): |
| 483 | error_description = "SSL - The requested feature is not available"; |
| 484 | break; |
| 485 | case -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA): |
| 486 | error_description = "SSL - Bad input parameters to function"; |
| 487 | break; |
| 488 | case -(MBEDTLS_ERR_SSL_INVALID_MAC): |
| 489 | error_description = "SSL - Verification of the message MAC failed"; |
| 490 | break; |
| 491 | case -(MBEDTLS_ERR_SSL_INVALID_RECORD): |
| 492 | error_description = "SSL - An invalid SSL record was received"; |
| 493 | break; |
| 494 | case -(MBEDTLS_ERR_SSL_CONN_EOF): |
| 495 | error_description = "SSL - The connection indicated an EOF"; |
| 496 | break; |
| 497 | case -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER): |
| 498 | error_description = "SSL - An unknown cipher was received"; |
| 499 | break; |
| 500 | case -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN): |
| 501 | error_description = "SSL - The server has no ciphersuites in common with the client"; |
| 502 | break; |
| 503 | case -(MBEDTLS_ERR_SSL_NO_RNG): |
| 504 | error_description = "SSL - No RNG was provided to the SSL module"; |
| 505 | break; |
| 506 | case -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE): |
| 507 | error_description = "SSL - No client certification received from the client, but required by the authentication mode"; |
| 508 | break; |
| 509 | case -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE): |
| 510 | error_description = "SSL - Our own certificate(s) is/are too large to send in an SSL message"; |
| 511 | break; |
| 512 | case -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED): |
| 513 | error_description = "SSL - The own certificate is not set, but needed by the server"; |
| 514 | break; |
| 515 | case -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED): |
| 516 | error_description = "SSL - The own private key or pre-shared key is not set, but needed"; |
| 517 | break; |
| 518 | case -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED): |
| 519 | error_description = "SSL - No CA Chain is set, but required to operate"; |
| 520 | break; |
| 521 | case -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE): |
| 522 | error_description = "SSL - An unexpected message was received from our peer"; |
| 523 | break; |
| 524 | case -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE): |
| 525 | error_description = "SSL - A fatal alert message was received from our peer"; |
| 526 | break; |
| 527 | case -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED): |
| 528 | error_description = "SSL - Verification of our peer failed"; |
| 529 | break; |
| 530 | case -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY): |
| 531 | error_description = "SSL - The peer notified us that the connection is going to be closed"; |
| 532 | break; |
| 533 | case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO): |
| 534 | error_description = "SSL - Processing of the ClientHello handshake message failed"; |
| 535 | break; |
| 536 | case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO): |
| 537 | error_description = "SSL - Processing of the ServerHello handshake message failed"; |
| 538 | break; |
| 539 | case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE): |
| 540 | error_description = "SSL - Processing of the Certificate handshake message failed"; |
| 541 | break; |
| 542 | case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST): |
| 543 | error_description = "SSL - Processing of the CertificateRequest handshake message failed"; |
| 544 | break; |
| 545 | case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE): |
| 546 | error_description = "SSL - Processing of the ServerKeyExchange handshake message failed"; |
| 547 | break; |
| 548 | case -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE): |
| 549 | error_description = "SSL - Processing of the ServerHelloDone handshake message failed"; |
| 550 | break; |
| 551 | case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE): |
| 552 | error_description = "SSL - Processing of the ClientKeyExchange handshake message failed"; |
| 553 | break; |
| 554 | case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP): |
| 555 | error_description = "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public"; |
| 556 | break; |
| 557 | case -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS): |
| 558 | error_description = "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret"; |
| 559 | break; |
| 560 | case -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY): |
| 561 | error_description = "SSL - Processing of the CertificateVerify handshake message failed"; |
| 562 | break; |
| 563 | case -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC): |
| 564 | error_description = "SSL - Processing of the ChangeCipherSpec handshake message failed"; |
| 565 | break; |
| 566 | case -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED): |
| 567 | error_description = "SSL - Processing of the Finished handshake message failed"; |
| 568 | break; |
| 569 | case -(MBEDTLS_ERR_SSL_ALLOC_FAILED): |
| 570 | error_description = "SSL - Memory allocation failed"; |
| 571 | break; |
| 572 | case -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED): |
| 573 | error_description = "SSL - Hardware acceleration function returned with error"; |
| 574 | break; |
| 575 | case -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH): |
| 576 | error_description = "SSL - Hardware acceleration function skipped / left alone data"; |
| 577 | break; |
| 578 | case -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED): |
| 579 | error_description = "SSL - Processing of the compression / decompression failed"; |
| 580 | break; |
| 581 | case -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION): |
| 582 | error_description = "SSL - Handshake protocol not within min/max boundaries"; |
| 583 | break; |
| 584 | case -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET): |
| 585 | error_description = "SSL - Processing of the NewSessionTicket handshake message failed"; |
| 586 | break; |
| 587 | case -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED): |
| 588 | error_description = "SSL - Session ticket has expired"; |
| 589 | break; |
| 590 | case -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH): |
| 591 | error_description = "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)"; |
| 592 | break; |
| 593 | case -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY): |
| 594 | error_description = "SSL - Unknown identity received (eg, PSK identity)"; |
| 595 | break; |
| 596 | case -(MBEDTLS_ERR_SSL_INTERNAL_ERROR): |
| 597 | error_description = "SSL - Internal error (eg, unexpected failure in lower-level module)"; |
| 598 | break; |
| 599 | case -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING): |
| 600 | error_description = "SSL - A counter would wrap (eg, too many messages exchanged)"; |
| 601 | break; |
| 602 | case -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO): |
| 603 | error_description = "SSL - Unexpected message at ServerHello in renegotiation"; |
| 604 | break; |
| 605 | case -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED): |
| 606 | error_description = "SSL - DTLS client must retry for hello verification"; |
| 607 | break; |
| 608 | case -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL): |
| 609 | error_description = "SSL - A buffer is too small to receive or write a message"; |
| 610 | break; |
| 611 | case -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE): |
| 612 | error_description = "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)"; |
| 613 | break; |
| 614 | case -(MBEDTLS_ERR_SSL_WANT_READ): |
| 615 | error_description = "SSL - No data of requested type currently available on underlying transport"; |
| 616 | break; |
| 617 | case -(MBEDTLS_ERR_SSL_WANT_WRITE): |
| 618 | error_description = "SSL - Connection requires a write call"; |
| 619 | break; |
| 620 | case -(MBEDTLS_ERR_SSL_TIMEOUT): |
| 621 | error_description = "SSL - The operation timed out"; |
| 622 | break; |
| 623 | case -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT): |
| 624 | error_description = "SSL - The client initiated a reconnect from the same port"; |
| 625 | break; |
| 626 | case -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD): |
| 627 | error_description = "SSL - Record header looks valid but is not expected"; |
| 628 | break; |
| 629 | case -(MBEDTLS_ERR_SSL_NON_FATAL): |
| 630 | error_description = "SSL - The alert message received indicates a non-fatal error"; |
| 631 | break; |
| 632 | case -(MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH): |
| 633 | error_description = "SSL - Couldn't set the hash for verifying CertificateVerify"; |
| 634 | break; |
| 635 | case -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING): |
| 636 | error_description = "SSL - Internal-only message signaling that further message-processing should be done"; |
| 637 | break; |
| 638 | case -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS): |
| 639 | error_description = "SSL - The asynchronous operation is not completed yet"; |
| 640 | break; |
| 641 | case -(MBEDTLS_ERR_SSL_EARLY_MESSAGE): |
| 642 | error_description = "SSL - Internal-only message signaling that a message arrived early"; |
| 643 | break; |
| 644 | case -(MBEDTLS_ERR_SSL_UNEXPECTED_CID): |
| 645 | error_description = "SSL - An encrypted DTLS-frame with an unexpected CID was received"; |
| 646 | break; |
| 647 | case -(MBEDTLS_ERR_SSL_VERSION_MISMATCH): |
| 648 | error_description = "SSL - An operation failed due to an unexpected version or configuration"; |
| 649 | break; |
| 650 | case -(MBEDTLS_ERR_SSL_CRYPTO_IN_PROGRESS): |
| 651 | error_description = "SSL - A cryptographic operation is in progress. Try again later"; |
| 652 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 653 | #endif /* MBEDTLS_SSL_TLS_C */ |
| 654 | |
| 655 | #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 656 | case -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE): |
| 657 | error_description = "X509 - Unavailable feature, e.g. RSA hashing/encryption combination"; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 658 | break; |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 659 | case -(MBEDTLS_ERR_X509_UNKNOWN_OID): |
| 660 | error_description = "X509 - Requested OID is unknown"; |
| 661 | break; |
| 662 | case -(MBEDTLS_ERR_X509_INVALID_FORMAT): |
| 663 | error_description = "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected"; |
| 664 | break; |
| 665 | case -(MBEDTLS_ERR_X509_INVALID_VERSION): |
| 666 | error_description = "X509 - The CRT/CRL/CSR version element is invalid"; |
| 667 | break; |
| 668 | case -(MBEDTLS_ERR_X509_INVALID_SERIAL): |
| 669 | error_description = "X509 - The serial tag or value is invalid"; |
| 670 | break; |
| 671 | case -(MBEDTLS_ERR_X509_INVALID_ALG): |
| 672 | error_description = "X509 - The algorithm tag or value is invalid"; |
| 673 | break; |
| 674 | case -(MBEDTLS_ERR_X509_INVALID_NAME): |
| 675 | error_description = "X509 - The name tag or value is invalid"; |
| 676 | break; |
| 677 | case -(MBEDTLS_ERR_X509_INVALID_DATE): |
| 678 | error_description = "X509 - The date tag or value is invalid"; |
| 679 | break; |
| 680 | case -(MBEDTLS_ERR_X509_INVALID_SIGNATURE): |
| 681 | error_description = "X509 - The signature tag or value invalid"; |
| 682 | break; |
| 683 | case -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS): |
| 684 | error_description = "X509 - The extension tag or value is invalid"; |
| 685 | break; |
| 686 | case -(MBEDTLS_ERR_X509_UNKNOWN_VERSION): |
| 687 | error_description = "X509 - CRT/CRL/CSR has an unsupported version number"; |
| 688 | break; |
| 689 | case -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG): |
| 690 | error_description = "X509 - Signature algorithm (oid) is unsupported"; |
| 691 | break; |
| 692 | case -(MBEDTLS_ERR_X509_SIG_MISMATCH): |
| 693 | error_description = "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)"; |
| 694 | break; |
| 695 | case -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED): |
| 696 | error_description = "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed"; |
| 697 | break; |
| 698 | case -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT): |
| 699 | error_description = "X509 - Format not recognized as DER or PEM"; |
| 700 | break; |
| 701 | case -(MBEDTLS_ERR_X509_BAD_INPUT_DATA): |
| 702 | error_description = "X509 - Input invalid"; |
| 703 | break; |
| 704 | case -(MBEDTLS_ERR_X509_ALLOC_FAILED): |
| 705 | error_description = "X509 - Allocation of memory failed"; |
| 706 | break; |
| 707 | case -(MBEDTLS_ERR_X509_FILE_IO_ERROR): |
| 708 | error_description = "X509 - Read/write of file failed"; |
| 709 | break; |
| 710 | case -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL): |
| 711 | error_description = "X509 - Destination buffer is too small"; |
| 712 | break; |
| 713 | case -(MBEDTLS_ERR_X509_FATAL_ERROR): |
| 714 | error_description = "X509 - A fatal error occurred, eg the chain is too long or the vrfy callback failed"; |
| 715 | break; |
| 716 | #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ |
Gaurav Aggarwal | 3d02db2 | 2020-04-11 17:14:03 -0700 | [diff] [blame^] | 717 | /* End Auto-Generated Code. */ |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 718 | |
| 719 | default: |
| 720 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | return error_description; |
| 724 | } |
| 725 | |
| 726 | const char * mbedtls_low_level_strerr( int error_code ) |
| 727 | { |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 728 | const char *error_description = NULL; |
| 729 | |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 730 | switch( error_code ) |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 731 | { |
Gaurav Aggarwal | 3d02db2 | 2020-04-11 17:14:03 -0700 | [diff] [blame^] | 732 | /* Begin Auto-Generated Code. */ |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 733 | #if defined(MBEDTLS_AES_C) |
| 734 | case -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH): |
| 735 | error_description = "AES - Invalid key length"; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 736 | break; |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 737 | case -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH): |
| 738 | error_description = "AES - Invalid data input length"; |
| 739 | break; |
| 740 | case -(MBEDTLS_ERR_AES_BAD_INPUT_DATA): |
| 741 | error_description = "AES - Invalid input data"; |
| 742 | break; |
| 743 | case -(MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE): |
| 744 | error_description = "AES - Feature not available. For example, an unsupported AES key size"; |
| 745 | break; |
| 746 | case -(MBEDTLS_ERR_AES_HW_ACCEL_FAILED): |
| 747 | error_description = "AES - AES hardware accelerator failed"; |
| 748 | break; |
| 749 | #endif /* MBEDTLS_AES_C */ |
| 750 | |
| 751 | #if defined(MBEDTLS_ARC4_C) |
| 752 | case -(MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED): |
| 753 | error_description = "ARC4 - ARC4 hardware accelerator failed"; |
| 754 | break; |
| 755 | #endif /* MBEDTLS_ARC4_C */ |
| 756 | |
| 757 | #if defined(MBEDTLS_ARIA_C) |
| 758 | case -(MBEDTLS_ERR_ARIA_BAD_INPUT_DATA): |
| 759 | error_description = "ARIA - Bad input data"; |
| 760 | break; |
| 761 | case -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH): |
| 762 | error_description = "ARIA - Invalid data input length"; |
| 763 | break; |
| 764 | case -(MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE): |
| 765 | error_description = "ARIA - Feature not available. For example, an unsupported ARIA key size"; |
| 766 | break; |
| 767 | case -(MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED): |
| 768 | error_description = "ARIA - ARIA hardware accelerator failed"; |
| 769 | break; |
| 770 | #endif /* MBEDTLS_ARIA_C */ |
| 771 | |
| 772 | #if defined(MBEDTLS_ASN1_PARSE_C) |
| 773 | case -(MBEDTLS_ERR_ASN1_OUT_OF_DATA): |
| 774 | error_description = "ASN1 - Out of data when parsing an ASN1 data structure"; |
| 775 | break; |
| 776 | case -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG): |
| 777 | error_description = "ASN1 - ASN1 tag was of an unexpected value"; |
| 778 | break; |
| 779 | case -(MBEDTLS_ERR_ASN1_INVALID_LENGTH): |
| 780 | error_description = "ASN1 - Error when trying to determine the length or invalid length"; |
| 781 | break; |
| 782 | case -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH): |
| 783 | error_description = "ASN1 - Actual length differs from expected length"; |
| 784 | break; |
| 785 | case -(MBEDTLS_ERR_ASN1_INVALID_DATA): |
| 786 | error_description = "ASN1 - Data is invalid"; |
| 787 | break; |
| 788 | case -(MBEDTLS_ERR_ASN1_ALLOC_FAILED): |
| 789 | error_description = "ASN1 - Memory allocation failed"; |
| 790 | break; |
| 791 | case -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL): |
| 792 | error_description = "ASN1 - Buffer too small when writing ASN.1 data structure"; |
| 793 | break; |
| 794 | #endif /* MBEDTLS_ASN1_PARSE_C */ |
| 795 | |
| 796 | #if defined(MBEDTLS_BASE64_C) |
| 797 | case -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL): |
| 798 | error_description = "BASE64 - Output buffer too small"; |
| 799 | break; |
| 800 | case -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER): |
| 801 | error_description = "BASE64 - Invalid character in input"; |
| 802 | break; |
| 803 | #endif /* MBEDTLS_BASE64_C */ |
| 804 | |
| 805 | #if defined(MBEDTLS_BIGNUM_C) |
| 806 | case -(MBEDTLS_ERR_MPI_FILE_IO_ERROR): |
| 807 | error_description = "BIGNUM - An error occurred while reading from or writing to a file"; |
| 808 | break; |
| 809 | case -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA): |
| 810 | error_description = "BIGNUM - Bad input parameters to function"; |
| 811 | break; |
| 812 | case -(MBEDTLS_ERR_MPI_INVALID_CHARACTER): |
| 813 | error_description = "BIGNUM - There is an invalid character in the digit string"; |
| 814 | break; |
| 815 | case -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL): |
| 816 | error_description = "BIGNUM - The buffer is too small to write to"; |
| 817 | break; |
| 818 | case -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE): |
| 819 | error_description = "BIGNUM - The input arguments are negative or result in illegal output"; |
| 820 | break; |
| 821 | case -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO): |
| 822 | error_description = "BIGNUM - The input argument for division is zero, which is not allowed"; |
| 823 | break; |
| 824 | case -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE): |
| 825 | error_description = "BIGNUM - The input arguments are not acceptable"; |
| 826 | break; |
| 827 | case -(MBEDTLS_ERR_MPI_ALLOC_FAILED): |
| 828 | error_description = "BIGNUM - Memory allocation failed"; |
| 829 | break; |
| 830 | #endif /* MBEDTLS_BIGNUM_C */ |
| 831 | |
| 832 | #if defined(MBEDTLS_BLOWFISH_C) |
| 833 | case -(MBEDTLS_ERR_BLOWFISH_BAD_INPUT_DATA): |
| 834 | error_description = "BLOWFISH - Bad input data"; |
| 835 | break; |
| 836 | case -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH): |
| 837 | error_description = "BLOWFISH - Invalid data input length"; |
| 838 | break; |
| 839 | case -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED): |
| 840 | error_description = "BLOWFISH - Blowfish hardware accelerator failed"; |
| 841 | break; |
| 842 | #endif /* MBEDTLS_BLOWFISH_C */ |
| 843 | |
| 844 | #if defined(MBEDTLS_CAMELLIA_C) |
| 845 | case -(MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA): |
| 846 | error_description = "CAMELLIA - Bad input data"; |
| 847 | break; |
| 848 | case -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH): |
| 849 | error_description = "CAMELLIA - Invalid data input length"; |
| 850 | break; |
| 851 | case -(MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED): |
| 852 | error_description = "CAMELLIA - Camellia hardware accelerator failed"; |
| 853 | break; |
| 854 | #endif /* MBEDTLS_CAMELLIA_C */ |
| 855 | |
| 856 | #if defined(MBEDTLS_CCM_C) |
| 857 | case -(MBEDTLS_ERR_CCM_BAD_INPUT): |
| 858 | error_description = "CCM - Bad input parameters to the function"; |
| 859 | break; |
| 860 | case -(MBEDTLS_ERR_CCM_AUTH_FAILED): |
| 861 | error_description = "CCM - Authenticated decryption failed"; |
| 862 | break; |
| 863 | case -(MBEDTLS_ERR_CCM_HW_ACCEL_FAILED): |
| 864 | error_description = "CCM - CCM hardware accelerator failed"; |
| 865 | break; |
| 866 | #endif /* MBEDTLS_CCM_C */ |
| 867 | |
| 868 | #if defined(MBEDTLS_CHACHA20_C) |
| 869 | case -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA): |
| 870 | error_description = "CHACHA20 - Invalid input parameter(s)"; |
| 871 | break; |
| 872 | case -(MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE): |
| 873 | error_description = "CHACHA20 - Feature not available. For example, s part of the API is not implemented"; |
| 874 | break; |
| 875 | case -(MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED): |
| 876 | error_description = "CHACHA20 - Chacha20 hardware accelerator failed"; |
| 877 | break; |
| 878 | #endif /* MBEDTLS_CHACHA20_C */ |
| 879 | |
| 880 | #if defined(MBEDTLS_CHACHAPOLY_C) |
| 881 | case -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE): |
| 882 | error_description = "CHACHAPOLY - The requested operation is not permitted in the current state"; |
| 883 | break; |
| 884 | case -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED): |
| 885 | error_description = "CHACHAPOLY - Authenticated decryption failed: data was not authentic"; |
| 886 | break; |
| 887 | #endif /* MBEDTLS_CHACHAPOLY_C */ |
| 888 | |
| 889 | #if defined(MBEDTLS_CMAC_C) |
| 890 | case -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED): |
| 891 | error_description = "CMAC - CMAC hardware accelerator failed"; |
| 892 | break; |
| 893 | #endif /* MBEDTLS_CMAC_C */ |
| 894 | |
| 895 | #if defined(MBEDTLS_CTR_DRBG_C) |
| 896 | case -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED): |
| 897 | error_description = "CTR_DRBG - The entropy source failed"; |
| 898 | break; |
| 899 | case -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG): |
| 900 | error_description = "CTR_DRBG - The requested random buffer length is too big"; |
| 901 | break; |
| 902 | case -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG): |
| 903 | error_description = "CTR_DRBG - The input (entropy + additional data) is too large"; |
| 904 | break; |
| 905 | case -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR): |
| 906 | error_description = "CTR_DRBG - Read or write error in file"; |
| 907 | break; |
| 908 | #endif /* MBEDTLS_CTR_DRBG_C */ |
| 909 | |
| 910 | #if defined(MBEDTLS_DES_C) |
| 911 | case -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH): |
| 912 | error_description = "DES - The data input has an invalid length"; |
| 913 | break; |
| 914 | case -(MBEDTLS_ERR_DES_HW_ACCEL_FAILED): |
| 915 | error_description = "DES - DES hardware accelerator failed"; |
| 916 | break; |
| 917 | #endif /* MBEDTLS_DES_C */ |
| 918 | |
| 919 | #if defined(MBEDTLS_ENTROPY_C) |
| 920 | case -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED): |
| 921 | error_description = "ENTROPY - Critical entropy source failure"; |
| 922 | break; |
| 923 | case -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES): |
| 924 | error_description = "ENTROPY - No more sources can be added"; |
| 925 | break; |
| 926 | case -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED): |
| 927 | error_description = "ENTROPY - No sources have been added to poll"; |
| 928 | break; |
| 929 | case -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE): |
| 930 | error_description = "ENTROPY - No strong sources have been added to poll"; |
| 931 | break; |
| 932 | case -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR): |
| 933 | error_description = "ENTROPY - Read/write error in file"; |
| 934 | break; |
| 935 | #endif /* MBEDTLS_ENTROPY_C */ |
| 936 | |
| 937 | #if defined(MBEDTLS_ERROR_C) |
| 938 | case -(MBEDTLS_ERR_ERROR_GENERIC_ERROR): |
| 939 | error_description = "ERROR - Generic error"; |
| 940 | break; |
| 941 | case -(MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED): |
| 942 | error_description = "ERROR - This is a bug in the library"; |
| 943 | break; |
| 944 | #endif /* MBEDTLS_ERROR_C */ |
| 945 | |
| 946 | #if defined(MBEDTLS_GCM_C) |
| 947 | case -(MBEDTLS_ERR_GCM_AUTH_FAILED): |
| 948 | error_description = "GCM - Authenticated decryption failed"; |
| 949 | break; |
| 950 | case -(MBEDTLS_ERR_GCM_HW_ACCEL_FAILED): |
| 951 | error_description = "GCM - GCM hardware accelerator failed"; |
| 952 | break; |
| 953 | case -(MBEDTLS_ERR_GCM_BAD_INPUT): |
| 954 | error_description = "GCM - Bad input parameters to function"; |
| 955 | break; |
| 956 | #endif /* MBEDTLS_GCM_C */ |
| 957 | |
| 958 | #if defined(MBEDTLS_HKDF_C) |
| 959 | case -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA): |
| 960 | error_description = "HKDF - Bad input parameters to function"; |
| 961 | break; |
| 962 | #endif /* MBEDTLS_HKDF_C */ |
| 963 | |
| 964 | #if defined(MBEDTLS_HMAC_DRBG_C) |
| 965 | case -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG): |
| 966 | error_description = "HMAC_DRBG - Too many random requested in single call"; |
| 967 | break; |
| 968 | case -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG): |
| 969 | error_description = "HMAC_DRBG - Input too large (Entropy + additional)"; |
| 970 | break; |
| 971 | case -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR): |
| 972 | error_description = "HMAC_DRBG - Read/write error in file"; |
| 973 | break; |
| 974 | case -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED): |
| 975 | error_description = "HMAC_DRBG - The entropy source failed"; |
| 976 | break; |
| 977 | #endif /* MBEDTLS_HMAC_DRBG_C */ |
| 978 | |
| 979 | #if defined(MBEDTLS_MD2_C) |
| 980 | case -(MBEDTLS_ERR_MD2_HW_ACCEL_FAILED): |
| 981 | error_description = "MD2 - MD2 hardware accelerator failed"; |
| 982 | break; |
| 983 | #endif /* MBEDTLS_MD2_C */ |
| 984 | |
| 985 | #if defined(MBEDTLS_MD4_C) |
| 986 | case -(MBEDTLS_ERR_MD4_HW_ACCEL_FAILED): |
| 987 | error_description = "MD4 - MD4 hardware accelerator failed"; |
| 988 | break; |
| 989 | #endif /* MBEDTLS_MD4_C */ |
| 990 | |
| 991 | #if defined(MBEDTLS_MD5_C) |
| 992 | case -(MBEDTLS_ERR_MD5_HW_ACCEL_FAILED): |
| 993 | error_description = "MD5 - MD5 hardware accelerator failed"; |
| 994 | break; |
| 995 | #endif /* MBEDTLS_MD5_C */ |
| 996 | |
| 997 | #if defined(MBEDTLS_NET_C) |
| 998 | case -(MBEDTLS_ERR_NET_SOCKET_FAILED): |
| 999 | error_description = "NET - Failed to open a socket"; |
| 1000 | break; |
| 1001 | case -(MBEDTLS_ERR_NET_CONNECT_FAILED): |
| 1002 | error_description = "NET - The connection to the given server / port failed"; |
| 1003 | break; |
| 1004 | case -(MBEDTLS_ERR_NET_BIND_FAILED): |
| 1005 | error_description = "NET - Binding of the socket failed"; |
| 1006 | break; |
| 1007 | case -(MBEDTLS_ERR_NET_LISTEN_FAILED): |
| 1008 | error_description = "NET - Could not listen on the socket"; |
| 1009 | break; |
| 1010 | case -(MBEDTLS_ERR_NET_ACCEPT_FAILED): |
| 1011 | error_description = "NET - Could not accept the incoming connection"; |
| 1012 | break; |
| 1013 | case -(MBEDTLS_ERR_NET_RECV_FAILED): |
| 1014 | error_description = "NET - Reading information from the socket failed"; |
| 1015 | break; |
| 1016 | case -(MBEDTLS_ERR_NET_SEND_FAILED): |
| 1017 | error_description = "NET - Sending information through the socket failed"; |
| 1018 | break; |
| 1019 | case -(MBEDTLS_ERR_NET_CONN_RESET): |
| 1020 | error_description = "NET - Connection was reset by peer"; |
| 1021 | break; |
| 1022 | case -(MBEDTLS_ERR_NET_UNKNOWN_HOST): |
| 1023 | error_description = "NET - Failed to get an IP address for the given hostname"; |
| 1024 | break; |
| 1025 | case -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL): |
| 1026 | error_description = "NET - Buffer is too small to hold the data"; |
| 1027 | break; |
| 1028 | case -(MBEDTLS_ERR_NET_INVALID_CONTEXT): |
| 1029 | error_description = "NET - The context is invalid, eg because it was free()ed"; |
| 1030 | break; |
| 1031 | case -(MBEDTLS_ERR_NET_POLL_FAILED): |
| 1032 | error_description = "NET - Polling the net context failed"; |
| 1033 | break; |
| 1034 | case -(MBEDTLS_ERR_NET_BAD_INPUT_DATA): |
| 1035 | error_description = "NET - Input invalid"; |
| 1036 | break; |
| 1037 | #endif /* MBEDTLS_NET_C */ |
| 1038 | |
| 1039 | #if defined(MBEDTLS_OID_C) |
| 1040 | case -(MBEDTLS_ERR_OID_NOT_FOUND): |
| 1041 | error_description = "OID - OID is not found"; |
| 1042 | break; |
| 1043 | case -(MBEDTLS_ERR_OID_BUF_TOO_SMALL): |
| 1044 | error_description = "OID - output buffer is too small"; |
| 1045 | break; |
| 1046 | #endif /* MBEDTLS_OID_C */ |
| 1047 | |
| 1048 | #if defined(MBEDTLS_PADLOCK_C) |
| 1049 | case -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED): |
| 1050 | error_description = "PADLOCK - Input data should be aligned"; |
| 1051 | break; |
| 1052 | #endif /* MBEDTLS_PADLOCK_C */ |
| 1053 | |
| 1054 | #if defined(MBEDTLS_PLATFORM_C) |
| 1055 | case -(MBEDTLS_ERR_PLATFORM_HW_ACCEL_FAILED): |
| 1056 | error_description = "PLATFORM - Hardware accelerator failed"; |
| 1057 | break; |
| 1058 | case -(MBEDTLS_ERR_PLATFORM_FEATURE_UNSUPPORTED): |
| 1059 | error_description = "PLATFORM - The requested feature is not supported by the platform"; |
| 1060 | break; |
| 1061 | #endif /* MBEDTLS_PLATFORM_C */ |
| 1062 | |
| 1063 | #if defined(MBEDTLS_POLY1305_C) |
| 1064 | case -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA): |
| 1065 | error_description = "POLY1305 - Invalid input parameter(s)"; |
| 1066 | break; |
| 1067 | case -(MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE): |
| 1068 | error_description = "POLY1305 - Feature not available. For example, s part of the API is not implemented"; |
| 1069 | break; |
| 1070 | case -(MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED): |
| 1071 | error_description = "POLY1305 - Poly1305 hardware accelerator failed"; |
| 1072 | break; |
| 1073 | #endif /* MBEDTLS_POLY1305_C */ |
| 1074 | |
| 1075 | #if defined(MBEDTLS_RIPEMD160_C) |
| 1076 | case -(MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED): |
| 1077 | error_description = "RIPEMD160 - RIPEMD160 hardware accelerator failed"; |
| 1078 | break; |
| 1079 | #endif /* MBEDTLS_RIPEMD160_C */ |
| 1080 | |
| 1081 | #if defined(MBEDTLS_SHA1_C) |
| 1082 | case -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED): |
| 1083 | error_description = "SHA1 - SHA-1 hardware accelerator failed"; |
| 1084 | break; |
| 1085 | case -(MBEDTLS_ERR_SHA1_BAD_INPUT_DATA): |
| 1086 | error_description = "SHA1 - SHA-1 input data was malformed"; |
| 1087 | break; |
| 1088 | #endif /* MBEDTLS_SHA1_C */ |
| 1089 | |
| 1090 | #if defined(MBEDTLS_SHA256_C) |
| 1091 | case -(MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED): |
| 1092 | error_description = "SHA256 - SHA-256 hardware accelerator failed"; |
| 1093 | break; |
| 1094 | case -(MBEDTLS_ERR_SHA256_BAD_INPUT_DATA): |
| 1095 | error_description = "SHA256 - SHA-256 input data was malformed"; |
| 1096 | break; |
| 1097 | #endif /* MBEDTLS_SHA256_C */ |
| 1098 | |
| 1099 | #if defined(MBEDTLS_SHA512_C) |
| 1100 | case -(MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED): |
| 1101 | error_description = "SHA512 - SHA-512 hardware accelerator failed"; |
| 1102 | break; |
| 1103 | case -(MBEDTLS_ERR_SHA512_BAD_INPUT_DATA): |
| 1104 | error_description = "SHA512 - SHA-512 input data was malformed"; |
| 1105 | break; |
| 1106 | #endif /* MBEDTLS_SHA512_C */ |
| 1107 | |
| 1108 | #if defined(MBEDTLS_THREADING_C) |
| 1109 | case -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE): |
| 1110 | error_description = "THREADING - The selected feature is not available"; |
| 1111 | break; |
| 1112 | case -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA): |
| 1113 | error_description = "THREADING - Bad input parameters to function"; |
| 1114 | break; |
| 1115 | case -(MBEDTLS_ERR_THREADING_MUTEX_ERROR): |
| 1116 | error_description = "THREADING - Locking / unlocking / free failed with error code"; |
| 1117 | break; |
| 1118 | #endif /* MBEDTLS_THREADING_C */ |
| 1119 | |
| 1120 | #if defined(MBEDTLS_XTEA_C) |
| 1121 | case -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH): |
| 1122 | error_description = "XTEA - The data input has an invalid length"; |
| 1123 | break; |
| 1124 | case -(MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED): |
| 1125 | error_description = "XTEA - XTEA hardware accelerator failed"; |
| 1126 | break; |
| 1127 | #endif /* MBEDTLS_XTEA_C */ |
Gaurav Aggarwal | 3d02db2 | 2020-04-11 17:14:03 -0700 | [diff] [blame^] | 1128 | /* End Auto-Generated Code. */ |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 1129 | |
| 1130 | default: |
| 1131 | break; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | return error_description; |
| 1135 | } |
| 1136 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1137 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1138 | { |
| 1139 | size_t len; |
| 1140 | int use_ret; |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1141 | const char * high_level_error_description = NULL; |
| 1142 | const char * low_level_error_description = NULL; |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1143 | |
Paul Bakker | b9cfaa0 | 2013-10-11 18:58:55 +0200 | [diff] [blame] | 1144 | if( buflen == 0 ) |
| 1145 | return; |
| 1146 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1147 | memset( buf, 0x00, buflen ); |
Paul Bakker | b9cfaa0 | 2013-10-11 18:58:55 +0200 | [diff] [blame] | 1148 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1149 | if( ret < 0 ) |
| 1150 | ret = -ret; |
| 1151 | |
| 1152 | if( ret & 0xFF80 ) |
| 1153 | { |
| 1154 | use_ret = ret & 0xFF80; |
| 1155 | |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1156 | // Translate high level error code. |
| 1157 | high_level_error_description = mbedtls_high_level_strerr(use_ret); |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 1158 | |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1159 | if( high_level_error_description == NULL ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1160 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1161 | else |
| 1162 | mbedtls_snprintf( buf, buflen, "%s", high_level_error_description ); |
| 1163 | |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 1164 | #if defined(MBEDTLS_SSL_TLS_C) |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1165 | // Early return in case of a fatal error - do not try to translate low |
| 1166 | // level code. |
| 1167 | if(use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE)) |
| 1168 | return; |
Gaurav Aggarwal | a4a2aa5 | 2020-04-09 11:39:04 -0700 | [diff] [blame] | 1169 | #endif /* MBEDTLS_SSL_TLS_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1170 | } |
| 1171 | |
| 1172 | use_ret = ret & ~0xFF80; |
| 1173 | |
| 1174 | if( use_ret == 0 ) |
| 1175 | return; |
| 1176 | |
| 1177 | // If high level code is present, make a concatenation between both |
| 1178 | // error strings. |
| 1179 | // |
| 1180 | len = strlen( buf ); |
| 1181 | |
| 1182 | if( len > 0 ) |
| 1183 | { |
| 1184 | if( buflen - len < 5 ) |
| 1185 | return; |
| 1186 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1187 | mbedtls_snprintf( buf + len, buflen - len, " : " ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1188 | |
| 1189 | buf += len + 3; |
| 1190 | buflen -= len + 3; |
| 1191 | } |
| 1192 | |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1193 | // Translate low level error code. |
| 1194 | low_level_error_description = mbedtls_low_level_strerr( use_ret ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1195 | |
Gaurav Aggarwal | a9f6400 | 2020-04-09 01:44:52 -0700 | [diff] [blame] | 1196 | if( low_level_error_description == NULL ) |
| 1197 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
| 1198 | else |
| 1199 | mbedtls_snprintf( buf, buflen, "%s", low_level_error_description ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 1200 | } |
| 1201 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1202 | #else /* MBEDTLS_ERROR_C */ |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 1203 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1204 | #if defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 1205 | |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 1206 | /* |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1207 | * Provide an non-function in case MBEDTLS_ERROR_C is not defined |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 1208 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1209 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 1210 | { |
| 1211 | ((void) ret); |
| 1212 | |
| 1213 | if( buflen > 0 ) |
| 1214 | buf[0] = '\0'; |
| 1215 | } |
| 1216 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1217 | #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ |
Paul Bakker | e2ab84f | 2013-06-29 18:24:32 +0200 | [diff] [blame] | 1218 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 1219 | #endif /* MBEDTLS_ERROR_C */ |