Split witness call (fixes #62)

This commit is contained in:
Max Goedjen 2020-03-18 20:04:24 -07:00
parent 5a2d3ecc2e
commit 85eb4983bc
No known key found for this signature in database
GPG Key ID: E58C21DD77B9B8E8
3 changed files with 9 additions and 1 deletions

View File

@ -24,6 +24,9 @@ class Notifier {
extension Notifier: SigningWitness {
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws {
}
func witness(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws {
notify(accessTo: secret, by: provenance)
}

View File

@ -87,7 +87,7 @@ extension Agent {
let provenance = requestTracer.provenance(from: pid)
if let witness = witness {
try witness.witness(accessTo: secret, by: provenance)
try witness.speakNowOrForeverHoldYourPeace(forAccessTo: secret, by: provenance)
}
let dataToSign = try reader.readNextChunk()
@ -122,6 +122,10 @@ extension Agent {
sub.append(writer.lengthAndData(of: signatureChunk))
signedData.append(writer.lengthAndData(of: sub))
if let witness = witness {
try witness.witness(accessTo: secret, by: provenance)
}
os_log(.debug, "Agent signed request")
return signedData

View File

@ -3,6 +3,7 @@ import SecretKit
public protocol SigningWitness {
func speakNowOrForeverHoldYourPeace(forAccessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws
func witness(accessTo secret: AnySecret, by provenance: SigningRequestProvenance) throws
}