Skip to content

Commit 1fbb6ef

Browse files
authored
Avoid the macOS requirement. (#204)
1 parent d8799da commit 1fbb6ef

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Sources/X509/SecKeyWrapper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ extension Certificate.PrivateKey {
119119
)
120120
}
121121

122-
if privateKeyType == (kSecAttrKeyTypeECDSA as String) {
122+
if privateKeyType == (kSecAttrKeyTypeECSECPrimeRandom as String) {
123123
let keySize = attributes[kSecAttrKeySizeInBits as String] as? Int ?? -1
124124

125125
if keySize == 256 {

Tests/X509Tests/SecKeyWrapperTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ final class SecKeyWrapperTests: XCTestCase {
3838
)
3939

4040
// eliptic curves
41-
for keyType in [kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeyTypeEC, kSecAttrKeyTypeECDSA] {
41+
var keyTypes = [kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeyTypeEC]
42+
#if os(macOS)
43+
keyTypes.append(kSecAttrKeyTypeECDSA)
44+
#endif
45+
46+
for keyType in keyTypes {
4247
for keySize in [256, 384] {
4348
for useSEP in [true, false] {
4449
keys.append(
@@ -52,9 +57,11 @@ final class SecKeyWrapperTests: XCTestCase {
5257
}
5358
}
5459
}
60+
5561
return keys
5662
}
5763

64+
@available(macOS 11.0, iOS 14, tvOS 14, watchOS 7, *)
5865
func testPEMExport() throws {
5966
for candidate in try generateCandidateKeys() {
6067
try XCTContext.runActivity(named: "Testing \(candidate.type) key (size: \(candidate.keySize))") { _ in

0 commit comments

Comments
 (0)