mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-10 19:47:24 +01:00
.
This commit is contained in:
@@ -2,7 +2,7 @@ import Foundation
|
||||
import Combine
|
||||
import SecretKit
|
||||
|
||||
extension SmartCard {
|
||||
extension ProxyAgent {
|
||||
|
||||
/// An implementation of Secret backed by a Smart Card.
|
||||
public struct Secret: SecretKit.Secret {
|
||||
|
||||
@@ -9,13 +9,16 @@ extension ProxyAgent {
|
||||
/// An implementation of Store backed by a Proxy Agent.
|
||||
public class Store: SecretStore {
|
||||
|
||||
@Published public var isAvailable: Bool = false
|
||||
@Published public var isAvailable: Bool = true
|
||||
public let id = UUID()
|
||||
public private(set) var name = NSLocalizedString("Proxy SSH Agent", comment: "Proxy SSH Agent")
|
||||
@Published public private(set) var secrets: [Secret] = []
|
||||
private let agentPath: String
|
||||
|
||||
/// Initializes a Store.
|
||||
public init() {
|
||||
public init(path: String) {
|
||||
agentPath = path
|
||||
secrets.append(Secret(id: "hello".data(using: .utf8)!, name: "Test", algorithm: .ellipticCurve, keySize: 256, publicKey: Data(base64Encoded: "AAAAC3NzaC1lZDI1NTE5AAAAIINQz8WohBS46ICEUtkJ/vdxJPM63T5Dy4bQC35JVgGR")!))
|
||||
}
|
||||
|
||||
// MARK: Public API
|
||||
@@ -29,6 +32,7 @@ extension ProxyAgent {
|
||||
}
|
||||
|
||||
public func sign(data: Data, with secret: SecretType, for provenance: SigningRequestProvenance) throws -> Data {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
public func existingPersistedAuthenticationContext(secret: ProxyAgent.Secret) -> PersistedAuthenticationContext? {
|
||||
@@ -50,8 +54,6 @@ extension ProxyAgent {
|
||||
|
||||
/// A signing-related error.
|
||||
public struct SigningError: Error {
|
||||
/// The underlying error reported by the API, if one was returned.
|
||||
public let error: SecurityError?
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +64,10 @@ extension OpenSSHKeyWriter {
|
||||
switch algorithm {
|
||||
case .ellipticCurve:
|
||||
return "ecdsa-sha2-nistp" + String(describing: length)
|
||||
case .rsa:
|
||||
return "ssh-rsa"
|
||||
case .ed25519:
|
||||
return "ssh-ed25519"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,6 +80,11 @@ extension OpenSSHKeyWriter {
|
||||
switch algorithm {
|
||||
case .ellipticCurve:
|
||||
return "nistp" + String(describing: length)
|
||||
// TODO: VERIFY
|
||||
case .rsa:
|
||||
return "rsa"
|
||||
case .ed25519:
|
||||
return "ed25519"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ public protocol Secret: Identifiable, Hashable {
|
||||
/// The type of algorithm the Secret uses. Currently, only elliptic curve algorithms are supported.
|
||||
public enum Algorithm: Hashable {
|
||||
|
||||
case rsa
|
||||
case ed25519
|
||||
case ellipticCurve
|
||||
|
||||
/// Initializes the Algorithm with a secAttr representation of an algorithm.
|
||||
|
||||
Reference in New Issue
Block a user