Separating public and private keys from RSA keypair variable

后端 未结 4 2018
陌清茗
陌清茗 2020-12-18 13:04

As the title says, I have some code that generates a pair of RSA keys. I want to split them apart and use them individually to encrypt/decrypt, rather than use the variable

4条回答
  •  臣服心动
    2020-12-18 13:35

    You can extract the RSA public key from RSA keypair using d2i_RSAPublicKey and i2d_RSAPublicKey (link). Use i2d_RSAPublicKey to encode your keypair to PKCS#1 RSAPublicKey stucture, store it in a bytestring, then use d2i_RSAPublicKey to decode it back to RSA key struct.

提交回复
热议问题