s2n_handshake_hashes.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "crypto/s2n_hash.h"
  18. #include "crypto/s2n_tls13_keys.h"
  19. struct s2n_handshake_hashes {
  20. struct s2n_hash_state md5;
  21. struct s2n_hash_state sha1;
  22. struct s2n_hash_state sha224;
  23. struct s2n_hash_state sha256;
  24. struct s2n_hash_state sha384;
  25. struct s2n_hash_state sha512;
  26. struct s2n_hash_state md5_sha1;
  27. /* TLS1.3 requires transcript hash digests to calculate secrets.
  28. */
  29. uint8_t transcript_hash_digest[S2N_TLS13_SECRET_MAX_LEN];
  30. /* To avoid allocating memory for hash objects, we reuse one temporary hash object.
  31. * Do NOT rely on this hash state maintaining its value outside of the current context.
  32. */
  33. struct s2n_hash_state hash_workspace;
  34. };
  35. S2N_RESULT s2n_handshake_hashes_new(struct s2n_handshake_hashes **hashes);
  36. S2N_RESULT s2n_handshake_hashes_wipe(struct s2n_handshake_hashes *hashes);
  37. S2N_CLEANUP_RESULT s2n_handshake_hashes_free(struct s2n_handshake_hashes **hashes);