Skip to content

Conversation

@paulidale
Copy link
Contributor

This unifies out time handle and will help avoid 2038 problems.
Because we have some public APIs that accept time_t and struct timeval, it's impossible to completely convert.

Checklist
  • documentation is added or updated
  • tests are added or updated

@paulidale paulidale self-assigned this Aug 29, 2022
@github-actions github-actions bot added the severity: fips change The pull request changes FIPS provider sources label Aug 29, 2022
@paulidale paulidale marked this pull request as ready for review August 31, 2022 23:49
@paulidale paulidale added branch: master Applies to master branch approval: review pending This pull request needs review by a committer approval: otc review pending labels Aug 31, 2022
Copy link
Contributor

@tmshort tmshort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few places where calculations with a constant are still performed, but there are macros/functions that could be used instead.

I would also suggest changing the SSL_METHOD get_timeout() function to return OSSL_TIME.

@paulidale
Copy link
Contributor Author

I added the extra helper functions late in the process (when I got sick of repeating the same bits of code). I missed a few, thanks for pointing these out.

One thing I was struggling with was duration vs time. I considered adding an OSSL_DURATION to make this distinction typesafe.
If we ever switch to an Epoch that isn't based on Unix's 1970 (e.g. by using clock_gettime(2)), we will need to be very careful about conversions & it's easy to get it wrong (as I did above at least once). Maybe the second type should be introduced after all.

Existing uses of time_t and struct timeval are problematic because they do not distinguish between the two flavours.

@tmshort
Copy link
Contributor

tmshort commented Sep 2, 2022

One thing I was struggling with was duration vs time. I considered adding an OSSL_DURATION to make this distinction typesafe.

I completely agree that duration vs "calendar time" are different but related, and are bound by the same type constraints... kinda. A duration is nominally positive. "Calendar time" can be negative. But both represent a time offset.

Edit: While a duration is positive, the difference between times could be negative (time a is before time b). So is this an abs()?

Copy link
Member

@mattcaswell mattcaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reconfirm

@paulidale
Copy link
Contributor Author

Merged, thanks for the feedbacks.

@paulidale paulidale closed this Sep 13, 2022
@paulidale paulidale deleted the ossl-time branch September 13, 2022 11:13
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
Some of the recently added functions were not documents.  This has been addressed.
Also added utility functions for conversions between time_t, seconds and struct timeval
to/from OSSL_TIME.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
This is instead of time_t and struct timeval.  Some public APIs mandate a
presence of these two types, but they are converted to OSSL_TIME internally.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
Keep building it for libssl without exposing any symbols.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
openssl-machine pushed a commit that referenced this pull request Sep 13, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from #19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
Some of the recently added functions were not documents.  This has been addressed.
Also added utility functions for conversions between time_t, seconds and struct timeval
to/from OSSL_TIME.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
This is instead of time_t and struct timeval.  Some public APIs mandate a
presence of these two types, but they are converted to OSSL_TIME internally.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
Keep building it for libssl without exposing any symbols.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
sftcd pushed a commit to sftcd/openssl that referenced this pull request Sep 24, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Some of the recently added functions were not documents.  This has been addressed.
Also added utility functions for conversions between time_t, seconds and struct timeval
to/from OSSL_TIME.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
This is instead of time_t and struct timeval.  Some public APIs mandate a
presence of these two types, but they are converted to OSSL_TIME internally.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Keep building it for libssl without exposing any symbols.

Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Reviewed-by: Todd Short <[email protected]>
Reviewed-by: Richard Levitte <[email protected]>
Reviewed-by: Matt Caswell <[email protected]>
(Merged from openssl#19082)
tniessen added a commit to tniessen/node that referenced this pull request May 15, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
nodejs-github-bot pushed a commit to nodejs/node that referenced this pull request May 18, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: #53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
targos pushed a commit to nodejs/node that referenced this pull request May 21, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: #53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
ebouye pushed a commit to ebouye/node that referenced this pull request Jun 20, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: nodejs#53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: nodejs#53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
marco-ippolito pushed a commit to nodejs/node that referenced this pull request Jul 19, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: #53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
marco-ippolito pushed a commit to nodejs/node that referenced this pull request Jul 19, 2024
For historical reasons, the second argument of SSL_CTX_set_timeout is a
signed integer, and Node.js has so far passed arbitrary (signed) int32_t
values. However, new versions of OpenSSL have changed the handling of
negative values inside SSL_CTX_set_timeout, and we should shield users
of Node.js from both the old and the new behavior. Hence, reject any
negative values by throwing an error from within createSecureContext.

Refs: openssl/openssl#19082
PR-URL: #53002
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Tim Perry <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: done This pull request has the required number of approvals branch: master Applies to master branch severity: fips change The pull request changes FIPS provider sources

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants