s2n_crypto.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 "crypto/s2n_certificate.h"
  17. #include "crypto/s2n_cipher.h"
  18. #include "crypto/s2n_dhe.h"
  19. #include "crypto/s2n_ecc_evp.h"
  20. #include "crypto/s2n_hash.h"
  21. #include "crypto/s2n_hmac.h"
  22. #include "crypto/s2n_pkey.h"
  23. #include "crypto/s2n_signature.h"
  24. #include "crypto/s2n_tls13_keys.h"
  25. #include "tls/s2n_crypto_constants.h"
  26. #include "tls/s2n_kem.h"
  27. #include "tls/s2n_signature_scheme.h"
  28. #include "tls/s2n_tls13_secrets.h"
  29. struct s2n_kex_parameters {
  30. struct s2n_dh_params server_dh_params;
  31. struct s2n_ecc_evp_params server_ecc_evp_params;
  32. const struct s2n_ecc_named_curve *mutually_supported_curves[S2N_ECC_EVP_SUPPORTED_CURVES_COUNT];
  33. struct s2n_ecc_evp_params client_ecc_evp_params;
  34. struct s2n_kem_group_params server_kem_group_params;
  35. struct s2n_kem_group_params client_kem_group_params;
  36. const struct s2n_kem_group *mutually_supported_kem_groups[S2N_SUPPORTED_KEM_GROUPS_COUNT];
  37. struct s2n_kem_params kem_params;
  38. struct s2n_blob client_key_exchange_message;
  39. struct s2n_blob client_pq_kem_extension;
  40. };
  41. struct s2n_tls12_secrets {
  42. uint8_t rsa_premaster_secret[S2N_TLS_SECRET_LEN];
  43. uint8_t master_secret[S2N_TLS_SECRET_LEN];
  44. };
  45. struct s2n_secrets {
  46. union {
  47. struct s2n_tls12_secrets tls12;
  48. struct s2n_tls13_secrets tls13;
  49. } version;
  50. s2n_extract_secret_type_t extract_secret_type;
  51. };
  52. struct s2n_crypto_parameters {
  53. struct s2n_cipher_suite *cipher_suite;
  54. struct s2n_session_key client_key;
  55. struct s2n_session_key server_key;
  56. struct s2n_hmac_state client_record_mac;
  57. struct s2n_hmac_state server_record_mac;
  58. uint8_t client_implicit_iv[S2N_TLS_MAX_IV_LEN];
  59. uint8_t server_implicit_iv[S2N_TLS_MAX_IV_LEN];
  60. uint8_t client_sequence_number[S2N_TLS_SEQUENCE_NUM_LEN];
  61. uint8_t server_sequence_number[S2N_TLS_SEQUENCE_NUM_LEN];
  62. };
  63. S2N_RESULT s2n_crypto_parameters_new(struct s2n_crypto_parameters **params);
  64. S2N_RESULT s2n_crypto_parameters_wipe(struct s2n_crypto_parameters *params);
  65. S2N_CLEANUP_RESULT s2n_crypto_parameters_free(struct s2n_crypto_parameters **params);
  66. S2N_RESULT s2n_crypto_parameters_switch(struct s2n_connection *conn);