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) +}