From 67e54ae1db7966bd8cfa8d685eb5784269186ebe Mon Sep 17 00:00:00 2001 From: Si Beaumont Date: Wed, 12 Mar 2025 15:18:27 +0000 Subject: [PATCH] Add missing availability guards required when development mode enabled (#337) ### Motivation When developing code that uses the BoringSSL backend on macOS, developers set a `development` boolean flag in the Package.swift. We recently switched from declaring minimum platform versions to annotating symbols with availability annotations. However, when `development = true`, it flushes out some annotations that were missing in the first pass. The result is that `main` currently doesn't build on macOS with this flag set. ### Modifications - Add missing availability guards required when development mode enabled. ### Result: Code builds macOS with `development = true` in Package.swift. --- Sources/Crypto/ASN1/ASN1.swift | 2 ++ Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift | 1 + Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift | 1 + Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift | 1 + Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift | 1 + Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift | 1 + Sources/Crypto/CryptoKitErrors.swift | 1 + .../Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift | 1 + Sources/Crypto/Signatures/ECDSA.swift | 3 +++ Sources/Crypto/Util/SecureBytes.swift | 4 ++++ 10 files changed, 16 insertions(+) diff --git a/Sources/Crypto/ASN1/ASN1.swift b/Sources/Crypto/ASN1/ASN1.swift index f5d6eeeb..27c0dec0 100644 --- a/Sources/Crypto/ASN1/ASN1.swift +++ b/Sources/Crypto/ASN1/ASN1.swift @@ -127,6 +127,7 @@ extension ASN1 { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1ParserNode: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) @@ -335,6 +336,7 @@ extension ASN1 { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1ParseResult: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift index 089776b3..10c1dcb5 100644 --- a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift +++ b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1BitString.swift @@ -58,6 +58,7 @@ extension ASN1 { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1BitString: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift index 019fbb0e..a6922916 100644 --- a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift +++ b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Identifier.swift @@ -138,6 +138,7 @@ extension ASN1.ASN1Identifier { internal static let generalizedTime = try! ASN1.ASN1Identifier(rawIdentifier: 0x18) } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1Identifier: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift index 23ed05d3..121de7de 100644 --- a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift +++ b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1Integer.swift @@ -170,6 +170,7 @@ extension IntegerBytesCollection: RandomAccessCollection { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension IntegerBytesCollection.Index: Equatable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift index ebe9894b..a09da49d 100644 --- a/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift +++ b/Sources/Crypto/ASN1/Basic ASN1 Types/ASN1OctetString.swift @@ -51,6 +51,7 @@ extension ASN1 { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1OctetString: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift b/Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift index c9127b14..55641bc6 100644 --- a/Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift +++ b/Sources/Crypto/ASN1/Basic ASN1 Types/ObjectIdentifier.swift @@ -133,6 +133,7 @@ extension ASN1 { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension ASN1.ASN1ObjectIdentifier: Hashable {} @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) diff --git a/Sources/Crypto/CryptoKitErrors.swift b/Sources/Crypto/CryptoKitErrors.swift index 3ded315e..c3c61c92 100644 --- a/Sources/Crypto/CryptoKitErrors.swift +++ b/Sources/Crypto/CryptoKitErrors.swift @@ -34,6 +34,7 @@ public enum CryptoKitError: Error { case invalidParameter } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension CryptoKitError: Equatable, Hashable {} /// Errors from decoding ASN.1 content. diff --git a/Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift b/Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift index 1056f947..4a8c8287 100644 --- a/Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift +++ b/Sources/Crypto/HPKE/Ciphersuite/KEM/Conformances/HPKE-KEM-Curve25519.swift @@ -16,6 +16,7 @@ #else import Foundation +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension Curve25519.KeyAgreement.PrivateKey: HPKEDiffieHellmanPrivateKeyGeneration {} diff --git a/Sources/Crypto/Signatures/ECDSA.swift b/Sources/Crypto/Signatures/ECDSA.swift index 029e1750..94102471 100644 --- a/Sources/Crypto/Signatures/ECDSA.swift +++ b/Sources/Crypto/Signatures/ECDSA.swift @@ -131,6 +131,7 @@ extension P256.Signing { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension P256.Signing: NISTSigning {} // MARK: - P256 + PrivateKey @@ -300,6 +301,7 @@ extension P384.Signing { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension P384.Signing: NISTSigning {} // MARK: - P384 + PrivateKey @@ -469,6 +471,7 @@ extension P521.Signing { } } +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension P521.Signing: NISTSigning {} // MARK: - P521 + PrivateKey diff --git a/Sources/Crypto/Util/SecureBytes.swift b/Sources/Crypto/Util/SecureBytes.swift index 5fc2277d..5ad2544d 100644 --- a/Sources/Crypto/Util/SecureBytes.swift +++ b/Sources/Crypto/Util/SecureBytes.swift @@ -144,9 +144,11 @@ extension SecureBytes: BidirectionalCollection { } // MARK: - RandomAccessCollection conformance +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension SecureBytes: RandomAccessCollection { } // MARK: - MutableCollection conformance +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension SecureBytes: MutableCollection { } // MARK: - RangeReplaceableCollection conformance @@ -224,9 +226,11 @@ extension SecureBytes: DataProtocol { } // MARK: - MutableDataProtocol conformance +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension SecureBytes: MutableDataProtocol { } // MARK: - Index conformances +@available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *) extension SecureBytes.Index: Hashable { } @available(macOS 10.15, iOS 13, watchOS 6, tvOS 13, *)