Skip to content

Commit

Permalink
Fix Linux compatibilty issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mgriebling committed Jul 11, 2023
1 parent 61fa088 commit b4b6e3b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/BigInt/BigInt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1834,13 +1834,15 @@ extension BInt {
// MARK: Prime number functions

static internal func randomBytes(_ bytes: inout Bytes) {
guard SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes) == errSecSuccess else {
// Use nil in place of kSecRandomDefault for Linux compatibility
guard SecRandomCopyBytes(nil, bytes.count, &bytes) == errSecSuccess else {
fatalError("randomBytes failed")
}
}

static internal func randomLimbs(_ limbs: inout Limbs) {
guard SecRandomCopyBytes(kSecRandomDefault, 8 * limbs.count, &limbs) == errSecSuccess else {
// Use nil in place of kSecRandomDefault for Linux compatibility
guard SecRandomCopyBytes(nil, 8 * limbs.count, &limbs) == errSecSuccess else {
fatalError("randomLimbs failed")
}
}
Expand Down

0 comments on commit b4b6e3b

Please sign in to comment.