diff --git a/Sources/Packages/Sources/SecretKit/Erasers/AnySecret.swift b/Sources/Packages/Sources/SecretKit/Erasers/AnySecret.swift index b5a748d..f6e8bef 100644 --- a/Sources/Packages/Sources/SecretKit/Erasers/AnySecret.swift +++ b/Sources/Packages/Sources/SecretKit/Erasers/AnySecret.swift @@ -9,6 +9,7 @@ public struct AnySecret: Secret { private let _name: () -> String private let _algorithm: () -> Algorithm private let _keySize: () -> Int + private let _requiresAuthentication: () -> Bool private let _publicKey: () -> Data public init(_ secret: T) where T: Secret { @@ -19,6 +20,7 @@ public struct AnySecret: Secret { _name = secret._name _algorithm = secret._algorithm _keySize = secret._keySize + _requiresAuthentication = secret._requiresAuthentication _publicKey = secret._publicKey } else { base = secret as Any @@ -27,6 +29,7 @@ public struct AnySecret: Secret { _name = { secret.name } _algorithm = { secret.algorithm } _keySize = { secret.keySize } + _requiresAuthentication = { secret.requiresAuthentication } _publicKey = { secret.publicKey } } } @@ -47,6 +50,10 @@ public struct AnySecret: Secret { _keySize() } + public var requiresAuthentication: Bool { + _requiresAuthentication() + } + public var publicKey: Data { _publicKey() } diff --git a/Sources/Packages/Sources/SecretKit/Types/Secret.swift b/Sources/Packages/Sources/SecretKit/Types/Secret.swift index 154a2d3..6fc57a1 100644 --- a/Sources/Packages/Sources/SecretKit/Types/Secret.swift +++ b/Sources/Packages/Sources/SecretKit/Types/Secret.swift @@ -9,6 +9,8 @@ public protocol Secret: Identifiable, Hashable { var algorithm: Algorithm { get } /// The key size for the secret. var keySize: Int { get } + /// Whether the secret requires authentication before use. + var requiresAuthentication: Bool { get } /// The public key data for the secret. var publicKey: Data { get } diff --git a/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveSecret.swift b/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveSecret.swift index c8a87ba..530d01e 100644 --- a/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveSecret.swift +++ b/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveSecret.swift @@ -11,6 +11,7 @@ extension SecureEnclave { public let name: String public let algorithm = Algorithm.ellipticCurve public let keySize = 256 + public let requiresAuthentication: Bool public let publicKey: Data } diff --git a/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveStore.swift b/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveStore.swift index a902901..063b84c 100644 --- a/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveStore.swift +++ b/Sources/Packages/Sources/SecureEnclaveSecretKit/SecureEnclaveStore.swift @@ -201,7 +201,7 @@ extension SecureEnclave.Store { let publicKeyRef = $0[kSecValueRef] as! SecKey let publicKeyAttributes = SecKeyCopyAttributes(publicKeyRef) as! [CFString: Any] let publicKey = publicKeyAttributes[kSecValueData] as! Data - return SecureEnclave.Secret(id: id, name: name, publicKey: publicKey) + return SecureEnclave.Secret(id: id, name: name, requiresAuthentication: false, publicKey: publicKey) } secrets.append(contentsOf: wrapped) } diff --git a/Sources/Packages/Sources/SmartCardSecretKit/SmartCardSecret.swift b/Sources/Packages/Sources/SmartCardSecretKit/SmartCardSecret.swift index c5e9109..655214f 100644 --- a/Sources/Packages/Sources/SmartCardSecretKit/SmartCardSecret.swift +++ b/Sources/Packages/Sources/SmartCardSecretKit/SmartCardSecret.swift @@ -11,6 +11,7 @@ extension SmartCard { public let name: String public let algorithm: Algorithm public let keySize: Int + public let requiresAuthentication: Bool = false public let publicKey: Data } diff --git a/Sources/Secretive/Preview Content/PreviewStore.swift b/Sources/Secretive/Preview Content/PreviewStore.swift index 4d4fbdb..b68c677 100644 --- a/Sources/Secretive/Preview Content/PreviewStore.swift +++ b/Sources/Secretive/Preview Content/PreviewStore.swift @@ -11,6 +11,7 @@ extension Preview { let name: String let algorithm = Algorithm.ellipticCurve let keySize = 256 + let requiresAuthentication: Bool = false let publicKey = UUID().uuidString.data(using: .utf8)! }