mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-08-26 23:20:57 +00:00
Add capabilities.
This commit is contained in:
parent
8c2f9c14cd
commit
bfa7a3cd51
@ -12,6 +12,12 @@ extension SmartCard {
|
|||||||
public let keySize: Int
|
public let keySize: Int
|
||||||
public let requiresAuthentication: Bool = false
|
public let requiresAuthentication: Bool = false
|
||||||
public let publicKey: Data
|
public let publicKey: Data
|
||||||
|
public let capabilities: Set<KeyCapabilities>
|
||||||
|
|
||||||
|
public enum KeyCapabilities: Sendable {
|
||||||
|
case signature
|
||||||
|
case encryption
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,7 +170,14 @@ extension SmartCard.Store {
|
|||||||
let publicKeySecRef = SecKeyCopyPublicKey(publicKeyRef)!
|
let publicKeySecRef = SecKeyCopyPublicKey(publicKeyRef)!
|
||||||
let publicKeyAttributes = SecKeyCopyAttributes(publicKeySecRef) as! [CFString: Any]
|
let publicKeyAttributes = SecKeyCopyAttributes(publicKeySecRef) as! [CFString: Any]
|
||||||
let publicKey = publicKeyAttributes[kSecValueData] as! Data
|
let publicKey = publicKeyAttributes[kSecValueData] as! Data
|
||||||
return SmartCard.Secret(id: tokenID, name: name, algorithm: algorithm, keySize: keySize, publicKey: publicKey)
|
var capabilities: Set<SmartCard.Secret.KeyCapabilities> = []
|
||||||
|
if ($0[kSecAttrCanSign] as? Bool) == true {
|
||||||
|
capabilities.insert(.signature)
|
||||||
|
}
|
||||||
|
if ($0[kSecAttrCanEncrypt] as? Bool) == true && ($0[kSecAttrCanDecrypt] as? Bool) == true {
|
||||||
|
capabilities.insert(.encryption)
|
||||||
|
}
|
||||||
|
return SmartCard.Secret(id: tokenID, name: name, algorithm: algorithm, keySize: keySize, publicKey: publicKey, capabilities: capabilities)
|
||||||
}
|
}
|
||||||
state.secrets.append(contentsOf: wrapped)
|
state.secrets.append(contentsOf: wrapped)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user