s2n_encrypted_extensions.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #include "error/s2n_errno.h"
  16. #include "stuffer/s2n_stuffer.h"
  17. #include "tls/extensions/s2n_extension_list.h"
  18. #include "tls/s2n_tls.h"
  19. #include "tls/s2n_tls13.h"
  20. #include "utils/s2n_safety.h"
  21. /**
  22. * Specified in https://tools.ietf.org/html/rfc8446#section-4.3.1
  23. *
  24. * In all handshakes, the server MUST send the EncryptedExtensions
  25. * message immediately after the ServerHello message.
  26. *
  27. * The EncryptedExtensions message contains extensions that can be
  28. * protected, i.e., any which are not needed to establish the
  29. * cryptographic context but which are not associated with individual
  30. * certificates.
  31. **/
  32. int s2n_encrypted_extensions_send(struct s2n_connection *conn)
  33. {
  34. POSIX_ENSURE_REF(conn);
  35. POSIX_ENSURE(conn->actual_protocol_version >= S2N_TLS13, S2N_ERR_BAD_MESSAGE);
  36. struct s2n_stuffer *out = &conn->handshake.io;
  37. POSIX_GUARD(s2n_extension_list_send(S2N_EXTENSION_LIST_ENCRYPTED_EXTENSIONS, conn, out));
  38. return S2N_SUCCESS;
  39. }
  40. int s2n_encrypted_extensions_recv(struct s2n_connection *conn)
  41. {
  42. POSIX_ENSURE_REF(conn);
  43. POSIX_ENSURE(conn->actual_protocol_version >= S2N_TLS13, S2N_ERR_BAD_MESSAGE);
  44. struct s2n_stuffer *in = &conn->handshake.io;
  45. POSIX_GUARD(s2n_extension_list_recv(S2N_EXTENSION_LIST_ENCRYPTED_EXTENSIONS, conn, in));
  46. return S2N_SUCCESS;
  47. }