Hannes Tschofenig
/
aes-gcm-test-program
Example program to test AES-GCM functionality. Used for a workshop
SSL/library/error.c@0:796d0f61a05b, 2018-09-27 (annotated)
- Committer:
- HannesTschofenig
- Date:
- Thu Sep 27 06:34:22 2018 +0000
- Revision:
- 0:796d0f61a05b
Example AES-GCM test program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
HannesTschofenig | 0:796d0f61a05b | 1 | /* |
HannesTschofenig | 0:796d0f61a05b | 2 | * Error message information |
HannesTschofenig | 0:796d0f61a05b | 3 | * |
HannesTschofenig | 0:796d0f61a05b | 4 | * Copyright (C) 2006-2014, Brainspark B.V. |
HannesTschofenig | 0:796d0f61a05b | 5 | * |
HannesTschofenig | 0:796d0f61a05b | 6 | * This file is part of PolarSSL (http://www.polarssl.org) |
HannesTschofenig | 0:796d0f61a05b | 7 | * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org> |
HannesTschofenig | 0:796d0f61a05b | 8 | * |
HannesTschofenig | 0:796d0f61a05b | 9 | * All rights reserved. |
HannesTschofenig | 0:796d0f61a05b | 10 | * |
HannesTschofenig | 0:796d0f61a05b | 11 | * This program is free software; you can redistribute it and/or modify |
HannesTschofenig | 0:796d0f61a05b | 12 | * it under the terms of the GNU General Public License as published by |
HannesTschofenig | 0:796d0f61a05b | 13 | * the Free Software Foundation; either version 2 of the License, or |
HannesTschofenig | 0:796d0f61a05b | 14 | * (at your option) any later version. |
HannesTschofenig | 0:796d0f61a05b | 15 | * |
HannesTschofenig | 0:796d0f61a05b | 16 | * This program is distributed in the hope that it will be useful, |
HannesTschofenig | 0:796d0f61a05b | 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
HannesTschofenig | 0:796d0f61a05b | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
HannesTschofenig | 0:796d0f61a05b | 19 | * GNU General Public License for more details. |
HannesTschofenig | 0:796d0f61a05b | 20 | * |
HannesTschofenig | 0:796d0f61a05b | 21 | * You should have received a copy of the GNU General Public License along |
HannesTschofenig | 0:796d0f61a05b | 22 | * with this program; if not, write to the Free Software Foundation, Inc., |
HannesTschofenig | 0:796d0f61a05b | 23 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
HannesTschofenig | 0:796d0f61a05b | 24 | */ |
HannesTschofenig | 0:796d0f61a05b | 25 | |
HannesTschofenig | 0:796d0f61a05b | 26 | #if !defined(POLARSSL_CONFIG_FILE) |
HannesTschofenig | 0:796d0f61a05b | 27 | #include "polarssl/config.h" |
HannesTschofenig | 0:796d0f61a05b | 28 | #else |
HannesTschofenig | 0:796d0f61a05b | 29 | #include POLARSSL_CONFIG_FILE |
HannesTschofenig | 0:796d0f61a05b | 30 | #endif |
HannesTschofenig | 0:796d0f61a05b | 31 | |
HannesTschofenig | 0:796d0f61a05b | 32 | #if defined(POLARSSL_ERROR_C) |
HannesTschofenig | 0:796d0f61a05b | 33 | |
HannesTschofenig | 0:796d0f61a05b | 34 | #include "polarssl/error.h" |
HannesTschofenig | 0:796d0f61a05b | 35 | |
HannesTschofenig | 0:796d0f61a05b | 36 | #if defined(POLARSSL_AES_C) |
HannesTschofenig | 0:796d0f61a05b | 37 | #include "polarssl/aes.h" |
HannesTschofenig | 0:796d0f61a05b | 38 | #endif |
HannesTschofenig | 0:796d0f61a05b | 39 | |
HannesTschofenig | 0:796d0f61a05b | 40 | #if defined(POLARSSL_BASE64_C) |
HannesTschofenig | 0:796d0f61a05b | 41 | #include "polarssl/base64.h" |
HannesTschofenig | 0:796d0f61a05b | 42 | #endif |
HannesTschofenig | 0:796d0f61a05b | 43 | |
HannesTschofenig | 0:796d0f61a05b | 44 | #if defined(POLARSSL_BIGNUM_C) |
HannesTschofenig | 0:796d0f61a05b | 45 | #include "polarssl/bignum.h" |
HannesTschofenig | 0:796d0f61a05b | 46 | #endif |
HannesTschofenig | 0:796d0f61a05b | 47 | |
HannesTschofenig | 0:796d0f61a05b | 48 | #if defined(POLARSSL_BLOWFISH_C) |
HannesTschofenig | 0:796d0f61a05b | 49 | #include "polarssl/blowfish.h" |
HannesTschofenig | 0:796d0f61a05b | 50 | #endif |
HannesTschofenig | 0:796d0f61a05b | 51 | |
HannesTschofenig | 0:796d0f61a05b | 52 | #if defined(POLARSSL_CAMELLIA_C) |
HannesTschofenig | 0:796d0f61a05b | 53 | #include "polarssl/camellia.h" |
HannesTschofenig | 0:796d0f61a05b | 54 | #endif |
HannesTschofenig | 0:796d0f61a05b | 55 | |
HannesTschofenig | 0:796d0f61a05b | 56 | #if defined(POLARSSL_CIPHER_C) |
HannesTschofenig | 0:796d0f61a05b | 57 | #include "polarssl/cipher.h" |
HannesTschofenig | 0:796d0f61a05b | 58 | #endif |
HannesTschofenig | 0:796d0f61a05b | 59 | |
HannesTschofenig | 0:796d0f61a05b | 60 | #if defined(POLARSSL_CTR_DRBG_C) |
HannesTschofenig | 0:796d0f61a05b | 61 | #include "polarssl/ctr_drbg.h" |
HannesTschofenig | 0:796d0f61a05b | 62 | #endif |
HannesTschofenig | 0:796d0f61a05b | 63 | |
HannesTschofenig | 0:796d0f61a05b | 64 | #if defined(POLARSSL_DES_C) |
HannesTschofenig | 0:796d0f61a05b | 65 | #include "polarssl/des.h" |
HannesTschofenig | 0:796d0f61a05b | 66 | #endif |
HannesTschofenig | 0:796d0f61a05b | 67 | |
HannesTschofenig | 0:796d0f61a05b | 68 | #if defined(POLARSSL_DHM_C) |
HannesTschofenig | 0:796d0f61a05b | 69 | #include "polarssl/dhm.h" |
HannesTschofenig | 0:796d0f61a05b | 70 | #endif |
HannesTschofenig | 0:796d0f61a05b | 71 | |
HannesTschofenig | 0:796d0f61a05b | 72 | #if defined(POLARSSL_ECP_C) |
HannesTschofenig | 0:796d0f61a05b | 73 | #include "polarssl/ecp.h" |
HannesTschofenig | 0:796d0f61a05b | 74 | #endif |
HannesTschofenig | 0:796d0f61a05b | 75 | |
HannesTschofenig | 0:796d0f61a05b | 76 | #if defined(POLARSSL_ENTROPY_C) |
HannesTschofenig | 0:796d0f61a05b | 77 | #include "polarssl/entropy.h" |
HannesTschofenig | 0:796d0f61a05b | 78 | #endif |
HannesTschofenig | 0:796d0f61a05b | 79 | |
HannesTschofenig | 0:796d0f61a05b | 80 | #if defined(POLARSSL_GCM_C) |
HannesTschofenig | 0:796d0f61a05b | 81 | #include "polarssl/gcm.h" |
HannesTschofenig | 0:796d0f61a05b | 82 | #endif |
HannesTschofenig | 0:796d0f61a05b | 83 | |
HannesTschofenig | 0:796d0f61a05b | 84 | #if defined(POLARSSL_HMAC_DRBG_C) |
HannesTschofenig | 0:796d0f61a05b | 85 | #include "polarssl/hmac_drbg.h" |
HannesTschofenig | 0:796d0f61a05b | 86 | #endif |
HannesTschofenig | 0:796d0f61a05b | 87 | |
HannesTschofenig | 0:796d0f61a05b | 88 | #if defined(POLARSSL_MD_C) |
HannesTschofenig | 0:796d0f61a05b | 89 | #include "polarssl/md.h" |
HannesTschofenig | 0:796d0f61a05b | 90 | #endif |
HannesTschofenig | 0:796d0f61a05b | 91 | |
HannesTschofenig | 0:796d0f61a05b | 92 | #if defined(POLARSSL_MD2_C) |
HannesTschofenig | 0:796d0f61a05b | 93 | #include "polarssl/md2.h" |
HannesTschofenig | 0:796d0f61a05b | 94 | #endif |
HannesTschofenig | 0:796d0f61a05b | 95 | |
HannesTschofenig | 0:796d0f61a05b | 96 | #if defined(POLARSSL_MD4_C) |
HannesTschofenig | 0:796d0f61a05b | 97 | #include "polarssl/md4.h" |
HannesTschofenig | 0:796d0f61a05b | 98 | #endif |
HannesTschofenig | 0:796d0f61a05b | 99 | |
HannesTschofenig | 0:796d0f61a05b | 100 | #if defined(POLARSSL_MD5_C) |
HannesTschofenig | 0:796d0f61a05b | 101 | #include "polarssl/md5.h" |
HannesTschofenig | 0:796d0f61a05b | 102 | #endif |
HannesTschofenig | 0:796d0f61a05b | 103 | |
HannesTschofenig | 0:796d0f61a05b | 104 | #if defined(POLARSSL_NET_C) |
HannesTschofenig | 0:796d0f61a05b | 105 | #include "polarssl/net.h" |
HannesTschofenig | 0:796d0f61a05b | 106 | #endif |
HannesTschofenig | 0:796d0f61a05b | 107 | |
HannesTschofenig | 0:796d0f61a05b | 108 | #if defined(POLARSSL_OID_C) |
HannesTschofenig | 0:796d0f61a05b | 109 | #include "polarssl/oid.h" |
HannesTschofenig | 0:796d0f61a05b | 110 | #endif |
HannesTschofenig | 0:796d0f61a05b | 111 | |
HannesTschofenig | 0:796d0f61a05b | 112 | #if defined(POLARSSL_PADLOCK_C) |
HannesTschofenig | 0:796d0f61a05b | 113 | #include "polarssl/padlock.h" |
HannesTschofenig | 0:796d0f61a05b | 114 | #endif |
HannesTschofenig | 0:796d0f61a05b | 115 | |
HannesTschofenig | 0:796d0f61a05b | 116 | #if defined(POLARSSL_PBKDF2_C) |
HannesTschofenig | 0:796d0f61a05b | 117 | #include "polarssl/pbkdf2.h" |
HannesTschofenig | 0:796d0f61a05b | 118 | #endif |
HannesTschofenig | 0:796d0f61a05b | 119 | |
HannesTschofenig | 0:796d0f61a05b | 120 | #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) |
HannesTschofenig | 0:796d0f61a05b | 121 | #include "polarssl/pem.h" |
HannesTschofenig | 0:796d0f61a05b | 122 | #endif |
HannesTschofenig | 0:796d0f61a05b | 123 | |
HannesTschofenig | 0:796d0f61a05b | 124 | #if defined(POLARSSL_PK_C) |
HannesTschofenig | 0:796d0f61a05b | 125 | #include "polarssl/pk.h" |
HannesTschofenig | 0:796d0f61a05b | 126 | #endif |
HannesTschofenig | 0:796d0f61a05b | 127 | |
HannesTschofenig | 0:796d0f61a05b | 128 | #if defined(POLARSSL_PKCS12_C) |
HannesTschofenig | 0:796d0f61a05b | 129 | #include "polarssl/pkcs12.h" |
HannesTschofenig | 0:796d0f61a05b | 130 | #endif |
HannesTschofenig | 0:796d0f61a05b | 131 | |
HannesTschofenig | 0:796d0f61a05b | 132 | #if defined(POLARSSL_PKCS5_C) |
HannesTschofenig | 0:796d0f61a05b | 133 | #include "polarssl/pkcs5.h" |
HannesTschofenig | 0:796d0f61a05b | 134 | #endif |
HannesTschofenig | 0:796d0f61a05b | 135 | |
HannesTschofenig | 0:796d0f61a05b | 136 | #if defined(POLARSSL_RIPEMD160_C) |
HannesTschofenig | 0:796d0f61a05b | 137 | #include "polarssl/ripemd160.h" |
HannesTschofenig | 0:796d0f61a05b | 138 | #endif |
HannesTschofenig | 0:796d0f61a05b | 139 | |
HannesTschofenig | 0:796d0f61a05b | 140 | #if defined(POLARSSL_RSA_C) |
HannesTschofenig | 0:796d0f61a05b | 141 | #include "polarssl/rsa.h" |
HannesTschofenig | 0:796d0f61a05b | 142 | #endif |
HannesTschofenig | 0:796d0f61a05b | 143 | |
HannesTschofenig | 0:796d0f61a05b | 144 | #if defined(POLARSSL_SHA1_C) |
HannesTschofenig | 0:796d0f61a05b | 145 | #include "polarssl/sha1.h" |
HannesTschofenig | 0:796d0f61a05b | 146 | #endif |
HannesTschofenig | 0:796d0f61a05b | 147 | |
HannesTschofenig | 0:796d0f61a05b | 148 | #if defined(POLARSSL_SHA256_C) |
HannesTschofenig | 0:796d0f61a05b | 149 | #include "polarssl/sha256.h" |
HannesTschofenig | 0:796d0f61a05b | 150 | #endif |
HannesTschofenig | 0:796d0f61a05b | 151 | |
HannesTschofenig | 0:796d0f61a05b | 152 | #if defined(POLARSSL_SHA512_C) |
HannesTschofenig | 0:796d0f61a05b | 153 | #include "polarssl/sha512.h" |
HannesTschofenig | 0:796d0f61a05b | 154 | #endif |
HannesTschofenig | 0:796d0f61a05b | 155 | |
HannesTschofenig | 0:796d0f61a05b | 156 | #if defined(POLARSSL_SSL_TLS_C) |
HannesTschofenig | 0:796d0f61a05b | 157 | #include "polarssl/ssl.h" |
HannesTschofenig | 0:796d0f61a05b | 158 | #endif |
HannesTschofenig | 0:796d0f61a05b | 159 | |
HannesTschofenig | 0:796d0f61a05b | 160 | #if defined(POLARSSL_THREADING_C) |
HannesTschofenig | 0:796d0f61a05b | 161 | #include "polarssl/threading.h" |
HannesTschofenig | 0:796d0f61a05b | 162 | #endif |
HannesTschofenig | 0:796d0f61a05b | 163 | |
HannesTschofenig | 0:796d0f61a05b | 164 | #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) |
HannesTschofenig | 0:796d0f61a05b | 165 | #include "polarssl/x509.h" |
HannesTschofenig | 0:796d0f61a05b | 166 | #endif |
HannesTschofenig | 0:796d0f61a05b | 167 | |
HannesTschofenig | 0:796d0f61a05b | 168 | #if defined(POLARSSL_XTEA_C) |
HannesTschofenig | 0:796d0f61a05b | 169 | #include "polarssl/xtea.h" |
HannesTschofenig | 0:796d0f61a05b | 170 | #endif |
HannesTschofenig | 0:796d0f61a05b | 171 | |
HannesTschofenig | 0:796d0f61a05b | 172 | |
HannesTschofenig | 0:796d0f61a05b | 173 | #include <string.h> |
HannesTschofenig | 0:796d0f61a05b | 174 | |
HannesTschofenig | 0:796d0f61a05b | 175 | #if defined(_MSC_VER) && !defined snprintf && !defined(EFIX64) && \ |
HannesTschofenig | 0:796d0f61a05b | 176 | !defined(EFI32) |
HannesTschofenig | 0:796d0f61a05b | 177 | #define snprintf _snprintf |
HannesTschofenig | 0:796d0f61a05b | 178 | #endif |
HannesTschofenig | 0:796d0f61a05b | 179 | |
HannesTschofenig | 0:796d0f61a05b | 180 | void polarssl_strerror( int ret, char *buf, size_t buflen ) |
HannesTschofenig | 0:796d0f61a05b | 181 | { |
HannesTschofenig | 0:796d0f61a05b | 182 | size_t len; |
HannesTschofenig | 0:796d0f61a05b | 183 | int use_ret; |
HannesTschofenig | 0:796d0f61a05b | 184 | |
HannesTschofenig | 0:796d0f61a05b | 185 | if( buflen == 0 ) |
HannesTschofenig | 0:796d0f61a05b | 186 | return; |
HannesTschofenig | 0:796d0f61a05b | 187 | |
HannesTschofenig | 0:796d0f61a05b | 188 | memset( buf, 0x00, buflen ); |
HannesTschofenig | 0:796d0f61a05b | 189 | /* Reduce buflen to make sure MSVC _snprintf() ends with \0 as well */ |
HannesTschofenig | 0:796d0f61a05b | 190 | buflen -= 1; |
HannesTschofenig | 0:796d0f61a05b | 191 | |
HannesTschofenig | 0:796d0f61a05b | 192 | if( ret < 0 ) |
HannesTschofenig | 0:796d0f61a05b | 193 | ret = -ret; |
HannesTschofenig | 0:796d0f61a05b | 194 | |
HannesTschofenig | 0:796d0f61a05b | 195 | if( ret & 0xFF80 ) |
HannesTschofenig | 0:796d0f61a05b | 196 | { |
HannesTschofenig | 0:796d0f61a05b | 197 | use_ret = ret & 0xFF80; |
HannesTschofenig | 0:796d0f61a05b | 198 | |
HannesTschofenig | 0:796d0f61a05b | 199 | // High level error codes |
HannesTschofenig | 0:796d0f61a05b | 200 | // |
HannesTschofenig | 0:796d0f61a05b | 201 | #if defined(POLARSSL_CIPHER_C) |
HannesTschofenig | 0:796d0f61a05b | 202 | if( use_ret == -(POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 203 | snprintf( buf, buflen, "CIPHER - The selected feature is not available" ); |
HannesTschofenig | 0:796d0f61a05b | 204 | if( use_ret == -(POLARSSL_ERR_CIPHER_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 205 | snprintf( buf, buflen, "CIPHER - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 206 | if( use_ret == -(POLARSSL_ERR_CIPHER_ALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 207 | snprintf( buf, buflen, "CIPHER - Failed to allocate memory" ); |
HannesTschofenig | 0:796d0f61a05b | 208 | if( use_ret == -(POLARSSL_ERR_CIPHER_INVALID_PADDING) ) |
HannesTschofenig | 0:796d0f61a05b | 209 | snprintf( buf, buflen, "CIPHER - Input data contains invalid padding and is rejected" ); |
HannesTschofenig | 0:796d0f61a05b | 210 | if( use_ret == -(POLARSSL_ERR_CIPHER_FULL_BLOCK_EXPECTED) ) |
HannesTschofenig | 0:796d0f61a05b | 211 | snprintf( buf, buflen, "CIPHER - Decryption of block requires a full block" ); |
HannesTschofenig | 0:796d0f61a05b | 212 | if( use_ret == -(POLARSSL_ERR_CIPHER_AUTH_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 213 | snprintf( buf, buflen, "CIPHER - Authentication failed (for AEAD modes)" ); |
HannesTschofenig | 0:796d0f61a05b | 214 | #endif /* POLARSSL_CIPHER_C */ |
HannesTschofenig | 0:796d0f61a05b | 215 | |
HannesTschofenig | 0:796d0f61a05b | 216 | #if defined(POLARSSL_DHM_C) |
HannesTschofenig | 0:796d0f61a05b | 217 | if( use_ret == -(POLARSSL_ERR_DHM_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 218 | snprintf( buf, buflen, "DHM - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 219 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PARAMS_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 220 | snprintf( buf, buflen, "DHM - Reading of the DHM parameters failed" ); |
HannesTschofenig | 0:796d0f61a05b | 221 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PARAMS_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 222 | snprintf( buf, buflen, "DHM - Making of the DHM parameters failed" ); |
HannesTschofenig | 0:796d0f61a05b | 223 | if( use_ret == -(POLARSSL_ERR_DHM_READ_PUBLIC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 224 | snprintf( buf, buflen, "DHM - Reading of the public values failed" ); |
HannesTschofenig | 0:796d0f61a05b | 225 | if( use_ret == -(POLARSSL_ERR_DHM_MAKE_PUBLIC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 226 | snprintf( buf, buflen, "DHM - Making of the public value failed" ); |
HannesTschofenig | 0:796d0f61a05b | 227 | if( use_ret == -(POLARSSL_ERR_DHM_CALC_SECRET_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 228 | snprintf( buf, buflen, "DHM - Calculation of the DHM secret failed" ); |
HannesTschofenig | 0:796d0f61a05b | 229 | if( use_ret == -(POLARSSL_ERR_DHM_INVALID_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 230 | snprintf( buf, buflen, "DHM - The ASN.1 data is not formatted correctly" ); |
HannesTschofenig | 0:796d0f61a05b | 231 | if( use_ret == -(POLARSSL_ERR_DHM_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 232 | snprintf( buf, buflen, "DHM - Allocation of memory failed" ); |
HannesTschofenig | 0:796d0f61a05b | 233 | if( use_ret == -(POLARSSL_ERR_DHM_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 234 | snprintf( buf, buflen, "DHM - Read/write of file failed" ); |
HannesTschofenig | 0:796d0f61a05b | 235 | #endif /* POLARSSL_DHM_C */ |
HannesTschofenig | 0:796d0f61a05b | 236 | |
HannesTschofenig | 0:796d0f61a05b | 237 | #if defined(POLARSSL_ECP_C) |
HannesTschofenig | 0:796d0f61a05b | 238 | if( use_ret == -(POLARSSL_ERR_ECP_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 239 | snprintf( buf, buflen, "ECP - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 240 | if( use_ret == -(POLARSSL_ERR_ECP_BUFFER_TOO_SMALL) ) |
HannesTschofenig | 0:796d0f61a05b | 241 | snprintf( buf, buflen, "ECP - The buffer is too small to write to" ); |
HannesTschofenig | 0:796d0f61a05b | 242 | if( use_ret == -(POLARSSL_ERR_ECP_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 243 | snprintf( buf, buflen, "ECP - Requested curve not available" ); |
HannesTschofenig | 0:796d0f61a05b | 244 | if( use_ret == -(POLARSSL_ERR_ECP_VERIFY_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 245 | snprintf( buf, buflen, "ECP - The signature is not valid" ); |
HannesTschofenig | 0:796d0f61a05b | 246 | if( use_ret == -(POLARSSL_ERR_ECP_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 247 | snprintf( buf, buflen, "ECP - Memory allocation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 248 | if( use_ret == -(POLARSSL_ERR_ECP_RANDOM_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 249 | snprintf( buf, buflen, "ECP - Generation of random value, such as (ephemeral) key, failed" ); |
HannesTschofenig | 0:796d0f61a05b | 250 | if( use_ret == -(POLARSSL_ERR_ECP_INVALID_KEY) ) |
HannesTschofenig | 0:796d0f61a05b | 251 | snprintf( buf, buflen, "ECP - Invalid private or public key" ); |
HannesTschofenig | 0:796d0f61a05b | 252 | if( use_ret == -(POLARSSL_ERR_ECP_SIG_LEN_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 253 | snprintf( buf, buflen, "ECP - Signature is valid but shorter than the user-supplied length" ); |
HannesTschofenig | 0:796d0f61a05b | 254 | #endif /* POLARSSL_ECP_C */ |
HannesTschofenig | 0:796d0f61a05b | 255 | |
HannesTschofenig | 0:796d0f61a05b | 256 | #if defined(POLARSSL_MD_C) |
HannesTschofenig | 0:796d0f61a05b | 257 | if( use_ret == -(POLARSSL_ERR_MD_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 258 | snprintf( buf, buflen, "MD - The selected feature is not available" ); |
HannesTschofenig | 0:796d0f61a05b | 259 | if( use_ret == -(POLARSSL_ERR_MD_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 260 | snprintf( buf, buflen, "MD - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 261 | if( use_ret == -(POLARSSL_ERR_MD_ALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 262 | snprintf( buf, buflen, "MD - Failed to allocate memory" ); |
HannesTschofenig | 0:796d0f61a05b | 263 | if( use_ret == -(POLARSSL_ERR_MD_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 264 | snprintf( buf, buflen, "MD - Opening or reading of file failed" ); |
HannesTschofenig | 0:796d0f61a05b | 265 | #endif /* POLARSSL_MD_C */ |
HannesTschofenig | 0:796d0f61a05b | 266 | |
HannesTschofenig | 0:796d0f61a05b | 267 | #if defined(POLARSSL_PEM_PARSE_C) || defined(POLARSSL_PEM_WRITE_C) |
HannesTschofenig | 0:796d0f61a05b | 268 | if( use_ret == -(POLARSSL_ERR_PEM_NO_HEADER_FOOTER_PRESENT) ) |
HannesTschofenig | 0:796d0f61a05b | 269 | snprintf( buf, buflen, "PEM - No PEM header or footer found" ); |
HannesTschofenig | 0:796d0f61a05b | 270 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 271 | snprintf( buf, buflen, "PEM - PEM string is not as expected" ); |
HannesTschofenig | 0:796d0f61a05b | 272 | if( use_ret == -(POLARSSL_ERR_PEM_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 273 | snprintf( buf, buflen, "PEM - Failed to allocate memory" ); |
HannesTschofenig | 0:796d0f61a05b | 274 | if( use_ret == -(POLARSSL_ERR_PEM_INVALID_ENC_IV) ) |
HannesTschofenig | 0:796d0f61a05b | 275 | snprintf( buf, buflen, "PEM - RSA IV is not in hex-format" ); |
HannesTschofenig | 0:796d0f61a05b | 276 | if( use_ret == -(POLARSSL_ERR_PEM_UNKNOWN_ENC_ALG) ) |
HannesTschofenig | 0:796d0f61a05b | 277 | snprintf( buf, buflen, "PEM - Unsupported key encryption algorithm" ); |
HannesTschofenig | 0:796d0f61a05b | 278 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_REQUIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 279 | snprintf( buf, buflen, "PEM - Private key password can't be empty" ); |
HannesTschofenig | 0:796d0f61a05b | 280 | if( use_ret == -(POLARSSL_ERR_PEM_PASSWORD_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 281 | snprintf( buf, buflen, "PEM - Given private key password does not allow for correct decryption" ); |
HannesTschofenig | 0:796d0f61a05b | 282 | if( use_ret == -(POLARSSL_ERR_PEM_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 283 | snprintf( buf, buflen, "PEM - Unavailable feature, e.g. hashing/encryption combination" ); |
HannesTschofenig | 0:796d0f61a05b | 284 | if( use_ret == -(POLARSSL_ERR_PEM_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 285 | snprintf( buf, buflen, "PEM - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 286 | #endif /* POLARSSL_PEM_PARSE_C || POLARSSL_PEM_WRITE_C */ |
HannesTschofenig | 0:796d0f61a05b | 287 | |
HannesTschofenig | 0:796d0f61a05b | 288 | #if defined(POLARSSL_PK_C) |
HannesTschofenig | 0:796d0f61a05b | 289 | if( use_ret == -(POLARSSL_ERR_PK_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 290 | snprintf( buf, buflen, "PK - Memory alloation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 291 | if( use_ret == -(POLARSSL_ERR_PK_TYPE_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 292 | snprintf( buf, buflen, "PK - Type mismatch, eg attempt to encrypt with an ECDSA key" ); |
HannesTschofenig | 0:796d0f61a05b | 293 | if( use_ret == -(POLARSSL_ERR_PK_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 294 | snprintf( buf, buflen, "PK - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 295 | if( use_ret == -(POLARSSL_ERR_PK_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 296 | snprintf( buf, buflen, "PK - Read/write of file failed" ); |
HannesTschofenig | 0:796d0f61a05b | 297 | if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_VERSION) ) |
HannesTschofenig | 0:796d0f61a05b | 298 | snprintf( buf, buflen, "PK - Unsupported key version" ); |
HannesTschofenig | 0:796d0f61a05b | 299 | if( use_ret == -(POLARSSL_ERR_PK_KEY_INVALID_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 300 | snprintf( buf, buflen, "PK - Invalid key tag or value" ); |
HannesTschofenig | 0:796d0f61a05b | 301 | if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_PK_ALG) ) |
HannesTschofenig | 0:796d0f61a05b | 302 | snprintf( buf, buflen, "PK - Key algorithm is unsupported (only RSA and EC are supported)" ); |
HannesTschofenig | 0:796d0f61a05b | 303 | if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_REQUIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 304 | snprintf( buf, buflen, "PK - Private key password can't be empty" ); |
HannesTschofenig | 0:796d0f61a05b | 305 | if( use_ret == -(POLARSSL_ERR_PK_PASSWORD_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 306 | snprintf( buf, buflen, "PK - Given private key password does not allow for correct decryption" ); |
HannesTschofenig | 0:796d0f61a05b | 307 | if( use_ret == -(POLARSSL_ERR_PK_INVALID_PUBKEY) ) |
HannesTschofenig | 0:796d0f61a05b | 308 | snprintf( buf, buflen, "PK - The pubkey tag or value is invalid (only RSA and EC are supported)" ); |
HannesTschofenig | 0:796d0f61a05b | 309 | if( use_ret == -(POLARSSL_ERR_PK_INVALID_ALG) ) |
HannesTschofenig | 0:796d0f61a05b | 310 | snprintf( buf, buflen, "PK - The algorithm tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 311 | if( use_ret == -(POLARSSL_ERR_PK_UNKNOWN_NAMED_CURVE) ) |
HannesTschofenig | 0:796d0f61a05b | 312 | snprintf( buf, buflen, "PK - Elliptic curve is unsupported (only NIST curves are supported)" ); |
HannesTschofenig | 0:796d0f61a05b | 313 | if( use_ret == -(POLARSSL_ERR_PK_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 314 | snprintf( buf, buflen, "PK - Unavailable feature, e.g. RSA disabled for RSA key" ); |
HannesTschofenig | 0:796d0f61a05b | 315 | if( use_ret == -(POLARSSL_ERR_PK_SIG_LEN_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 316 | snprintf( buf, buflen, "PK - The signature is valid but its length is less than expected" ); |
HannesTschofenig | 0:796d0f61a05b | 317 | #endif /* POLARSSL_PK_C */ |
HannesTschofenig | 0:796d0f61a05b | 318 | |
HannesTschofenig | 0:796d0f61a05b | 319 | #if defined(POLARSSL_PKCS12_C) |
HannesTschofenig | 0:796d0f61a05b | 320 | if( use_ret == -(POLARSSL_ERR_PKCS12_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 321 | snprintf( buf, buflen, "PKCS12 - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 322 | if( use_ret == -(POLARSSL_ERR_PKCS12_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 323 | snprintf( buf, buflen, "PKCS12 - Feature not available, e.g. unsupported encryption scheme" ); |
HannesTschofenig | 0:796d0f61a05b | 324 | if( use_ret == -(POLARSSL_ERR_PKCS12_PBE_INVALID_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 325 | snprintf( buf, buflen, "PKCS12 - PBE ASN.1 data not as expected" ); |
HannesTschofenig | 0:796d0f61a05b | 326 | if( use_ret == -(POLARSSL_ERR_PKCS12_PASSWORD_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 327 | snprintf( buf, buflen, "PKCS12 - Given private key password does not allow for correct decryption" ); |
HannesTschofenig | 0:796d0f61a05b | 328 | #endif /* POLARSSL_PKCS12_C */ |
HannesTschofenig | 0:796d0f61a05b | 329 | |
HannesTschofenig | 0:796d0f61a05b | 330 | #if defined(POLARSSL_PKCS5_C) |
HannesTschofenig | 0:796d0f61a05b | 331 | if( use_ret == -(POLARSSL_ERR_PKCS5_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 332 | snprintf( buf, buflen, "PKCS5 - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 333 | if( use_ret == -(POLARSSL_ERR_PKCS5_INVALID_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 334 | snprintf( buf, buflen, "PKCS5 - Unexpected ASN.1 data" ); |
HannesTschofenig | 0:796d0f61a05b | 335 | if( use_ret == -(POLARSSL_ERR_PKCS5_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 336 | snprintf( buf, buflen, "PKCS5 - Requested encryption or digest alg not available" ); |
HannesTschofenig | 0:796d0f61a05b | 337 | if( use_ret == -(POLARSSL_ERR_PKCS5_PASSWORD_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 338 | snprintf( buf, buflen, "PKCS5 - Given private key password does not allow for correct decryption" ); |
HannesTschofenig | 0:796d0f61a05b | 339 | #endif /* POLARSSL_PKCS5_C */ |
HannesTschofenig | 0:796d0f61a05b | 340 | |
HannesTschofenig | 0:796d0f61a05b | 341 | #if defined(POLARSSL_RSA_C) |
HannesTschofenig | 0:796d0f61a05b | 342 | if( use_ret == -(POLARSSL_ERR_RSA_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 343 | snprintf( buf, buflen, "RSA - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 344 | if( use_ret == -(POLARSSL_ERR_RSA_INVALID_PADDING) ) |
HannesTschofenig | 0:796d0f61a05b | 345 | snprintf( buf, buflen, "RSA - Input data contains invalid padding and is rejected" ); |
HannesTschofenig | 0:796d0f61a05b | 346 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_GEN_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 347 | snprintf( buf, buflen, "RSA - Something failed during generation of a key" ); |
HannesTschofenig | 0:796d0f61a05b | 348 | if( use_ret == -(POLARSSL_ERR_RSA_KEY_CHECK_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 349 | snprintf( buf, buflen, "RSA - Key failed to pass the libraries validity check" ); |
HannesTschofenig | 0:796d0f61a05b | 350 | if( use_ret == -(POLARSSL_ERR_RSA_PUBLIC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 351 | snprintf( buf, buflen, "RSA - The public key operation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 352 | if( use_ret == -(POLARSSL_ERR_RSA_PRIVATE_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 353 | snprintf( buf, buflen, "RSA - The private key operation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 354 | if( use_ret == -(POLARSSL_ERR_RSA_VERIFY_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 355 | snprintf( buf, buflen, "RSA - The PKCS#1 verification failed" ); |
HannesTschofenig | 0:796d0f61a05b | 356 | if( use_ret == -(POLARSSL_ERR_RSA_OUTPUT_TOO_LARGE) ) |
HannesTschofenig | 0:796d0f61a05b | 357 | snprintf( buf, buflen, "RSA - The output buffer for decryption is not large enough" ); |
HannesTschofenig | 0:796d0f61a05b | 358 | if( use_ret == -(POLARSSL_ERR_RSA_RNG_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 359 | snprintf( buf, buflen, "RSA - The random generator failed to generate non-zeros" ); |
HannesTschofenig | 0:796d0f61a05b | 360 | #endif /* POLARSSL_RSA_C */ |
HannesTschofenig | 0:796d0f61a05b | 361 | |
HannesTschofenig | 0:796d0f61a05b | 362 | #if defined(POLARSSL_SSL_TLS_C) |
HannesTschofenig | 0:796d0f61a05b | 363 | if( use_ret == -(POLARSSL_ERR_SSL_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 364 | snprintf( buf, buflen, "SSL - The requested feature is not available" ); |
HannesTschofenig | 0:796d0f61a05b | 365 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 366 | snprintf( buf, buflen, "SSL - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 367 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_MAC) ) |
HannesTschofenig | 0:796d0f61a05b | 368 | snprintf( buf, buflen, "SSL - Verification of the message MAC failed" ); |
HannesTschofenig | 0:796d0f61a05b | 369 | if( use_ret == -(POLARSSL_ERR_SSL_INVALID_RECORD) ) |
HannesTschofenig | 0:796d0f61a05b | 370 | snprintf( buf, buflen, "SSL - An invalid SSL record was received" ); |
HannesTschofenig | 0:796d0f61a05b | 371 | if( use_ret == -(POLARSSL_ERR_SSL_CONN_EOF) ) |
HannesTschofenig | 0:796d0f61a05b | 372 | snprintf( buf, buflen, "SSL - The connection indicated an EOF" ); |
HannesTschofenig | 0:796d0f61a05b | 373 | if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_CIPHER) ) |
HannesTschofenig | 0:796d0f61a05b | 374 | snprintf( buf, buflen, "SSL - An unknown cipher was received" ); |
HannesTschofenig | 0:796d0f61a05b | 375 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CIPHER_CHOSEN) ) |
HannesTschofenig | 0:796d0f61a05b | 376 | snprintf( buf, buflen, "SSL - The server has no ciphersuites in common with the client" ); |
HannesTschofenig | 0:796d0f61a05b | 377 | if( use_ret == -(POLARSSL_ERR_SSL_NO_RNG) ) |
HannesTschofenig | 0:796d0f61a05b | 378 | snprintf( buf, buflen, "SSL - No RNG was provided to the SSL module" ); |
HannesTschofenig | 0:796d0f61a05b | 379 | if( use_ret == -(POLARSSL_ERR_SSL_NO_CLIENT_CERTIFICATE) ) |
HannesTschofenig | 0:796d0f61a05b | 380 | snprintf( buf, buflen, "SSL - No client certification received from the client, but required by the authentication mode" ); |
HannesTschofenig | 0:796d0f61a05b | 381 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_TOO_LARGE) ) |
HannesTschofenig | 0:796d0f61a05b | 382 | snprintf( buf, buflen, "SSL - DESCRIPTION MISSING" ); |
HannesTschofenig | 0:796d0f61a05b | 383 | if( use_ret == -(POLARSSL_ERR_SSL_CERTIFICATE_REQUIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 384 | snprintf( buf, buflen, "SSL - The own certificate is not set, but needed by the server" ); |
HannesTschofenig | 0:796d0f61a05b | 385 | if( use_ret == -(POLARSSL_ERR_SSL_PRIVATE_KEY_REQUIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 386 | snprintf( buf, buflen, "SSL - The own private key or pre-shared key is not set, but needed" ); |
HannesTschofenig | 0:796d0f61a05b | 387 | if( use_ret == -(POLARSSL_ERR_SSL_CA_CHAIN_REQUIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 388 | snprintf( buf, buflen, "SSL - No CA Chain is set, but required to operate" ); |
HannesTschofenig | 0:796d0f61a05b | 389 | if( use_ret == -(POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE) ) |
HannesTschofenig | 0:796d0f61a05b | 390 | snprintf( buf, buflen, "SSL - An unexpected message was received from our peer" ); |
HannesTschofenig | 0:796d0f61a05b | 391 | if( use_ret == -(POLARSSL_ERR_SSL_FATAL_ALERT_MESSAGE) ) |
HannesTschofenig | 0:796d0f61a05b | 392 | { |
HannesTschofenig | 0:796d0f61a05b | 393 | snprintf( buf, buflen, "SSL - A fatal alert message was received from our peer" ); |
HannesTschofenig | 0:796d0f61a05b | 394 | return; |
HannesTschofenig | 0:796d0f61a05b | 395 | } |
HannesTschofenig | 0:796d0f61a05b | 396 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_VERIFY_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 397 | snprintf( buf, buflen, "SSL - Verification of our peer failed" ); |
HannesTschofenig | 0:796d0f61a05b | 398 | if( use_ret == -(POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY) ) |
HannesTschofenig | 0:796d0f61a05b | 399 | snprintf( buf, buflen, "SSL - The peer notified us that the connection is going to be closed" ); |
HannesTschofenig | 0:796d0f61a05b | 400 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_HELLO) ) |
HannesTschofenig | 0:796d0f61a05b | 401 | snprintf( buf, buflen, "SSL - Processing of the ClientHello handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 402 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO) ) |
HannesTschofenig | 0:796d0f61a05b | 403 | snprintf( buf, buflen, "SSL - Processing of the ServerHello handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 404 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE) ) |
HannesTschofenig | 0:796d0f61a05b | 405 | snprintf( buf, buflen, "SSL - Processing of the Certificate handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 406 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_REQUEST) ) |
HannesTschofenig | 0:796d0f61a05b | 407 | snprintf( buf, buflen, "SSL - Processing of the CertificateRequest handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 408 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_KEY_EXCHANGE) ) |
HannesTschofenig | 0:796d0f61a05b | 409 | snprintf( buf, buflen, "SSL - Processing of the ServerKeyExchange handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 410 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_SERVER_HELLO_DONE) ) |
HannesTschofenig | 0:796d0f61a05b | 411 | snprintf( buf, buflen, "SSL - Processing of the ServerHelloDone handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 412 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE) ) |
HannesTschofenig | 0:796d0f61a05b | 413 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 414 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_RP) ) |
HannesTschofenig | 0:796d0f61a05b | 415 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Read Public" ); |
HannesTschofenig | 0:796d0f61a05b | 416 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CLIENT_KEY_EXCHANGE_CS) ) |
HannesTschofenig | 0:796d0f61a05b | 417 | snprintf( buf, buflen, "SSL - Processing of the ClientKeyExchange handshake message failed in DHM / ECDH Calculate Secret" ); |
HannesTschofenig | 0:796d0f61a05b | 418 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CERTIFICATE_VERIFY) ) |
HannesTschofenig | 0:796d0f61a05b | 419 | snprintf( buf, buflen, "SSL - Processing of the CertificateVerify handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 420 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_CHANGE_CIPHER_SPEC) ) |
HannesTschofenig | 0:796d0f61a05b | 421 | snprintf( buf, buflen, "SSL - Processing of the ChangeCipherSpec handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 422 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_FINISHED) ) |
HannesTschofenig | 0:796d0f61a05b | 423 | snprintf( buf, buflen, "SSL - Processing of the Finished handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 424 | if( use_ret == -(POLARSSL_ERR_SSL_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 425 | snprintf( buf, buflen, "SSL - Memory allocation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 426 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 427 | snprintf( buf, buflen, "SSL - Hardware acceleration function returned with error" ); |
HannesTschofenig | 0:796d0f61a05b | 428 | if( use_ret == -(POLARSSL_ERR_SSL_HW_ACCEL_FALLTHROUGH) ) |
HannesTschofenig | 0:796d0f61a05b | 429 | snprintf( buf, buflen, "SSL - Hardware acceleration function skipped / left alone data" ); |
HannesTschofenig | 0:796d0f61a05b | 430 | if( use_ret == -(POLARSSL_ERR_SSL_COMPRESSION_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 431 | snprintf( buf, buflen, "SSL - Processing of the compression / decompression failed" ); |
HannesTschofenig | 0:796d0f61a05b | 432 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_PROTOCOL_VERSION) ) |
HannesTschofenig | 0:796d0f61a05b | 433 | snprintf( buf, buflen, "SSL - Handshake protocol not within min/max boundaries" ); |
HannesTschofenig | 0:796d0f61a05b | 434 | if( use_ret == -(POLARSSL_ERR_SSL_BAD_HS_NEW_SESSION_TICKET) ) |
HannesTschofenig | 0:796d0f61a05b | 435 | snprintf( buf, buflen, "SSL - Processing of the NewSessionTicket handshake message failed" ); |
HannesTschofenig | 0:796d0f61a05b | 436 | if( use_ret == -(POLARSSL_ERR_SSL_SESSION_TICKET_EXPIRED) ) |
HannesTschofenig | 0:796d0f61a05b | 437 | snprintf( buf, buflen, "SSL - Session ticket has expired" ); |
HannesTschofenig | 0:796d0f61a05b | 438 | if( use_ret == -(POLARSSL_ERR_SSL_PK_TYPE_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 439 | snprintf( buf, buflen, "SSL - Public key type mismatch (eg, asked for RSA key exchange and presented EC key)" ); |
HannesTschofenig | 0:796d0f61a05b | 440 | if( use_ret == -(POLARSSL_ERR_SSL_UNKNOWN_IDENTITY) ) |
HannesTschofenig | 0:796d0f61a05b | 441 | snprintf( buf, buflen, "SSL - Unknown identity received (eg, PSK identity)" ); |
HannesTschofenig | 0:796d0f61a05b | 442 | if( use_ret == -(POLARSSL_ERR_SSL_INTERNAL_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 443 | snprintf( buf, buflen, "SSL - Internal error (eg, unexpected failure in lower-level module)" ); |
HannesTschofenig | 0:796d0f61a05b | 444 | if( use_ret == -(POLARSSL_ERR_SSL_COUNTER_WRAPPING) ) |
HannesTschofenig | 0:796d0f61a05b | 445 | snprintf( buf, buflen, "SSL - A counter would wrap (eg, too many messages exchanged)" ); |
HannesTschofenig | 0:796d0f61a05b | 446 | #endif /* POLARSSL_SSL_TLS_C */ |
HannesTschofenig | 0:796d0f61a05b | 447 | |
HannesTschofenig | 0:796d0f61a05b | 448 | #if defined(POLARSSL_X509_USE_C) || defined(POLARSSL_X509_CREATE_C) |
HannesTschofenig | 0:796d0f61a05b | 449 | if( use_ret == -(POLARSSL_ERR_X509_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 450 | snprintf( buf, buflen, "X509 - Unavailable feature, e.g. RSA hashing/encryption combination" ); |
HannesTschofenig | 0:796d0f61a05b | 451 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_OID) ) |
HannesTschofenig | 0:796d0f61a05b | 452 | snprintf( buf, buflen, "X509 - Requested OID is unknown" ); |
HannesTschofenig | 0:796d0f61a05b | 453 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 454 | snprintf( buf, buflen, "X509 - The CRT/CRL/CSR format is invalid, e.g. different type expected" ); |
HannesTschofenig | 0:796d0f61a05b | 455 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_VERSION) ) |
HannesTschofenig | 0:796d0f61a05b | 456 | snprintf( buf, buflen, "X509 - The CRT/CRL/CSR version element is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 457 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_SERIAL) ) |
HannesTschofenig | 0:796d0f61a05b | 458 | snprintf( buf, buflen, "X509 - The serial tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 459 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_ALG) ) |
HannesTschofenig | 0:796d0f61a05b | 460 | snprintf( buf, buflen, "X509 - The algorithm tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 461 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_NAME) ) |
HannesTschofenig | 0:796d0f61a05b | 462 | snprintf( buf, buflen, "X509 - The name tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 463 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_DATE) ) |
HannesTschofenig | 0:796d0f61a05b | 464 | snprintf( buf, buflen, "X509 - The date tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 465 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_SIGNATURE) ) |
HannesTschofenig | 0:796d0f61a05b | 466 | snprintf( buf, buflen, "X509 - The signature tag or value invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 467 | if( use_ret == -(POLARSSL_ERR_X509_INVALID_EXTENSIONS) ) |
HannesTschofenig | 0:796d0f61a05b | 468 | snprintf( buf, buflen, "X509 - The extension tag or value is invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 469 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_VERSION) ) |
HannesTschofenig | 0:796d0f61a05b | 470 | snprintf( buf, buflen, "X509 - CRT/CRL/CSR has an unsupported version number" ); |
HannesTschofenig | 0:796d0f61a05b | 471 | if( use_ret == -(POLARSSL_ERR_X509_UNKNOWN_SIG_ALG) ) |
HannesTschofenig | 0:796d0f61a05b | 472 | snprintf( buf, buflen, "X509 - Signature algorithm (oid) is unsupported" ); |
HannesTschofenig | 0:796d0f61a05b | 473 | if( use_ret == -(POLARSSL_ERR_X509_SIG_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 474 | snprintf( buf, buflen, "X509 - Signature algorithms do not match. (see \\c ::x509_crt sig_oid)" ); |
HannesTschofenig | 0:796d0f61a05b | 475 | if( use_ret == -(POLARSSL_ERR_X509_CERT_VERIFY_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 476 | snprintf( buf, buflen, "X509 - Certificate verification failed, e.g. CRL, CA or signature check failed" ); |
HannesTschofenig | 0:796d0f61a05b | 477 | if( use_ret == -(POLARSSL_ERR_X509_CERT_UNKNOWN_FORMAT) ) |
HannesTschofenig | 0:796d0f61a05b | 478 | snprintf( buf, buflen, "X509 - Format not recognized as DER or PEM" ); |
HannesTschofenig | 0:796d0f61a05b | 479 | if( use_ret == -(POLARSSL_ERR_X509_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 480 | snprintf( buf, buflen, "X509 - Input invalid" ); |
HannesTschofenig | 0:796d0f61a05b | 481 | if( use_ret == -(POLARSSL_ERR_X509_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 482 | snprintf( buf, buflen, "X509 - Allocation of memory failed" ); |
HannesTschofenig | 0:796d0f61a05b | 483 | if( use_ret == -(POLARSSL_ERR_X509_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 484 | snprintf( buf, buflen, "X509 - Read/write of file failed" ); |
HannesTschofenig | 0:796d0f61a05b | 485 | #endif /* POLARSSL_X509_USE,X509_CREATE_C */ |
HannesTschofenig | 0:796d0f61a05b | 486 | |
HannesTschofenig | 0:796d0f61a05b | 487 | if( strlen( buf ) == 0 ) |
HannesTschofenig | 0:796d0f61a05b | 488 | snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
HannesTschofenig | 0:796d0f61a05b | 489 | } |
HannesTschofenig | 0:796d0f61a05b | 490 | |
HannesTschofenig | 0:796d0f61a05b | 491 | use_ret = ret & ~0xFF80; |
HannesTschofenig | 0:796d0f61a05b | 492 | |
HannesTschofenig | 0:796d0f61a05b | 493 | if( use_ret == 0 ) |
HannesTschofenig | 0:796d0f61a05b | 494 | return; |
HannesTschofenig | 0:796d0f61a05b | 495 | |
HannesTschofenig | 0:796d0f61a05b | 496 | // If high level code is present, make a concatenation between both |
HannesTschofenig | 0:796d0f61a05b | 497 | // error strings. |
HannesTschofenig | 0:796d0f61a05b | 498 | // |
HannesTschofenig | 0:796d0f61a05b | 499 | len = strlen( buf ); |
HannesTschofenig | 0:796d0f61a05b | 500 | |
HannesTschofenig | 0:796d0f61a05b | 501 | if( len > 0 ) |
HannesTschofenig | 0:796d0f61a05b | 502 | { |
HannesTschofenig | 0:796d0f61a05b | 503 | if( buflen - len < 5 ) |
HannesTschofenig | 0:796d0f61a05b | 504 | return; |
HannesTschofenig | 0:796d0f61a05b | 505 | |
HannesTschofenig | 0:796d0f61a05b | 506 | snprintf( buf + len, buflen - len, " : " ); |
HannesTschofenig | 0:796d0f61a05b | 507 | |
HannesTschofenig | 0:796d0f61a05b | 508 | buf += len + 3; |
HannesTschofenig | 0:796d0f61a05b | 509 | buflen -= len + 3; |
HannesTschofenig | 0:796d0f61a05b | 510 | } |
HannesTschofenig | 0:796d0f61a05b | 511 | |
HannesTschofenig | 0:796d0f61a05b | 512 | // Low level error codes |
HannesTschofenig | 0:796d0f61a05b | 513 | // |
HannesTschofenig | 0:796d0f61a05b | 514 | #if defined(POLARSSL_AES_C) |
HannesTschofenig | 0:796d0f61a05b | 515 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_KEY_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 516 | snprintf( buf, buflen, "AES - Invalid key length" ); |
HannesTschofenig | 0:796d0f61a05b | 517 | if( use_ret == -(POLARSSL_ERR_AES_INVALID_INPUT_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 518 | snprintf( buf, buflen, "AES - Invalid data input length" ); |
HannesTschofenig | 0:796d0f61a05b | 519 | #endif /* POLARSSL_AES_C */ |
HannesTschofenig | 0:796d0f61a05b | 520 | |
HannesTschofenig | 0:796d0f61a05b | 521 | #if defined(POLARSSL_ASN1_PARSE_C) |
HannesTschofenig | 0:796d0f61a05b | 522 | if( use_ret == -(POLARSSL_ERR_ASN1_OUT_OF_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 523 | snprintf( buf, buflen, "ASN1 - Out of data when parsing an ASN1 data structure" ); |
HannesTschofenig | 0:796d0f61a05b | 524 | if( use_ret == -(POLARSSL_ERR_ASN1_UNEXPECTED_TAG) ) |
HannesTschofenig | 0:796d0f61a05b | 525 | snprintf( buf, buflen, "ASN1 - ASN1 tag was of an unexpected value" ); |
HannesTschofenig | 0:796d0f61a05b | 526 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 527 | snprintf( buf, buflen, "ASN1 - Error when trying to determine the length or invalid length" ); |
HannesTschofenig | 0:796d0f61a05b | 528 | if( use_ret == -(POLARSSL_ERR_ASN1_LENGTH_MISMATCH) ) |
HannesTschofenig | 0:796d0f61a05b | 529 | snprintf( buf, buflen, "ASN1 - Actual length differs from expected length" ); |
HannesTschofenig | 0:796d0f61a05b | 530 | if( use_ret == -(POLARSSL_ERR_ASN1_INVALID_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 531 | snprintf( buf, buflen, "ASN1 - Data is invalid. (not used)" ); |
HannesTschofenig | 0:796d0f61a05b | 532 | if( use_ret == -(POLARSSL_ERR_ASN1_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 533 | snprintf( buf, buflen, "ASN1 - Memory allocation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 534 | if( use_ret == -(POLARSSL_ERR_ASN1_BUF_TOO_SMALL) ) |
HannesTschofenig | 0:796d0f61a05b | 535 | snprintf( buf, buflen, "ASN1 - Buffer too small when writing ASN.1 data structure" ); |
HannesTschofenig | 0:796d0f61a05b | 536 | #endif /* POLARSSL_ASN1_PARSE_C */ |
HannesTschofenig | 0:796d0f61a05b | 537 | |
HannesTschofenig | 0:796d0f61a05b | 538 | #if defined(POLARSSL_BASE64_C) |
HannesTschofenig | 0:796d0f61a05b | 539 | if( use_ret == -(POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) ) |
HannesTschofenig | 0:796d0f61a05b | 540 | snprintf( buf, buflen, "BASE64 - Output buffer too small" ); |
HannesTschofenig | 0:796d0f61a05b | 541 | if( use_ret == -(POLARSSL_ERR_BASE64_INVALID_CHARACTER) ) |
HannesTschofenig | 0:796d0f61a05b | 542 | snprintf( buf, buflen, "BASE64 - Invalid character in input" ); |
HannesTschofenig | 0:796d0f61a05b | 543 | #endif /* POLARSSL_BASE64_C */ |
HannesTschofenig | 0:796d0f61a05b | 544 | |
HannesTschofenig | 0:796d0f61a05b | 545 | #if defined(POLARSSL_BIGNUM_C) |
HannesTschofenig | 0:796d0f61a05b | 546 | if( use_ret == -(POLARSSL_ERR_MPI_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 547 | snprintf( buf, buflen, "BIGNUM - An error occurred while reading from or writing to a file" ); |
HannesTschofenig | 0:796d0f61a05b | 548 | if( use_ret == -(POLARSSL_ERR_MPI_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 549 | snprintf( buf, buflen, "BIGNUM - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 550 | if( use_ret == -(POLARSSL_ERR_MPI_INVALID_CHARACTER) ) |
HannesTschofenig | 0:796d0f61a05b | 551 | snprintf( buf, buflen, "BIGNUM - There is an invalid character in the digit string" ); |
HannesTschofenig | 0:796d0f61a05b | 552 | if( use_ret == -(POLARSSL_ERR_MPI_BUFFER_TOO_SMALL) ) |
HannesTschofenig | 0:796d0f61a05b | 553 | snprintf( buf, buflen, "BIGNUM - The buffer is too small to write to" ); |
HannesTschofenig | 0:796d0f61a05b | 554 | if( use_ret == -(POLARSSL_ERR_MPI_NEGATIVE_VALUE) ) |
HannesTschofenig | 0:796d0f61a05b | 555 | snprintf( buf, buflen, "BIGNUM - The input arguments are negative or result in illegal output" ); |
HannesTschofenig | 0:796d0f61a05b | 556 | if( use_ret == -(POLARSSL_ERR_MPI_DIVISION_BY_ZERO) ) |
HannesTschofenig | 0:796d0f61a05b | 557 | snprintf( buf, buflen, "BIGNUM - The input argument for division is zero, which is not allowed" ); |
HannesTschofenig | 0:796d0f61a05b | 558 | if( use_ret == -(POLARSSL_ERR_MPI_NOT_ACCEPTABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 559 | snprintf( buf, buflen, "BIGNUM - The input arguments are not acceptable" ); |
HannesTschofenig | 0:796d0f61a05b | 560 | if( use_ret == -(POLARSSL_ERR_MPI_MALLOC_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 561 | snprintf( buf, buflen, "BIGNUM - Memory allocation failed" ); |
HannesTschofenig | 0:796d0f61a05b | 562 | #endif /* POLARSSL_BIGNUM_C */ |
HannesTschofenig | 0:796d0f61a05b | 563 | |
HannesTschofenig | 0:796d0f61a05b | 564 | #if defined(POLARSSL_BLOWFISH_C) |
HannesTschofenig | 0:796d0f61a05b | 565 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_KEY_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 566 | snprintf( buf, buflen, "BLOWFISH - Invalid key length" ); |
HannesTschofenig | 0:796d0f61a05b | 567 | if( use_ret == -(POLARSSL_ERR_BLOWFISH_INVALID_INPUT_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 568 | snprintf( buf, buflen, "BLOWFISH - Invalid data input length" ); |
HannesTschofenig | 0:796d0f61a05b | 569 | #endif /* POLARSSL_BLOWFISH_C */ |
HannesTschofenig | 0:796d0f61a05b | 570 | |
HannesTschofenig | 0:796d0f61a05b | 571 | #if defined(POLARSSL_CAMELLIA_C) |
HannesTschofenig | 0:796d0f61a05b | 572 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_KEY_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 573 | snprintf( buf, buflen, "CAMELLIA - Invalid key length" ); |
HannesTschofenig | 0:796d0f61a05b | 574 | if( use_ret == -(POLARSSL_ERR_CAMELLIA_INVALID_INPUT_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 575 | snprintf( buf, buflen, "CAMELLIA - Invalid data input length" ); |
HannesTschofenig | 0:796d0f61a05b | 576 | #endif /* POLARSSL_CAMELLIA_C */ |
HannesTschofenig | 0:796d0f61a05b | 577 | |
HannesTschofenig | 0:796d0f61a05b | 578 | #if defined(POLARSSL_CTR_DRBG_C) |
HannesTschofenig | 0:796d0f61a05b | 579 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_ENTROPY_SOURCE_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 580 | snprintf( buf, buflen, "CTR_DRBG - The entropy source failed" ); |
HannesTschofenig | 0:796d0f61a05b | 581 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_REQUEST_TOO_BIG) ) |
HannesTschofenig | 0:796d0f61a05b | 582 | snprintf( buf, buflen, "CTR_DRBG - Too many random requested in single call" ); |
HannesTschofenig | 0:796d0f61a05b | 583 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_INPUT_TOO_BIG) ) |
HannesTschofenig | 0:796d0f61a05b | 584 | snprintf( buf, buflen, "CTR_DRBG - Input too large (Entropy + additional)" ); |
HannesTschofenig | 0:796d0f61a05b | 585 | if( use_ret == -(POLARSSL_ERR_CTR_DRBG_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 586 | snprintf( buf, buflen, "CTR_DRBG - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 587 | #endif /* POLARSSL_CTR_DRBG_C */ |
HannesTschofenig | 0:796d0f61a05b | 588 | |
HannesTschofenig | 0:796d0f61a05b | 589 | #if defined(POLARSSL_DES_C) |
HannesTschofenig | 0:796d0f61a05b | 590 | if( use_ret == -(POLARSSL_ERR_DES_INVALID_INPUT_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 591 | snprintf( buf, buflen, "DES - The data input has an invalid length" ); |
HannesTschofenig | 0:796d0f61a05b | 592 | #endif /* POLARSSL_DES_C */ |
HannesTschofenig | 0:796d0f61a05b | 593 | |
HannesTschofenig | 0:796d0f61a05b | 594 | #if defined(POLARSSL_ENTROPY_C) |
HannesTschofenig | 0:796d0f61a05b | 595 | if( use_ret == -(POLARSSL_ERR_ENTROPY_SOURCE_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 596 | snprintf( buf, buflen, "ENTROPY - Critical entropy source failure" ); |
HannesTschofenig | 0:796d0f61a05b | 597 | if( use_ret == -(POLARSSL_ERR_ENTROPY_MAX_SOURCES) ) |
HannesTschofenig | 0:796d0f61a05b | 598 | snprintf( buf, buflen, "ENTROPY - No more sources can be added" ); |
HannesTschofenig | 0:796d0f61a05b | 599 | if( use_ret == -(POLARSSL_ERR_ENTROPY_NO_SOURCES_DEFINED) ) |
HannesTschofenig | 0:796d0f61a05b | 600 | snprintf( buf, buflen, "ENTROPY - No sources have been added to poll" ); |
HannesTschofenig | 0:796d0f61a05b | 601 | if( use_ret == -(POLARSSL_ERR_ENTROPY_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 602 | snprintf( buf, buflen, "ENTROPY - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 603 | #endif /* POLARSSL_ENTROPY_C */ |
HannesTschofenig | 0:796d0f61a05b | 604 | |
HannesTschofenig | 0:796d0f61a05b | 605 | #if defined(POLARSSL_GCM_C) |
HannesTschofenig | 0:796d0f61a05b | 606 | if( use_ret == -(POLARSSL_ERR_GCM_AUTH_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 607 | snprintf( buf, buflen, "GCM - Authenticated decryption failed" ); |
HannesTschofenig | 0:796d0f61a05b | 608 | if( use_ret == -(POLARSSL_ERR_GCM_BAD_INPUT) ) |
HannesTschofenig | 0:796d0f61a05b | 609 | snprintf( buf, buflen, "GCM - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 610 | #endif /* POLARSSL_GCM_C */ |
HannesTschofenig | 0:796d0f61a05b | 611 | |
HannesTschofenig | 0:796d0f61a05b | 612 | #if defined(POLARSSL_HMAC_DRBG_C) |
HannesTschofenig | 0:796d0f61a05b | 613 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_REQUEST_TOO_BIG) ) |
HannesTschofenig | 0:796d0f61a05b | 614 | snprintf( buf, buflen, "HMAC_DRBG - Too many random requested in single call" ); |
HannesTschofenig | 0:796d0f61a05b | 615 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_INPUT_TOO_BIG) ) |
HannesTschofenig | 0:796d0f61a05b | 616 | snprintf( buf, buflen, "HMAC_DRBG - Input too large (Entropy + additional)" ); |
HannesTschofenig | 0:796d0f61a05b | 617 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 618 | snprintf( buf, buflen, "HMAC_DRBG - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 619 | if( use_ret == -(POLARSSL_ERR_HMAC_DRBG_ENTROPY_SOURCE_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 620 | snprintf( buf, buflen, "HMAC_DRBG - The entropy source failed" ); |
HannesTschofenig | 0:796d0f61a05b | 621 | #endif /* POLARSSL_HMAC_DRBG_C */ |
HannesTschofenig | 0:796d0f61a05b | 622 | |
HannesTschofenig | 0:796d0f61a05b | 623 | #if defined(POLARSSL_MD2_C) |
HannesTschofenig | 0:796d0f61a05b | 624 | if( use_ret == -(POLARSSL_ERR_MD2_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 625 | snprintf( buf, buflen, "MD2 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 626 | #endif /* POLARSSL_MD2_C */ |
HannesTschofenig | 0:796d0f61a05b | 627 | |
HannesTschofenig | 0:796d0f61a05b | 628 | #if defined(POLARSSL_MD4_C) |
HannesTschofenig | 0:796d0f61a05b | 629 | if( use_ret == -(POLARSSL_ERR_MD4_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 630 | snprintf( buf, buflen, "MD4 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 631 | #endif /* POLARSSL_MD4_C */ |
HannesTschofenig | 0:796d0f61a05b | 632 | |
HannesTschofenig | 0:796d0f61a05b | 633 | #if defined(POLARSSL_MD5_C) |
HannesTschofenig | 0:796d0f61a05b | 634 | if( use_ret == -(POLARSSL_ERR_MD5_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 635 | snprintf( buf, buflen, "MD5 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 636 | #endif /* POLARSSL_MD5_C */ |
HannesTschofenig | 0:796d0f61a05b | 637 | |
HannesTschofenig | 0:796d0f61a05b | 638 | #if defined(POLARSSL_NET_C) |
HannesTschofenig | 0:796d0f61a05b | 639 | if( use_ret == -(POLARSSL_ERR_NET_UNKNOWN_HOST) ) |
HannesTschofenig | 0:796d0f61a05b | 640 | snprintf( buf, buflen, "NET - Failed to get an IP address for the given hostname" ); |
HannesTschofenig | 0:796d0f61a05b | 641 | if( use_ret == -(POLARSSL_ERR_NET_SOCKET_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 642 | snprintf( buf, buflen, "NET - Failed to open a socket" ); |
HannesTschofenig | 0:796d0f61a05b | 643 | if( use_ret == -(POLARSSL_ERR_NET_CONNECT_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 644 | snprintf( buf, buflen, "NET - The connection to the given server / port failed" ); |
HannesTschofenig | 0:796d0f61a05b | 645 | if( use_ret == -(POLARSSL_ERR_NET_BIND_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 646 | snprintf( buf, buflen, "NET - Binding of the socket failed" ); |
HannesTschofenig | 0:796d0f61a05b | 647 | if( use_ret == -(POLARSSL_ERR_NET_LISTEN_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 648 | snprintf( buf, buflen, "NET - Could not listen on the socket" ); |
HannesTschofenig | 0:796d0f61a05b | 649 | if( use_ret == -(POLARSSL_ERR_NET_ACCEPT_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 650 | snprintf( buf, buflen, "NET - Could not accept the incoming connection" ); |
HannesTschofenig | 0:796d0f61a05b | 651 | if( use_ret == -(POLARSSL_ERR_NET_RECV_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 652 | snprintf( buf, buflen, "NET - Reading information from the socket failed" ); |
HannesTschofenig | 0:796d0f61a05b | 653 | if( use_ret == -(POLARSSL_ERR_NET_SEND_FAILED) ) |
HannesTschofenig | 0:796d0f61a05b | 654 | snprintf( buf, buflen, "NET - Sending information through the socket failed" ); |
HannesTschofenig | 0:796d0f61a05b | 655 | if( use_ret == -(POLARSSL_ERR_NET_CONN_RESET) ) |
HannesTschofenig | 0:796d0f61a05b | 656 | snprintf( buf, buflen, "NET - Connection was reset by peer" ); |
HannesTschofenig | 0:796d0f61a05b | 657 | if( use_ret == -(POLARSSL_ERR_NET_WANT_READ) ) |
HannesTschofenig | 0:796d0f61a05b | 658 | snprintf( buf, buflen, "NET - Connection requires a read call" ); |
HannesTschofenig | 0:796d0f61a05b | 659 | if( use_ret == -(POLARSSL_ERR_NET_WANT_WRITE) ) |
HannesTschofenig | 0:796d0f61a05b | 660 | snprintf( buf, buflen, "NET - Connection requires a write call" ); |
HannesTschofenig | 0:796d0f61a05b | 661 | #endif /* POLARSSL_NET_C */ |
HannesTschofenig | 0:796d0f61a05b | 662 | |
HannesTschofenig | 0:796d0f61a05b | 663 | #if defined(POLARSSL_OID_C) |
HannesTschofenig | 0:796d0f61a05b | 664 | if( use_ret == -(POLARSSL_ERR_OID_NOT_FOUND) ) |
HannesTschofenig | 0:796d0f61a05b | 665 | snprintf( buf, buflen, "OID - OID is not found" ); |
HannesTschofenig | 0:796d0f61a05b | 666 | if( use_ret == -(POLARSSL_ERR_OID_BUF_TOO_SMALL) ) |
HannesTschofenig | 0:796d0f61a05b | 667 | snprintf( buf, buflen, "OID - output buffer is too small" ); |
HannesTschofenig | 0:796d0f61a05b | 668 | #endif /* POLARSSL_OID_C */ |
HannesTschofenig | 0:796d0f61a05b | 669 | |
HannesTschofenig | 0:796d0f61a05b | 670 | #if defined(POLARSSL_PADLOCK_C) |
HannesTschofenig | 0:796d0f61a05b | 671 | if( use_ret == -(POLARSSL_ERR_PADLOCK_DATA_MISALIGNED) ) |
HannesTschofenig | 0:796d0f61a05b | 672 | snprintf( buf, buflen, "PADLOCK - Input data should be aligned" ); |
HannesTschofenig | 0:796d0f61a05b | 673 | #endif /* POLARSSL_PADLOCK_C */ |
HannesTschofenig | 0:796d0f61a05b | 674 | |
HannesTschofenig | 0:796d0f61a05b | 675 | #if defined(POLARSSL_PBKDF2_C) |
HannesTschofenig | 0:796d0f61a05b | 676 | if( use_ret == -(POLARSSL_ERR_PBKDF2_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 677 | snprintf( buf, buflen, "PBKDF2 - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 678 | #endif /* POLARSSL_PBKDF2_C */ |
HannesTschofenig | 0:796d0f61a05b | 679 | |
HannesTschofenig | 0:796d0f61a05b | 680 | #if defined(POLARSSL_RIPEMD160_C) |
HannesTschofenig | 0:796d0f61a05b | 681 | if( use_ret == -(POLARSSL_ERR_RIPEMD160_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 682 | snprintf( buf, buflen, "RIPEMD160 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 683 | #endif /* POLARSSL_RIPEMD160_C */ |
HannesTschofenig | 0:796d0f61a05b | 684 | |
HannesTschofenig | 0:796d0f61a05b | 685 | #if defined(POLARSSL_SHA1_C) |
HannesTschofenig | 0:796d0f61a05b | 686 | if( use_ret == -(POLARSSL_ERR_SHA1_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 687 | snprintf( buf, buflen, "SHA1 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 688 | #endif /* POLARSSL_SHA1_C */ |
HannesTschofenig | 0:796d0f61a05b | 689 | |
HannesTschofenig | 0:796d0f61a05b | 690 | #if defined(POLARSSL_SHA256_C) |
HannesTschofenig | 0:796d0f61a05b | 691 | if( use_ret == -(POLARSSL_ERR_SHA256_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 692 | snprintf( buf, buflen, "SHA256 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 693 | #endif /* POLARSSL_SHA256_C */ |
HannesTschofenig | 0:796d0f61a05b | 694 | |
HannesTschofenig | 0:796d0f61a05b | 695 | #if defined(POLARSSL_SHA512_C) |
HannesTschofenig | 0:796d0f61a05b | 696 | if( use_ret == -(POLARSSL_ERR_SHA512_FILE_IO_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 697 | snprintf( buf, buflen, "SHA512 - Read/write error in file" ); |
HannesTschofenig | 0:796d0f61a05b | 698 | #endif /* POLARSSL_SHA512_C */ |
HannesTschofenig | 0:796d0f61a05b | 699 | |
HannesTschofenig | 0:796d0f61a05b | 700 | #if defined(POLARSSL_THREADING_C) |
HannesTschofenig | 0:796d0f61a05b | 701 | if( use_ret == -(POLARSSL_ERR_THREADING_FEATURE_UNAVAILABLE) ) |
HannesTschofenig | 0:796d0f61a05b | 702 | snprintf( buf, buflen, "THREADING - The selected feature is not available" ); |
HannesTschofenig | 0:796d0f61a05b | 703 | if( use_ret == -(POLARSSL_ERR_THREADING_BAD_INPUT_DATA) ) |
HannesTschofenig | 0:796d0f61a05b | 704 | snprintf( buf, buflen, "THREADING - Bad input parameters to function" ); |
HannesTschofenig | 0:796d0f61a05b | 705 | if( use_ret == -(POLARSSL_ERR_THREADING_MUTEX_ERROR) ) |
HannesTschofenig | 0:796d0f61a05b | 706 | snprintf( buf, buflen, "THREADING - Locking / unlocking / free failed with error code" ); |
HannesTschofenig | 0:796d0f61a05b | 707 | #endif /* POLARSSL_THREADING_C */ |
HannesTschofenig | 0:796d0f61a05b | 708 | |
HannesTschofenig | 0:796d0f61a05b | 709 | #if defined(POLARSSL_XTEA_C) |
HannesTschofenig | 0:796d0f61a05b | 710 | if( use_ret == -(POLARSSL_ERR_XTEA_INVALID_INPUT_LENGTH) ) |
HannesTschofenig | 0:796d0f61a05b | 711 | snprintf( buf, buflen, "XTEA - The data input has an invalid length" ); |
HannesTschofenig | 0:796d0f61a05b | 712 | #endif /* POLARSSL_XTEA_C */ |
HannesTschofenig | 0:796d0f61a05b | 713 | |
HannesTschofenig | 0:796d0f61a05b | 714 | if( strlen( buf ) != 0 ) |
HannesTschofenig | 0:796d0f61a05b | 715 | return; |
HannesTschofenig | 0:796d0f61a05b | 716 | |
HannesTschofenig | 0:796d0f61a05b | 717 | snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", use_ret ); |
HannesTschofenig | 0:796d0f61a05b | 718 | } |
HannesTschofenig | 0:796d0f61a05b | 719 | |
HannesTschofenig | 0:796d0f61a05b | 720 | #if defined(POLARSSL_ERROR_STRERROR_BC) |
HannesTschofenig | 0:796d0f61a05b | 721 | void error_strerror( int ret, char *buf, size_t buflen ) |
HannesTschofenig | 0:796d0f61a05b | 722 | { |
HannesTschofenig | 0:796d0f61a05b | 723 | polarssl_strerror( ret, buf, buflen ); |
HannesTschofenig | 0:796d0f61a05b | 724 | } |
HannesTschofenig | 0:796d0f61a05b | 725 | #endif /* POLARSSL_ERROR_STRERROR_BC */ |
HannesTschofenig | 0:796d0f61a05b | 726 | |
HannesTschofenig | 0:796d0f61a05b | 727 | #else /* POLARSSL_ERROR_C */ |
HannesTschofenig | 0:796d0f61a05b | 728 | |
HannesTschofenig | 0:796d0f61a05b | 729 | #if defined(POLARSSL_ERROR_STRERROR_DUMMY) |
HannesTschofenig | 0:796d0f61a05b | 730 | |
HannesTschofenig | 0:796d0f61a05b | 731 | #include <string.h> |
HannesTschofenig | 0:796d0f61a05b | 732 | |
HannesTschofenig | 0:796d0f61a05b | 733 | /* |
HannesTschofenig | 0:796d0f61a05b | 734 | * Provide an non-function in case POLARSSL_ERROR_C is not defined |
HannesTschofenig | 0:796d0f61a05b | 735 | */ |
HannesTschofenig | 0:796d0f61a05b | 736 | void polarssl_strerror( int ret, char *buf, size_t buflen ) |
HannesTschofenig | 0:796d0f61a05b | 737 | { |
HannesTschofenig | 0:796d0f61a05b | 738 | ((void) ret); |
HannesTschofenig | 0:796d0f61a05b | 739 | |
HannesTschofenig | 0:796d0f61a05b | 740 | if( buflen > 0 ) |
HannesTschofenig | 0:796d0f61a05b | 741 | buf[0] = '\0'; |
HannesTschofenig | 0:796d0f61a05b | 742 | } |
HannesTschofenig | 0:796d0f61a05b | 743 | |
HannesTschofenig | 0:796d0f61a05b | 744 | #if defined(POLARSSL_ERROR_STRERROR_BC) |
HannesTschofenig | 0:796d0f61a05b | 745 | void error_strerror( int ret, char *buf, size_t buflen ) |
HannesTschofenig | 0:796d0f61a05b | 746 | { |
HannesTschofenig | 0:796d0f61a05b | 747 | polarssl_strerror( ret, buf, buflen ); |
HannesTschofenig | 0:796d0f61a05b | 748 | } |
HannesTschofenig | 0:796d0f61a05b | 749 | #endif /* POLARSSL_ERROR_STRERROR_BC */ |
HannesTschofenig | 0:796d0f61a05b | 750 | #endif /* POLARSSL_ERROR_STRERROR_DUMMY */ |
HannesTschofenig | 0:796d0f61a05b | 751 | |
HannesTschofenig | 0:796d0f61a05b | 752 | #endif /* POLARSSL_ERROR_C */ |
HannesTschofenig | 0:796d0f61a05b | 753 | |
HannesTschofenig | 0:796d0f61a05b | 754 |