Fix a few analyzer/Xcode 13.4b1 warnings (#449)

* Fix missing combine imports

* Fix a few other new warnings
This commit is contained in:
Max Goedjen
2023-02-18 17:37:38 -08:00
committed by GitHub
parent 3bd8e3b494
commit f54b2a33bf
5 changed files with 34 additions and 27 deletions

View File

@@ -27,7 +27,7 @@ extension Stub {
flags,
nil) as Any
let attributes = [
let attributes = KeychainDictionary([
kSecAttrLabel: name,
kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom,
kSecAttrKeySizeInBits: size,
@@ -35,11 +35,10 @@ extension Stub {
kSecAttrIsPermanent: true,
kSecAttrAccessControl: access
]
] as CFDictionary
])
var privateKey: SecKey! = nil
var publicKey: SecKey! = nil
SecKeyGeneratePair(attributes, &publicKey, &privateKey)
let privateKey = SecKeyCreateRandomKey(attributes, nil)!
let publicKey = SecKeyCopyPublicKey(privateKey)!
let publicAttributes = SecKeyCopyAttributes(publicKey) as! [CFString: Any]
let privateAttributes = SecKeyCopyAttributes(privateKey) as! [CFString: Any]
let publicData = (publicAttributes[kSecValueData] as! Data)
@@ -53,11 +52,11 @@ extension Stub {
guard !shouldThrow else {
throw NSError(domain: "test", code: 0, userInfo: nil)
}
let privateKey = SecKeyCreateWithData(secret.privateKey as CFData, [
let privateKey = SecKeyCreateWithData(secret.privateKey as CFData, KeychainDictionary([
kSecAttrKeyType: kSecAttrKeyTypeECSECPrimeRandom,
kSecAttrKeySizeInBits: secret.keySize,
kSecAttrKeyClass: kSecAttrKeyClassPrivate
] as CFDictionary
])
, nil)!
let signatureAlgorithm: SecKeyAlgorithm
switch secret.keySize {