Skip to content

Commit

Permalink
Avoid the macOS requirement. (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukasa authored Oct 15, 2024
1 parent d8799da commit 1fbb6ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Sources/X509/SecKeyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extension Certificate.PrivateKey {
)
}

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

if keySize == 256 {
Expand Down
9 changes: 8 additions & 1 deletion Tests/X509Tests/SecKeyWrapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ final class SecKeyWrapperTests: XCTestCase {
)

// eliptic curves
for keyType in [kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeyTypeEC, kSecAttrKeyTypeECDSA] {
var keyTypes = [kSecAttrKeyTypeECSECPrimeRandom, kSecAttrKeyTypeEC]
#if os(macOS)
keyTypes.append(kSecAttrKeyTypeECDSA)
#endif

for keyType in keyTypes {
for keySize in [256, 384] {
for useSEP in [true, false] {
keys.append(
Expand All @@ -52,9 +57,11 @@ final class SecKeyWrapperTests: XCTestCase {
}
}
}

return keys
}

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

0 comments on commit 1fbb6ef

Please sign in to comment.