s2n_tls.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 <stdbool.h>
  17. #include <stdint.h>
  18. #include "tls/s2n_connection.h"
  19. extern uint8_t s2n_unknown_protocol_version;
  20. extern uint8_t s2n_highest_protocol_version;
  21. int s2n_flush(struct s2n_connection *conn, s2n_blocked_status *more);
  22. S2N_RESULT s2n_client_hello_request_validate(struct s2n_connection *conn);
  23. S2N_RESULT s2n_client_hello_request_recv(struct s2n_connection *conn);
  24. int s2n_client_hello_send(struct s2n_connection *conn);
  25. int s2n_client_hello_recv(struct s2n_connection *conn);
  26. int s2n_establish_session(struct s2n_connection *conn);
  27. int s2n_sslv2_client_hello_recv(struct s2n_connection *conn);
  28. int s2n_server_hello_retry_send(struct s2n_connection *conn);
  29. int s2n_server_hello_retry_recv(struct s2n_connection *conn);
  30. int s2n_server_hello_write_message(struct s2n_connection *conn);
  31. int s2n_server_hello_send(struct s2n_connection *conn);
  32. int s2n_server_hello_recv(struct s2n_connection *conn);
  33. int s2n_encrypted_extensions_send(struct s2n_connection *conn);
  34. int s2n_encrypted_extensions_recv(struct s2n_connection *conn);
  35. int s2n_next_protocol_send(struct s2n_connection *conn);
  36. int s2n_next_protocol_recv(struct s2n_connection *conn);
  37. int s2n_server_cert_send(struct s2n_connection *conn);
  38. int s2n_server_cert_recv(struct s2n_connection *conn);
  39. int s2n_server_status_send(struct s2n_connection *conn);
  40. int s2n_server_status_recv(struct s2n_connection *conn);
  41. int s2n_server_key_send(struct s2n_connection *conn);
  42. int s2n_server_key_recv(struct s2n_connection *conn);
  43. int s2n_cert_req_recv(struct s2n_connection *conn);
  44. int s2n_cert_req_send(struct s2n_connection *conn);
  45. int s2n_tls13_cert_req_send(struct s2n_connection *conn);
  46. int s2n_tls13_cert_req_recv(struct s2n_connection *conn);
  47. int s2n_server_done_send(struct s2n_connection *conn);
  48. int s2n_server_done_recv(struct s2n_connection *conn);
  49. int s2n_client_cert_recv(struct s2n_connection *conn);
  50. int s2n_client_cert_send(struct s2n_connection *conn);
  51. int s2n_client_key_send(struct s2n_connection *conn);
  52. int s2n_client_key_recv(struct s2n_connection *conn);
  53. int s2n_client_cert_verify_recv(struct s2n_connection *conn);
  54. int s2n_client_cert_verify_send(struct s2n_connection *conn);
  55. int s2n_tls13_cert_verify_recv(struct s2n_connection *conn);
  56. int s2n_tls13_cert_verify_send(struct s2n_connection *conn);
  57. int s2n_server_nst_send(struct s2n_connection *conn);
  58. int s2n_server_nst_recv(struct s2n_connection *conn);
  59. S2N_RESULT s2n_tls13_server_nst_send(struct s2n_connection *conn, s2n_blocked_status *blocked);
  60. S2N_RESULT s2n_tls13_server_nst_write(struct s2n_connection *conn, struct s2n_stuffer *output);
  61. S2N_RESULT s2n_tls13_server_nst_recv(struct s2n_connection *conn, struct s2n_stuffer *input);
  62. int s2n_ccs_send(struct s2n_connection *conn);
  63. int s2n_basic_ccs_recv(struct s2n_connection *conn);
  64. int s2n_server_ccs_recv(struct s2n_connection *conn);
  65. int s2n_client_ccs_recv(struct s2n_connection *conn);
  66. int s2n_client_finished_send(struct s2n_connection *conn);
  67. int s2n_client_finished_recv(struct s2n_connection *conn);
  68. int s2n_server_finished_send(struct s2n_connection *conn);
  69. int s2n_server_finished_recv(struct s2n_connection *conn);
  70. int s2n_tls13_client_finished_send(struct s2n_connection *conn);
  71. int s2n_tls13_client_finished_recv(struct s2n_connection *conn);
  72. int s2n_tls13_server_finished_send(struct s2n_connection *conn);
  73. int s2n_tls13_server_finished_recv(struct s2n_connection *conn);
  74. int s2n_end_of_early_data_send(struct s2n_connection *conn);
  75. int s2n_end_of_early_data_recv(struct s2n_connection *conn);
  76. int s2n_process_client_hello(struct s2n_connection *conn);
  77. int s2n_handshake_write_header(struct s2n_stuffer *out, uint8_t message_type);
  78. int s2n_handshake_finish_header(struct s2n_stuffer *out);
  79. S2N_RESULT s2n_handshake_parse_header(struct s2n_stuffer *io, uint8_t *message_type, uint32_t *length);
  80. int s2n_read_full_record(struct s2n_connection *conn, uint8_t *record_type, int *isSSLv2);
  81. extern uint16_t mfl_code_to_length[5];
  82. #define s2n_server_received_server_name(conn) ((conn)->server_name[0] != 0)
  83. #define s2n_server_can_send_ec_point_formats(conn) \
  84. ((conn)->ec_point_formats)
  85. #define s2n_server_can_send_ocsp(conn) ((conn)->mode == S2N_SERVER \
  86. && (conn)->status_type == S2N_STATUS_REQUEST_OCSP \
  87. && (conn)->handshake_params.our_chain_and_key \
  88. && (conn)->handshake_params.our_chain_and_key->ocsp_status.size > 0)
  89. #define s2n_server_sent_ocsp(conn) ((conn)->mode == S2N_CLIENT \
  90. && (conn)->status_type == S2N_STATUS_REQUEST_OCSP)
  91. #define s2n_server_can_send_sct_list(conn) ((conn)->mode == S2N_SERVER \
  92. && (conn)->ct_level_requested == S2N_CT_SUPPORT_REQUEST \
  93. && (conn)->handshake_params.our_chain_and_key \
  94. && (conn)->handshake_params.our_chain_and_key->sct_list.size > 0)
  95. #define s2n_server_sending_nst(conn) ((conn)->config->use_tickets \
  96. && (conn)->session_ticket_status == S2N_NEW_TICKET)