Skip to content
Discussion options

You must be logged in to vote

Unfortunately, at this point, there is no API for that. But, for RSA, you can do it using cryptography-serialization-asn1-modules models. It could look like this:

private fun getPrivateKey(
    privateKey: RSA.PSS.PrivateKey,
    digest: CryptographyAlgorithmId<Digest>,
): RSA.PSS.PublicKey {
    val decoder = CryptographyProvider.Default.get(RSA.PSS).publicKeyDecoder(digest)
    val rsaPrivateKey = Der.decodeFromByteArray<RsaPrivateKey>(
        privateKey.encodeToByteArrayBlocking(RSA.PrivateKey.Format.DER.PKCS1)
    )
    val rsaPublicKey = RsaPublicKey(
        modulus = rsaPrivateKey.modulus,
        publicExponent = rsaPrivateKey.publicExponent,
    )
    return decoder.decodeFromBy…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@emoiroux
Comment options

Answer selected by whyoleg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants