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

Net::SSLeay assumes all libssl/libcrypto constants are doubles #315

Open
chrisnovakovic opened this issue Oct 7, 2021 · 5 comments
Open
Labels
tech-debt Technical debt

Comments

@chrisnovakovic
Copy link
Collaborator

chrisnovakovic commented Oct 7, 2021

Raised by @h-vn in a comment in #313, but it deserves its own issue.

helper_script/regen_openssl_constants.pl (and, when #313 is merged, helper_script/update-exported-constants) generates C code that returns the values of libssl and libcrypto constants as doubles:

static double
constant (const char *name, size_t len) {

This assumes that the values of constants will never be greater than 253. This appears to be the case for all constants we currently export for all versions of OpenSSL and LibreSSL we currently support, although this isn't guaranteed to be true in future.

@h-vn
Copy link
Contributor

h-vn commented Dec 16, 2021

What if we start with a partial solution: switch to an unsigned 64bit integer with Perls that support 64bit integer?

h-vn added a commit that referenced this issue Dec 23, 2021
This is a partial solution to GH-315. 64 bit constants are used with OpenSSL
3.0.0 and later when perl supports 64 bit integers.

Otherwise constants, SSL_CTX_get_options() and its related functions continue
to use double as the flag type.

OpenSSL 3.0.0-alpha17 switched from long to uint64_t with
SSL_CTX_get_options() family of functions.
@h-vn
Copy link
Contributor

h-vn commented Dec 23, 2021

Pull request #344 implements the partial solution.

However, https://metacpan.org/pod/Math::Int64#C-API looks like a better option. If we change to it, parts of the pull request can still be used. It would also be usable with API functions that use 64 bit integers. None are exposed yet, but when they are needed, we'd have the support correctly available.

@h-vn
Copy link
Contributor

h-vn commented Dec 28, 2021

After a closer look at Math::Int64, it appears that use of it would create a dependency which would also affect 64bit integer Perl environments. I guess there's no possibility to have a dependency that would only apply with 32bit integer Perls. This optional dependency would also require a number of ifdefs in the code, possibly two typemap files and would otherwise be ugly. I would stay with pull request #344 for now to cover most of the target Perls.

h-vn added a commit that referenced this issue Dec 29, 2021
This is a partial solution to GH-315. 64 bit constants are used with OpenSSL
3.0.0 and later when perl supports 64 bit integers.

Otherwise constants, SSL_CTX_get_options() and its related functions continue
to use double as the flag type.

OpenSSL 3.0.0-alpha17 switched from long to uint64_t with
SSL_CTX_get_options() family of functions.
h-vn added a commit that referenced this issue Dec 29, 2021
h-vn added a commit that referenced this issue Dec 29, 2021
…software/p5-net-ssleay into GH-315-support-64bit-constants
h-vn added a commit that referenced this issue Dec 29, 2021
h-vn added a commit that referenced this issue Dec 29, 2021
h-vn added a commit that referenced this issue Dec 29, 2021
* GH-315 Use 64 bit constants with OpenSSL 3.0.0 and later.

This is a partial solution to GH-315. 64 bit constants are used with OpenSSL
3.0.0 and later when perl supports 64 bit integers.

Otherwise constants continue to use double, and SSL_CTX_get_options()
and its related functions continue to use long as the flag type.

OpenSSL 3.0.0-alpha17 switched from long to uint64_t with
SSL_CTX_get_options() family of functions.
@h-vn
Copy link
Contributor

h-vn commented Dec 29, 2021

Changes in pull request GH-344 fix this for Perls that use 64bit integers.

Perls with 32bit integers continue to use double and long with OpenSSL 3.0 and later. This needs to be addressed later while also keeping in mind that starting with OpenSSL 1.1.0, a number of APIs are now using 64bit types. These are typically new APIs with SSL_CTX_get_options() family of functions being an exception that changed from long to uint64_t in OpenSSL 3.0.0-alpha17.

@h-vn
Copy link
Contributor

h-vn commented Jan 12, 2022

Stable release 1.92 includes the changes described above. Constants use type uint64_t when OpenSSL is 3.0 and Perl has 64bit integers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tech-debt Technical debt
Projects
None yet
Development

No branches or pull requests

2 participants