From 8a95ba464626c3f6be9b932d41c44b86eea3d6d3 Mon Sep 17 00:00:00 2001 From: cach30verfl0w Date: Fri, 14 Jun 2024 20:29:38 +0200 Subject: [PATCH] Fix tests by fixing helper --- .../io/karma/advcrypto/algorithm/delegates/KeyStoreFactory.kt | 2 +- .../kotlin/io/karma/advcrypto/linux/utils/KeyReaderHelper.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kmp-advcrypto/src/commonMain/kotlin/io/karma/advcrypto/algorithm/delegates/KeyStoreFactory.kt b/kmp-advcrypto/src/commonMain/kotlin/io/karma/advcrypto/algorithm/delegates/KeyStoreFactory.kt index 3e9e7bb..52d5367 100644 --- a/kmp-advcrypto/src/commonMain/kotlin/io/karma/advcrypto/algorithm/delegates/KeyStoreFactory.kt +++ b/kmp-advcrypto/src/commonMain/kotlin/io/karma/advcrypto/algorithm/delegates/KeyStoreFactory.kt @@ -45,7 +45,7 @@ class KeyStoreFactory(val name: String) { */ fun createKeyStore(): KeyStore = object: KeyStore { private val context = initialize() - + override fun readKeyFromFile(path: Path, algorithm: String, purposes: UByte): Key = readKeyFromFile!!.invoke(context, path, algorithm, purposes) } diff --git a/kmp-advcrypto/src/linuxX64Main/kotlin/io/karma/advcrypto/linux/utils/KeyReaderHelper.kt b/kmp-advcrypto/src/linuxX64Main/kotlin/io/karma/advcrypto/linux/utils/KeyReaderHelper.kt index 4a14342..33df445 100644 --- a/kmp-advcrypto/src/linuxX64Main/kotlin/io/karma/advcrypto/linux/utils/KeyReaderHelper.kt +++ b/kmp-advcrypto/src/linuxX64Main/kotlin/io/karma/advcrypto/linux/utils/KeyReaderHelper.kt @@ -193,7 +193,7 @@ object KeyReaderHelper { */ fun tryParse(array: ByteArray, purposes: UByte, algorithm: String? = null): Key? = array.usePinned { val parsedKey = tryParse(it.addressOf(0), array.size.toULong(), purposes)?: return null - if (parsedKey.algorithm != algorithm) + if (algorithm != null && parsedKey.algorithm != algorithm) throw IllegalArgumentException("The algorithm '$algorithm' was specified, but key is '${parsedKey.algorithm}'") return parsedKey }