Skip to content

Commit 1d9d3b1

Browse files
committed
Removes warnings
1 parent a0ecad8 commit 1d9d3b1

File tree

7 files changed

+15
-11
lines changed

7 files changed

+15
-11
lines changed

Sources/SwiftSecurity/CryptoKit/SecKeyConvertible.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ extension SecKeyConvertible {
107107
}
108108
}
109109

110-
public struct SecKeyDescriptor {
111-
public var keyType: KeyType
112-
public var keyClass: KeyClass
110+
public struct SecKeyDescriptor: Sendable {
111+
public let keyType: KeyType
112+
public let keyClass: KeyClass
113113

114114
/// A private key for elliptic curve cryptography. Suitable for `P256`/`P384`/`P521` keys from `CryptoKit`.
115115
public static let ecPrivateKey = SecKeyDescriptor(keyType: .ecsecPrimeRandom, keyClass: .private)

Sources/SwiftSecurity/Keychain/Keychain.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ extension Keychain: SecKeyStore {
343343
}
344344

345345
var error: Unmanaged<CFError>?
346-
guard let data = SecKeyCopyExternalRepresentation(secKey as! SecKey, &error) as Data? else {
346+
guard let data = SecKeyCopyExternalRepresentation(secKey as SecKey, &error) as Data? else {
347347
if let error = error?.takeRetainedValue() {
348348
throw SwiftSecurityError(error: error)
349349
}
@@ -381,7 +381,7 @@ extension Keychain: SecCertificateStore {
381381
else {
382382
return nil
383383
}
384-
return T(certificate: secCertificate as! SecCertificate)
384+
return T(certificate: secCertificate)
385385
}
386386
}
387387

@@ -406,7 +406,7 @@ extension Keychain: SecIdentityStore {
406406
else {
407407
return nil
408408
}
409-
return T(identity: secIdentity as! SecIdentity)
409+
return T(identity: secIdentity)
410410
}
411411
}
412412

Sources/SwiftSecurity/Keychain/SecItem/SecReturnType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import Foundation
99

10-
public struct SecReturnType: OptionSet {
10+
public struct SecReturnType: OptionSet, Sendable {
1111
/// Returns a data of an item.
1212
public static let data = SecReturnType(rawValue: 1 << 0)
1313
/// Returns an attributes of an item.

Sources/SwiftSecurity/Keychain/SecItemAttr/KeyClass.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99
import Security
1010

11-
public enum KeyClass {
11+
public enum KeyClass: Sendable {
1212
/// A public key of a public-private pair.
1313
case `public`
1414
/// A private key of a public-private pair.

Sources/SwiftSecurity/Keychain/SecItemAttr/KeyType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Security
1111
@available(*, renamed: "KeyType")
1212
public typealias KeyCipher = KeyType
1313

14-
public enum KeyType {
14+
public enum KeyType: Sendable {
1515
/// RSA.
1616
case rsa
1717
/// Elliptic curve. Suitable for `P256`, `P384`, `P521` keys from `CryptoKit`.

Sources/SwiftSecurity/Security/DigitalIdentity.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ extension DigitalIdentity {
6161
var secKey: SecKey?
6262
switch SecIdentityCopyPrivateKey(secIdentity, &secKey) {
6363
case errSecSuccess:
64-
return secKey as! SecKey
64+
if let secKey {
65+
return secKey
66+
} else {
67+
throw SwiftSecurityError.invalidParameter
68+
}
6569
case let status:
6670
throw SwiftSecurityError.underlyingSecurityError(error: status)
6771
}

Sources/SwiftSecurity/Security/PKCS12.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public enum PKCS12 {
2929
] as CFDictionary, &result) {
3030
case errSecSuccess:
3131
if let items = result as? Array<[String: Any]> {
32-
return try items.map { item in
32+
return items.map { item in
3333
SecImportItemInfo(rawValue: item)
3434
}
3535
} else {

0 commit comments

Comments
 (0)