s2n_supported_versions.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 "tls/extensions/s2n_supported_versions.h"
  16. #include <stdint.h>
  17. #include <sys/param.h>
  18. #include "tls/s2n_security_policies.h"
  19. #include "utils/s2n_safety.h"
  20. S2N_RESULT s2n_connection_get_minimum_supported_version(struct s2n_connection *conn, uint8_t *min_version)
  21. {
  22. RESULT_ENSURE_REF(min_version);
  23. const struct s2n_security_policy *security_policy = NULL;
  24. RESULT_GUARD_POSIX(s2n_connection_get_security_policy(conn, &security_policy));
  25. RESULT_ENSURE_REF(security_policy);
  26. *min_version = security_policy->minimum_protocol_version;
  27. /* QUIC requires >= TLS1.3 */
  28. if (s2n_connection_is_quic_enabled(conn)) {
  29. *min_version = MAX(*min_version, S2N_TLS13);
  30. }
  31. return S2N_RESULT_OK;
  32. }