diff options
author | Matt Caswell <matt@openssl.org> | 2024-03-25 11:53:35 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2024-05-01 08:52:05 +0100 |
commit | eb3b903af9b8de754f198a4ea5ea239f3721e3ee (patch) | |
tree | 2a506d85f05baabc46714db7e350a2a138d6b701 | |
parent | bbae0c9f05f345d12b50422b3136c3de404ed7f1 (diff) |
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 <tomas@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23966)
(cherry picked from commit afb6ce0d0f5b8e88f8b4f420aba0a8e59f58934f)
-rw-r--r-- | test/sslapitest.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/test/sslapitest.c b/test/sslapitest.c index 0b2d7b5e6d..025d204f52 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, |