aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/aws/s2n/utils/s2n_init.c
diff options
context:
space:
mode:
authorrobot-contrib <robot-contrib@yandex-team.com>2022-08-23 13:55:32 +0300
committerrobot-contrib <robot-contrib@yandex-team.com>2022-08-23 13:55:32 +0300
commit843fc844ab1de7725a9eaaab9d308ada1aa87e72 (patch)
tree82a048515821a5c92a53a278ec3e81aa44b3772e /contrib/restricted/aws/s2n/utils/s2n_init.c
parente200c8e2aa45d15f672a8ea2029e39a9f1620e6a (diff)
downloadydb-843fc844ab1de7725a9eaaab9d308ada1aa87e72.tar.gz
Update contrib/restricted/aws/s2n to 1.3.20
Diffstat (limited to 'contrib/restricted/aws/s2n/utils/s2n_init.c')
-rw-r--r--contrib/restricted/aws/s2n/utils/s2n_init.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/contrib/restricted/aws/s2n/utils/s2n_init.c b/contrib/restricted/aws/s2n/utils/s2n_init.c
index 7ea035ded2..2b3d78fefd 100644
--- a/contrib/restricted/aws/s2n/utils/s2n_init.c
+++ b/contrib/restricted/aws/s2n/utils/s2n_init.c
@@ -49,11 +49,17 @@ int s2n_disable_atexit(void) {
int s2n_init(void)
{
main_thread = pthread_self();
+ /* Should run before any init method that calls libcrypto methods
+ * to ensure we don't try to call methods that don't exist.
+ * It doesn't require any locks since it only deals with values that
+ * should be constant, so can run before s2n_locking_init. */
POSIX_GUARD_RESULT(s2n_libcrypto_validate_runtime());
- POSIX_GUARD(s2n_fips_init());
+ /* Must run before any init method that allocates memory. */
POSIX_GUARD(s2n_mem_init());
- POSIX_GUARD_RESULT(s2n_rand_init());
+ /* Must run before any init method that calls libcrypto methods. */
POSIX_GUARD_RESULT(s2n_locking_init());
+ POSIX_GUARD(s2n_fips_init());
+ POSIX_GUARD_RESULT(s2n_rand_init());
POSIX_GUARD(s2n_cipher_suites_init());
POSIX_GUARD(s2n_security_policies_init());
POSIX_GUARD(s2n_config_defaults_init());
@@ -82,9 +88,9 @@ static bool s2n_cleanup_atexit_impl(void)
/* the configs need to be wiped before resetting the memory callbacks */
s2n_wipe_static_configs();
- return s2n_result_is_ok(s2n_locking_cleanup()) &&
- s2n_result_is_ok(s2n_rand_cleanup_thread()) &&
+ return s2n_result_is_ok(s2n_rand_cleanup_thread()) &&
s2n_result_is_ok(s2n_rand_cleanup()) &&
+ s2n_result_is_ok(s2n_locking_cleanup()) &&
(s2n_mem_cleanup() == S2N_SUCCESS);
}