mirror of
				https://github.com/maxgoedjen/secretive.git
				synced 2025-10-30 15:00:57 +00:00 
			
		
		
		
	Add protocol requirements
This commit is contained in:
		
							parent
							
								
									067f1526b0
								
							
						
					
					
						commit
						53c8629870
					
				| @ -9,6 +9,7 @@ public struct AnySecret: Secret { | |||||||
|     private let _name: () -> String |     private let _name: () -> String | ||||||
|     private let _algorithm: () -> Algorithm |     private let _algorithm: () -> Algorithm | ||||||
|     private let _keySize: () -> Int |     private let _keySize: () -> Int | ||||||
|  |     private let _requiresAuthentication: () -> Bool | ||||||
|     private let _publicKey: () -> Data |     private let _publicKey: () -> Data | ||||||
| 
 | 
 | ||||||
|     public init<T>(_ secret: T) where T: Secret { |     public init<T>(_ secret: T) where T: Secret { | ||||||
| @ -19,6 +20,7 @@ public struct AnySecret: Secret { | |||||||
|             _name = secret._name |             _name = secret._name | ||||||
|             _algorithm = secret._algorithm |             _algorithm = secret._algorithm | ||||||
|             _keySize = secret._keySize |             _keySize = secret._keySize | ||||||
|  |             _requiresAuthentication = secret._requiresAuthentication | ||||||
|             _publicKey = secret._publicKey |             _publicKey = secret._publicKey | ||||||
|         } else { |         } else { | ||||||
|             base = secret as Any |             base = secret as Any | ||||||
| @ -27,6 +29,7 @@ public struct AnySecret: Secret { | |||||||
|             _name = { secret.name } |             _name = { secret.name } | ||||||
|             _algorithm = { secret.algorithm } |             _algorithm = { secret.algorithm } | ||||||
|             _keySize = { secret.keySize } |             _keySize = { secret.keySize } | ||||||
|  |             _requiresAuthentication = { secret.requiresAuthentication } | ||||||
|             _publicKey = { secret.publicKey } |             _publicKey = { secret.publicKey } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @ -47,6 +50,10 @@ public struct AnySecret: Secret { | |||||||
|         _keySize() |         _keySize() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public var requiresAuthentication: Bool { | ||||||
|  |         _requiresAuthentication() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public var publicKey: Data { |     public var publicKey: Data { | ||||||
|         _publicKey() |         _publicKey() | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -9,6 +9,8 @@ public protocol Secret: Identifiable, Hashable { | |||||||
|     var algorithm: Algorithm { get } |     var algorithm: Algorithm { get } | ||||||
|     /// The key size for the secret. |     /// The key size for the secret. | ||||||
|     var keySize: Int { get } |     var keySize: Int { get } | ||||||
|  |     /// Whether the secret requires authentication before use. | ||||||
|  |     var requiresAuthentication: Bool { get } | ||||||
|     /// The public key data for the secret. |     /// The public key data for the secret. | ||||||
|     var publicKey: Data { get } |     var publicKey: Data { get } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ extension SecureEnclave { | |||||||
|         public let name: String |         public let name: String | ||||||
|         public let algorithm = Algorithm.ellipticCurve |         public let algorithm = Algorithm.ellipticCurve | ||||||
|         public let keySize = 256 |         public let keySize = 256 | ||||||
|  |         public let requiresAuthentication: Bool | ||||||
|         public let publicKey: Data |         public let publicKey: Data | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -201,7 +201,7 @@ extension SecureEnclave.Store { | |||||||
|             let publicKeyRef = $0[kSecValueRef] as! SecKey |             let publicKeyRef = $0[kSecValueRef] as! SecKey | ||||||
|             let publicKeyAttributes = SecKeyCopyAttributes(publicKeyRef) as! [CFString: Any] |             let publicKeyAttributes = SecKeyCopyAttributes(publicKeyRef) as! [CFString: Any] | ||||||
|             let publicKey = publicKeyAttributes[kSecValueData] as! Data |             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) |         secrets.append(contentsOf: wrapped) | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ extension SmartCard { | |||||||
|         public let name: String |         public let name: String | ||||||
|         public let algorithm: Algorithm |         public let algorithm: Algorithm | ||||||
|         public let keySize: Int |         public let keySize: Int | ||||||
|  |         public let requiresAuthentication: Bool = false | ||||||
|         public let publicKey: Data |         public let publicKey: Data | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -11,6 +11,7 @@ extension Preview { | |||||||
|         let name: String |         let name: String | ||||||
|         let algorithm = Algorithm.ellipticCurve |         let algorithm = Algorithm.ellipticCurve | ||||||
|         let keySize = 256 |         let keySize = 256 | ||||||
|  |         let requiresAuthentication: Bool = false | ||||||
|         let publicKey = UUID().uuidString.data(using: .utf8)! |         let publicKey = UUID().uuidString.data(using: .utf8)! | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user