s2n_kex.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "tls/s2n_kex_data.h"
  19. #include "utils/s2n_result.h"
  20. struct s2n_kex {
  21. bool is_ephemeral;
  22. const struct s2n_kex *hybrid[2];
  23. S2N_RESULT (*connection_supported)(const struct s2n_cipher_suite *cipher_suite, struct s2n_connection *conn, bool *is_supported);
  24. S2N_RESULT (*configure_connection)(const struct s2n_cipher_suite *cipher_suite, struct s2n_connection *conn);
  25. int (*server_key_recv_read_data)(struct s2n_connection *conn, struct s2n_blob *data_to_verify, struct s2n_kex_raw_server_data *kex_data);
  26. int (*server_key_recv_parse_data)(struct s2n_connection *conn, struct s2n_kex_raw_server_data *kex_data);
  27. int (*server_key_send)(struct s2n_connection *conn, struct s2n_blob *data_to_sign);
  28. int (*client_key_recv)(struct s2n_connection *conn, struct s2n_blob *shared_key);
  29. int (*client_key_send)(struct s2n_connection *conn, struct s2n_blob *shared_key);
  30. int (*prf)(struct s2n_connection *conn, struct s2n_blob *premaster_secret);
  31. };
  32. extern const struct s2n_kex s2n_kem;
  33. extern const struct s2n_kex s2n_rsa;
  34. extern const struct s2n_kex s2n_dhe;
  35. extern const struct s2n_kex s2n_ecdhe;
  36. extern const struct s2n_kex s2n_hybrid_ecdhe_kem;
  37. S2N_RESULT s2n_kex_supported(const struct s2n_cipher_suite *cipher_suite, struct s2n_connection *conn, bool *is_supported);
  38. S2N_RESULT s2n_configure_kex(const struct s2n_cipher_suite *cipher_suite, struct s2n_connection *conn);
  39. S2N_RESULT s2n_kex_is_ephemeral(const struct s2n_kex *kex, bool *is_ephemeral);
  40. S2N_RESULT s2n_kex_server_key_recv_read_data(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_blob *data_to_verify,
  41. struct s2n_kex_raw_server_data *raw_server_data);
  42. S2N_RESULT s2n_kex_server_key_recv_parse_data(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_kex_raw_server_data *raw_server_data);
  43. S2N_RESULT s2n_kex_server_key_send(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_blob *data_to_sign);
  44. S2N_RESULT s2n_kex_client_key_recv(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_blob *shared_key);
  45. S2N_RESULT s2n_kex_client_key_send(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_blob *shared_key);
  46. S2N_RESULT s2n_kex_tls_prf(const struct s2n_kex *kex, struct s2n_connection *conn, struct s2n_blob *premaster_secret);
  47. bool s2n_kex_includes(const struct s2n_kex *kex, const struct s2n_kex *query);