From 3117deb0226451e0bff9050cc81d788638708239 Mon Sep 17 00:00:00 2001 From: Goncalo Frade Date: Mon, 28 Oct 2024 15:47:00 +0000 Subject: [PATCH] maintenance: add swift 6 support --- Package.swift | 5 +++-- README.md | 5 +++-- .../Compression/ContentCompressionAlgorithm.swift | 2 +- .../ChaChaPoly/XC20P+ContentEncryption.swift | 2 +- .../ContentEncryption/ContentEncryptionAlgorithm.swift | 2 +- .../CryptoImplementation/AES/AESCBC_SHA.swift | 2 +- .../KeyManagement/JWKRepresentable.swift | 2 +- .../KeyManagement/KeyDerivation/PBES2/PBES2SHA.swift | 2 +- .../RSA/RSA15KeyUnwrap+KeyUnwrapping.swift | 2 +- .../RSA/RSA15KeyWrapper+KeyEncryption.swift | 2 +- .../RSA/RSAOAEP256KeyUnwrap+KeyUnwrapping.swift | 2 +- .../RSA/RSAOAEP256KeyWrap+KeyEncryption.swift | 2 +- .../RSA/RSAOAEPKeyUnwrap+KeyUnwrapping.swift | 2 +- .../RSA/RSAOAEPKeyWrap+KeyEncryption.swift | 2 +- .../KeyManagement/KeyEncryptionAlgorithm.swift | 2 +- .../KeyManagement/KeyRepresentable/DataKey.swift | 2 +- .../KeyRepresentable/KeyRepresentable.swift | 2 +- .../KeyRepresentable/SecKeyExtended.swift | 2 +- .../Signatures/EC/Signers/ES256KSigner.swift | 4 ++-- .../Signatures/EC/Verifiers/ES256KVerifier.swift | 2 +- .../Signatures/RSA/Helpers/RSA+Security.swift | 2 +- .../Signatures/RSA/Signers/PS256Signer.swift | 2 +- .../Signatures/RSA/Signers/PS384Signer.swift | 2 +- .../Signatures/RSA/Signers/PS512Signer.swift | 2 +- .../Signatures/RSA/Signers/RS256Signer.swift | 2 +- .../Signatures/RSA/Signers/RS384Signer.swift | 2 +- .../Signatures/RSA/Signers/RS512Signer.swift | 2 +- .../Signatures/RSA/Verifiers/PS256Verifier.swift | 2 +- .../Signatures/RSA/Verifiers/PS384Verifier.swift | 2 +- .../Signatures/RSA/Verifiers/PS512Verifier.swift | 2 +- .../Signatures/RSA/Verifiers/RS256Verifier.swift | 2 +- .../Signatures/RSA/Verifiers/RS384Verifier.swift | 2 +- .../Signatures/RSA/Verifiers/RS512Verifier.swift | 2 +- .../Signatures/SigningAlgorithm.swift | 2 +- .../EncryptionModule/Decryptors/JWEDecryptor.swift | 4 ++-- .../EncryptionModule/Encryptors/JWEEncrypter.swift | 4 ++-- .../EncryptionModule/JWE+EncryptionModule.swift | 2 +- .../EncryptionModule/JWEEncryptionModule.swift | 8 ++++---- Sources/JSONWebEncryption/JWE.swift | 2 +- .../JSONWebEncryption/JWERegisteredFieldsHeader.swift | 2 +- .../KeyManagementAlgorithm+Family.swift | 2 +- Sources/JSONWebKey/JWK.swift | 10 +++++----- Sources/JSONWebSignature/JWS.swift | 2 +- .../JSONWebSignature/JWSRegisteredFieldsHeader.swift | 2 +- Sources/JSONWebToken/JWT.swift | 2 +- Tests/JWATests/Mocks/JWK+Testing.swift | 2 +- Tests/JWETests/Mocks/JWK+Testing.swift | 2 +- Tests/JWTTests/Mock/JWK+Testing.swift | 2 +- 48 files changed, 62 insertions(+), 60 deletions(-) diff --git a/Package.swift b/Package.swift index 35b5a2e..9f7e02a 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 5.8.1 +// swift-tools-version: 5.9.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -112,5 +112,6 @@ let package = Package( "JSONWebToken" ] ), - ] + ], + swiftLanguageVersions: [.version("6"), .v5] ) diff --git a/README.md b/README.md index 02dc565..e1030cb 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![Screenshot](jose-swift-logo.png) # Jose Swift Library -[![Swift](https://img.shields.io/badge/swift-brightgreen.svg)]() [![iOS](https://img.shields.io/badge/ios-brightgreen.svg)]() [![MacOS](https://img.shields.io/badge/macos-brightgreen.svg)]() [![WatchOS](https://img.shields.io/badge/watchos-brightgreen.svg)]() [![TvOS](https://img.shields.io/badge/tvos-brightgreen.svg)]() +[![Swift](https://img.shields.io/badge/swift-brightgreen.svg)]() [![Swift6](https://img.shields.io/badge/swift6-brightgreen.svg)]() [![iOS](https://img.shields.io/badge/ios-brightgreen.svg)]() [![MacOS](https://img.shields.io/badge/macos-brightgreen.svg)]() [![WatchOS](https://img.shields.io/badge/watchos-brightgreen.svg)]() [![TvOS](https://img.shields.io/badge/tvos-brightgreen.svg)]() This library provides comprehensive support for the Jose suite of standards, including JWA (JSON Web Algorithms), JWK (JSON Web Key), JWE (JSON Web Encryption), JWS (JSON Web Signature), and JWT (JSON Web Token). These standards are integral to modern security protocols on the web, offering methods for secure key management, data encryption, signing, and representation of claims among different parties. @@ -168,7 +168,8 @@ Note: JWS Unencoded payload as referenced in the [RFC-7797](https://datatracker. ## Requirements -- Swift 5.7.1 or later +- Swift 5.8.1 or later +- Swift 6 or later - iOS 15.0 or later - macOS 12.0 or later - Mac Catalyst 15.0 or later diff --git a/Sources/JSONWebAlgorithms/Compression/ContentCompressionAlgorithm.swift b/Sources/JSONWebAlgorithms/Compression/ContentCompressionAlgorithm.swift index 627c655..fd8e826 100644 --- a/Sources/JSONWebAlgorithms/Compression/ContentCompressionAlgorithm.swift +++ b/Sources/JSONWebAlgorithms/Compression/ContentCompressionAlgorithm.swift @@ -17,7 +17,7 @@ import Foundation /// `ContentCompressionAlgorithm` is an enumeration representing the supported content compression algorithms. -public enum ContentCompressionAlgorithm: String, Codable { +public enum ContentCompressionAlgorithm: String, Codable, Sendable { /// The DEFLATE compression algorithm. case deflate = "DEF" } diff --git a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift index 9d0ef49..ce7e3ce 100644 --- a/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift +++ b/Sources/JSONWebAlgorithms/ContentEncryption/ChaChaPoly/XC20P+ContentEncryption.swift @@ -1,4 +1,4 @@ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation /// `XC20P` provides methods to encrypt and decrypt data using the XChaCha20-Poly1305 algorithm. diff --git a/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift b/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift index 46b8405..7da07cd 100644 --- a/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift +++ b/Sources/JSONWebAlgorithms/ContentEncryption/ContentEncryptionAlgorithm.swift @@ -9,7 +9,7 @@ import Foundation /// `ContentEncryptionAlgorithm` is an enumeration representing the supported content encryption algorithms. -public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable, Hashable { +public enum ContentEncryptionAlgorithm: String, Codable, Equatable, CaseIterable, Hashable, Sendable { /// AES encryption in CBC mode with an HMAC using SHA-256. /// The algorithm uses a 256-bit key and is commonly used for its balance of security and performance. case a128CBCHS256 = "A128CBC-HS256" diff --git a/Sources/JSONWebAlgorithms/CryptoImplementation/AES/AESCBC_SHA.swift b/Sources/JSONWebAlgorithms/CryptoImplementation/AES/AESCBC_SHA.swift index d7e82d7..d536927 100644 --- a/Sources/JSONWebAlgorithms/CryptoImplementation/AES/AESCBC_SHA.swift +++ b/Sources/JSONWebAlgorithms/CryptoImplementation/AES/AESCBC_SHA.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import CryptoKit import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/KeyManagement/JWKRepresentable.swift b/Sources/JSONWebAlgorithms/KeyManagement/JWKRepresentable.swift index 2a5aac7..41ecafe 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/JWKRepresentable.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/JWKRepresentable.swift @@ -7,7 +7,7 @@ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. import CryptoKit -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import secp256k1 diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyDerivation/PBES2/PBES2SHA.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyDerivation/PBES2/PBES2SHA.swift index c77c0cb..fa07cef 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyDerivation/PBES2/PBES2SHA.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyDerivation/PBES2/PBES2SHA.swift @@ -15,7 +15,7 @@ */ import CryptoKit -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyUnwrap+KeyUnwrapping.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyUnwrap+KeyUnwrapping.swift index 5ccb1b2..0726450 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyUnwrap+KeyUnwrapping.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyUnwrap+KeyUnwrapping.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyWrapper+KeyEncryption.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyWrapper+KeyEncryption.swift index 9f6d9c4..51f7517 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyWrapper+KeyEncryption.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSA15KeyWrapper+KeyEncryption.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyUnwrap+KeyUnwrapping.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyUnwrap+KeyUnwrapping.swift index 96fd9ed..bcda825 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyUnwrap+KeyUnwrapping.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyUnwrap+KeyUnwrapping.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyWrap+KeyEncryption.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyWrap+KeyEncryption.swift index e599f25..1f7182c 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyWrap+KeyEncryption.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEP256KeyWrap+KeyEncryption.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyUnwrap+KeyUnwrapping.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyUnwrap+KeyUnwrapping.swift index b5ed5d1..4c95411 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyUnwrap+KeyUnwrapping.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyUnwrap+KeyUnwrapping.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyWrap+KeyEncryption.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyWrap+KeyEncryption.swift index 0fe3fb0..b336294 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyWrap+KeyEncryption.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryption/RSA/RSAOAEPKeyWrap+KeyEncryption.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryptionAlgorithm.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryptionAlgorithm.swift index da3f855..9391060 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryptionAlgorithm.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyEncryptionAlgorithm.swift @@ -11,7 +11,7 @@ import Foundation /// Supported JWE cryptographic algorithms for key management. /// /// For more information, see [RFC7518 Section 4.1](https://www.rfc-editor.org/rfc/rfc7518#section-4.1) -public enum KeyManagementAlgorithm: String, Equatable, Codable { +public enum KeyManagementAlgorithm: String, Sendable, Equatable, Codable { /// RSA algorithm with PKCS #1 v1.5 padding. case rsa1_5 = "RSA1_5" diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/DataKey.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/DataKey.swift index bcd0c7c..3d43b35 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/DataKey.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/DataKey.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import CryptoKit import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/KeyRepresentable.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/KeyRepresentable.swift index 6ec5585..866315c 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/KeyRepresentable.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/KeyRepresentable.swift @@ -1,5 +1,5 @@ import CryptoKit -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import secp256k1 diff --git a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/SecKeyExtended.swift b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/SecKeyExtended.swift index 847116e..31f6455 100644 --- a/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/SecKeyExtended.swift +++ b/Sources/JSONWebAlgorithms/KeyManagement/KeyRepresentable/SecKeyExtended.swift @@ -1,5 +1,5 @@ import CryptoKit -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey import Security diff --git a/Sources/JSONWebAlgorithms/Signatures/EC/Signers/ES256KSigner.swift b/Sources/JSONWebAlgorithms/Signatures/EC/Signers/ES256KSigner.swift index 1cb71a3..ba18696 100644 --- a/Sources/JSONWebAlgorithms/Signatures/EC/Signers/ES256KSigner.swift +++ b/Sources/JSONWebAlgorithms/Signatures/EC/Signers/ES256KSigner.swift @@ -30,9 +30,9 @@ public struct ES256KSigner: Signer { } /// The output format of the signature. - public static var outputFormat = ES256KSigner.SignatureFormat.raw + nonisolated(unsafe) public static var outputFormat = ES256KSigner.SignatureFormat.raw /// Indicates whether the bytes R and S are inverted. - public static var invertedBytesR_S = false + nonisolated(unsafe) public static var invertedBytesR_S = false /// The algorithm used for signing. public var algorithm: String { SigningAlgorithm.ES256K.rawValue } diff --git a/Sources/JSONWebAlgorithms/Signatures/EC/Verifiers/ES256KVerifier.swift b/Sources/JSONWebAlgorithms/Signatures/EC/Verifiers/ES256KVerifier.swift index 80c7c62..6864a5e 100644 --- a/Sources/JSONWebAlgorithms/Signatures/EC/Verifiers/ES256KVerifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/EC/Verifiers/ES256KVerifier.swift @@ -22,7 +22,7 @@ import secp256k1 public struct ES256KVerifier: Verifier { /// Indicates whether to use a fail-safe mechanism compatible with Bouncy Castle. - public static var bouncyCastleFailSafe = false + nonisolated(unsafe) public static var bouncyCastleFailSafe = false /// The algorithm used for verification. public var algorithm: String { SigningAlgorithm.ES256K.rawValue } diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Helpers/RSA+Security.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Helpers/RSA+Security.swift index d877f7e..caf9732 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Helpers/RSA+Security.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Helpers/RSA+Security.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import Security diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS256Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS256Signer.swift index 0581e4e..1d6d64f 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS256Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS256Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS384Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS384Signer.swift index 96aaab9..4682364 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS384Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS384Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS512Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS512Signer.swift index 30952a4..cf3c2a9 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS512Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/PS512Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS256Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS256Signer.swift index f21a00e..65b98f3 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS256Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS256Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS384Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS384Signer.swift index 1ea0069..30ef4f0 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS384Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS384Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS512Signer.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS512Signer.swift index 41e946a..48dc8e6 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS512Signer.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Signers/RS512Signer.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS256Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS256Verifier.swift index 678c97b..ac89c9b 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS256Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS256Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS384Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS384Verifier.swift index abc5199..95a7dff 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS384Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS384Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS512Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS512Verifier.swift index e254d0c..a5bb77f 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS512Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/PS512Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS256Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS256Verifier.swift index 7f8825c..ba54ced 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS256Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS256Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS384Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS384Verifier.swift index d7acee4..ba55d69 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS384Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS384Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS512Verifier.swift b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS512Verifier.swift index 7b97610..af03752 100644 --- a/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS512Verifier.swift +++ b/Sources/JSONWebAlgorithms/Signatures/RSA/Verifiers/RS512Verifier.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import Foundation import JSONWebKey diff --git a/Sources/JSONWebAlgorithms/Signatures/SigningAlgorithm.swift b/Sources/JSONWebAlgorithms/Signatures/SigningAlgorithm.swift index b17cdca..8dd9dec 100644 --- a/Sources/JSONWebAlgorithms/Signatures/SigningAlgorithm.swift +++ b/Sources/JSONWebAlgorithms/Signatures/SigningAlgorithm.swift @@ -25,7 +25,7 @@ import Foundation /// - `PS256`, `PS384`, `PS512`: RSASSA-PSS (RSA Probabilistic Signature Scheme) using SHA-256, SHA-384, and SHA-512 hash functions, respectively, and MGF1 (Mask Generation Function 1). /// - `none`: Represents the absence of a digital signature or MAC. /// - `invalid`: A placeholder for an invalid or unsupported algorithm, useful for error handling or invalid state representation. -public enum SigningAlgorithm: String, Codable { +public enum SigningAlgorithm: String, Codable, Sendable { /// HMAC using SHA-256 case HS256 = "HS256" diff --git a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/JWEDecryptor.swift b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/JWEDecryptor.swift index d1d8e54..6b104e7 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Decryptors/JWEDecryptor.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Decryptors/JWEDecryptor.swift @@ -19,7 +19,7 @@ import JSONWebAlgorithms import JSONWebKey /// `JWEDecryptor` protocol defines functionality for decrypting JWE objects. -public protocol JWEDecryptor { +public protocol JWEDecryptor: Sendable { /// Supported key management algorithms by this decryptor. var supportedKeyManagementAlgorithms: [KeyManagementAlgorithm] { get } @@ -59,7 +59,7 @@ public protocol JWEDecryptor { } /// `JWEMultiDecryptor` protocol defines functionality for decrypting JWE objects with multiple recipients. -public protocol JWEMultiDecryptor { +public protocol JWEMultiDecryptor: Sendable { /// Decrypts a JWE object with multiple recipients given various headers and cryptographic components. /// - Parameters: /// - protectedHeader: Protected header, conforming to `JWERegisteredFieldsHeader`. diff --git a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/JWEEncrypter.swift b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/JWEEncrypter.swift index a058fd2..cfdd49c 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/Encryptors/JWEEncrypter.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/Encryptors/JWEEncrypter.swift @@ -19,7 +19,7 @@ import JSONWebAlgorithms import JSONWebKey /// JWEEncryptor protocol defines the encryption process for JWE. -public protocol JWEEncryptor { +public protocol JWEEncryptor: Sendable { /// Supported key management algorithms. var supportedKeyManagmentAlgorithms: [KeyManagementAlgorithm] { get } @@ -62,7 +62,7 @@ public protocol JWEEncryptor { } /// JWEMultiEncryptor protocol defines the encryption process for JWE with multiple recipients. -public protocol JWEMultiEncryptor { +public protocol JWEMultiEncryptor: Sendable { /// Encrypts a payload for multiple recipients. /// - Parameters: /// - payload: Data to be encrypted. diff --git a/Sources/JSONWebEncryption/EncryptionModule/JWE+EncryptionModule.swift b/Sources/JSONWebEncryption/EncryptionModule/JWE+EncryptionModule.swift index 35a73a1..d188e71 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/JWE+EncryptionModule.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/JWE+EncryptionModule.swift @@ -1,5 +1,5 @@ import Foundation extension JWE { - public static var encryptionModule: JWEEncryptionModule = .default + public static let encryptionModule: JWEEncryptionModule = .default } diff --git a/Sources/JSONWebEncryption/EncryptionModule/JWEEncryptionModule.swift b/Sources/JSONWebEncryption/EncryptionModule/JWEEncryptionModule.swift index 10f5e4c..b835fd3 100644 --- a/Sources/JSONWebEncryption/EncryptionModule/JWEEncryptionModule.swift +++ b/Sources/JSONWebEncryption/EncryptionModule/JWEEncryptionModule.swift @@ -18,7 +18,7 @@ import Foundation import JSONWebAlgorithms /// `JWEEncryptionProvider` represents an encryption provider for JSON Web Encryption (JWE) with a specific algorithm family. -public struct JWEEncryptionProvider: Hashable { +public struct JWEEncryptionProvider: Sendable, Hashable { /// The family of key management algorithm. public let family: KeyManagementAlgorithm.Family @@ -60,7 +60,7 @@ public struct JWEEncryptionProvider: Hashable { } /// `JWEEncryptionModule` manages a collection of `JWEEncryptionProvider` instances and provides encryption and decryption functionalities. -public struct JWEEncryptionModule { +public struct JWEEncryptionModule: Sendable { /// A set of registered encryption providers. public let registeredEncryptions: Set @@ -99,7 +99,7 @@ public struct JWEEncryptionModule { extension JWEEncryptionModule { /// The default `JWEEncryptionModule` instance with a predefined set of encryption providers. - public static var `default`: JWEEncryptionModule = .init( + public static let `default`: JWEEncryptionModule = .init( registeredEncryptions: Set( [ .init( @@ -145,7 +145,7 @@ extension JWEEncryptionModule { /// The default `JWEEncryptionModule` instance with a predefined set of encryption providers, were ECDH-1PU and ECDH-ES /// use a master ephemeral key for multiple recipients. - public static var defaultWithMasterEphemeralKey: JWEEncryptionModule = .init( + public static let defaultWithMasterEphemeralKey: JWEEncryptionModule = .init( registeredEncryptions: Set( [ .init( diff --git a/Sources/JSONWebEncryption/JWE.swift b/Sources/JSONWebEncryption/JWE.swift index 0bfb510..555703e 100644 --- a/Sources/JSONWebEncryption/JWE.swift +++ b/Sources/JSONWebEncryption/JWE.swift @@ -19,7 +19,7 @@ import Tools /// `JWE` struct represents a JSON Web Encryption (JWE) structure as defined in [RFC7516](https://tools.ietf.org/html/rfc7516). /// It provides mechanisms to encrypt content, represented as the `cipher`, along with various headers and authentication data. -public struct JWE { +public struct JWE: Sendable { /// The `protectedHeader` is a JWE header with registered fields that are integrity protected. public let protectedHeader: JWERegisteredFieldsHeader diff --git a/Sources/JSONWebEncryption/JWERegisteredFieldsHeader.swift b/Sources/JSONWebEncryption/JWERegisteredFieldsHeader.swift index f33d9a3..40bf0ce 100644 --- a/Sources/JSONWebEncryption/JWERegisteredFieldsHeader.swift +++ b/Sources/JSONWebEncryption/JWERegisteredFieldsHeader.swift @@ -20,7 +20,7 @@ import JSONWebKey /// `JWERegisteredFieldsHeader` protocol defines the standard fields used in the header of a JSON Web Encryption (JWE) object. /// It includes fields for specifying algorithms, keys, and other metadata related to JWE. -public protocol JWERegisteredFieldsHeader: JWARegisteredFieldsHeader { +public protocol JWERegisteredFieldsHeader: JWARegisteredFieldsHeader, Sendable { /// The algorithm used for key management in the JWE process. var keyManagementAlgorithm: KeyManagementAlgorithm? { get set } diff --git a/Sources/JSONWebEncryption/KeyManagementAlgorithm+Family.swift b/Sources/JSONWebEncryption/KeyManagementAlgorithm+Family.swift index 3b7b610..1f74647 100644 --- a/Sources/JSONWebEncryption/KeyManagementAlgorithm+Family.swift +++ b/Sources/JSONWebEncryption/KeyManagementAlgorithm+Family.swift @@ -19,7 +19,7 @@ import JSONWebAlgorithms extension KeyManagementAlgorithm { /// `Family` is an enumeration representing different families of cryptographic algorithms. - public enum Family: String, CaseIterable { + public enum Family: String, Sendable, CaseIterable { /// RSA family of algorithms. case rsa = "RSA" diff --git a/Sources/JSONWebKey/JWK.swift b/Sources/JSONWebKey/JWK.swift index 8fd3ea7..d8cd151 100644 --- a/Sources/JSONWebKey/JWK.swift +++ b/Sources/JSONWebKey/JWK.swift @@ -10,7 +10,7 @@ import CryptoKit import Foundation /// A JSON Web Key (JWK) representation [RFC7517](https://www.rfc-editor.org/rfc/rfc7517) -public struct JWK: Equatable, Hashable { +public struct JWK: Equatable, Hashable, Sendable { /// The key type. public var keyType: KeyType @@ -129,7 +129,7 @@ public extension JWK { /// For more information, see /// - https://www.rfc-editor.org/rfc/rfc7518#section-6.1 /// - https://www.rfc-editor.org/rfc/rfc8037#section-2 - enum KeyType: String, Codable, Equatable { + enum KeyType: String, Codable, Equatable, Sendable { case ellipticCurve = "EC" case rsa = "RSA" case octetSequence = "oct" @@ -139,7 +139,7 @@ public extension JWK { /// The intended use of the public key. /// /// For more information, see https://www.rfc-editor.org/rfc/rfc7517#section-4.2 - enum PublicKeyUse: String, Codable, Equatable { + enum PublicKeyUse: String, Codable, Equatable, Sendable { case signature = "sig" case encryption = "enc" } @@ -147,14 +147,14 @@ public extension JWK { /// The key operations that the key is intended to be used for. /// /// For more information, see https://www.rfc-editor.org/rfc/rfc7517#section-4.3 - enum KeyOperations: String, Codable, Equatable { + enum KeyOperations: String, Codable, Equatable, Sendable { case sign, verify, encrypt, decrypt, wrapKey, unwrapKey, deriveKey, deriveBits } /// The cryptographic curves. /// /// For more information, see https://www.rfc-editor.org/rfc/rfc7518#section-6.1 - enum CryptographicCurve: String, Codable, CaseIterable, Equatable { + enum CryptographicCurve: String, Codable, CaseIterable, Equatable, Sendable { case p256 = "P-256" case p384 = "P-384" case p521 = "P-521" diff --git a/Sources/JSONWebSignature/JWS.swift b/Sources/JSONWebSignature/JWS.swift index 933e952..c82ae99 100644 --- a/Sources/JSONWebSignature/JWS.swift +++ b/Sources/JSONWebSignature/JWS.swift @@ -22,7 +22,7 @@ import Tools /// `JWS` represents a JSON Web Signature (JWS) structure as defined in [RFC7515](https://tools.ietf.org/html/rfc7515). /// It encapsulates the protected header, payload, and signature of a JWS, /// and provides functionality for initializing and manipulating JWS objects in compliance with the standard. -public struct JWS { +public struct JWS: Sendable { /// The protected header fields of the JWS as specified in RFC 7515. /// This header contains metadata about the type of signature and algorithm used. public let protectedHeader: JWSRegisteredFieldsHeader diff --git a/Sources/JSONWebSignature/JWSRegisteredFieldsHeader.swift b/Sources/JSONWebSignature/JWSRegisteredFieldsHeader.swift index 83008aa..a441af1 100644 --- a/Sources/JSONWebSignature/JWSRegisteredFieldsHeader.swift +++ b/Sources/JSONWebSignature/JWSRegisteredFieldsHeader.swift @@ -20,7 +20,7 @@ import JSONWebKey /// `JWSProtectedFieldsHeader` protocol defines the structure for the protected header fields used in a JSON Web Signature (JWS). /// It includes various optional fields that can be included in a JWS Header. -public protocol JWSRegisteredFieldsHeader: Codable { +public protocol JWSRegisteredFieldsHeader: Codable, Sendable { /// The signing algorithm to be used. var algorithm: SigningAlgorithm? { get set } diff --git a/Sources/JSONWebToken/JWT.swift b/Sources/JSONWebToken/JWT.swift index 518f2eb..9f0f72f 100644 --- a/Sources/JSONWebToken/JWT.swift +++ b/Sources/JSONWebToken/JWT.swift @@ -22,7 +22,7 @@ import JSONWebKey /// `JWT` represents a JSON Web Token (JWT) structure as defined in [RFC7519](https://tools.ietf.org/html/rfc7519). public struct JWT { /// `Format` is an enumeration that defines the two possible formats for a JWT: JWE and JWS. - public enum Format { + public enum Format: Sendable { /// JWE format, representing an encrypted JWT. case jwe(JWE) diff --git a/Tests/JWATests/Mocks/JWK+Testing.swift b/Tests/JWATests/Mocks/JWK+Testing.swift index fe33dc2..a0ca2af 100644 --- a/Tests/JWATests/Mocks/JWK+Testing.swift +++ b/Tests/JWATests/Mocks/JWK+Testing.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import CryptoKit import Foundation import JSONWebKey diff --git a/Tests/JWETests/Mocks/JWK+Testing.swift b/Tests/JWETests/Mocks/JWK+Testing.swift index 2637059..003d75b 100644 --- a/Tests/JWETests/Mocks/JWK+Testing.swift +++ b/Tests/JWETests/Mocks/JWK+Testing.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import CryptoKit import Foundation import JSONWebKey diff --git a/Tests/JWTTests/Mock/JWK+Testing.swift b/Tests/JWTTests/Mock/JWK+Testing.swift index 2637059..003d75b 100644 --- a/Tests/JWTTests/Mock/JWK+Testing.swift +++ b/Tests/JWTTests/Mock/JWK+Testing.swift @@ -14,7 +14,7 @@ * limitations under the License. */ -import CryptoSwift +@preconcurrency import CryptoSwift import CryptoKit import Foundation import JSONWebKey