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

Change inclusiveMin param of ArbitraryPrecisionInteger.random from UInt64 to UInt #242

Merged
merged 1 commit into from
Jun 27, 2024

Conversation

simonjbeaumont
Copy link
Contributor

@simonjbeaumont simonjbeaumont commented Jun 27, 2024

Motivation

Currently ArbitraryPrecisionInteger.random(inclusiveMin:exclusiveMax:) takes a UInt64 for inclusiveMin and uses this for the BN_ULONG parameter of BN_rand_range_ex, but BN_ULONG is UInt32 on 32-bit platforms. For example, when compiling for "Any watchOS Simulator Device", we get the following compiler error:

swift-crypto/Sources/CryptoBoringWrapper/ArbitraryPrecisionInteger.swift:444:62: error: cannot convert value of type 'UInt64' to expected argument type 'BN_ULONG' (aka 'UInt32')
                CCryptoBoringSSL_BN_rand_range_ex(resultPtr, inclusiveMin, exclusiveMaxPtr)
                                                             ^
                                                             BN_ULONG(   )

Modifications

Change inclusiveMin param of ArbitraryPrecisionInteger.random from UInt64 to UInt.

Result

Can now build on 32-bit platforms, where BN_ULONG is uint32_t.

@simonjbeaumont
Copy link
Contributor Author

/cc @finagolfin

@simonjbeaumont simonjbeaumont marked this pull request as ready for review June 27, 2024 13:35
@glbrntt glbrntt merged commit 33f65a3 into apple:main Jun 27, 2024
9 checks passed
@finagolfin
Copy link
Contributor

Thanks, this fixed it on Android armv7 also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 semver/patch No public API change.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants