Skip to content

Commit 186a420

Browse files
authored
Add support for RIPEMD160 digest (#55)
* Use ubuntu 24.04 with OpenSSL >= 3.0.8 for native builds (#55 (comment))
1 parent 69b77a8 commit 186a420

File tree

13 files changed

+30
-3
lines changed

13 files changed

+30
-3
lines changed

.github/workflows/run-tests-compatibility.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
os: [ 'ubuntu-latest' ]
21-
target: [ 'jvm', 'js', 'wasm', 'native' ]
21+
target: [ 'jvm', 'js', 'wasm' ]
2222
include:
2323
- os: 'macos-latest'
2424
target: 'macos'
2525
- os: 'windows-latest'
2626
target: 'native'
27+
- os: 'ubuntu-24.04'
28+
target: 'native'
2729
steps:
2830
- uses: actions/checkout@v4
2931
- uses: ./.github/actions/setup-environment
@@ -66,12 +68,14 @@ jobs:
6668
fail-fast: false
6769
matrix:
6870
os: [ 'ubuntu-latest' ]
69-
target: [ 'jvm', 'js', 'wasm', 'native' ]
71+
target: [ 'jvm', 'js', 'wasm' ]
7072
include:
7173
- os: 'macos-latest'
7274
target: 'macos'
7375
- os: 'windows-latest'
7476
target: 'native'
77+
- os: 'ubuntu-24.04'
78+
target: 'native'
7579
steps:
7680
- uses: actions/checkout@v4
7781
- uses: ./.github/actions/setup-environment

.github/workflows/run-tests-default.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
fail-fast: false
1515
matrix:
1616
os: [ 'ubuntu-latest' ]
17-
target: [ 'jvmAll', 'js', 'wasm', 'native' ]
17+
target: [ 'jvmAll', 'js', 'wasm' ]
1818
include:
1919
- os: 'macos-latest'
2020
target: 'macos'
@@ -35,6 +35,8 @@ jobs:
3535
- os: 'ubuntu-22.04'
3636
target: 'connectedAndroid'
3737
android-api-level: 33
38+
- os: 'ubuntu-24.04'
39+
target: 'native'
3840
steps:
3941
- uses: actions/checkout@v4
4042
- uses: ./.github/actions/setup-environment

build-logic/src/main/kotlin/ckbuild/tests/GenerateProviderTestsTask.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ abstract class GenerateProviderTestsTask : DefaultTask() {
8888
"Sha3B256CompatibilityTest",
8989
"Sha3B384CompatibilityTest",
9090
"Sha3B512CompatibilityTest",
91+
"Ripemd160CompatibilityTest",
9192

9293
"AesCbcTest",
9394
"AesCbcCompatibilityTest",

cryptography-core/api/cryptography-core.api

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ public abstract interface class dev/whyoleg/cryptography/algorithms/PBKDF2 : dev
446446
public final class dev/whyoleg/cryptography/algorithms/PBKDF2$Companion : dev/whyoleg/cryptography/CryptographyAlgorithmId {
447447
}
448448

449+
public final class dev/whyoleg/cryptography/algorithms/RIPEMD160 : dev/whyoleg/cryptography/CryptographyAlgorithmId {
450+
public static final field INSTANCE Ldev/whyoleg/cryptography/algorithms/RIPEMD160;
451+
}
452+
449453
public abstract interface class dev/whyoleg/cryptography/algorithms/RSA : dev/whyoleg/cryptography/CryptographyAlgorithm {
450454
public abstract fun keyPairGenerator-imL9hLU (ILdev/whyoleg/cryptography/CryptographyAlgorithmId;Ldev/whyoleg/cryptography/bigint/BigInt;)Ldev/whyoleg/cryptography/materials/key/KeyGenerator;
451455
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;

cryptography-core/api/cryptography-core.klib.api

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,8 @@ open class dev.whyoleg.cryptography/CryptographyException : kotlin/RuntimeExcept
801801

802802
final object dev.whyoleg.cryptography.algorithms/MD5 : dev.whyoleg.cryptography/CryptographyAlgorithmId<dev.whyoleg.cryptography.algorithms/Digest> // dev.whyoleg.cryptography.algorithms/MD5|null[0]
803803

804+
final object dev.whyoleg.cryptography.algorithms/RIPEMD160 : dev.whyoleg.cryptography/CryptographyAlgorithmId<dev.whyoleg.cryptography.algorithms/Digest> // dev.whyoleg.cryptography.algorithms/RIPEMD160|null[0]
805+
804806
final object dev.whyoleg.cryptography.algorithms/SHA1 : dev.whyoleg.cryptography/CryptographyAlgorithmId<dev.whyoleg.cryptography.algorithms/Digest> // dev.whyoleg.cryptography.algorithms/SHA1|null[0]
805807

806808
final object dev.whyoleg.cryptography.algorithms/SHA224 : dev.whyoleg.cryptography/CryptographyAlgorithmId<dev.whyoleg.cryptography.algorithms/Digest> // dev.whyoleg.cryptography.algorithms/SHA224|null[0]

cryptography-core/src/commonMain/kotlin/algorithms/Digest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ public object SHA3_384 : CryptographyAlgorithmId<Digest>("SHA3-384")
3737

3838
@Suppress("ClassName")
3939
public object SHA3_512 : CryptographyAlgorithmId<Digest>("SHA3-512")
40+
41+
@DelicateCryptographyApi
42+
public object RIPEMD160 : CryptographyAlgorithmId<Digest>("RIPEMD-160")

cryptography-providers-tests-api/src/commonMain/kotlin/support.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ fun AlgorithmTestScope<*>.supportsDigest(digest: CryptographyAlgorithmId<Digest>
2929
digest in sha3Algorithms &&
3030
provider.isJdkDefault &&
3131
(platform.isJdk { major < 17 } || platform.isAndroid) -> "${digest.name} signatures on old JDK"
32+
digest == RIPEMD160 && (provider.isJdkDefault || provider.isApple || provider.isWebCrypto)
33+
-> digest.name
3234
else -> null
3335
}
3436
}

cryptography-providers-tests/src/commonMain/kotlin/SupportedAlgorithmsTest.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ abstract class SupportedAlgorithmsTest(provider: CryptographyProvider) : Provide
4444
assertSupports(SHA3_384, supportsSha3)
4545
assertSupports(SHA3_512, supportsSha3)
4646

47+
assertSupports(RIPEMD160, !context.provider.isApple && !context.provider.isWebCrypto)
48+
4749
assertSupports(ECDSA)
4850
assertSupports(ECDH, !context.provider.isApple)
4951

cryptography-providers-tests/src/commonMain/kotlin/compatibility/DigestCompatibilityTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ abstract class Sha3B224CompatibilityTest(provider: CryptographyProvider) : Diges
2525
abstract class Sha3B256CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_256, provider)
2626
abstract class Sha3B384CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_384, provider)
2727
abstract class Sha3B512CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(SHA3_512, provider)
28+
abstract class Ripemd160CompatibilityTest(provider: CryptographyProvider) : DigestCompatibilityTest(RIPEMD160, provider)
2829

2930
abstract class DigestCompatibilityTest(algorithmId: CryptographyAlgorithmId<Digest>, provider: CryptographyProvider) :
3031
CompatibilityTest<Digest>(algorithmId, provider) {

cryptography-providers-tests/src/commonMain/kotlin/default/DigestTest.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ abstract class DigestTest(provider: CryptographyProvider) : ProviderTest(provide
9898
@Test
9999
fun testSHA3_512() = test(SHA3_512, 64)
100100

101+
@Test
102+
fun testRIPEMD160() = test(RIPEMD160, 20)
103+
101104
@Test
102105
fun testFunctionIndexes() = testWithAlgorithm(SHA256) {
103106
if (!supportsFunctions()) return@testWithAlgorithm

0 commit comments

Comments
 (0)