From 96955d9dec66b6ccbafaf9893ceb7811e780d8bb Mon Sep 17 00:00:00 2001 From: huskcasaca <100605532+huskcasaca@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:26:04 +0800 Subject: [PATCH 1/4] Add support for RIPEMD --- .../ckbuild/tests/GenerateProviderTestsTask.kt | 8 ++++++++ cryptography-core/api/cryptography-core.api | 16 ++++++++++++++++ cryptography-core/api/cryptography-core.klib.api | 8 ++++++++ .../src/commonMain/kotlin/algorithms/Digest.kt | 6 ++++++ .../commonMain/kotlin/SupportedAlgorithmsTest.kt | 5 +++++ .../compatibility/DigestCompatibilityTest.kt | 5 +++++ .../src/commonMain/kotlin/default/DigestTest.kt | 12 ++++++++++++ .../jvmMain/kotlin/JdkCryptographyProvider.kt | 4 ++++ .../kotlin/Openssl3CryptographyProvider.kt | 1 + docs/providers/index.md | 1 + 10 files changed, 66 insertions(+) diff --git a/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt b/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt index a27aeda4..e8fe9cb0 100644 --- a/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt +++ b/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt @@ -78,17 +78,25 @@ abstract class GenerateProviderTestsTask : DefaultTask() { "HkdfTestvectorsTest", "DigestTest", + "Md5CompatibilityTest", + "Sha1CompatibilityTest", "Sha224CompatibilityTest", "Sha256CompatibilityTest", "Sha384CompatibilityTest", "Sha512CompatibilityTest", + "Sha3B224CompatibilityTest", "Sha3B256CompatibilityTest", "Sha3B384CompatibilityTest", "Sha3B512CompatibilityTest", + "Ripemd128CompatibilityTest", + "Ripemd160CompatibilityTest", + "Ripemd256CompatibilityTest", + "Ripemd320CompatibilityTest", + "AesCbcTest", "AesCbcCompatibilityTest", "AesCtrTest", diff --git a/cryptography-core/api/cryptography-core.api b/cryptography-core/api/cryptography-core.api index 28cc80fa..1a4b933b 100644 --- a/cryptography-core/api/cryptography-core.api +++ b/cryptography-core/api/cryptography-core.api @@ -446,6 +446,22 @@ public abstract interface class dev/whyoleg/cryptography/algorithms/PBKDF2 : dev public final class dev/whyoleg/cryptography/algorithms/PBKDF2$Companion : dev/whyoleg/cryptography/CryptographyAlgorithmId { } +public final class dev/whyoleg/cryptography/algorithms/RIPEMD128 : dev/whyoleg/cryptography/CryptographyAlgorithmId { + public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD128; +} + +public final class dev/whyoleg/cryptography/algorithms/RIPEMD160 : dev/whyoleg/cryptography/CryptographyAlgorithmId { + public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD160; +} + +public final class dev/whyoleg/cryptography/algorithms/RIPEMD256 : dev/whyoleg/cryptography/CryptographyAlgorithmId { + public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD256; +} + +public final class dev/whyoleg/cryptography/algorithms/RIPEMD320 : dev/whyoleg/cryptography/CryptographyAlgorithmId { + public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD320; +} + public abstract interface class dev/whyoleg/cryptography/algorithms/RSA : dev/whyoleg/cryptography/CryptographyAlgorithm { public abstract fun keyPairGenerator-imL9hLU (ILdev/whyoleg/cryptography/CryptographyAlgorithmId;Ldev/whyoleg/cryptography/bigint/BigInt;)Ldev/whyoleg/cryptography/materials/key/KeyGenerator; public static synthetic fun keyPairGenerator-imL9hLU$default (Ldev/whyoleg/cryptography/algorithms/RSA;ILdev/whyoleg/cryptography/CryptographyAlgorithmId;Ldev/whyoleg/cryptography/bigint/BigInt;ILjava/lang/Object;)Ldev/whyoleg/cryptography/materials/key/KeyGenerator; diff --git a/cryptography-core/api/cryptography-core.klib.api b/cryptography-core/api/cryptography-core.klib.api index 5fc5301e..9da04d7f 100644 --- a/cryptography-core/api/cryptography-core.klib.api +++ b/cryptography-core/api/cryptography-core.klib.api @@ -801,6 +801,14 @@ open class dev.whyoleg.cryptography/CryptographyException : kotlin/RuntimeExcept final object dev.whyoleg.cryptography.algorithms/MD5 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/MD5|null[0] +final object dev.whyoleg.cryptography.algorithms/RIPEMD128 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD128|null[0] + +final object dev.whyoleg.cryptography.algorithms/RIPEMD160 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD160|null[0] + +final object dev.whyoleg.cryptography.algorithms/RIPEMD256 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD256|null[0] + +final object dev.whyoleg.cryptography.algorithms/RIPEMD320 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD320|null[0] + final object dev.whyoleg.cryptography.algorithms/SHA1 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/SHA1|null[0] final object dev.whyoleg.cryptography.algorithms/SHA224 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/SHA224|null[0] diff --git a/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt b/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt index 50ad0518..c0e35d4b 100644 --- a/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt +++ b/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt @@ -37,3 +37,9 @@ public object SHA3_384 : CryptographyAlgorithmId("SHA3-384") @Suppress("ClassName") public object SHA3_512 : CryptographyAlgorithmId("SHA3-512") + +@DelicateCryptographyApi +public object RIPEMD128 : CryptographyAlgorithmId("RIPEMD-128") +public object RIPEMD160 : CryptographyAlgorithmId("RIPEMD-160") +public object RIPEMD256 : CryptographyAlgorithmId("RIPEMD-256") +public object RIPEMD320 : CryptographyAlgorithmId("RIPEMD-320") diff --git a/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt index 8facc7c1..e1ecc63a 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt @@ -44,6 +44,11 @@ abstract class SupportedAlgorithmsTest(provider: CryptographyProvider) : Provide assertSupports(SHA3_384, supportsSha3) assertSupports(SHA3_512, supportsSha3) + assertSupports(RIPEMD128, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) + assertSupports(RIPEMD160, !context.provider.isApple && !context.provider.isWebCrypto) + assertSupports(RIPEMD256, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) + assertSupports(RIPEMD320, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) + assertSupports(ECDSA) assertSupports(ECDH, !context.provider.isApple) diff --git a/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt index 63464870..1ab3e5a9 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt @@ -26,6 +26,11 @@ abstract class Sha3B256CompatibilityTest(provider: CryptographyProvider) : Diges abstract class Sha3B384CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_384, provider) abstract class Sha3B512CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_512, provider) +abstract class Ripemd128CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD128, provider) +abstract class Ripemd160CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD160, provider) +abstract class Ripemd256CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD256, provider) +abstract class Ripemd320CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD320, provider) + abstract class DigestCompatibilityTest(algorithmId: CryptographyAlgorithmId, provider: CryptographyProvider) : CompatibilityTest(algorithmId, provider) { override suspend fun CompatibilityTestScope.generate(isStressTest: Boolean) { diff --git a/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt index 4258ad07..5819ae67 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt @@ -98,6 +98,18 @@ abstract class DigestTest(provider: CryptographyProvider) : ProviderTest(provide @Test fun testSHA3_512() = test(SHA3_512, 64) + @Test + fun testRIPEMD128() = test(RIPEMD128, 16) + + @Test + fun testRIPEMD160() = test(RIPEMD160, 20) + + @Test + fun testRIPEMD256() = test(RIPEMD256, 32) + + @Test + fun testRIPEMD320() = test(RIPEMD320, 40) + @Test fun testFunctionIndexes() = testWithAlgorithm(SHA256) { if (!supportsFunctions()) return@testWithAlgorithm diff --git a/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt b/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt index bda7996f..e32c223b 100644 --- a/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt +++ b/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt @@ -77,6 +77,10 @@ internal class JdkCryptographyProvider( SHA3_256 -> JdkDigest(state, "SHA3-256", SHA3_256) SHA3_384 -> JdkDigest(state, "SHA3-384", SHA3_384) SHA3_512 -> JdkDigest(state, "SHA3-512", SHA3_512) + RIPEMD128 -> JdkDigest(state, "RIPEMD128", RIPEMD128) + RIPEMD160 -> JdkDigest(state, "RIPEMD160", RIPEMD160) + RIPEMD256 -> JdkDigest(state, "RIPEMD256", RIPEMD256) + RIPEMD320 -> JdkDigest(state, "RIPEMD320", RIPEMD320) HMAC -> JdkHmac(state) AES.CBC -> JdkAesCbc(state) AES.CTR -> JdkAesCtr(state) diff --git a/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt b/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt index 8cd43b7e..fc3912fc 100644 --- a/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt +++ b/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt @@ -30,6 +30,7 @@ internal object Openssl3CryptographyProvider : CryptographyProvider() { SHA3_256 -> Openssl3Digest("SHA3-256", SHA3_256) SHA3_384 -> Openssl3Digest("SHA3-384", SHA3_384) SHA3_512 -> Openssl3Digest("SHA3-512", SHA3_512) + RIPEMD160 -> Openssl3Digest("RIPEMD160", RIPEMD160) HMAC -> Openssl3Hmac AES.CBC -> Openssl3AesCbc AES.CTR -> Openssl3AesCtr diff --git a/docs/providers/index.md b/docs/providers/index.md index 6e73b052..4d5056f5 100644 --- a/docs/providers/index.md +++ b/docs/providers/index.md @@ -57,6 +57,7 @@ For additional limitation please consult provider specific documentation. | | SHA384 | ✅ | ✅ | ✅ | ✅ | | | SHA512 | ✅ | ✅ | ✅ | ✅ | | | SHA3 family | ✅ | ❌ | ❌ | ✅ | +| | ⚠️ RIPEMD160 | ✅ | ❌ | ❌ | ✅ | | **MAC** | HMAC | ✅ | ✅ | ✅ | ✅ | | **Symmetric-key
encryption/decryption** | AES-CBC | ✅ | ✅ | ✅ | ✅ | | | AES-CTR | ✅ | ✅ | ✅ | ✅ | From 5e9b10f6b5a7b02ac5493d628b4836a083538bd3 Mon Sep 17 00:00:00 2001 From: huskcasaca <100605532+huskcasaca@users.noreply.github.com> Date: Wed, 4 Dec 2024 19:17:49 +0800 Subject: [PATCH 2/4] Fix RIPEMD supported platforms --- .../src/commonMain/kotlin/support.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt b/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt index 8aee96c6..b9431392 100644 --- a/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt +++ b/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt @@ -21,6 +21,7 @@ fun AlgorithmTestScope<*>.supportsFunctions() = supports { fun AlgorithmTestScope<*>.supportsDigest(digest: CryptographyAlgorithmId): Boolean = supports { val sha3Algorithms = setOf(SHA3_224, SHA3_256, SHA3_384, SHA3_512) + val ripemdAlgorithms = setOf(RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320) when { (digest == SHA224 || digest in sha3Algorithms) && provider.isWebCrypto -> digest.name @@ -29,6 +30,10 @@ fun AlgorithmTestScope<*>.supportsDigest(digest: CryptographyAlgorithmId digest in sha3Algorithms && provider.isJdkDefault && (platform.isJdk { major < 17 } || platform.isAndroid) -> "${digest.name} signatures on old JDK" + digest in ripemdAlgorithms && (provider.isJdkDefault || provider.isApple || provider.isWebCrypto) + -> digest.name + digest != RIPEMD160 && digest in ripemdAlgorithms && provider.isOpenssl3 + -> digest.name else -> null } } From 452d658c91e59ea2b261278e122bc15cbf57b14d Mon Sep 17 00:00:00 2001 From: huskcasaca <100605532+huskcasaca@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:01:54 +0800 Subject: [PATCH 3/4] Remove RIPEMD128/256/320 --- .../ckbuild/tests/GenerateProviderTestsTask.kt | 7 ------- cryptography-core/api/cryptography-core.api | 12 ------------ cryptography-core/api/cryptography-core.klib.api | 6 ------ .../src/commonMain/kotlin/algorithms/Digest.kt | 3 --- .../src/commonMain/kotlin/support.kt | 5 +---- .../src/commonMain/kotlin/SupportedAlgorithmsTest.kt | 3 --- .../kotlin/compatibility/DigestCompatibilityTest.kt | 4 ---- .../src/commonMain/kotlin/default/DigestTest.kt | 9 --------- .../src/jvmMain/kotlin/JdkCryptographyProvider.kt | 3 --- .../kotlin/Openssl3CryptographyProvider.kt | 2 +- 10 files changed, 2 insertions(+), 52 deletions(-) diff --git a/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt b/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt index e8fe9cb0..f6be1ed4 100644 --- a/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt +++ b/build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt @@ -78,24 +78,17 @@ abstract class GenerateProviderTestsTask : DefaultTask() { "HkdfTestvectorsTest", "DigestTest", - "Md5CompatibilityTest", - "Sha1CompatibilityTest", "Sha224CompatibilityTest", "Sha256CompatibilityTest", "Sha384CompatibilityTest", "Sha512CompatibilityTest", - "Sha3B224CompatibilityTest", "Sha3B256CompatibilityTest", "Sha3B384CompatibilityTest", "Sha3B512CompatibilityTest", - - "Ripemd128CompatibilityTest", "Ripemd160CompatibilityTest", - "Ripemd256CompatibilityTest", - "Ripemd320CompatibilityTest", "AesCbcTest", "AesCbcCompatibilityTest", diff --git a/cryptography-core/api/cryptography-core.api b/cryptography-core/api/cryptography-core.api index 1a4b933b..327b419d 100644 --- a/cryptography-core/api/cryptography-core.api +++ b/cryptography-core/api/cryptography-core.api @@ -446,22 +446,10 @@ public abstract interface class dev/whyoleg/cryptography/algorithms/PBKDF2 : dev public final class dev/whyoleg/cryptography/algorithms/PBKDF2$Companion : dev/whyoleg/cryptography/CryptographyAlgorithmId { } -public final class dev/whyoleg/cryptography/algorithms/RIPEMD128 : dev/whyoleg/cryptography/CryptographyAlgorithmId { - public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD128; -} - public final class dev/whyoleg/cryptography/algorithms/RIPEMD160 : dev/whyoleg/cryptography/CryptographyAlgorithmId { public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD160; } -public final class dev/whyoleg/cryptography/algorithms/RIPEMD256 : dev/whyoleg/cryptography/CryptographyAlgorithmId { - public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD256; -} - -public final class dev/whyoleg/cryptography/algorithms/RIPEMD320 : dev/whyoleg/cryptography/CryptographyAlgorithmId { - public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD320; -} - public abstract interface class dev/whyoleg/cryptography/algorithms/RSA : dev/whyoleg/cryptography/CryptographyAlgorithm { public abstract fun keyPairGenerator-imL9hLU (ILdev/whyoleg/cryptography/CryptographyAlgorithmId;Ldev/whyoleg/cryptography/bigint/BigInt;)Ldev/whyoleg/cryptography/materials/key/KeyGenerator; public static synthetic fun keyPairGenerator-imL9hLU$default (Ldev/whyoleg/cryptography/algorithms/RSA;ILdev/whyoleg/cryptography/CryptographyAlgorithmId;Ldev/whyoleg/cryptography/bigint/BigInt;ILjava/lang/Object;)Ldev/whyoleg/cryptography/materials/key/KeyGenerator; diff --git a/cryptography-core/api/cryptography-core.klib.api b/cryptography-core/api/cryptography-core.klib.api index 9da04d7f..4d43f5b9 100644 --- a/cryptography-core/api/cryptography-core.klib.api +++ b/cryptography-core/api/cryptography-core.klib.api @@ -801,14 +801,8 @@ open class dev.whyoleg.cryptography/CryptographyException : kotlin/RuntimeExcept final object dev.whyoleg.cryptography.algorithms/MD5 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/MD5|null[0] -final object dev.whyoleg.cryptography.algorithms/RIPEMD128 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD128|null[0] - final object dev.whyoleg.cryptography.algorithms/RIPEMD160 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD160|null[0] -final object dev.whyoleg.cryptography.algorithms/RIPEMD256 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD256|null[0] - -final object dev.whyoleg.cryptography.algorithms/RIPEMD320 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/RIPEMD320|null[0] - final object dev.whyoleg.cryptography.algorithms/SHA1 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/SHA1|null[0] final object dev.whyoleg.cryptography.algorithms/SHA224 : dev.whyoleg.cryptography/CryptographyAlgorithmId // dev.whyoleg.cryptography.algorithms/SHA224|null[0] diff --git a/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt b/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt index c0e35d4b..8e68e3b3 100644 --- a/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt +++ b/cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt @@ -39,7 +39,4 @@ public object SHA3_384 : CryptographyAlgorithmId("SHA3-384") public object SHA3_512 : CryptographyAlgorithmId("SHA3-512") @DelicateCryptographyApi -public object RIPEMD128 : CryptographyAlgorithmId("RIPEMD-128") public object RIPEMD160 : CryptographyAlgorithmId("RIPEMD-160") -public object RIPEMD256 : CryptographyAlgorithmId("RIPEMD-256") -public object RIPEMD320 : CryptographyAlgorithmId("RIPEMD-320") diff --git a/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt b/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt index b9431392..4d65d83d 100644 --- a/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt +++ b/cryptography-providers-tests-api/src/commonMain/kotlin/support.kt @@ -21,7 +21,6 @@ fun AlgorithmTestScope<*>.supportsFunctions() = supports { fun AlgorithmTestScope<*>.supportsDigest(digest: CryptographyAlgorithmId): Boolean = supports { val sha3Algorithms = setOf(SHA3_224, SHA3_256, SHA3_384, SHA3_512) - val ripemdAlgorithms = setOf(RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320) when { (digest == SHA224 || digest in sha3Algorithms) && provider.isWebCrypto -> digest.name @@ -30,9 +29,7 @@ fun AlgorithmTestScope<*>.supportsDigest(digest: CryptographyAlgorithmId digest in sha3Algorithms && provider.isJdkDefault && (platform.isJdk { major < 17 } || platform.isAndroid) -> "${digest.name} signatures on old JDK" - digest in ripemdAlgorithms && (provider.isJdkDefault || provider.isApple || provider.isWebCrypto) - -> digest.name - digest != RIPEMD160 && digest in ripemdAlgorithms && provider.isOpenssl3 + digest == RIPEMD160 && (provider.isJdkDefault || provider.isApple || provider.isWebCrypto) -> digest.name else -> null } diff --git a/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt index e1ecc63a..419935d6 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt @@ -44,10 +44,7 @@ abstract class SupportedAlgorithmsTest(provider: CryptographyProvider) : Provide assertSupports(SHA3_384, supportsSha3) assertSupports(SHA3_512, supportsSha3) - assertSupports(RIPEMD128, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) assertSupports(RIPEMD160, !context.provider.isApple && !context.provider.isWebCrypto) - assertSupports(RIPEMD256, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) - assertSupports(RIPEMD320, !context.provider.isApple && !context.provider.isOpenssl3 && !context.provider.isWebCrypto) assertSupports(ECDSA) assertSupports(ECDH, !context.provider.isApple) diff --git a/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt index 1ab3e5a9..027325af 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt @@ -25,11 +25,7 @@ abstract class Sha3B224CompatibilityTest(provider: CryptographyProvider) : Diges abstract class Sha3B256CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_256, provider) abstract class Sha3B384CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_384, provider) abstract class Sha3B512CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_512, provider) - -abstract class Ripemd128CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD128, provider) abstract class Ripemd160CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD160, provider) -abstract class Ripemd256CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD256, provider) -abstract class Ripemd320CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD320, provider) abstract class DigestCompatibilityTest(algorithmId: CryptographyAlgorithmId, provider: CryptographyProvider) : CompatibilityTest(algorithmId, provider) { diff --git a/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt b/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt index 5819ae67..83ef6fbd 100644 --- a/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt +++ b/cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt @@ -98,18 +98,9 @@ abstract class DigestTest(provider: CryptographyProvider) : ProviderTest(provide @Test fun testSHA3_512() = test(SHA3_512, 64) - @Test - fun testRIPEMD128() = test(RIPEMD128, 16) - @Test fun testRIPEMD160() = test(RIPEMD160, 20) - @Test - fun testRIPEMD256() = test(RIPEMD256, 32) - - @Test - fun testRIPEMD320() = test(RIPEMD320, 40) - @Test fun testFunctionIndexes() = testWithAlgorithm(SHA256) { if (!supportsFunctions()) return@testWithAlgorithm diff --git a/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt b/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt index e32c223b..470150d1 100644 --- a/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt +++ b/cryptography-providers/jdk/src/jvmMain/kotlin/JdkCryptographyProvider.kt @@ -77,10 +77,7 @@ internal class JdkCryptographyProvider( SHA3_256 -> JdkDigest(state, "SHA3-256", SHA3_256) SHA3_384 -> JdkDigest(state, "SHA3-384", SHA3_384) SHA3_512 -> JdkDigest(state, "SHA3-512", SHA3_512) - RIPEMD128 -> JdkDigest(state, "RIPEMD128", RIPEMD128) RIPEMD160 -> JdkDigest(state, "RIPEMD160", RIPEMD160) - RIPEMD256 -> JdkDigest(state, "RIPEMD256", RIPEMD256) - RIPEMD320 -> JdkDigest(state, "RIPEMD320", RIPEMD320) HMAC -> JdkHmac(state) AES.CBC -> JdkAesCbc(state) AES.CTR -> JdkAesCtr(state) diff --git a/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt b/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt index fc3912fc..fa6741af 100644 --- a/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt +++ b/cryptography-providers/openssl3/api/src/commonMain/kotlin/Openssl3CryptographyProvider.kt @@ -30,7 +30,7 @@ internal object Openssl3CryptographyProvider : CryptographyProvider() { SHA3_256 -> Openssl3Digest("SHA3-256", SHA3_256) SHA3_384 -> Openssl3Digest("SHA3-384", SHA3_384) SHA3_512 -> Openssl3Digest("SHA3-512", SHA3_512) - RIPEMD160 -> Openssl3Digest("RIPEMD160", RIPEMD160) + RIPEMD160 -> Openssl3Digest("RIPEMD160", RIPEMD160) HMAC -> Openssl3Hmac AES.CBC -> Openssl3AesCbc AES.CTR -> Openssl3AesCtr From 04c2b98fd7fbe1bf726407516a63cb14b7cf91cc Mon Sep 17 00:00:00 2001 From: huskcasaca <100605532+huskcasaca@users.noreply.github.com> Date: Wed, 11 Dec 2024 18:49:03 +0800 Subject: [PATCH 4/4] Use ubuntu 24.04 with OpenSSL >= 3.0.8 for native builds --- .github/workflows/run-tests-compatibility.yml | 8 ++++++-- .github/workflows/run-tests-default.yml | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-tests-compatibility.yml b/.github/workflows/run-tests-compatibility.yml index 76deb532..a9a745b6 100644 --- a/.github/workflows/run-tests-compatibility.yml +++ b/.github/workflows/run-tests-compatibility.yml @@ -18,12 +18,14 @@ jobs: fail-fast: false matrix: os: [ 'ubuntu-latest' ] - target: [ 'jvm', 'js', 'wasm', 'native' ] + target: [ 'jvm', 'js', 'wasm' ] include: - os: 'macos-latest' target: 'macos' - os: 'windows-latest' target: 'native' + - os: 'ubuntu-24.04' + target: 'native' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-environment @@ -66,12 +68,14 @@ jobs: fail-fast: false matrix: os: [ 'ubuntu-latest' ] - target: [ 'jvm', 'js', 'wasm', 'native' ] + target: [ 'jvm', 'js', 'wasm' ] include: - os: 'macos-latest' target: 'macos' - os: 'windows-latest' target: 'native' + - os: 'ubuntu-24.04' + target: 'native' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-environment diff --git a/.github/workflows/run-tests-default.yml b/.github/workflows/run-tests-default.yml index a8b294ae..dbd199ba 100644 --- a/.github/workflows/run-tests-default.yml +++ b/.github/workflows/run-tests-default.yml @@ -14,7 +14,7 @@ jobs: fail-fast: false matrix: os: [ 'ubuntu-latest' ] - target: [ 'jvmAll', 'js', 'wasm', 'native' ] + target: [ 'jvmAll', 'js', 'wasm' ] include: - os: 'macos-latest' target: 'macos' @@ -35,6 +35,8 @@ jobs: - os: 'ubuntu-22.04' target: 'connectedAndroid' android-api-level: 33 + - os: 'ubuntu-24.04' + target: 'native' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-environment