Skip to content

Commit 7413d58

Browse files
Only include SHA-3 digests in DigestTests when available in the SDK
1 parent 5d1c1ba commit 7413d58

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Tests/CryptoTests/Digests/DigestsTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ enum TestError: Error {
2727

2828
func nullTestVectorForAlgorithm<H: HashFunction>(hashFunction: H.Type) throws -> String {
2929
#if !CRYPTOKIT_IN_SEP
30+
#if !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
3031
if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, visionOS 2.0, *) {
3132
switch H.self {
3233
case is SHA3_256.Type: return "a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a"
@@ -36,6 +37,7 @@ func nullTestVectorForAlgorithm<H: HashFunction>(hashFunction: H.Type) throws ->
3637
break
3738
}
3839
}
40+
#endif // !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
3941
#endif // !CRYPTOKIT_IN_SEP
4042

4143
switch H.self {
@@ -51,6 +53,7 @@ func nullTestVectorForAlgorithm<H: HashFunction>(hashFunction: H.Type) throws ->
5153

5254
func testVectorForAlgorithm<H: HashFunction>(hashFunction: H.Type) throws -> String {
5355
#if !CRYPTOKIT_IN_SEP
56+
#if !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
5457
if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, visionOS 2.0, *) {
5558
switch H.self {
5659
case is SHA3_256.Type: return "916f6061fe879741ca6469b43971dfdb28b1a32dc36cb3254e812be27aad1d18"
@@ -60,6 +63,7 @@ func testVectorForAlgorithm<H: HashFunction>(hashFunction: H.Type) throws -> Str
6063
break
6164
}
6265
}
66+
#endif // !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
6367
#endif // !CRYPTOKIT_IN_SEP
6468

6569
switch H.self {
@@ -114,11 +118,13 @@ class DigestsTests: XCTestCase {
114118
try orFail { try testHashFunction(hf: SHA384.self) }
115119
try orFail { try testHashFunction(hf: SHA512.self) }
116120
#if !CRYPTOKIT_IN_SEP
121+
#if !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
117122
if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, visionOS 2.0, *) {
118123
try orFail { try testHashFunction(hf: SHA3_256.self) }
119124
try orFail { try testHashFunction(hf: SHA3_384.self) }
120125
try orFail { try testHashFunction(hf: SHA3_512.self) }
121126
}
127+
#endif // !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
122128
#endif // !CRYPTOKIT_IN_SEP
123129
}
124130

@@ -143,11 +149,13 @@ class DigestsTests: XCTestCase {
143149
try orFail { try testHashFunctionImplementsCoW(hf: SHA384.self) }
144150
try orFail { try testHashFunctionImplementsCoW(hf: SHA512.self) }
145151
#if !CRYPTOKIT_IN_SEP
152+
#if !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
146153
if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, visionOS 2.0, *) {
147154
try orFail { try testHashFunctionImplementsCoW(hf: SHA3_256.self) }
148155
try orFail { try testHashFunctionImplementsCoW(hf: SHA3_384.self) }
149156
try orFail { try testHashFunctionImplementsCoW(hf: SHA3_512.self) }
150157
}
158+
#endif // !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
151159
#endif // !CRYPTOKIT_IN_SEP
152160
}
153161

@@ -160,11 +168,13 @@ class DigestsTests: XCTestCase {
160168
XCTAssertEqual(SHA512.blockByteCount, 128)
161169

162170
#if !CRYPTOKIT_IN_SEP
171+
#if !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
163172
if #available(iOS 19.0, macOS 16.0, watchOS 12.0, tvOS 19.0, macCatalyst 19.0, visionOS 2.0, *) {
164173
XCTAssertEqual(SHA3_256.blockByteCount, 136)
165174
XCTAssertEqual(SHA3_384.blockByteCount, 104)
166175
XCTAssertEqual(SHA3_512.blockByteCount, 72)
167176
}
177+
#endif // !canImport(Darwin) || canImport(CryptoKit, _version: 324.0.4)
168178
#endif // !CRYPTOKIT_IN_SEP
169179
}
170180
}

0 commit comments

Comments
 (0)