mirror of
https://github.com/bitwarden/ios.git
synced 2025-12-11 13:54:06 -06:00
32 lines
784 B
Swift
32 lines
784 B
Swift
import CryptoKit
|
|
import Foundation
|
|
|
|
@testable import AuthenticatorBridgeKit
|
|
|
|
class MockSharedKeychainRepository {
|
|
var authenticatorKey: Data?
|
|
}
|
|
|
|
extension MockSharedKeychainRepository: SharedKeychainRepository {
|
|
func generateKeyData() -> Data {
|
|
let key = SymmetricKey(size: .bits256)
|
|
return key.withUnsafeBytes { Data(Array($0)) }
|
|
}
|
|
|
|
func deleteAuthenticatorKey() throws {
|
|
authenticatorKey = nil
|
|
}
|
|
|
|
func getAuthenticatorKey() async throws -> Data {
|
|
if let authenticatorKey {
|
|
return authenticatorKey
|
|
} else {
|
|
throw AuthenticatorKeychainServiceError.keyNotFound(.authenticatorKey)
|
|
}
|
|
}
|
|
|
|
func setAuthenticatorKey(_ value: Data) async throws {
|
|
authenticatorKey = value
|
|
}
|
|
}
|