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.
Motivation
Currently
ArbitraryPrecisionInteger.random(inclusiveMin:exclusiveMax:)
takes aUInt64
forinclusiveMin
and uses this for theBN_ULONG
parameter ofBN_rand_range_ex
, butBN_ULONG
isUInt32
on 32-bit platforms. For example, when compiling for "Any watchOS Simulator Device", we get the following compiler error:Modifications
Change
inclusiveMin
param ofArbitraryPrecisionInteger.random
fromUInt64
toUInt
.Result
Can now build on 32-bit platforms, where
BN_ULONG
isuint32_t
.