s2n_alerts.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License").
  5. * You may not use this file except in compliance with the License.
  6. * A copy of the License is located at
  7. *
  8. * http://aws.amazon.com/apache2.0
  9. *
  10. * or in the "license" file accompanying this file. This file is distributed
  11. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12. * express or implied. See the License for the specific language governing
  13. * permissions and limitations under the License.
  14. */
  15. #pragma once
  16. #include <stdint.h>
  17. #include "tls/s2n_connection.h"
  18. #define S2N_TLS_ALERT_LEVEL_WARNING 1
  19. #define S2N_TLS_ALERT_LEVEL_FATAL 2
  20. typedef enum {
  21. /*
  22. *= https://tools.ietf.org/rfc/rfc8446#section-6
  23. *# enum {
  24. *# close_notify(0),
  25. *# unexpected_message(10),
  26. *# bad_record_mac(20),
  27. *# record_overflow(22),
  28. *# handshake_failure(40),
  29. */
  30. S2N_TLS_ALERT_CLOSE_NOTIFY = 0,
  31. S2N_TLS_ALERT_UNEXPECTED_MESSAGE = 10,
  32. S2N_TLS_ALERT_BAD_RECORD_MAC = 20,
  33. S2N_TLS_ALERT_RECORD_OVERFLOW = 22,
  34. S2N_TLS_ALERT_HANDSHAKE_FAILURE = 40,
  35. /*
  36. *= https://tools.ietf.org/rfc/rfc8446#section-6
  37. *# bad_certificate(42),
  38. *# unsupported_certificate(43),
  39. *# certificate_revoked(44),
  40. *# certificate_expired(45),
  41. *# certificate_unknown(46),
  42. */
  43. S2N_TLS_ALERT_BAD_CERTIFICATE = 42,
  44. S2N_TLS_ALERT_UNSUPPORTED_CERTIFICATE = 43,
  45. S2N_TLS_ALERT_CERTIFICATE_REVOKED = 44,
  46. S2N_TLS_ALERT_CERTIFICATE_EXPIRED = 45,
  47. S2N_TLS_ALERT_CERTIFICATE_UNKNOWN = 46,
  48. /*
  49. *= https://tools.ietf.org/rfc/rfc8446#section-6
  50. *# illegal_parameter(47),
  51. *# unknown_ca(48),
  52. *# access_denied(49),
  53. *# decode_error(50),
  54. *# decrypt_error(51),
  55. */
  56. S2N_TLS_ALERT_ILLEGAL_PARAMETER = 47,
  57. S2N_TLS_ALERT_UNKNOWN_CA = 48,
  58. S2N_TLS_ALERT_ACCESS_DENIED = 49,
  59. S2N_TLS_ALERT_DECODE_ERROR = 50,
  60. S2N_TLS_ALERT_DECRYPT_ERROR = 51,
  61. /*
  62. *= https://tools.ietf.org/rfc/rfc8446#section-6
  63. *# protocol_version(70),
  64. *# insufficient_security(71),
  65. *# internal_error(80),
  66. *# inappropriate_fallback(86),
  67. *# user_canceled(90),
  68. */
  69. S2N_TLS_ALERT_PROTOCOL_VERSION = 70,
  70. S2N_TLS_ALERT_INSUFFICIENT_SECURITY = 71,
  71. S2N_TLS_ALERT_INTERNAL_ERROR = 80,
  72. S2N_TLS_ALERT_INAPPROPRIATE_FALLBACK = 86,
  73. S2N_TLS_ALERT_USER_CANCELED = 90,
  74. /*
  75. *= https://tools.ietf.org/rfc/rfc5246#section-7.2
  76. *# no_renegotiation(100),
  77. */
  78. S2N_TLS_ALERT_NO_RENEGOTIATION = 100,
  79. /*
  80. *= https://tools.ietf.org/rfc/rfc8446#section-6
  81. *# missing_extension(109),
  82. *# unsupported_extension(110),
  83. *# unrecognized_name(112),
  84. *# bad_certificate_status_response(113),
  85. *# unknown_psk_identity(115),
  86. */
  87. S2N_TLS_ALERT_MISSING_EXTENSION = 109,
  88. S2N_TLS_ALERT_UNSUPPORTED_EXTENSION = 110,
  89. S2N_TLS_ALERT_UNRECOGNIZED_NAME = 112,
  90. S2N_TLS_ALERT_BAD_CERTIFICATE_STATUS_RESPONSE = 113,
  91. S2N_TLS_ALERT_UNKNOWN_PSK_IDENTITY = 115,
  92. /*
  93. *= https://tools.ietf.org/rfc/rfc8446#section-6
  94. *# certificate_required(116),
  95. *# no_application_protocol(120),
  96. *# (255)
  97. *# } AlertDescription;
  98. */
  99. S2N_TLS_ALERT_CERTIFICATE_REQUIRED = 116,
  100. S2N_TLS_ALERT_NO_APPLICATION_PROTOCOL = 120,
  101. } s2n_tls_alert_code;
  102. int s2n_process_alert_fragment(struct s2n_connection *conn);
  103. int s2n_queue_reader_unsupported_protocol_version_alert(struct s2n_connection *conn);
  104. int s2n_queue_reader_handshake_failure_alert(struct s2n_connection *conn);
  105. S2N_RESULT s2n_queue_reader_no_renegotiation_alert(struct s2n_connection *conn);
  106. S2N_RESULT s2n_alerts_write_error_or_close_notify(struct s2n_connection *conn);
  107. S2N_RESULT s2n_alerts_write_warning(struct s2n_connection *conn);