s2n_early_data.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "api/s2n.h"
  17. #include "tls/s2n_crypto_constants.h"
  18. #include "utils/s2n_blob.h"
  19. #include "utils/s2n_result.h"
  20. struct s2n_psk;
  21. typedef enum {
  22. S2N_UNKNOWN_EARLY_DATA_STATE = 0,
  23. S2N_EARLY_DATA_REQUESTED,
  24. S2N_EARLY_DATA_NOT_REQUESTED,
  25. S2N_EARLY_DATA_ACCEPTED,
  26. S2N_EARLY_DATA_REJECTED,
  27. S2N_END_OF_EARLY_DATA,
  28. S2N_EARLY_DATA_STATES_COUNT
  29. } s2n_early_data_state;
  30. S2N_RESULT s2n_connection_set_early_data_state(struct s2n_connection *conn, s2n_early_data_state state);
  31. struct s2n_early_data_config {
  32. uint32_t max_early_data_size;
  33. uint8_t protocol_version;
  34. struct s2n_cipher_suite *cipher_suite;
  35. struct s2n_blob application_protocol;
  36. struct s2n_blob context;
  37. };
  38. S2N_CLEANUP_RESULT s2n_early_data_config_free(struct s2n_early_data_config *config);
  39. S2N_RESULT s2n_early_data_config_clone(struct s2n_psk *new_psk, struct s2n_early_data_config *old_config);
  40. struct s2n_offered_early_data {
  41. struct s2n_connection *conn;
  42. };
  43. bool s2n_early_data_is_valid_for_connection(struct s2n_connection *conn);
  44. S2N_RESULT s2n_early_data_accept_or_reject(struct s2n_connection *conn);
  45. S2N_RESULT s2n_early_data_get_server_max_size(struct s2n_connection *conn, uint32_t *max_early_data_size);
  46. S2N_RESULT s2n_early_data_record_bytes(struct s2n_connection *conn, ssize_t data_len);
  47. S2N_RESULT s2n_early_data_validate_send(struct s2n_connection *conn, uint32_t bytes_to_send);
  48. S2N_RESULT s2n_early_data_validate_recv(struct s2n_connection *conn);
  49. bool s2n_early_data_is_trial_decryption_allowed(struct s2n_connection *conn, uint8_t record_type);
  50. int s2n_connection_set_early_data_expected(struct s2n_connection *conn);
  51. int s2n_connection_set_end_of_early_data(struct s2n_connection *conn);