Compare commits

...
3 Commits
Author SHA1 Message Date
Kyle 06dc63c6d8 Fix WASI platform build issue (#291) 2024-10-30 13:36:45 +00:00
Paul ToffoloniandCory Benfield 62958ed575 Fix Windows CI (#289)
Co-authored-by: Cory Benfield <lukasa@apple.com>
2024-10-29 14:29:05 +00:00
Franz Busch e9d46e7bf9 [CI] Enable Windows CI (#288) 2024-10-29 13:57:41 +00:00
5 changed files with 29 additions and 25 deletions

No files matched your search

+2
View File
@@ -3,6 +3,8 @@ name: Main
on:
push:
branches: [main]
schedule:
- cron: "0 8,20 * * *"
jobs:
unit-tests:
+6
View File
@@ -28,6 +28,12 @@ jobs:
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
windows_6_0_enabled: true
windows_nightly_6_0_enabled: true
windows_nightly_main_enabled: true
windows_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
windows_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
cxx-interop:
name: Cxx interop
-20
View File
@@ -1,20 +0,0 @@
name: Scheduled
on:
schedule:
- cron: "0 8,20 * * *"
jobs:
unit-tests:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_9_arguments_override: "--explicit-target-dependency-import-check error"
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_6_0_arguments_override: "--explicit-target-dependency-import-check error"
linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error"
cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
@@ -21,9 +21,6 @@ extension UnsafeMutableRawBufferPointer {
#if canImport(Darwin) || os(Linux) || os(Android) || os(Windows)
var rng = SystemRandomNumberGenerator()
#else
fatalError("No secure random number generator on this platform.")
#endif
precondition(count <= self.count)
// We store bytes 64-bits at a time until we can't anymore.
@@ -41,6 +38,9 @@ extension UnsafeMutableRawBufferPointer {
remainingWord >>= 8
targetPtr = UnsafeMutableRawBufferPointer(rebasing: targetPtr[1...])
}
#else
fatalError("No secure random number generator on this platform.")
#endif
}
}
@@ -25,6 +25,20 @@ import Foundation
import Android
#endif
#if os(Windows)
import WinSDK
private func getPageSize() -> Int {
var info = SYSTEM_INFO()
GetSystemInfo(&info)
return Int(info.dwPageSize)
}
#else
private func getPageSize() -> Int {
return Int(sysconf(Int32(_SC_PAGESIZE)))
}
#endif
internal struct BoringSSLScrypt {
/// Derives a secure key using the provided passphrase and salt.
///
@@ -39,9 +53,11 @@ internal struct BoringSSLScrypt {
static func deriveKey<Passphrase: DataProtocol, Salt: DataProtocol>(from password: Passphrase, salt: Salt, outputByteCount: Int, rounds: Int, blockSize: Int, parallelism: Int, maxMemory: Int? = nil) throws -> SymmetricKey {
// This should be SecureBytes, but we can't use that here.
var derivedKeyData = Data(count: outputByteCount)
// This computes the maximum amount of memory that will be used by the scrypt algorithm with an additional memory page to spare. This value will be used by the BoringSSL as the memory limit for the algorithm. An additional memory page is added to the computed value (using POSIX specification) to ensure that the memory limit is not too tight.
let maxMemory = maxMemory ?? (128 * rounds * blockSize * parallelism + Int(sysconf(Int32(_SC_PAGESIZE))))
// This computes the maximum amount of memory that will be used by the scrypt algorithm with an additional memory page to spare. This value will be used by the BoringSSL as the memory limit for the algorithm.
// An additional memory page is added to the computed value (using POSIX specification) to ensure that the memory limit is not too tight.
let maxMemory = maxMemory ?? (128 * rounds * blockSize * parallelism + getPageSize())
let result = derivedKeyData.withUnsafeMutableBytes { derivedKeyBytes -> Int32 in
let saltBytes: ContiguousBytes = salt.regions.count == 1 ? salt.regions.first! : Array(salt)