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 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 28 | #if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 29 | #include "mbedtls/error.h" |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 30 | #include <string.h> |
Manuel Pégourié-Gonnard | bee8ded | 2014-06-25 12:22:59 +0200 | [diff] [blame] | 31 | #endif |
| 32 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 33 | #if defined(MBEDTLS_PLATFORM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 34 | #include "mbedtls/platform.h" |
Manuel Pégourié-Gonnard | 0928640 | 2015-02-13 15:18:33 +0000 | [diff] [blame] | 35 | #else |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 36 | #define mbedtls_snprintf snprintf |
-~- redtangent ~-~ | 9fa2e86 | 2016-05-26 10:07:49 +0100 | [diff] [blame] | 37 | #define mbedtls_time_t time_t |
Manuel Pégourié-Gonnard | bee8ded | 2014-06-25 12:22:59 +0200 | [diff] [blame] | 38 | #endif |
| 39 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 40 | #if defined(MBEDTLS_ERROR_C) |
Paul Bakker | 3c2122f | 2013-06-24 19:03:14 +0200 | [diff] [blame] | 41 | |
Rich Evans | 00ab470 | 2015-02-06 13:43:58 +0000 | [diff] [blame] | 42 | #include <stdio.h> |
| 43 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 44 | #if defined(MBEDTLS_AES_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 45 | #include "mbedtls/aes.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 46 | #endif |
| 47 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 48 | #if defined(MBEDTLS_ARC4_C) |
| 49 | #include "mbedtls/arc4.h" |
| 50 | #endif |
| 51 | |
Markku-Juhani O. Saarinen | 07478d6 | 2017-12-01 16:20:15 +0000 | [diff] [blame] | 52 | #if defined(MBEDTLS_ARIA_C) |
| 53 | #include "mbedtls/aria.h" |
| 54 | #endif |
| 55 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 56 | #if defined(MBEDTLS_BASE64_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 57 | #include "mbedtls/base64.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 60 | #if defined(MBEDTLS_BIGNUM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 61 | #include "mbedtls/bignum.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 62 | #endif |
| 63 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 64 | #if defined(MBEDTLS_BLOWFISH_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 65 | #include "mbedtls/blowfish.h" |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 68 | #if defined(MBEDTLS_CAMELLIA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 69 | #include "mbedtls/camellia.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 70 | #endif |
| 71 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 72 | #if defined(MBEDTLS_CCM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 73 | #include "mbedtls/ccm.h" |
Manuel Pégourié-Gonnard | a6916fa | 2014-05-02 15:17:29 +0200 | [diff] [blame] | 74 | #endif |
| 75 | |
Daniel King | 34b822c | 2016-05-15 17:28:08 -0300 | [diff] [blame] | 76 | #if defined(MBEDTLS_CHACHA20_C) |
| 77 | #include "mbedtls/chacha20.h" |
| 78 | #endif |
| 79 | |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 80 | #if defined(MBEDTLS_CHACHAPOLY_C) |
| 81 | #include "mbedtls/chachapoly.h" |
| 82 | #endif |
| 83 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 84 | #if defined(MBEDTLS_CIPHER_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 85 | #include "mbedtls/cipher.h" |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 86 | #endif |
| 87 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 88 | #if defined(MBEDTLS_CMAC_C) |
| 89 | #include "mbedtls/cmac.h" |
| 90 | #endif |
| 91 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 92 | #if defined(MBEDTLS_CTR_DRBG_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 93 | #include "mbedtls/ctr_drbg.h" |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 94 | #endif |
| 95 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 96 | #if defined(MBEDTLS_DES_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 97 | #include "mbedtls/des.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 98 | #endif |
| 99 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 100 | #if defined(MBEDTLS_DHM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 101 | #include "mbedtls/dhm.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 102 | #endif |
| 103 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 104 | #if defined(MBEDTLS_ECP_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 105 | #include "mbedtls/ecp.h" |
Paul Bakker | cf4365f | 2013-01-16 17:00:43 +0100 | [diff] [blame] | 106 | #endif |
| 107 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 108 | #if defined(MBEDTLS_ENTROPY_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 109 | #include "mbedtls/entropy.h" |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 110 | #endif |
| 111 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 112 | #if defined(MBEDTLS_GCM_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 113 | #include "mbedtls/gcm.h" |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 114 | #endif |
| 115 | |
Thomas Fossati | 656864b | 2016-07-17 08:51:22 +0100 | [diff] [blame] | 116 | #if defined(MBEDTLS_HKDF_C) |
| 117 | #include "mbedtls/hkdf.h" |
| 118 | #endif |
| 119 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 120 | #if defined(MBEDTLS_HMAC_DRBG_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 121 | #include "mbedtls/hmac_drbg.h" |
Manuel Pégourié-Gonnard | cf38367 | 2014-02-01 10:22:21 +0100 | [diff] [blame] | 122 | #endif |
| 123 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 124 | #if defined(MBEDTLS_MD_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 125 | #include "mbedtls/md.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 126 | #endif |
| 127 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 128 | #if defined(MBEDTLS_MD2_C) |
| 129 | #include "mbedtls/md2.h" |
| 130 | #endif |
| 131 | |
| 132 | #if defined(MBEDTLS_MD4_C) |
| 133 | #include "mbedtls/md4.h" |
| 134 | #endif |
| 135 | |
| 136 | #if defined(MBEDTLS_MD5_C) |
| 137 | #include "mbedtls/md5.h" |
| 138 | #endif |
| 139 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 140 | #if defined(MBEDTLS_NET_C) |
Andres AG | 3616f6f | 2016-09-14 14:32:09 +0100 | [diff] [blame] | 141 | #include "mbedtls/net_sockets.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 142 | #endif |
| 143 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 144 | #if defined(MBEDTLS_OID_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 145 | #include "mbedtls/oid.h" |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 146 | #endif |
| 147 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 148 | #if defined(MBEDTLS_PADLOCK_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 149 | #include "mbedtls/padlock.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 150 | #endif |
| 151 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 152 | #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] | 153 | #include "mbedtls/pem.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 154 | #endif |
| 155 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 156 | #if defined(MBEDTLS_PK_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 157 | #include "mbedtls/pk.h" |
Manuel Pégourié-Gonnard | 7a6c946 | 2013-07-09 10:04:07 +0200 | [diff] [blame] | 158 | #endif |
| 159 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 160 | #if defined(MBEDTLS_PKCS12_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 161 | #include "mbedtls/pkcs12.h" |
Paul Bakker | f1f21fe | 2013-06-24 19:17:19 +0200 | [diff] [blame] | 162 | #endif |
| 163 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 164 | #if defined(MBEDTLS_PKCS5_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 165 | #include "mbedtls/pkcs5.h" |
Paul Bakker | b0c19a4 | 2013-06-24 19:26:38 +0200 | [diff] [blame] | 166 | #endif |
| 167 | |
Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame] | 168 | #if defined(MBEDTLS_POLY1305_C) |
| 169 | #include "mbedtls/poly1305.h" |
| 170 | #endif |
| 171 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 172 | #if defined(MBEDTLS_RIPEMD160_C) |
| 173 | #include "mbedtls/ripemd160.h" |
| 174 | #endif |
| 175 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 176 | #if defined(MBEDTLS_RSA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 177 | #include "mbedtls/rsa.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 178 | #endif |
| 179 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 180 | #if defined(MBEDTLS_SHA1_C) |
| 181 | #include "mbedtls/sha1.h" |
| 182 | #endif |
| 183 | |
| 184 | #if defined(MBEDTLS_SHA256_C) |
| 185 | #include "mbedtls/sha256.h" |
| 186 | #endif |
| 187 | |
| 188 | #if defined(MBEDTLS_SHA512_C) |
| 189 | #include "mbedtls/sha512.h" |
| 190 | #endif |
| 191 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 192 | #if defined(MBEDTLS_SSL_TLS_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 193 | #include "mbedtls/ssl.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 194 | #endif |
| 195 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 196 | #if defined(MBEDTLS_THREADING_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 197 | #include "mbedtls/threading.h" |
Paul Bakker | 2466d93 | 2013-09-28 14:40:38 +0200 | [diff] [blame] | 198 | #endif |
| 199 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 200 | #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 201 | #include "mbedtls/x509.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 202 | #endif |
| 203 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 204 | #if defined(MBEDTLS_XTEA_C) |
Manuel Pégourié-Gonnard | 7f80997 | 2015-03-09 17:05:11 +0000 | [diff] [blame] | 205 | #include "mbedtls/xtea.h" |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 206 | #endif |
| 207 | |
Paul Bakker | dceecd8 | 2011-11-15 16:38:34 +0000 | [diff] [blame] | 208 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 209 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 210 | { |
| 211 | size_t len; |
| 212 | int use_ret; |
| 213 | |
Paul Bakker | b9cfaa0 | 2013-10-11 18:58:55 +0200 | [diff] [blame] | 214 | if( buflen == 0 ) |
| 215 | return; |
| 216 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 217 | memset( buf, 0x00, buflen ); |
Paul Bakker | b9cfaa0 | 2013-10-11 18:58:55 +0200 | [diff] [blame] | 218 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 219 | if( ret < 0 ) |
| 220 | ret = -ret; |
| 221 | |
| 222 | if( ret & 0xFF80 ) |
| 223 | { |
| 224 | use_ret = ret & 0xFF80; |
| 225 | |
| 226 | // High level error codes |
| 227 | // |
Manuel Pégourié-Gonnard | fe671f4 | 2014-04-11 18:06:44 +0200 | [diff] [blame] | 228 | // BEGIN generated code |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 229 | #if defined(MBEDTLS_CIPHER_C) |
| 230 | if( use_ret == -(MBEDTLS_ERR_CIPHER_FEATURE_UNAVAILABLE) ) |
| 231 | mbedtls_snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); |
| 232 | if( use_ret == -(MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA) ) |
Rose Zadik | 9ba6b62 | 2018-01-24 12:59:19 +0000 | [diff] [blame] | 233 | mbedtls_snprintf( buf, buflen, "CIPHER - Bad input parameters" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 234 | if( use_ret == -(MBEDTLS_ERR_CIPHER_ALLOC_FAILED) ) |
| 235 | mbedtls_snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); |
| 236 | if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_PADDING) ) |
| 237 | mbedtls_snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); |
| 238 | if( use_ret == -(MBEDTLS_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) |
| 239 | mbedtls_snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); |
| 240 | if( use_ret == -(MBEDTLS_ERR_CIPHER_AUTH_FAILED) ) |
| 241 | mbedtls_snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); |
Janos Follath | 98e28a7 | 2016-05-31 14:03:54 +0100 | [diff] [blame] | 242 | if( use_ret == -(MBEDTLS_ERR_CIPHER_INVALID_CONTEXT) ) |
Rose Zadik | 9ba6b62 | 2018-01-24 12:59:19 +0000 | [diff] [blame] | 243 | mbedtls_snprintf( buf, buflen, "CIPHER - The context is invalid. For example, because it was freed" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 244 | if( use_ret == -(MBEDTLS_ERR_CIPHER_HW_ACCEL_FAILED) ) |
| 245 | mbedtls_snprintf( buf, buflen, "CIPHER - Cipher hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 246 | #endif /* MBEDTLS_CIPHER_C */ |
Paul Bakker | ff61a78 | 2011-06-09 15:42:02 +0000 | [diff] [blame] | 247 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 248 | #if defined(MBEDTLS_DHM_C) |
| 249 | if( use_ret == -(MBEDTLS_ERR_DHM_BAD_INPUT_DATA) ) |
Rose Zadik | 41ad082 | 2018-01-26 10:54:57 +0000 | [diff] [blame] | 250 | mbedtls_snprintf( buf, buflen, "DHM - Bad input parameters" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 251 | if( use_ret == -(MBEDTLS_ERR_DHM_READ_PARAMS_FAILED) ) |
| 252 | mbedtls_snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); |
| 253 | if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PARAMS_FAILED) ) |
| 254 | mbedtls_snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); |
| 255 | if( use_ret == -(MBEDTLS_ERR_DHM_READ_PUBLIC_FAILED) ) |
| 256 | mbedtls_snprintf( buf, buflen, "DHM - Reading of the public values failed" ); |
| 257 | if( use_ret == -(MBEDTLS_ERR_DHM_MAKE_PUBLIC_FAILED) ) |
| 258 | mbedtls_snprintf( buf, buflen, "DHM - Making of the public value failed" ); |
| 259 | if( use_ret == -(MBEDTLS_ERR_DHM_CALC_SECRET_FAILED) ) |
| 260 | mbedtls_snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); |
| 261 | if( use_ret == -(MBEDTLS_ERR_DHM_INVALID_FORMAT) ) |
| 262 | mbedtls_snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 263 | if( use_ret == -(MBEDTLS_ERR_DHM_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 264 | mbedtls_snprintf( buf, buflen, "DHM - Allocation of memory failed" ); |
| 265 | if( use_ret == -(MBEDTLS_ERR_DHM_FILE_IO_ERROR) ) |
Rose Zadik | 41ad082 | 2018-01-26 10:54:57 +0000 | [diff] [blame] | 266 | mbedtls_snprintf( buf, buflen, "DHM - Read or write of file failed" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 267 | if( use_ret == -(MBEDTLS_ERR_DHM_HW_ACCEL_FAILED) ) |
| 268 | mbedtls_snprintf( buf, buflen, "DHM - DHM hardware accelerator failed" ); |
Hanno Becker | a6dd90d | 2017-10-04 13:15:54 +0100 | [diff] [blame] | 269 | if( use_ret == -(MBEDTLS_ERR_DHM_SET_GROUP_FAILED) ) |
Jaeden Amero | 784de59 | 2018-01-26 17:52:01 +0000 | [diff] [blame] | 270 | mbedtls_snprintf( buf, buflen, "DHM - Setting the modulus and generator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 271 | #endif /* MBEDTLS_DHM_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 272 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 273 | #if defined(MBEDTLS_ECP_C) |
| 274 | if( use_ret == -(MBEDTLS_ERR_ECP_BAD_INPUT_DATA) ) |
| 275 | mbedtls_snprintf( buf, buflen, "ECP - Bad input parameters to function" ); |
| 276 | if( use_ret == -(MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL) ) |
| 277 | mbedtls_snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); |
| 278 | if( use_ret == -(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE) ) |
Jaeden Amero | 3dd8abd | 2018-04-24 10:56:55 +0100 | [diff] [blame] | 279 | mbedtls_snprintf( buf, buflen, "ECP - The requested feature is not available, for example, the requested curve is not supported" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 280 | if( use_ret == -(MBEDTLS_ERR_ECP_VERIFY_FAILED) ) |
| 281 | mbedtls_snprintf( buf, buflen, "ECP - The signature is not valid" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 282 | if( use_ret == -(MBEDTLS_ERR_ECP_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 283 | mbedtls_snprintf( buf, buflen, "ECP - Memory allocation failed" ); |
| 284 | if( use_ret == -(MBEDTLS_ERR_ECP_RANDOM_FAILED) ) |
Jaeden Amero | 3dd8abd | 2018-04-24 10:56:55 +0100 | [diff] [blame] | 285 | mbedtls_snprintf( buf, buflen, "ECP - Generation of random value, such as ephemeral key, failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 286 | if( use_ret == -(MBEDTLS_ERR_ECP_INVALID_KEY) ) |
| 287 | mbedtls_snprintf( buf, buflen, "ECP - Invalid private or public key" ); |
| 288 | if( use_ret == -(MBEDTLS_ERR_ECP_SIG_LEN_MISMATCH) ) |
Gilles Peskine | cc78ac4 | 2018-03-30 18:52:10 +0200 | [diff] [blame] | 289 | mbedtls_snprintf( buf, buflen, "ECP - The buffer contains a valid signature followed by more data" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 290 | if( use_ret == -(MBEDTLS_ERR_ECP_HW_ACCEL_FAILED) ) |
Jaeden Amero | 3dd8abd | 2018-04-24 10:56:55 +0100 | [diff] [blame] | 291 | mbedtls_snprintf( buf, buflen, "ECP - The ECP hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 292 | #endif /* MBEDTLS_ECP_C */ |
Paul Bakker | cf4365f | 2013-01-16 17:00:43 +0100 | [diff] [blame] | 293 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 294 | #if defined(MBEDTLS_MD_C) |
| 295 | if( use_ret == -(MBEDTLS_ERR_MD_FEATURE_UNAVAILABLE) ) |
| 296 | mbedtls_snprintf( buf, buflen, "MD - The selected feature is not available" ); |
| 297 | if( use_ret == -(MBEDTLS_ERR_MD_BAD_INPUT_DATA) ) |
| 298 | mbedtls_snprintf( buf, buflen, "MD - Bad input parameters to function" ); |
| 299 | if( use_ret == -(MBEDTLS_ERR_MD_ALLOC_FAILED) ) |
| 300 | mbedtls_snprintf( buf, buflen, "MD - Failed to allocate memory" ); |
| 301 | if( use_ret == -(MBEDTLS_ERR_MD_FILE_IO_ERROR) ) |
| 302 | mbedtls_snprintf( buf, buflen, "MD - Opening or reading of file failed" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 303 | if( use_ret == -(MBEDTLS_ERR_MD_HW_ACCEL_FAILED) ) |
| 304 | mbedtls_snprintf( buf, buflen, "MD - MD hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 305 | #endif /* MBEDTLS_MD_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 306 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 307 | #if defined(MBEDTLS_PEM_PARSE_C) || defined(MBEDTLS_PEM_WRITE_C) |
| 308 | if( use_ret == -(MBEDTLS_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) |
| 309 | mbedtls_snprintf( buf, buflen, "PEM - No PEM header or footer found" ); |
| 310 | if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_DATA) ) |
| 311 | mbedtls_snprintf( buf, buflen, "PEM - PEM string is not as expected" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 312 | if( use_ret == -(MBEDTLS_ERR_PEM_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 313 | mbedtls_snprintf( buf, buflen, "PEM - Failed to allocate memory" ); |
| 314 | if( use_ret == -(MBEDTLS_ERR_PEM_INVALID_ENC_IV) ) |
| 315 | mbedtls_snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); |
| 316 | if( use_ret == -(MBEDTLS_ERR_PEM_UNKNOWN_ENC_ALG) ) |
| 317 | mbedtls_snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); |
| 318 | if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_REQUIRED) ) |
| 319 | mbedtls_snprintf( buf, buflen, "PEM - Private key password can't be empty" ); |
| 320 | if( use_ret == -(MBEDTLS_ERR_PEM_PASSWORD_MISMATCH) ) |
| 321 | mbedtls_snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); |
| 322 | if( use_ret == -(MBEDTLS_ERR_PEM_FEATURE_UNAVAILABLE) ) |
| 323 | mbedtls_snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); |
| 324 | if( use_ret == -(MBEDTLS_ERR_PEM_BAD_INPUT_DATA) ) |
| 325 | mbedtls_snprintf( buf, buflen, "PEM - Bad input parameters to function" ); |
| 326 | #endif /* MBEDTLS_PEM_PARSE_C || MBEDTLS_PEM_WRITE_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 327 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 328 | #if defined(MBEDTLS_PK_C) |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 329 | if( use_ret == -(MBEDTLS_ERR_PK_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 41b9c2b | 2015-05-28 14:56:20 +0200 | [diff] [blame] | 330 | mbedtls_snprintf( buf, buflen, "PK - Memory allocation failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 331 | if( use_ret == -(MBEDTLS_ERR_PK_TYPE_MISMATCH) ) |
| 332 | mbedtls_snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); |
| 333 | if( use_ret == -(MBEDTLS_ERR_PK_BAD_INPUT_DATA) ) |
| 334 | mbedtls_snprintf( buf, buflen, "PK - Bad input parameters to function" ); |
| 335 | if( use_ret == -(MBEDTLS_ERR_PK_FILE_IO_ERROR) ) |
| 336 | mbedtls_snprintf( buf, buflen, "PK - Read/write of file failed" ); |
| 337 | if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_VERSION) ) |
| 338 | mbedtls_snprintf( buf, buflen, "PK - Unsupported key version" ); |
| 339 | if( use_ret == -(MBEDTLS_ERR_PK_KEY_INVALID_FORMAT) ) |
| 340 | mbedtls_snprintf( buf, buflen, "PK - Invalid key tag or value" ); |
| 341 | if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_PK_ALG) ) |
| 342 | mbedtls_snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); |
| 343 | if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_REQUIRED) ) |
| 344 | mbedtls_snprintf( buf, buflen, "PK - Private key password can't be empty" ); |
| 345 | if( use_ret == -(MBEDTLS_ERR_PK_PASSWORD_MISMATCH) ) |
| 346 | mbedtls_snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); |
| 347 | if( use_ret == -(MBEDTLS_ERR_PK_INVALID_PUBKEY) ) |
| 348 | mbedtls_snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); |
| 349 | if( use_ret == -(MBEDTLS_ERR_PK_INVALID_ALG) ) |
| 350 | mbedtls_snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); |
| 351 | if( use_ret == -(MBEDTLS_ERR_PK_UNKNOWN_NAMED_CURVE) ) |
| 352 | mbedtls_snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); |
| 353 | if( use_ret == -(MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE) ) |
| 354 | mbedtls_snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); |
| 355 | if( use_ret == -(MBEDTLS_ERR_PK_SIG_LEN_MISMATCH) ) |
Gilles Peskine | cc78ac4 | 2018-03-30 18:52:10 +0200 | [diff] [blame] | 356 | mbedtls_snprintf( buf, buflen, "PK - The buffer contains a valid signature followed by more data" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 357 | if( use_ret == -(MBEDTLS_ERR_PK_HW_ACCEL_FAILED) ) |
| 358 | mbedtls_snprintf( buf, buflen, "PK - PK hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 359 | #endif /* MBEDTLS_PK_C */ |
Manuel Pégourié-Gonnard | 7a6c946 | 2013-07-09 10:04:07 +0200 | [diff] [blame] | 360 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 361 | #if defined(MBEDTLS_PKCS12_C) |
| 362 | if( use_ret == -(MBEDTLS_ERR_PKCS12_BAD_INPUT_DATA) ) |
| 363 | mbedtls_snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); |
| 364 | if( use_ret == -(MBEDTLS_ERR_PKCS12_FEATURE_UNAVAILABLE) ) |
| 365 | mbedtls_snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); |
| 366 | if( use_ret == -(MBEDTLS_ERR_PKCS12_PBE_INVALID_FORMAT) ) |
| 367 | mbedtls_snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); |
| 368 | if( use_ret == -(MBEDTLS_ERR_PKCS12_PASSWORD_MISMATCH) ) |
| 369 | mbedtls_snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); |
| 370 | #endif /* MBEDTLS_PKCS12_C */ |
Paul Bakker | f1f21fe | 2013-06-24 19:17:19 +0200 | [diff] [blame] | 371 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 372 | #if defined(MBEDTLS_PKCS5_C) |
| 373 | if( use_ret == -(MBEDTLS_ERR_PKCS5_BAD_INPUT_DATA) ) |
| 374 | mbedtls_snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); |
| 375 | if( use_ret == -(MBEDTLS_ERR_PKCS5_INVALID_FORMAT) ) |
| 376 | mbedtls_snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); |
| 377 | if( use_ret == -(MBEDTLS_ERR_PKCS5_FEATURE_UNAVAILABLE) ) |
| 378 | mbedtls_snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); |
| 379 | if( use_ret == -(MBEDTLS_ERR_PKCS5_PASSWORD_MISMATCH) ) |
| 380 | mbedtls_snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); |
| 381 | #endif /* MBEDTLS_PKCS5_C */ |
Paul Bakker | 28144de | 2013-06-24 19:28:55 +0200 | [diff] [blame] | 382 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 383 | #if defined(MBEDTLS_RSA_C) |
| 384 | if( use_ret == -(MBEDTLS_ERR_RSA_BAD_INPUT_DATA) ) |
| 385 | mbedtls_snprintf( buf, buflen, "RSA - Bad input parameters to function" ); |
| 386 | if( use_ret == -(MBEDTLS_ERR_RSA_INVALID_PADDING) ) |
| 387 | mbedtls_snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); |
| 388 | if( use_ret == -(MBEDTLS_ERR_RSA_KEY_GEN_FAILED) ) |
| 389 | mbedtls_snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); |
| 390 | if( use_ret == -(MBEDTLS_ERR_RSA_KEY_CHECK_FAILED) ) |
Rose Zadik | 042e97f | 2018-01-26 16:35:10 +0000 | [diff] [blame] | 391 | mbedtls_snprintf( buf, buflen, "RSA - Key failed to pass the validity check of the library" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 392 | if( use_ret == -(MBEDTLS_ERR_RSA_PUBLIC_FAILED) ) |
| 393 | mbedtls_snprintf( buf, buflen, "RSA - The public key operation failed" ); |
| 394 | if( use_ret == -(MBEDTLS_ERR_RSA_PRIVATE_FAILED) ) |
| 395 | mbedtls_snprintf( buf, buflen, "RSA - The private key operation failed" ); |
| 396 | if( use_ret == -(MBEDTLS_ERR_RSA_VERIFY_FAILED) ) |
| 397 | mbedtls_snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); |
| 398 | if( use_ret == -(MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE) ) |
| 399 | mbedtls_snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); |
| 400 | if( use_ret == -(MBEDTLS_ERR_RSA_RNG_FAILED) ) |
| 401 | mbedtls_snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); |
Hanno Becker | 3cdc711 | 2017-10-05 10:09:31 +0100 | [diff] [blame] | 402 | if( use_ret == -(MBEDTLS_ERR_RSA_UNSUPPORTED_OPERATION) ) |
Rose Zadik | 042e97f | 2018-01-26 16:35:10 +0000 | [diff] [blame] | 403 | mbedtls_snprintf( buf, buflen, "RSA - The implementation does not offer the requested operation, for example, because of security violations or lack of functionality" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 404 | if( use_ret == -(MBEDTLS_ERR_RSA_HW_ACCEL_FAILED) ) |
| 405 | mbedtls_snprintf( buf, buflen, "RSA - RSA hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 406 | #endif /* MBEDTLS_RSA_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 407 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 408 | #if defined(MBEDTLS_SSL_TLS_C) |
| 409 | if( use_ret == -(MBEDTLS_ERR_SSL_FEATURE_UNAVAILABLE) ) |
| 410 | mbedtls_snprintf( buf, buflen, "SSL - The requested feature is not available" ); |
| 411 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_INPUT_DATA) ) |
| 412 | mbedtls_snprintf( buf, buflen, "SSL - Bad input parameters to function" ); |
| 413 | if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_MAC) ) |
| 414 | mbedtls_snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); |
| 415 | if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_RECORD) ) |
| 416 | mbedtls_snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); |
| 417 | if( use_ret == -(MBEDTLS_ERR_SSL_CONN_EOF) ) |
| 418 | mbedtls_snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); |
| 419 | if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_CIPHER) ) |
| 420 | mbedtls_snprintf( buf, buflen, "SSL - An unknown cipher was received" ); |
| 421 | if( use_ret == -(MBEDTLS_ERR_SSL_NO_CIPHER_CHOSEN) ) |
| 422 | mbedtls_snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); |
| 423 | if( use_ret == -(MBEDTLS_ERR_SSL_NO_RNG) ) |
| 424 | mbedtls_snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); |
| 425 | if( use_ret == -(MBEDTLS_ERR_SSL_NO_CLIENT_CERTIFICATE) ) |
| 426 | mbedtls_snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); |
| 427 | if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE) ) |
| 428 | mbedtls_snprintf( buf, buflen, "SSL - Our own certificate(s) is/are too large to send in an SSL message" ); |
| 429 | if( use_ret == -(MBEDTLS_ERR_SSL_CERTIFICATE_REQUIRED) ) |
| 430 | mbedtls_snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); |
| 431 | if( use_ret == -(MBEDTLS_ERR_SSL_PRIVATE_KEY_REQUIRED) ) |
| 432 | mbedtls_snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); |
| 433 | if( use_ret == -(MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED) ) |
| 434 | mbedtls_snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); |
| 435 | if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_MESSAGE) ) |
| 436 | mbedtls_snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); |
| 437 | if( use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE) ) |
Paul Bakker | 3aac1da | 2012-05-08 13:12:27 +0000 | [diff] [blame] | 438 | { |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 439 | mbedtls_snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); |
Paul Bakker | 3aac1da | 2012-05-08 13:12:27 +0000 | [diff] [blame] | 440 | return; |
| 441 | } |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 442 | if( use_ret == -(MBEDTLS_ERR_SSL_PEER_VERIFY_FAILED) ) |
| 443 | mbedtls_snprintf( buf, buflen, "SSL - Verification of our peer failed" ); |
| 444 | if( use_ret == -(MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) ) |
| 445 | mbedtls_snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); |
| 446 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_HELLO) ) |
| 447 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); |
| 448 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO) ) |
| 449 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); |
| 450 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE) ) |
| 451 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); |
| 452 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) |
| 453 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); |
| 454 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) |
| 455 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); |
| 456 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) |
| 457 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); |
| 458 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) |
| 459 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); |
| 460 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) |
| 461 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); |
| 462 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) |
| 463 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); |
| 464 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) |
| 465 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); |
| 466 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) |
| 467 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); |
| 468 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_FINISHED) ) |
| 469 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 470 | if( use_ret == -(MBEDTLS_ERR_SSL_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 471 | mbedtls_snprintf( buf, buflen, "SSL - Memory allocation failed" ); |
| 472 | if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FAILED) ) |
| 473 | mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); |
| 474 | if( use_ret == -(MBEDTLS_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) |
| 475 | mbedtls_snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); |
| 476 | if( use_ret == -(MBEDTLS_ERR_SSL_COMPRESSION_FAILED) ) |
| 477 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); |
| 478 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) |
| 479 | mbedtls_snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); |
| 480 | if( use_ret == -(MBEDTLS_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) |
| 481 | mbedtls_snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); |
| 482 | if( use_ret == -(MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED) ) |
| 483 | mbedtls_snprintf( buf, buflen, "SSL - Session ticket has expired" ); |
| 484 | if( use_ret == -(MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH) ) |
| 485 | mbedtls_snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); |
| 486 | if( use_ret == -(MBEDTLS_ERR_SSL_UNKNOWN_IDENTITY) ) |
| 487 | mbedtls_snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); |
| 488 | if( use_ret == -(MBEDTLS_ERR_SSL_INTERNAL_ERROR) ) |
| 489 | mbedtls_snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); |
| 490 | if( use_ret == -(MBEDTLS_ERR_SSL_COUNTER_WRAPPING) ) |
| 491 | mbedtls_snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); |
| 492 | if( use_ret == -(MBEDTLS_ERR_SSL_WAITING_SERVER_HELLO_RENEGO) ) |
| 493 | mbedtls_snprintf( buf, buflen, "SSL - Unexpected message at ServerHello in renegotiation" ); |
| 494 | if( use_ret == -(MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED) ) |
| 495 | mbedtls_snprintf( buf, buflen, "SSL - DTLS client must retry for hello verification" ); |
| 496 | if( use_ret == -(MBEDTLS_ERR_SSL_BUFFER_TOO_SMALL) ) |
| 497 | mbedtls_snprintf( buf, buflen, "SSL - A buffer is too small to receive or write a message" ); |
| 498 | if( use_ret == -(MBEDTLS_ERR_SSL_NO_USABLE_CIPHERSUITE) ) |
| 499 | mbedtls_snprintf( buf, buflen, "SSL - None of the common ciphersuites is usable (eg, no suitable certificate, see debug messages)" ); |
Manuel Pégourié-Gonnard | 8836994 | 2015-05-06 16:19:31 +0100 | [diff] [blame] | 500 | if( use_ret == -(MBEDTLS_ERR_SSL_WANT_READ) ) |
Hanno Becker | 8ec8102 | 2017-10-10 10:35:08 +0100 | [diff] [blame] | 501 | mbedtls_snprintf( buf, buflen, "SSL - No data of requested type currently available on underlying transport" ); |
Manuel Pégourié-Gonnard | 8836994 | 2015-05-06 16:19:31 +0100 | [diff] [blame] | 502 | if( use_ret == -(MBEDTLS_ERR_SSL_WANT_WRITE) ) |
| 503 | mbedtls_snprintf( buf, buflen, "SSL - Connection requires a write call" ); |
| 504 | if( use_ret == -(MBEDTLS_ERR_SSL_TIMEOUT) ) |
| 505 | mbedtls_snprintf( buf, buflen, "SSL - The operation timed out" ); |
Manuel Pégourié-Gonnard | be619c1 | 2015-09-08 11:21:21 +0200 | [diff] [blame] | 506 | if( use_ret == -(MBEDTLS_ERR_SSL_CLIENT_RECONNECT) ) |
| 507 | mbedtls_snprintf( buf, buflen, "SSL - The client initiated a reconnect from the same port" ); |
Manuel Pégourié-Gonnard | e2e25e7 | 2015-12-03 16:13:17 +0100 | [diff] [blame] | 508 | if( use_ret == -(MBEDTLS_ERR_SSL_UNEXPECTED_RECORD) ) |
| 509 | mbedtls_snprintf( buf, buflen, "SSL - Record header looks valid but is not expected" ); |
Simon Butcher | 9900014 | 2016-10-13 17:21:01 +0100 | [diff] [blame] | 510 | if( use_ret == -(MBEDTLS_ERR_SSL_NON_FATAL) ) |
| 511 | mbedtls_snprintf( buf, buflen, "SSL - The alert message received indicates a non-fatal error" ); |
| 512 | if( use_ret == -(MBEDTLS_ERR_SSL_INVALID_VERIFY_HASH) ) |
| 513 | mbedtls_snprintf( buf, buflen, "SSL - Couldn't set the hash for verifying CertificateVerify" ); |
Hanno Becker | 8ec8102 | 2017-10-10 10:35:08 +0100 | [diff] [blame] | 514 | if( use_ret == -(MBEDTLS_ERR_SSL_CONTINUE_PROCESSING) ) |
Hanno Becker | c9f4d6d | 2018-03-19 09:23:13 +0000 | [diff] [blame] | 515 | mbedtls_snprintf( buf, buflen, "SSL - Internal-only message signaling that further message-processing should be done" ); |
Gilles Peskine | 8bf79f6 | 2018-01-05 21:11:53 +0100 | [diff] [blame] | 516 | if( use_ret == -(MBEDTLS_ERR_SSL_ASYNC_IN_PROGRESS) ) |
Gilles Peskine | b44692f | 2018-04-24 12:18:19 +0200 | [diff] [blame] | 517 | mbedtls_snprintf( buf, buflen, "SSL - The asynchronous operation is not completed yet" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 518 | #endif /* MBEDTLS_SSL_TLS_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 519 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 520 | #if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C) |
| 521 | if( use_ret == -(MBEDTLS_ERR_X509_FEATURE_UNAVAILABLE) ) |
| 522 | mbedtls_snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); |
| 523 | if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_OID) ) |
| 524 | mbedtls_snprintf( buf, buflen, "X509 - Requested OID is unknown" ); |
| 525 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_FORMAT) ) |
| 526 | mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); |
| 527 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_VERSION) ) |
| 528 | mbedtls_snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); |
| 529 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SERIAL) ) |
| 530 | mbedtls_snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); |
| 531 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_ALG) ) |
| 532 | mbedtls_snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); |
| 533 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_NAME) ) |
| 534 | mbedtls_snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); |
| 535 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_DATE) ) |
| 536 | mbedtls_snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); |
| 537 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_SIGNATURE) ) |
| 538 | mbedtls_snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); |
| 539 | if( use_ret == -(MBEDTLS_ERR_X509_INVALID_EXTENSIONS) ) |
| 540 | mbedtls_snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); |
| 541 | if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_VERSION) ) |
| 542 | mbedtls_snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); |
| 543 | if( use_ret == -(MBEDTLS_ERR_X509_UNKNOWN_SIG_ALG) ) |
| 544 | mbedtls_snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); |
| 545 | if( use_ret == -(MBEDTLS_ERR_X509_SIG_MISMATCH) ) |
| 546 | mbedtls_snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::mbedtls_x509_crt sig_oid)" ); |
| 547 | if( use_ret == -(MBEDTLS_ERR_X509_CERT_VERIFY_FAILED) ) |
| 548 | mbedtls_snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); |
| 549 | if( use_ret == -(MBEDTLS_ERR_X509_CERT_UNKNOWN_FORMAT) ) |
| 550 | mbedtls_snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); |
| 551 | if( use_ret == -(MBEDTLS_ERR_X509_BAD_INPUT_DATA) ) |
| 552 | mbedtls_snprintf( buf, buflen, "X509 - Input invalid" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 553 | if( use_ret == -(MBEDTLS_ERR_X509_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 554 | mbedtls_snprintf( buf, buflen, "X509 - Allocation of memory failed" ); |
| 555 | if( use_ret == -(MBEDTLS_ERR_X509_FILE_IO_ERROR) ) |
| 556 | mbedtls_snprintf( buf, buflen, "X509 - Read/write of file failed" ); |
Manuel Pégourié-Gonnard | 9dbaf40 | 2015-06-22 11:50:58 +0200 | [diff] [blame] | 557 | if( use_ret == -(MBEDTLS_ERR_X509_BUFFER_TOO_SMALL) ) |
| 558 | mbedtls_snprintf( buf, buflen, "X509 - Destination buffer is too small" ); |
Manuel Pégourié-Gonnard | 31458a1 | 2017-06-26 10:11:49 +0200 | [diff] [blame] | 559 | if( use_ret == -(MBEDTLS_ERR_X509_FATAL_ERROR) ) |
| 560 | mbedtls_snprintf( buf, buflen, "X509 - A fatal error occured, eg the chain is too long or the vrfy callback failed" ); |
Manuel Pégourié-Gonnard | e546ad4 | 2015-04-08 20:27:02 +0200 | [diff] [blame] | 561 | #endif /* MBEDTLS_X509_USE_C || MBEDTLS_X509_CREATE_C */ |
Manuel Pégourié-Gonnard | fe671f4 | 2014-04-11 18:06:44 +0200 | [diff] [blame] | 562 | // END generated code |
Paul Bakker | 0e06c0f | 2013-08-25 11:21:30 +0200 | [diff] [blame] | 563 | |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 564 | if( strlen( buf ) == 0 ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 565 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 566 | } |
| 567 | |
| 568 | use_ret = ret & ~0xFF80; |
| 569 | |
| 570 | if( use_ret == 0 ) |
| 571 | return; |
| 572 | |
| 573 | // If high level code is present, make a concatenation between both |
| 574 | // error strings. |
| 575 | // |
| 576 | len = strlen( buf ); |
| 577 | |
| 578 | if( len > 0 ) |
| 579 | { |
| 580 | if( buflen - len < 5 ) |
| 581 | return; |
| 582 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 583 | mbedtls_snprintf( buf + len, buflen - len, " : " ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 584 | |
| 585 | buf += len + 3; |
| 586 | buflen -= len + 3; |
| 587 | } |
| 588 | |
| 589 | // Low level error codes |
| 590 | // |
Manuel Pégourié-Gonnard | fe671f4 | 2014-04-11 18:06:44 +0200 | [diff] [blame] | 591 | // BEGIN generated code |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 592 | #if defined(MBEDTLS_AES_C) |
| 593 | if( use_ret == -(MBEDTLS_ERR_AES_INVALID_KEY_LENGTH) ) |
| 594 | mbedtls_snprintf( buf, buflen, "AES - Invalid key length" ); |
| 595 | if( use_ret == -(MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH) ) |
| 596 | mbedtls_snprintf( buf, buflen, "AES - Invalid data input length" ); |
Mohammad Azim Khan | e5b5bd7 | 2017-11-24 10:52:51 +0000 | [diff] [blame] | 597 | if( use_ret == -(MBEDTLS_ERR_AES_BAD_INPUT_DATA) ) |
| 598 | mbedtls_snprintf( buf, buflen, "AES - Invalid input data" ); |
Andres Amaya Garcia | fd48739 | 2017-06-14 16:19:12 +0100 | [diff] [blame] | 599 | if( use_ret == -(MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE) ) |
Rose Zadik | 7f44127 | 2018-01-22 11:48:23 +0000 | [diff] [blame] | 600 | mbedtls_snprintf( buf, buflen, "AES - Feature not available. For example, an unsupported AES key size" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 601 | if( use_ret == -(MBEDTLS_ERR_AES_HW_ACCEL_FAILED) ) |
| 602 | mbedtls_snprintf( buf, buflen, "AES - AES hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 603 | #endif /* MBEDTLS_AES_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 604 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 605 | #if defined(MBEDTLS_ARC4_C) |
| 606 | if( use_ret == -(MBEDTLS_ERR_ARC4_HW_ACCEL_FAILED) ) |
| 607 | mbedtls_snprintf( buf, buflen, "ARC4 - ARC4 hardware accelerator failed" ); |
| 608 | #endif /* MBEDTLS_ARC4_C */ |
| 609 | |
Markku-Juhani O. Saarinen | 07478d6 | 2017-12-01 16:20:15 +0000 | [diff] [blame] | 610 | #if defined(MBEDTLS_ARIA_C) |
| 611 | if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_KEY_LENGTH) ) |
| 612 | mbedtls_snprintf( buf, buflen, "ARIA - Invalid key length" ); |
| 613 | if( use_ret == -(MBEDTLS_ERR_ARIA_INVALID_INPUT_LENGTH) ) |
| 614 | mbedtls_snprintf( buf, buflen, "ARIA - Invalid data input length" ); |
Manuel Pégourié-Gonnard | 3c80009 | 2018-03-01 09:02:16 +0100 | [diff] [blame] | 615 | if( use_ret == -(MBEDTLS_ERR_ARIA_FEATURE_UNAVAILABLE) ) |
| 616 | mbedtls_snprintf( buf, buflen, "ARIA - Feature not available. For example, an unsupported ARIA key size" ); |
| 617 | if( use_ret == -(MBEDTLS_ERR_ARIA_HW_ACCEL_FAILED) ) |
| 618 | mbedtls_snprintf( buf, buflen, "ARIA - ARIA hardware accelerator failed" ); |
Markku-Juhani O. Saarinen | 07478d6 | 2017-12-01 16:20:15 +0000 | [diff] [blame] | 619 | #endif /* MBEDTLS_ARIA_C */ |
| 620 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 621 | #if defined(MBEDTLS_ASN1_PARSE_C) |
| 622 | if( use_ret == -(MBEDTLS_ERR_ASN1_OUT_OF_DATA) ) |
| 623 | mbedtls_snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); |
| 624 | if( use_ret == -(MBEDTLS_ERR_ASN1_UNEXPECTED_TAG) ) |
| 625 | mbedtls_snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); |
| 626 | if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_LENGTH) ) |
| 627 | mbedtls_snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); |
| 628 | if( use_ret == -(MBEDTLS_ERR_ASN1_LENGTH_MISMATCH) ) |
| 629 | mbedtls_snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); |
| 630 | if( use_ret == -(MBEDTLS_ERR_ASN1_INVALID_DATA) ) |
| 631 | mbedtls_snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 632 | if( use_ret == -(MBEDTLS_ERR_ASN1_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 633 | mbedtls_snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); |
| 634 | if( use_ret == -(MBEDTLS_ERR_ASN1_BUF_TOO_SMALL) ) |
| 635 | mbedtls_snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); |
| 636 | #endif /* MBEDTLS_ASN1_PARSE_C */ |
Paul Bakker | dceecd8 | 2011-11-15 16:38:34 +0000 | [diff] [blame] | 637 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 638 | #if defined(MBEDTLS_BASE64_C) |
| 639 | if( use_ret == -(MBEDTLS_ERR_BASE64_BUFFER_TOO_SMALL) ) |
| 640 | mbedtls_snprintf( buf, buflen, "BASE64 - Output buffer too small" ); |
| 641 | if( use_ret == -(MBEDTLS_ERR_BASE64_INVALID_CHARACTER) ) |
| 642 | mbedtls_snprintf( buf, buflen, "BASE64 - Invalid character in input" ); |
| 643 | #endif /* MBEDTLS_BASE64_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 644 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 645 | #if defined(MBEDTLS_BIGNUM_C) |
| 646 | if( use_ret == -(MBEDTLS_ERR_MPI_FILE_IO_ERROR) ) |
| 647 | mbedtls_snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); |
| 648 | if( use_ret == -(MBEDTLS_ERR_MPI_BAD_INPUT_DATA) ) |
| 649 | mbedtls_snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); |
| 650 | if( use_ret == -(MBEDTLS_ERR_MPI_INVALID_CHARACTER) ) |
| 651 | mbedtls_snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); |
| 652 | if( use_ret == -(MBEDTLS_ERR_MPI_BUFFER_TOO_SMALL) ) |
| 653 | mbedtls_snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); |
| 654 | if( use_ret == -(MBEDTLS_ERR_MPI_NEGATIVE_VALUE) ) |
| 655 | mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); |
| 656 | if( use_ret == -(MBEDTLS_ERR_MPI_DIVISION_BY_ZERO) ) |
| 657 | mbedtls_snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); |
| 658 | if( use_ret == -(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) ) |
| 659 | mbedtls_snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); |
Manuel Pégourié-Gonnard | 6a8ca33 | 2015-05-28 09:33:39 +0200 | [diff] [blame] | 660 | if( use_ret == -(MBEDTLS_ERR_MPI_ALLOC_FAILED) ) |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 661 | mbedtls_snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); |
| 662 | #endif /* MBEDTLS_BIGNUM_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 663 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 664 | #if defined(MBEDTLS_BLOWFISH_C) |
| 665 | if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) |
| 666 | mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 667 | if( use_ret == -(MBEDTLS_ERR_BLOWFISH_HW_ACCEL_FAILED) ) |
| 668 | mbedtls_snprintf( buf, buflen, "BLOWFISH - Blowfish hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 669 | if( use_ret == -(MBEDTLS_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) |
| 670 | mbedtls_snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); |
| 671 | #endif /* MBEDTLS_BLOWFISH_C */ |
Paul Bakker | 83f00bb | 2012-07-04 11:08:50 +0000 | [diff] [blame] | 672 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 673 | #if defined(MBEDTLS_CAMELLIA_C) |
| 674 | if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) |
| 675 | mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); |
| 676 | if( use_ret == -(MBEDTLS_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) |
| 677 | mbedtls_snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 678 | if( use_ret == -(MBEDTLS_ERR_CAMELLIA_HW_ACCEL_FAILED) ) |
| 679 | mbedtls_snprintf( buf, buflen, "CAMELLIA - Camellia hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 680 | #endif /* MBEDTLS_CAMELLIA_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 681 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 682 | #if defined(MBEDTLS_CCM_C) |
| 683 | if( use_ret == -(MBEDTLS_ERR_CCM_BAD_INPUT) ) |
Rose Zadik | eecdbea | 2018-01-24 12:56:53 +0000 | [diff] [blame] | 684 | mbedtls_snprintf( buf, buflen, "CCM - Bad input parameters to the function" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 685 | if( use_ret == -(MBEDTLS_ERR_CCM_AUTH_FAILED) ) |
| 686 | mbedtls_snprintf( buf, buflen, "CCM - Authenticated decryption failed" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 687 | if( use_ret == -(MBEDTLS_ERR_CCM_HW_ACCEL_FAILED) ) |
| 688 | mbedtls_snprintf( buf, buflen, "CCM - CCM hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 689 | #endif /* MBEDTLS_CCM_C */ |
Manuel Pégourié-Gonnard | a6916fa | 2014-05-02 15:17:29 +0200 | [diff] [blame] | 690 | |
Daniel King | 34b822c | 2016-05-15 17:28:08 -0300 | [diff] [blame] | 691 | #if defined(MBEDTLS_CHACHA20_C) |
| 692 | if( use_ret == -(MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA) ) |
| 693 | mbedtls_snprintf( buf, buflen, "CHACHA20 - Invalid input parameter(s)" ); |
Manuel Pégourié-Gonnard | b8bd80a | 2018-05-09 09:54:51 +0200 | [diff] [blame] | 694 | if( use_ret == -(MBEDTLS_ERR_CHACHA20_FEATURE_UNAVAILABLE) ) |
| 695 | mbedtls_snprintf( buf, buflen, "CHACHA20 - Feature not available. For example, s part of the API is not implemented" ); |
Manuel Pégourié-Gonnard | 3798b6b | 2018-05-24 13:27:45 +0200 | [diff] [blame] | 696 | if( use_ret == -(MBEDTLS_ERR_CHACHA20_HW_ACCEL_FAILED) ) |
| 697 | mbedtls_snprintf( buf, buflen, "CHACHA20 - Chacha20 hardware accelerator failed" ); |
Daniel King | 34b822c | 2016-05-15 17:28:08 -0300 | [diff] [blame] | 698 | #endif /* MBEDTLS_CHACHA20_C */ |
| 699 | |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 700 | #if defined(MBEDTLS_CHACHAPOLY_C) |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 701 | if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_BAD_STATE) ) |
| 702 | mbedtls_snprintf( buf, buflen, "CHACHAPOLY - The requested operation is not permitted in the current state" ); |
Manuel Pégourié-Gonnard | b8bd80a | 2018-05-09 09:54:51 +0200 | [diff] [blame] | 703 | if( use_ret == -(MBEDTLS_ERR_CHACHAPOLY_AUTH_FAILED) ) |
| 704 | mbedtls_snprintf( buf, buflen, "CHACHAPOLY - Authenticated decryption failed: data was not authentic" ); |
Manuel Pégourié-Gonnard | dca3a5d | 2018-05-07 10:43:27 +0200 | [diff] [blame] | 705 | #endif /* MBEDTLS_CHACHAPOLY_C */ |
| 706 | |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 707 | #if defined(MBEDTLS_CMAC_C) |
| 708 | if( use_ret == -(MBEDTLS_ERR_CMAC_HW_ACCEL_FAILED) ) |
| 709 | mbedtls_snprintf( buf, buflen, "CMAC - CMAC hardware accelerator failed" ); |
| 710 | #endif /* MBEDTLS_CMAC_C */ |
| 711 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 712 | #if defined(MBEDTLS_CTR_DRBG_C) |
| 713 | if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) |
| 714 | mbedtls_snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); |
| 715 | if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) |
Rose Zadik | 2f8163d | 2018-01-25 21:55:14 +0000 | [diff] [blame] | 716 | mbedtls_snprintf( buf, buflen, "CTR_DRBG - The requested random buffer length is too big" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 717 | if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_INPUT_TOO_BIG) ) |
Rose Zadik | 2f8163d | 2018-01-25 21:55:14 +0000 | [diff] [blame] | 718 | mbedtls_snprintf( buf, buflen, "CTR_DRBG - The input (entropy + additional data) is too large" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 719 | if( use_ret == -(MBEDTLS_ERR_CTR_DRBG_FILE_IO_ERROR) ) |
Rose Zadik | 2f8163d | 2018-01-25 21:55:14 +0000 | [diff] [blame] | 720 | mbedtls_snprintf( buf, buflen, "CTR_DRBG - Read or write error in file" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 721 | #endif /* MBEDTLS_CTR_DRBG_C */ |
Paul Bakker | 880ac7e | 2011-11-27 14:50:49 +0000 | [diff] [blame] | 722 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 723 | #if defined(MBEDTLS_DES_C) |
| 724 | if( use_ret == -(MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH) ) |
| 725 | mbedtls_snprintf( buf, buflen, "DES - The data input has an invalid length" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 726 | if( use_ret == -(MBEDTLS_ERR_DES_HW_ACCEL_FAILED) ) |
| 727 | mbedtls_snprintf( buf, buflen, "DES - DES hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 728 | #endif /* MBEDTLS_DES_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 729 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 730 | #if defined(MBEDTLS_ENTROPY_C) |
| 731 | if( use_ret == -(MBEDTLS_ERR_ENTROPY_SOURCE_FAILED) ) |
| 732 | mbedtls_snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); |
| 733 | if( use_ret == -(MBEDTLS_ERR_ENTROPY_MAX_SOURCES) ) |
| 734 | mbedtls_snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); |
| 735 | if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_SOURCES_DEFINED) ) |
| 736 | mbedtls_snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); |
Manuel Pégourié-Gonnard | f9cbd73 | 2015-06-22 12:06:50 +0200 | [diff] [blame] | 737 | if( use_ret == -(MBEDTLS_ERR_ENTROPY_NO_STRONG_SOURCE) ) |
| 738 | mbedtls_snprintf( buf, buflen, "ENTROPY - No strong sources have been added to poll" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 739 | if( use_ret == -(MBEDTLS_ERR_ENTROPY_FILE_IO_ERROR) ) |
| 740 | mbedtls_snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); |
| 741 | #endif /* MBEDTLS_ENTROPY_C */ |
Paul Bakker | 6083fd2 | 2011-12-03 21:45:14 +0000 | [diff] [blame] | 742 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 743 | #if defined(MBEDTLS_GCM_C) |
| 744 | if( use_ret == -(MBEDTLS_ERR_GCM_AUTH_FAILED) ) |
| 745 | mbedtls_snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 746 | if( use_ret == -(MBEDTLS_ERR_GCM_HW_ACCEL_FAILED) ) |
| 747 | mbedtls_snprintf( buf, buflen, "GCM - GCM hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 748 | if( use_ret == -(MBEDTLS_ERR_GCM_BAD_INPUT) ) |
| 749 | mbedtls_snprintf( buf, buflen, "GCM - Bad input parameters to function" ); |
| 750 | #endif /* MBEDTLS_GCM_C */ |
Paul Bakker | 030277a | 2012-04-17 12:24:26 +0000 | [diff] [blame] | 751 | |
Thomas Fossati | 656864b | 2016-07-17 08:51:22 +0100 | [diff] [blame] | 752 | #if defined(MBEDTLS_HKDF_C) |
| 753 | if( use_ret == -(MBEDTLS_ERR_HKDF_BAD_INPUT_DATA) ) |
| 754 | mbedtls_snprintf( buf, buflen, "HKDF - Bad input parameters to function" ); |
| 755 | #endif /* MBEDTLS_HKDF_C */ |
| 756 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 757 | #if defined(MBEDTLS_HMAC_DRBG_C) |
| 758 | if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) |
| 759 | mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); |
| 760 | if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) |
| 761 | mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); |
| 762 | if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_FILE_IO_ERROR) ) |
| 763 | mbedtls_snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); |
| 764 | if( use_ret == -(MBEDTLS_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) |
| 765 | mbedtls_snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); |
| 766 | #endif /* MBEDTLS_HMAC_DRBG_C */ |
Manuel Pégourié-Gonnard | cf38367 | 2014-02-01 10:22:21 +0100 | [diff] [blame] | 767 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 768 | #if defined(MBEDTLS_MD2_C) |
| 769 | if( use_ret == -(MBEDTLS_ERR_MD2_HW_ACCEL_FAILED) ) |
| 770 | mbedtls_snprintf( buf, buflen, "MD2 - MD2 hardware accelerator failed" ); |
| 771 | #endif /* MBEDTLS_MD2_C */ |
| 772 | |
| 773 | #if defined(MBEDTLS_MD4_C) |
| 774 | if( use_ret == -(MBEDTLS_ERR_MD4_HW_ACCEL_FAILED) ) |
| 775 | mbedtls_snprintf( buf, buflen, "MD4 - MD4 hardware accelerator failed" ); |
| 776 | #endif /* MBEDTLS_MD4_C */ |
| 777 | |
| 778 | #if defined(MBEDTLS_MD5_C) |
| 779 | if( use_ret == -(MBEDTLS_ERR_MD5_HW_ACCEL_FAILED) ) |
| 780 | mbedtls_snprintf( buf, buflen, "MD5 - MD5 hardware accelerator failed" ); |
| 781 | #endif /* MBEDTLS_MD5_C */ |
| 782 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 783 | #if defined(MBEDTLS_NET_C) |
| 784 | if( use_ret == -(MBEDTLS_ERR_NET_SOCKET_FAILED) ) |
| 785 | mbedtls_snprintf( buf, buflen, "NET - Failed to open a socket" ); |
| 786 | if( use_ret == -(MBEDTLS_ERR_NET_CONNECT_FAILED) ) |
| 787 | mbedtls_snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); |
| 788 | if( use_ret == -(MBEDTLS_ERR_NET_BIND_FAILED) ) |
| 789 | mbedtls_snprintf( buf, buflen, "NET - Binding of the socket failed" ); |
| 790 | if( use_ret == -(MBEDTLS_ERR_NET_LISTEN_FAILED) ) |
| 791 | mbedtls_snprintf( buf, buflen, "NET - Could not listen on the socket" ); |
| 792 | if( use_ret == -(MBEDTLS_ERR_NET_ACCEPT_FAILED) ) |
| 793 | mbedtls_snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); |
| 794 | if( use_ret == -(MBEDTLS_ERR_NET_RECV_FAILED) ) |
| 795 | mbedtls_snprintf( buf, buflen, "NET - Reading information from the socket failed" ); |
| 796 | if( use_ret == -(MBEDTLS_ERR_NET_SEND_FAILED) ) |
| 797 | mbedtls_snprintf( buf, buflen, "NET - Sending information through the socket failed" ); |
| 798 | if( use_ret == -(MBEDTLS_ERR_NET_CONN_RESET) ) |
| 799 | mbedtls_snprintf( buf, buflen, "NET - Connection was reset by peer" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 800 | if( use_ret == -(MBEDTLS_ERR_NET_UNKNOWN_HOST) ) |
| 801 | mbedtls_snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); |
Manuel Pégourié-Gonnard | 0b104b0 | 2015-05-14 21:52:40 +0200 | [diff] [blame] | 802 | if( use_ret == -(MBEDTLS_ERR_NET_BUFFER_TOO_SMALL) ) |
| 803 | mbedtls_snprintf( buf, buflen, "NET - Buffer is too small to hold the data" ); |
Manuel Pégourié-Gonnard | 9bd0afd | 2015-07-01 19:03:27 +0200 | [diff] [blame] | 804 | if( use_ret == -(MBEDTLS_ERR_NET_INVALID_CONTEXT) ) |
| 805 | mbedtls_snprintf( buf, buflen, "NET - The context is invalid, eg because it was free()ed" ); |
Hanno Becker | e09ca3d | 2017-05-22 15:06:06 +0100 | [diff] [blame] | 806 | if( use_ret == -(MBEDTLS_ERR_NET_POLL_FAILED) ) |
| 807 | mbedtls_snprintf( buf, buflen, "NET - Polling the net context failed" ); |
| 808 | if( use_ret == -(MBEDTLS_ERR_NET_BAD_INPUT_DATA) ) |
| 809 | mbedtls_snprintf( buf, buflen, "NET - Input invalid" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 810 | #endif /* MBEDTLS_NET_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 811 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 812 | #if defined(MBEDTLS_OID_C) |
| 813 | if( use_ret == -(MBEDTLS_ERR_OID_NOT_FOUND) ) |
| 814 | mbedtls_snprintf( buf, buflen, "OID - OID is not found" ); |
| 815 | if( use_ret == -(MBEDTLS_ERR_OID_BUF_TOO_SMALL) ) |
| 816 | mbedtls_snprintf( buf, buflen, "OID - output buffer is too small" ); |
| 817 | #endif /* MBEDTLS_OID_C */ |
Paul Bakker | c70b982 | 2013-04-07 22:00:46 +0200 | [diff] [blame] | 818 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 819 | #if defined(MBEDTLS_PADLOCK_C) |
| 820 | if( use_ret == -(MBEDTLS_ERR_PADLOCK_DATA_MISALIGNED) ) |
| 821 | mbedtls_snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); |
| 822 | #endif /* MBEDTLS_PADLOCK_C */ |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 823 | |
Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame] | 824 | #if defined(MBEDTLS_POLY1305_C) |
| 825 | if( use_ret == -(MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA) ) |
| 826 | mbedtls_snprintf( buf, buflen, "POLY1305 - Invalid input parameter(s)" ); |
Manuel Pégourié-Gonnard | b8bd80a | 2018-05-09 09:54:51 +0200 | [diff] [blame] | 827 | if( use_ret == -(MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE) ) |
| 828 | mbedtls_snprintf( buf, buflen, "POLY1305 - Feature not available. For example, s part of the API is not implemented" ); |
Manuel Pégourié-Gonnard | 3798b6b | 2018-05-24 13:27:45 +0200 | [diff] [blame] | 829 | if( use_ret == -(MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED) ) |
| 830 | mbedtls_snprintf( buf, buflen, "POLY1305 - Poly1305 hardware accelerator failed" ); |
Daniel King | adc32c0 | 2016-05-16 18:25:45 -0300 | [diff] [blame] | 831 | #endif /* MBEDTLS_POLY1305_C */ |
| 832 | |
Gilles Peskine | a381fe8 | 2018-01-23 18:16:11 +0100 | [diff] [blame] | 833 | #if defined(MBEDTLS_RIPEMD160_C) |
| 834 | if( use_ret == -(MBEDTLS_ERR_RIPEMD160_HW_ACCEL_FAILED) ) |
| 835 | mbedtls_snprintf( buf, buflen, "RIPEMD160 - RIPEMD160 hardware accelerator failed" ); |
| 836 | #endif /* MBEDTLS_RIPEMD160_C */ |
| 837 | |
| 838 | #if defined(MBEDTLS_SHA1_C) |
| 839 | if( use_ret == -(MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED) ) |
| 840 | mbedtls_snprintf( buf, buflen, "SHA1 - SHA-1 hardware accelerator failed" ); |
| 841 | #endif /* MBEDTLS_SHA1_C */ |
| 842 | |
| 843 | #if defined(MBEDTLS_SHA256_C) |
| 844 | if( use_ret == -(MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED) ) |
| 845 | mbedtls_snprintf( buf, buflen, "SHA256 - SHA-256 hardware accelerator failed" ); |
| 846 | #endif /* MBEDTLS_SHA256_C */ |
| 847 | |
| 848 | #if defined(MBEDTLS_SHA512_C) |
| 849 | if( use_ret == -(MBEDTLS_ERR_SHA512_HW_ACCEL_FAILED) ) |
| 850 | mbedtls_snprintf( buf, buflen, "SHA512 - SHA-512 hardware accelerator failed" ); |
| 851 | #endif /* MBEDTLS_SHA512_C */ |
| 852 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 853 | #if defined(MBEDTLS_THREADING_C) |
| 854 | if( use_ret == -(MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE) ) |
| 855 | mbedtls_snprintf( buf, buflen, "THREADING - The selected feature is not available" ); |
| 856 | if( use_ret == -(MBEDTLS_ERR_THREADING_BAD_INPUT_DATA) ) |
| 857 | mbedtls_snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); |
| 858 | if( use_ret == -(MBEDTLS_ERR_THREADING_MUTEX_ERROR) ) |
| 859 | mbedtls_snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); |
| 860 | #endif /* MBEDTLS_THREADING_C */ |
Paul Bakker | 2466d93 | 2013-09-28 14:40:38 +0200 | [diff] [blame] | 861 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 862 | #if defined(MBEDTLS_XTEA_C) |
| 863 | if( use_ret == -(MBEDTLS_ERR_XTEA_INVALID_INPUT_LENGTH) ) |
| 864 | mbedtls_snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); |
Gilles Peskine | 7ecab3d | 2018-01-26 17:56:38 +0100 | [diff] [blame] | 865 | if( use_ret == -(MBEDTLS_ERR_XTEA_HW_ACCEL_FAILED) ) |
| 866 | mbedtls_snprintf( buf, buflen, "XTEA - XTEA hardware accelerator failed" ); |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 867 | #endif /* MBEDTLS_XTEA_C */ |
Manuel Pégourié-Gonnard | fe671f4 | 2014-04-11 18:06:44 +0200 | [diff] [blame] | 868 | // END generated code |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 869 | |
| 870 | if( strlen( buf ) != 0 ) |
| 871 | return; |
| 872 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 873 | mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
Paul Bakker | 9d78140 | 2011-05-09 16:17:09 +0000 | [diff] [blame] | 874 | } |
| 875 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 876 | #else /* MBEDTLS_ERROR_C */ |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 877 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 878 | #if defined(MBEDTLS_ERROR_STRERROR_DUMMY) |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 879 | |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 880 | /* |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 881 | * Provide an non-function in case MBEDTLS_ERROR_C is not defined |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 882 | */ |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 883 | void mbedtls_strerror( int ret, char *buf, size_t buflen ) |
Paul Bakker | 8fe40dc | 2013-02-02 12:43:08 +0100 | [diff] [blame] | 884 | { |
| 885 | ((void) ret); |
| 886 | |
| 887 | if( buflen > 0 ) |
| 888 | buf[0] = '\0'; |
| 889 | } |
| 890 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 891 | #endif /* MBEDTLS_ERROR_STRERROR_DUMMY */ |
Paul Bakker | e2ab84f | 2013-06-29 18:24:32 +0200 | [diff] [blame] | 892 | |
Manuel Pégourié-Gonnard | 2cf5a7c | 2015-04-08 12:49:31 +0200 | [diff] [blame] | 893 | #endif /* MBEDTLS_ERROR_C */ |