From ecc608f51a2f2651215ec12234b924a03254c3e7 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Fri, 29 Jan 2021 10:44:11 +0600 Subject: [PATCH] add additional variant of doInDecryptionContextWithPKCS8Key --- .../utils/passport/PassportDataDecryptionHandling.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/passport/PassportDataDecryptionHandling.kt b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/passport/PassportDataDecryptionHandling.kt index 4743dd5ac1..a5a7dcfaaf 100644 --- a/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/passport/PassportDataDecryptionHandling.kt +++ b/tgbotapi.core/src/jvmMain/kotlin/dev/inmo/tgbotapi/utils/passport/PassportDataDecryptionHandling.kt @@ -13,3 +13,12 @@ inline fun PassportData.doInDecryptionContextWithPKCS8Key( expectedNonce ?.let { require(expectedNonce == decryptedCredentials.nonce) } return decryptedCredentials.secureData.run(block) } +inline fun PassportData.doInDecryptionContextWithPKCS8Key( + pkcs8Key: String, + expectedNonce: String? = null, + crossinline block: SecureData.() -> T +): T { + val decryptedCredentials = credentials.decryptWithPKCS8PrivateKey(pkcs8Key) + expectedNonce ?.let { require(expectedNonce == decryptedCredentials.nonce) } + return decryptedCredentials.secureData.run(block) +}