mirror of
https://github.com/maxgoedjen/secretive.git
synced 2024-11-24 22:47:06 +00:00
Identities offers both key and certificate when both are present (#454)
* Identities offers both key and certificate when both are present * Update Sources/Packages/Sources/SecretAgentKit/Agent.swift --------- Co-authored-by: Max Goedjen <max.goedjen@gmail.com>
This commit is contained in:
parent
2ca8279187
commit
0944d65ccb
@ -86,27 +86,24 @@ extension Agent {
|
|||||||
func identities() -> Data {
|
func identities() -> Data {
|
||||||
let secrets = storeList.allSecrets
|
let secrets = storeList.allSecrets
|
||||||
certificateHandler.reloadCertificates(for: secrets)
|
certificateHandler.reloadCertificates(for: secrets)
|
||||||
var count = UInt32(secrets.count).bigEndian
|
var count = secrets.count
|
||||||
let countData = Data(bytes: &count, count: UInt32.bitWidth/8)
|
|
||||||
var keyData = Data()
|
var keyData = Data()
|
||||||
|
|
||||||
for secret in secrets {
|
for secret in secrets {
|
||||||
let keyBlob: Data
|
let keyBlob = writer.data(secret: secret)
|
||||||
let curveData: Data
|
let curveData = writer.curveType(for: secret.algorithm, length: secret.keySize).data(using: .utf8)!
|
||||||
|
|
||||||
if let (certificateData, name) = try? certificateHandler.keyBlobAndName(for: secret) {
|
|
||||||
keyBlob = certificateData
|
|
||||||
curveData = name
|
|
||||||
} else {
|
|
||||||
keyBlob = writer.data(secret: secret)
|
|
||||||
curveData = writer.curveType(for: secret.algorithm, length: secret.keySize).data(using: .utf8)!
|
|
||||||
}
|
|
||||||
|
|
||||||
keyData.append(writer.lengthAndData(of: keyBlob))
|
keyData.append(writer.lengthAndData(of: keyBlob))
|
||||||
keyData.append(writer.lengthAndData(of: curveData))
|
keyData.append(writer.lengthAndData(of: curveData))
|
||||||
|
|
||||||
|
if let (certificateData, name) = try? certificateHandler.keyBlobAndName(for: secret) {
|
||||||
|
keyData.append(writer.lengthAndData(of: certificateData))
|
||||||
|
keyData.append(writer.lengthAndData(of: name))
|
||||||
|
count += 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logger.log("Agent enumerated \(secrets.count) identities")
|
logger.log("Agent enumerated \(count) identities")
|
||||||
|
var countBigEndian = UInt32(count).bigEndian
|
||||||
|
let countData = Data(bytes: &countBigEndian, count: UInt32.bitWidth/8)
|
||||||
return countData + keyData
|
return countData + keyData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user