Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the 4th argument to the OSSL_OPENSSL_PREREQ macro. #668

Closed

Conversation

junaruga
Copy link
Member

@junaruga junaruga commented Aug 22, 2023

This PR is to add the 4th argument patch to the OSSL_OPENSSL_PREREQ.

Because I want to run for example "OpenSSL version >= 3.1.0, and < 3.1.3" in the C files. And we can write it as OSSL_OPENSSL_PREREQ(3, 1, 0, 0) && !OSSL_OPENSSL_PREREQ(3, 1, 0, 3).


To compare with the OpenSSL 3.Y.Z version.

  • Change from the OSSL_OPENSSL_PREREQ(maj, min, pat) to the OSSL_OPENSSL_PREREQ(maj, min, fix, pat). The third argument is not "patch" but "fix". Add the firth argument "patch". Note below are the OPENSSL_VERSION_NUMBER formats.
    • OpenSSL 3: 0xMNN00PP0 (major minor 00 patch 0)
    • OpenSSL before 3: 0xMNNFFPPS (major minor fix patch status)
    • LibreSSL: 0x20000000 (fixed value)
  • Change from the OSSL_OPENSSL_PREREQ(maj, min, pat) to the OSSL_OPENSSL_PREREQ(maj, min, fix). The third argument is not "patch" but "fix". Note the LIBRESSL_VERSION_NUMBER format is 0xMNNFF00f (major minor fix patch status).

To compare with the OpenSSL 3.Y.Z version.

* Change from the `OSSL_OPENSSL_PREREQ(maj, min, pat)` to the
  `OSSL_OPENSSL_PREREQ(maj, min, fix, pat)`.
  The third argument is not "patch" but "fix".
  Add the firth argument "patch".
  Note below are the `OPENSSL_VERSION_NUMBER` formats.
  * OpenSSL 3: 0xMNN00PP0 (major minor 00 patch 0)
  * OpenSSL before 3: 0xMNNFFPPS (major minor fix patch status)
  * LibreSSL: 0x20000000 (fixed value)
* Change from the `OSSL_OPENSSL_PREREQ(maj, min, pat)` to the
  `OSSL_OPENSSL_PREREQ(maj, min, fix)`.
  The third argument is not "patch" but "fix".
  Note the `LIBRESSL_VERSION_NUMBER` format is 0xMNNFF00f (major minor fix patch
  status).
@junaruga
Copy link
Member Author

Another solution is to keep the OSSL_OPENSSL_PREREQ(maj, min, fix) with the 3 arguments, and create a new macro for example, OSSL_OPENSSL_PREREQ4(maj, min, fix, pat) with 4 arguments. In this way, we don't need to update the existing OSSL_OPENSSL_PREREQ macros with 4 arguments in each file.

@rhenium
Copy link
Member

rhenium commented Aug 24, 2023

As I commented on #669, I prefer to avoid writing library code depending on the version number whenever possible. I'd like to choose not to merge this if it turns out to be not immediately necessary.

If we want to check the "patch" version anyway, I think we should make OSSL_OPENSSL_PREREQ(3, 4, 5) to mean OpenSSL >= 3.4.5.

@junaruga
Copy link
Member Author

As I commented on #669, I prefer to avoid writing library code depending on the version number whenever possible. I'd like to choose not to merge this if it turns out to be not immediately necessary.

Sure. I understand your intention.

If we want to check the "patch" version anyway, I think we should make OSSL_OPENSSL_PREREQ(3, 4, 5) to mean OpenSSL >= 3.4.5.

You mean if we want to check the patch version, we should modify the current OSSL_OPENSSL_PREREQ macro to make OSSL_OPENSSL_PREREQ(3, 4, 5) to mean OpenSSL >= 3.4.5, right?

# define OSSL_OPENSSL_PREREQ(maj, min, pat) \
(OPENSSL_VERSION_NUMBER >= ((maj << 28) | (min << 20) | (pat << 12)))

  • OpenSSL 3: 0xMNN00PP0 (major minor 00 patch 0)
  • OpenSSL before 3: 0xMNNFFPPS (major minor fix patch status)

@junaruga
Copy link
Member Author

Let's close this PR.

@junaruga junaruga closed this Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants