mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added iCloud sync for keys??
reindented all apple sample code
This commit is contained in:
@@ -19,8 +19,6 @@ class KeyManager: ObservableObject {
|
|||||||
var keyIDs: [UUID] {
|
var keyIDs: [UUID] {
|
||||||
keypairs.map { $0.id }
|
keypairs.map { $0.id }
|
||||||
}
|
}
|
||||||
// @Published var keyTypes: [UUID: KeyType] = [:]
|
|
||||||
// @Published var keyNames: [UUID: String] = [:]
|
|
||||||
private let baseTag = "com.neon443.ShhShell.keys".data(using: .utf8)!
|
private let baseTag = "com.neon443.ShhShell.keys".data(using: .utf8)!
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
@@ -59,9 +57,8 @@ class KeyManager: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func deleteKey(_ keypair: Keypair) {
|
func deleteKey(_ keypair: Keypair) {
|
||||||
|
withAnimation { keypairs.removeAll(where: { $0.id == keypair.id }) }
|
||||||
removeFromKeycahin(keypair: keypair)
|
removeFromKeycahin(keypair: keypair)
|
||||||
let keyID = keypair.id
|
|
||||||
withAnimation { keypairs.removeAll(where: { $0.id == keyID }) }
|
|
||||||
saveKeypairs()
|
saveKeypairs()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
See the LICENSE.txt file for this sample’s licensing information.
|
See the LICENSE.txt file for this sample’s licensing information.
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
The interface required for conversion to a generic password keychain item.
|
The interface required for conversion to a generic password keychain item.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
See the LICENSE.txt file for this sample’s licensing information.
|
See the LICENSE.txt file for this sample’s licensing information.
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
Methods for storing generic password convertible items in the keychain.
|
Methods for storing generic password convertible items in the keychain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
@@ -21,6 +21,7 @@ struct GenericPasswordStore {
|
|||||||
kSecAttrAccount: account,
|
kSecAttrAccount: account,
|
||||||
kSecAttrAccessible: kSecAttrAccessibleWhenUnlocked,
|
kSecAttrAccessible: kSecAttrAccessibleWhenUnlocked,
|
||||||
kSecUseDataProtectionKeychain: true,
|
kSecUseDataProtectionKeychain: true,
|
||||||
|
kSecAttrSynchronizable: true,
|
||||||
kSecValueData: cfd] as [String: Any]
|
kSecValueData: cfd] as [String: Any]
|
||||||
|
|
||||||
// Add the key data.
|
// Add the key data.
|
||||||
@@ -39,7 +40,8 @@ struct GenericPasswordStore {
|
|||||||
let query = [kSecClass: kSecClassGenericPassword,
|
let query = [kSecClass: kSecClassGenericPassword,
|
||||||
kSecAttrAccount: account,
|
kSecAttrAccount: account,
|
||||||
kSecUseDataProtectionKeychain: true,
|
kSecUseDataProtectionKeychain: true,
|
||||||
kSecReturnData: true] as [String: Any]
|
kSecReturnData: true,
|
||||||
|
kSecAttrSynchronizable: true] as [String: Any]
|
||||||
|
|
||||||
// Find and cast the result as data.
|
// Find and cast the result as data.
|
||||||
var item: CFTypeRef?
|
var item: CFTypeRef?
|
||||||
@@ -73,6 +75,7 @@ struct GenericPasswordStore {
|
|||||||
func deleteKey(account: String) throws {
|
func deleteKey(account: String) throws {
|
||||||
let query = [kSecClass: kSecClassGenericPassword,
|
let query = [kSecClass: kSecClassGenericPassword,
|
||||||
kSecUseDataProtectionKeychain: true,
|
kSecUseDataProtectionKeychain: true,
|
||||||
|
kSecAttrSynchronizable: kSecAttrSynchronizableAny,
|
||||||
kSecAttrAccount: account] as [String: Any]
|
kSecAttrAccount: account] as [String: Any]
|
||||||
switch SecItemDelete(query as CFDictionary) {
|
switch SecItemDelete(query as CFDictionary) {
|
||||||
case errSecItemNotFound, errSecSuccess: break // Okay to ignore
|
case errSecItemNotFound, errSecSuccess: break // Okay to ignore
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
See the LICENSE.txt file for this sample’s licensing information.
|
See the LICENSE.txt file for this sample’s licensing information.
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
Errors that can be generated as a result of attempting to store keys.
|
Errors that can be generated as a result of attempting to store keys.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
See the LICENSE.txt file for this sample’s licensing information.
|
See the LICENSE.txt file for this sample’s licensing information.
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
The interface required for conversion to a SecKey instance.
|
The interface required for conversion to a SecKey instance.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
See the LICENSE.txt file for this sample’s licensing information.
|
See the LICENSE.txt file for this sample’s licensing information.
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
Methods for storing SecKey convertible items in the keychain.
|
Methods for storing SecKey convertible items in the keychain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
|||||||
Reference in New Issue
Block a user