error-ssl.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /* error-ssl.h
  2. *
  3. * Copyright (C) 2006-2024 wolfSSL Inc.
  4. *
  5. * This file is part of wolfSSL.
  6. *
  7. * wolfSSL is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * wolfSSL is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
  20. */
  21. #ifndef WOLFSSL_ERROR_H
  22. #define WOLFSSL_ERROR_H
  23. #include <wolfssl/wolfcrypt/error-crypt.h> /* pull in wolfCrypt errors */
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #ifdef WOLFSSL_DEBUG_TRACE_ERROR_CODES_H
  28. #include <wolfssl/debug-untrace-error-codes.h>
  29. #endif
  30. enum wolfSSL_ErrorCodes {
  31. WOLFSSL_FATAL_ERROR = -1, /* must be -1 for backward compat. */
  32. /* negative counterparts to namesake positive constants in ssl.h */
  33. WOLFSSL_ERROR_WANT_READ_E = -2,
  34. WOLFSSL_ERROR_WANT_WRITE_E = -3,
  35. WOLFSSL_ERROR_WANT_X509_LOOKUP_E = -4,
  36. WOLFSSL_ERROR_SYSCALL_E = -5,
  37. WOLFSSL_ERROR_ZERO_RETURN_E = -6,
  38. WOLFSSL_ERROR_WANT_CONNECT_E = -7,
  39. WOLFSSL_ERROR_WANT_ACCEPT_E = -8,
  40. WOLFSSL_FIRST_E = -301, /* start of native TLS codes */
  41. INPUT_CASE_ERROR = -301, /* process input state error */
  42. PREFIX_ERROR = -302, /* bad index to key rounds */
  43. MEMORY_ERROR = -303, /* out of memory */
  44. VERIFY_FINISHED_ERROR = -304, /* verify problem on finished */
  45. VERIFY_MAC_ERROR = -305, /* verify mac problem */
  46. PARSE_ERROR = -306, /* parse error on header */
  47. UNKNOWN_HANDSHAKE_TYPE = -307, /* weird handshake type */
  48. SOCKET_ERROR_E = -308, /* error state on socket */
  49. SOCKET_NODATA = -309, /* expected data, not there */
  50. INCOMPLETE_DATA = -310, /* don't have enough data to
  51. complete task */
  52. UNKNOWN_RECORD_TYPE = -311, /* unknown type in record hdr */
  53. DECRYPT_ERROR = -312, /* error during decryption */
  54. FATAL_ERROR = -313, /* recvd alert fatal error */
  55. ENCRYPT_ERROR = -314, /* error during encryption */
  56. FREAD_ERROR = -315, /* fread problem */
  57. NO_PEER_KEY = -316, /* need peer's key */
  58. NO_PRIVATE_KEY = -317, /* need the private key */
  59. RSA_PRIVATE_ERROR = -318, /* error during rsa priv op */
  60. NO_DH_PARAMS = -319, /* server missing DH params */
  61. BUILD_MSG_ERROR = -320, /* build message failure */
  62. BAD_HELLO = -321, /* client hello malformed */
  63. DOMAIN_NAME_MISMATCH = -322, /* peer subject name mismatch */
  64. WANT_READ = -323, /* want read, call again */
  65. NOT_READY_ERROR = -324, /* handshake layer not ready */
  66. IPADDR_MISMATCH = -325, /* peer ip address mismatch */
  67. VERSION_ERROR = -326, /* record layer version error */
  68. WANT_WRITE = -327, /* want write, call again */
  69. BUFFER_ERROR = -328, /* malformed buffer input */
  70. VERIFY_CERT_ERROR = -329, /* verify cert error */
  71. VERIFY_SIGN_ERROR = -330, /* verify sign error */
  72. CLIENT_ID_ERROR = -331, /* psk client identity error */
  73. SERVER_HINT_ERROR = -332, /* psk server hint error */
  74. PSK_KEY_ERROR = -333, /* psk key error */
  75. GETTIME_ERROR = -337, /* gettimeofday failed ??? */
  76. GETITIMER_ERROR = -338, /* getitimer failed ??? */
  77. SIGACT_ERROR = -339, /* sigaction failed ??? */
  78. SETITIMER_ERROR = -340, /* setitimer failed ??? */
  79. LENGTH_ERROR = -341, /* record layer length error */
  80. PEER_KEY_ERROR = -342, /* can't decode peer key */
  81. ZERO_RETURN = -343, /* peer sent close notify */
  82. SIDE_ERROR = -344, /* wrong client/server type */
  83. NO_PEER_CERT = -345, /* peer didn't send key */
  84. ECC_CURVETYPE_ERROR = -350, /* Bad ECC Curve Type */
  85. ECC_CURVE_ERROR = -351, /* Bad ECC Curve */
  86. ECC_PEERKEY_ERROR = -352, /* Bad Peer ECC Key */
  87. ECC_MAKEKEY_ERROR = -353, /* Bad Make ECC Key */
  88. ECC_EXPORT_ERROR = -354, /* Bad ECC Export Key */
  89. ECC_SHARED_ERROR = -355, /* Bad ECC Shared Secret */
  90. NOT_CA_ERROR = -357, /* Not a CA cert error */
  91. BAD_CERT_MANAGER_ERROR = -359, /* Bad Cert Manager */
  92. OCSP_CERT_REVOKED = -360, /* OCSP Certificate revoked */
  93. CRL_CERT_REVOKED = -361, /* CRL Certificate revoked */
  94. CRL_MISSING = -362, /* CRL Not loaded */
  95. MONITOR_SETUP_E = -363, /* CRL Monitor setup error */
  96. THREAD_CREATE_E = -364, /* Thread Create Error */
  97. OCSP_NEED_URL = -365, /* OCSP need an URL for lookup */
  98. OCSP_CERT_UNKNOWN = -366, /* OCSP responder doesn't know */
  99. OCSP_LOOKUP_FAIL = -367, /* OCSP lookup not successful */
  100. MAX_CHAIN_ERROR = -368, /* max chain depth exceeded */
  101. COOKIE_ERROR = -369, /* dtls cookie error */
  102. SEQUENCE_ERROR = -370, /* dtls sequence error */
  103. SUITES_ERROR = -371, /* suites pointer error */
  104. OUT_OF_ORDER_E = -373, /* out of order message */
  105. BAD_KEA_TYPE_E = -374, /* bad KEA type found */
  106. SANITY_CIPHER_E = -375, /* sanity check on cipher error */
  107. RECV_OVERFLOW_E = -376, /* RXCB returned more than read */
  108. GEN_COOKIE_E = -377, /* Generate Cookie Error */
  109. NO_PEER_VERIFY = -378, /* Need peer cert verify Error */
  110. FWRITE_ERROR = -379, /* fwrite problem */
  111. CACHE_MATCH_ERROR = -380, /* Cache hdr match error */
  112. UNKNOWN_SNI_HOST_NAME_E = -381, /* Unrecognized host name Error */
  113. UNKNOWN_MAX_FRAG_LEN_E = -382, /* Unrecognized max frag len Error */
  114. KEYUSE_SIGNATURE_E = -383, /* KeyUse digSignature error */
  115. KEYUSE_ENCIPHER_E = -385, /* KeyUse keyEncipher error */
  116. EXTKEYUSE_AUTH_E = -386, /* ExtKeyUse server|client_auth */
  117. SEND_OOB_READ_E = -387, /* Send Cb out of bounds read */
  118. SECURE_RENEGOTIATION_E = -388, /* Invalid Renegotiation Info */
  119. SESSION_TICKET_LEN_E = -389, /* Session Ticket too large */
  120. SESSION_TICKET_EXPECT_E = -390, /* Session Ticket missing */
  121. SCR_DIFFERENT_CERT_E = -391, /* SCR Different cert error */
  122. SESSION_SECRET_CB_E = -392, /* Session secret Cb fcn failure */
  123. NO_CHANGE_CIPHER_E = -393, /* Finished before change cipher */
  124. SANITY_MSG_E = -394, /* Sanity check on msg order error */
  125. DUPLICATE_MSG_E = -395, /* Duplicate message error */
  126. SNI_UNSUPPORTED = -396, /* SSL 3.0 does not support SNI */
  127. SOCKET_PEER_CLOSED_E = -397, /* Underlying transport closed */
  128. BAD_TICKET_KEY_CB_SZ = -398, /* Bad session ticket key cb size */
  129. BAD_TICKET_MSG_SZ = -399, /* Bad session ticket msg size */
  130. BAD_TICKET_ENCRYPT = -400, /* Bad user ticket encrypt */
  131. DH_KEY_SIZE_E = -401, /* DH Key too small */
  132. SNI_ABSENT_ERROR = -402, /* No SNI request. */
  133. RSA_SIGN_FAULT = -403, /* RSA Sign fault */
  134. HANDSHAKE_SIZE_ERROR = -404, /* Handshake message too large */
  135. UNKNOWN_ALPN_PROTOCOL_NAME_E = -405, /* Unrecognized protocol name Error*/
  136. BAD_CERTIFICATE_STATUS_ERROR = -406, /* Bad certificate status message */
  137. OCSP_INVALID_STATUS = -407, /* Invalid OCSP Status */
  138. OCSP_WANT_READ = -408, /* OCSP callback response WOLFSSL_CBIO_ERR_WANT_READ */
  139. RSA_KEY_SIZE_E = -409, /* RSA key too small */
  140. ECC_KEY_SIZE_E = -410, /* ECC key too small */
  141. DTLS_EXPORT_VER_E = -411, /* export version error */
  142. INPUT_SIZE_E = -412, /* input size too big error */
  143. CTX_INIT_MUTEX_E = -413, /* initialize ctx mutex error */
  144. EXT_MASTER_SECRET_NEEDED_E = -414, /* need EMS enabled to resume */
  145. DTLS_POOL_SZ_E = -415, /* exceeded DTLS pool size */
  146. DECODE_E = -416, /* decode handshake message error */
  147. HTTP_TIMEOUT = -417, /* HTTP timeout for OCSP or CRL req */
  148. WRITE_DUP_READ_E = -418, /* Write dup write side can't read */
  149. WRITE_DUP_WRITE_E = -419, /* Write dup read side can't write */
  150. INVALID_CERT_CTX_E = -420, /* TLS cert ctx not matching */
  151. BAD_KEY_SHARE_DATA = -421, /* Key Share data invalid */
  152. MISSING_HANDSHAKE_DATA = -422, /* Handshake message missing data */
  153. BAD_BINDER = -423, /* Binder does not match */
  154. EXT_NOT_ALLOWED = -424, /* Extension not allowed in msg */
  155. INVALID_PARAMETER = -425, /* Security parameter invalid */
  156. MCAST_HIGHWATER_CB_E = -426, /* Multicast highwater cb err */
  157. ALERT_COUNT_E = -427, /* Alert Count exceeded err */
  158. EXT_MISSING = -428, /* Required extension not found */
  159. UNSUPPORTED_EXTENSION = -429, /* TLSX not requested by client */
  160. PRF_MISSING = -430, /* PRF not compiled in */
  161. DTLS_RETX_OVER_TX = -431, /* Retransmit DTLS flight over */
  162. DH_PARAMS_NOT_FFDHE_E = -432, /* DH params from server not FFDHE */
  163. TCA_INVALID_ID_TYPE = -433, /* TLSX TCA ID type invalid */
  164. TCA_ABSENT_ERROR = -434, /* TLSX TCA ID no response */
  165. TSIP_MAC_DIGSZ_E = -435, /* Invalid MAC size for TSIP */
  166. CLIENT_CERT_CB_ERROR = -436, /* Client cert callback error */
  167. SSL_SHUTDOWN_ALREADY_DONE_E = -437, /* Shutdown called redundantly */
  168. TLS13_SECRET_CB_E = -438, /* TLS1.3 secret Cb fcn failure */
  169. DTLS_SIZE_ERROR = -439, /* Trying to send too much data */
  170. NO_CERT_ERROR = -440, /* TLS1.3 - no cert set error */
  171. APP_DATA_READY = -441, /* DTLS1.2 application data ready for read */
  172. TOO_MUCH_EARLY_DATA = -442, /* Too much Early data */
  173. SOCKET_FILTERED_E = -443, /* Session stopped by network filter */
  174. HTTP_RECV_ERR = -444, /* HTTP Receive error */
  175. HTTP_HEADER_ERR = -445, /* HTTP Header error */
  176. HTTP_PROTO_ERR = -446, /* HTTP Protocol error */
  177. HTTP_STATUS_ERR = -447, /* HTTP Status error */
  178. HTTP_VERSION_ERR = -448, /* HTTP Version error */
  179. HTTP_APPSTR_ERR = -449, /* HTTP Application string error */
  180. UNSUPPORTED_PROTO_VERSION = -450, /* bad/unsupported protocol version*/
  181. FALCON_KEY_SIZE_E = -451, /* Wrong key size for Falcon. */
  182. QUIC_TP_MISSING_E = -452, /* QUIC transport parameter missing */
  183. DILITHIUM_KEY_SIZE_E = -453, /* Wrong key size for Dilithium. */
  184. DTLS_CID_ERROR = -454, /* Wrong or missing CID */
  185. DTLS_TOO_MANY_FRAGMENTS_E = -455, /* Received too many fragments */
  186. QUIC_WRONG_ENC_LEVEL = -456, /* QUIC data received on wrong encryption level */
  187. DUPLICATE_TLS_EXT_E = -457, /* Duplicate TLS extension in msg. */
  188. /* legacy CyaSSL compat layer error codes */
  189. WOLFSSL_ALPN_NOT_FOUND = -458, /* TLS extension not found */
  190. WOLFSSL_BAD_CERTTYPE = -459, /* Certificate type not supported */
  191. WOLFSSL_BAD_STAT = -460, /* not used */
  192. WOLFSSL_BAD_PATH = -461, /* No certificates found at designated path */
  193. WOLFSSL_BAD_FILETYPE = -462, /* Data format not supported */
  194. WOLFSSL_BAD_FILE = -463, /* Input/output error on file */
  195. WOLFSSL_NOT_IMPLEMENTED = -464, /* Function not implemented */
  196. WOLFSSL_UNKNOWN = -465, /* Unknown algorithm (EVP) */
  197. /* negotiation parameter errors */
  198. UNSUPPORTED_SUITE = -500, /* unsupported cipher suite */
  199. MATCH_SUITE_ERROR = -501, /* can't match cipher suite */
  200. COMPRESSION_ERROR = -502, /* compression mismatch */
  201. KEY_SHARE_ERROR = -503, /* key share mismatch */
  202. POST_HAND_AUTH_ERROR = -504, /* client won't do post-hand auth */
  203. HRR_COOKIE_ERROR = -505, /* HRR msg cookie mismatch */
  204. UNSUPPORTED_CERTIFICATE = -506, /* unsupported certificate type */
  205. WOLFSSL_LAST_E = -506
  206. };
  207. /* I/O Callback default errors */
  208. enum IOerrors {
  209. WOLFSSL_CBIO_ERR_GENERAL = -1, /* general unexpected err */
  210. WOLFSSL_CBIO_ERR_WANT_READ = -2, /* need to call read again */
  211. WOLFSSL_CBIO_ERR_WANT_WRITE = -2, /* need to call write again */
  212. WOLFSSL_CBIO_ERR_CONN_RST = -3, /* connection reset */
  213. WOLFSSL_CBIO_ERR_ISR = -4, /* interrupt */
  214. WOLFSSL_CBIO_ERR_CONN_CLOSE = -5, /* connection closed or epipe */
  215. WOLFSSL_CBIO_ERR_TIMEOUT = -6 /* socket timeout */
  216. };
  217. #if defined(WOLFSSL_CALLBACKS) || defined(OPENSSL_EXTRA)
  218. enum {
  219. MIN_PARAM_ERR = UNSUPPORTED_SUITE,
  220. MAX_PARAM_ERR = MIN_PARAM_ERR - 10
  221. };
  222. #endif
  223. WOLFSSL_LOCAL
  224. void SetErrorString(int err, char* buff);
  225. #if defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES) && \
  226. (defined(BUILDING_WOLFSSL) || \
  227. defined(WOLFSSL_DEBUG_TRACE_ERROR_CODES_ALWAYS))
  228. #include <wolfssl/debug-trace-error-codes.h>
  229. #endif
  230. #ifdef __cplusplus
  231. } /* extern "C" */
  232. #endif
  233. #endif /* wolfSSL_ERROR_H */