s2n_tls13_secrets.h 2.1 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 "tls/s2n_crypto_constants.h"
  17. #include "tls/s2n_quic_support.h"
  18. #include "utils/s2n_blob.h"
  19. #include "utils/s2n_result.h"
  20. /* tls/s2n_tls13_secrets should eventually replace crypto/s2n_tls13_keys.h */
  21. #include "crypto/s2n_tls13_keys.h"
  22. typedef enum {
  23. S2N_NONE_SECRET = 0,
  24. S2N_EARLY_SECRET,
  25. S2N_HANDSHAKE_SECRET,
  26. S2N_MASTER_SECRET
  27. } s2n_extract_secret_type_t;
  28. struct s2n_tls13_secrets {
  29. uint8_t extract_secret[S2N_TLS13_SECRET_MAX_LEN];
  30. uint8_t client_early_secret[S2N_TLS13_SECRET_MAX_LEN];
  31. uint8_t client_handshake_secret[S2N_TLS13_SECRET_MAX_LEN];
  32. uint8_t server_handshake_secret[S2N_TLS13_SECRET_MAX_LEN];
  33. uint8_t client_app_secret[S2N_TLS13_SECRET_MAX_LEN];
  34. uint8_t server_app_secret[S2N_TLS13_SECRET_MAX_LEN];
  35. uint8_t resumption_master_secret[S2N_TLS13_SECRET_MAX_LEN];
  36. uint8_t exporter_master_secret[S2N_TLS13_SECRET_MAX_LEN];
  37. s2n_extract_secret_type_t extract_secret_type;
  38. };
  39. S2N_RESULT s2n_tls13_empty_transcripts_init();
  40. S2N_RESULT s2n_tls13_secrets_update(struct s2n_connection *conn);
  41. S2N_RESULT s2n_tls13_secrets_get(struct s2n_connection *conn, s2n_extract_secret_type_t secret_type,
  42. s2n_mode mode, struct s2n_blob *secret);
  43. S2N_RESULT s2n_tls13_secrets_clean(struct s2n_connection *conn);
  44. S2N_RESULT s2n_derive_binder_key(struct s2n_psk *psk, struct s2n_blob *output);
  45. S2N_RESULT s2n_derive_resumption_master_secret(struct s2n_connection *conn);
  46. S2N_RESULT s2n_derive_exporter_master_secret(struct s2n_connection *conn, struct s2n_blob *output);