This commit is contained in:
Max Goedjen 2025-08-24 15:32:29 -07:00
parent 3e317b8e08
commit d7292988f6
No known key found for this signature in database
4 changed files with 7 additions and 17 deletions

View File

@ -5356,9 +5356,6 @@
} }
} }
} }
},
"Test" : {
}, },
"test@example.com" : { "test@example.com" : {

View File

@ -35,7 +35,7 @@ import CryptoKit
#expect(stubWriter.data == Constants.Responses.requestFailure) #expect(stubWriter.data == Constants.Responses.requestFailure)
} }
@Test func signature() async throws { @Test func ecdsaSignature() async throws {
let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature) let stubReader = StubFileHandleReader(availableData: Constants.Requests.requestSignature)
let requestReader = OpenSSHReader(data: Constants.Requests.requestSignature[5...]) let requestReader = OpenSSHReader(data: Constants.Requests.requestSignature[5...])
_ = requestReader.readNextChunk() _ = requestReader.readNextChunk()

View File

@ -52,13 +52,8 @@ extension Stub {
guard !shouldThrow else { guard !shouldThrow else {
throw NSError(domain: "test", code: 0, userInfo: nil) throw NSError(domain: "test", code: 0, userInfo: nil)
} }
let privateKey = SecKeyCreateWithData(secret.privateKey as CFData, KeychainDictionary([ let privateKey = try CryptoKit.P256.Signing.PrivateKey(x963Representation: secret.privateKey)
kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom, return try privateKey.signature(for: data).rawRepresentation
kSecAttrKeySizeInBits: secret.keySize,
kSecAttrKeyClass: kSecAttrKeyClassPrivate
])
, nil)!
return SecKeyCreateSignature(privateKey, signatureAlgorithm(for: secret), data as CFData, nil)! as Data
} }
public func existingPersistedAuthenticationContext(secret: Stub.Secret) -> PersistedAuthenticationContext? { public func existingPersistedAuthenticationContext(secret: Stub.Secret) -> PersistedAuthenticationContext? {
@ -81,22 +76,20 @@ extension Stub {
let id = Data(UUID().uuidString.utf8) let id = Data(UUID().uuidString.utf8)
let name = UUID().uuidString let name = UUID().uuidString
let algorithm = Algorithm.ecdsa let attributes: Attributes
let keySize: Int
let publicKey: Data let publicKey: Data
let requiresAuthentication = false let requiresAuthentication = false
let privateKey: Data let privateKey: Data
init(keySize: Int, publicKey: Data, privateKey: Data) { init(keySize: Int, publicKey: Data, privateKey: Data) {
self.keySize = keySize self.attributes = Attributes(keyType: .init(algorithm: .ecdsa, size: keySize), authentication: .notRequired)
self.publicKey = publicKey self.publicKey = publicKey
self.privateKey = privateKey self.privateKey = privateKey
} }
var debugDescription: String { var debugDescription: String {
""" """
Key Size \(keySize) Key Size \(keyType.size)
Private: \(privateKey.base64EncodedString()) Private: \(privateKey.base64EncodedString())
Public: \(publicKey.base64EncodedString()) Public: \(publicKey.base64EncodedString())
""" """

View File

@ -69,7 +69,7 @@ final class Notifier: Sendable {
notificationContent.userInfo[Constants.persistSecretIDKey] = secret.id.description notificationContent.userInfo[Constants.persistSecretIDKey] = secret.id.description
notificationContent.userInfo[Constants.persistStoreIDKey] = store.id.description notificationContent.userInfo[Constants.persistStoreIDKey] = store.id.description
notificationContent.interruptionLevel = .timeSensitive notificationContent.interruptionLevel = .timeSensitive
if await store.existingPersistedAuthenticationContext(secret: secret) == nil && secret.requiresAuthentication { if await store.existingPersistedAuthenticationContext(secret: secret) == nil && secret.authenticationRequirement.required {
notificationContent.categoryIdentifier = Constants.persistAuthenticationCategoryIdentitifier notificationContent.categoryIdentifier = Constants.persistAuthenticationCategoryIdentitifier
} }
if let iconURL = provenance.origin.iconURL, let attachment = try? UNNotificationAttachment(identifier: "icon", url: iconURL, options: nil) { if let iconURL = provenance.origin.iconURL, let attachment = try? UNNotificationAttachment(identifier: "icon", url: iconURL, options: nil) {