From: Matt Caswell Date: Mon, 25 Mar 2024 11:53:35 +0000 (+0000) Subject: Use OSSL_TIME instead of using arithmetic directly on time_t X-Git-Tag: openssl-3.4.0-alpha1~616 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afb6ce0d0f5b8e88f8b4f420aba0a8e59f58934f;p=thirdparty%2Fopenssl.git Use OSSL_TIME instead of using arithmetic directly on time_t We have functions for adding/subtracting time. We should use them. Reviewed-by: Tomas Mraz Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23966) --- diff --git a/test/sslapitest.c b/test/sslapitest.c index ce8f642802a..9516fd09fef 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -3375,6 +3375,16 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity, static int artificial_ticket_time = 0; +static int sub_session_time(SSL_SESSION *sess) +{ + OSSL_TIME tick_time; + + tick_time = ossl_time_from_time_t(SSL_SESSION_get_time_ex(sess)); + tick_time = ossl_time_subtract(tick_time, ossl_seconds2time(10)); + + return SSL_SESSION_set_time_ex(sess, ossl_time_to_time_t(tick_time)) != 0; +} + static int ed_gen_cb(SSL *s, void *arg) { SSL_SESSION *sess = SSL_get0_session(s); @@ -3390,10 +3400,7 @@ static int ed_gen_cb(SSL *s, void *arg) return 1; artificial_ticket_time--; - if (SSL_SESSION_set_time_ex(sess, SSL_SESSION_get_time_ex(sess) - 10) == 0) - return 0; - - return 1; + return sub_session_time(sess); } /* @@ -3493,8 +3500,7 @@ static int setupearly_data_test(SSL_CTX **cctx, SSL_CTX **sctx, SSL **clientssl, * gave it on the server side */ if (artificial - && !TEST_time_t_gt(SSL_SESSION_set_time_ex(*sess, - SSL_SESSION_get_time_ex(*sess) - 10), 0)) + && !TEST_true(sub_session_time(*sess))) return 0; if (!TEST_true(create_ssl_objects(*sctx, *cctx, serverssl,