OpenSSL Encryption of Session Key

前端 未结 1 412
北海茫月
北海茫月 2020-12-22 00:56

I am writing a method that encrypts session keys. It needs to do this such that the key can be decrypted by a different program that has been tested successfully. The decryp

相关标签:
1条回答
  • 2020-12-22 01:41

    RSA encryption with PKCS padding and public key acquired from certificate:

    openssl rsautl -encrypt -in sesskey -inkey cert.pem -certin -out temp
    openssl base64 -e -in temp -out enc_sesskey
    

    RSA decryption with PKCS padding and private key:

    openssl base64 -d -in enc_sesskey -out temp
    openssl rsautl -decrypt -in temp -inkey privkey.pem -out sesskey2
    

    Tested and confirmed to be OK because content of the "sesskey" file is the same as content of the "sesskey2" file.

    0 讨论(0)
提交回复
热议问题