From 886c624612424283d1e0647a2a8a556c3f7a0c15 Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Sun, 20 Oct 2024 01:35:20 +0100 Subject: [PATCH 1/3] Provide typealias to remove CryptoKit implementation detail --- Sources/Crypto/CryptoKitErrors.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/Crypto/CryptoKitErrors.swift b/Sources/Crypto/CryptoKitErrors.swift index 53aad45d..db7d6eb8 100644 --- a/Sources/Crypto/CryptoKitErrors.swift +++ b/Sources/Crypto/CryptoKitErrors.swift @@ -64,3 +64,7 @@ public enum CryptoKitASN1Error: Equatable, Error, Hashable { case invalidPEMDocument } #endif + +public typealias CryptoError = CryptoKitError +@available(iOS 14, macOS 11, tvOS 14, watchOS 7, *) +public typealias CryptoASN1Error = CryptoKitASN1Error \ No newline at end of file From 66c1660bd7f0dca1410b27592b16af281bbe4a7e Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Sun, 20 Oct 2024 01:36:47 +0100 Subject: [PATCH 2/3] Rename public documentation --- README.md | 2 +- Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9a72b1c3..cbfc1518 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,7 @@ What this means for you is that you should depend on Swift Crypto with a version In SwiftPM that can be easily done specifying for example `from: "1.0.0"` meaning that you support Swift Crypto in every version starting from 1.0.0 up to (excluding) 2.0.0. SemVer and Swift Crypto's Public API guarantees should result in a working program without having to worry about testing every single version for compatibility. -Swift Crypto 2.0.0 was released in September 2021. The only breaking change between Swift Crypto 2.0.0 and 1.0.0 was the addition of new cases in the `CryptoKitError` enumeration. For most users, then, it's safe to depend on either the 1.0.0 _or_ 2.0.0 series of releases. +Swift Crypto 2.0.0 was released in September 2021. The only breaking change between Swift Crypto 2.0.0 and 1.0.0 was the addition of new cases in the `CryptoError` enumeration. For most users, then, it's safe to depend on either the 1.0.0 _or_ 2.0.0 series of releases. To do so, please use the following dependency in your `Package.swift`: diff --git a/Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift b/Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift index a197704e..4bb2f1c1 100644 --- a/Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift +++ b/Sources/_CryptoExtras/RSA/RSA+BlindSigning.swift @@ -475,7 +475,7 @@ extension _RSA.BlindSigning.PublicKey { extension _RSA.BlindSigning { /// Errors defined in the RSA Blind Signatures protocol. /// - /// - NOTE: This type does not conform to `Swift.Error`, it is used to construct a `CryptoKitError`. + /// - NOTE: This type does not conform to `Swift.Error`, it is used to construct a `CryptoError`. /// /// - Seealso: [RFC 9474: Errors](https://www.rfc-editor.org/rfc/rfc9474.html#name-errors). enum ProtocolError { @@ -490,7 +490,7 @@ extension _RSA.BlindSigning { } extension CryptoKitError { - /// Map an error from the RSA Blind Signatures protocol to a CryptoKitError. + /// Map an error from the RSA Blind Signatures protocol to a CryptoError. init(_ error: _RSA.BlindSigning.ProtocolError) { switch error { case .messageTooLong: From 544fa018cc483adada7222fa90e9159e70f5222a Mon Sep 17 00:00:00 2001 From: Tim <0xtimc@gmail.com> Date: Sun, 20 Oct 2024 01:39:05 +0100 Subject: [PATCH 3/3] File renames --- Sources/Crypto/CMakeLists.txt | 4 ++-- Sources/Crypto/{CryptoKitErrors.swift => CryptoErrors.swift} | 0 ...CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} | 0 Sources/CryptoBoringWrapper/CMakeLists.txt | 2 +- ...CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} | 0 Sources/_CryptoExtras/CMakeLists.txt | 2 +- ...CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} | 0 7 files changed, 4 insertions(+), 4 deletions(-) rename Sources/Crypto/{CryptoKitErrors.swift => CryptoErrors.swift} (100%) rename Sources/Crypto/Util/BoringSSL/{CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} (100%) rename Sources/CryptoBoringWrapper/{CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} (100%) rename Sources/_CryptoExtras/Util/{CryptoKitErrors_boring.swift => CryptoErrors_boring.swift} (100%) diff --git a/Sources/Crypto/CMakeLists.txt b/Sources/Crypto/CMakeLists.txt index 95a1c437..cb966cab 100644 --- a/Sources/Crypto/CMakeLists.txt +++ b/Sources/Crypto/CMakeLists.txt @@ -36,7 +36,7 @@ add_library(Crypto "ASN1/PKCS8PrivateKey.swift" "ASN1/SEC1PrivateKey.swift" "ASN1/SubjectPublicKeyInfo.swift" - "CryptoKitErrors.swift" + "CryptoErrors.swift" "Digests/BoringSSL/Digest_boring.swift" "Digests/Digest.swift" "Digests/Digests.swift" @@ -84,7 +84,7 @@ add_library(Crypto "Signatures/ECDSA.swift" "Signatures/Ed25519.swift" "Signatures/Signature.swift" - "Util/BoringSSL/CryptoKitErrors_boring.swift" + "Util/BoringSSL/CryptoErrors_boring.swift" "Util/BoringSSL/RNG_boring.swift" "Util/BoringSSL/SafeCompare_boring.swift" "Util/BoringSSL/Zeroization_boring.swift" diff --git a/Sources/Crypto/CryptoKitErrors.swift b/Sources/Crypto/CryptoErrors.swift similarity index 100% rename from Sources/Crypto/CryptoKitErrors.swift rename to Sources/Crypto/CryptoErrors.swift diff --git a/Sources/Crypto/Util/BoringSSL/CryptoKitErrors_boring.swift b/Sources/Crypto/Util/BoringSSL/CryptoErrors_boring.swift similarity index 100% rename from Sources/Crypto/Util/BoringSSL/CryptoKitErrors_boring.swift rename to Sources/Crypto/Util/BoringSSL/CryptoErrors_boring.swift diff --git a/Sources/CryptoBoringWrapper/CMakeLists.txt b/Sources/CryptoBoringWrapper/CMakeLists.txt index 33cc096e..27fd30b5 100644 --- a/Sources/CryptoBoringWrapper/CMakeLists.txt +++ b/Sources/CryptoBoringWrapper/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(CryptoBoringWrapper STATIC "AEAD/BoringSSLAEAD.swift" - "CryptoKitErrors_boring.swift" + "CryptoErrors_boring.swift" "EC/EllipticCurve.swift" "EC/EllipticCurvePoint.swift" "Util/ArbitraryPrecisionInteger.swift" diff --git a/Sources/CryptoBoringWrapper/CryptoKitErrors_boring.swift b/Sources/CryptoBoringWrapper/CryptoErrors_boring.swift similarity index 100% rename from Sources/CryptoBoringWrapper/CryptoKitErrors_boring.swift rename to Sources/CryptoBoringWrapper/CryptoErrors_boring.swift diff --git a/Sources/_CryptoExtras/CMakeLists.txt b/Sources/_CryptoExtras/CMakeLists.txt index b2d05631..410013c9 100644 --- a/Sources/_CryptoExtras/CMakeLists.txt +++ b/Sources/_CryptoExtras/CMakeLists.txt @@ -26,7 +26,7 @@ add_library(_CryptoExtras "RSA/RSA_boring.swift" "RSA/RSA_security.swift" "Util/BoringSSLHelpers.swift" - "Util/CryptoKitErrors_boring.swift" + "Util/CryptoErrors_boring.swift" "Util/DigestType.swift" "Util/Error.swift" "Util/PEMDocument.swift" diff --git a/Sources/_CryptoExtras/Util/CryptoKitErrors_boring.swift b/Sources/_CryptoExtras/Util/CryptoErrors_boring.swift similarity index 100% rename from Sources/_CryptoExtras/Util/CryptoKitErrors_boring.swift rename to Sources/_CryptoExtras/Util/CryptoErrors_boring.swift