Encrypt and Decrypt a Message
-
Encrypt the message using the following command:
|
›_ Console
|
openssl cms -encrypt -in signedRSAmessage.txt -out encryptedRSAsignedmessage.txt TestRSA.cert
|
The encrypted message will have the following format:
|
›_ Encrypted Message
|
MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64
MIIMFAYJKoZIhvcNAQcDoIIMBTCCDAECAQAxggF5MIIBdQIBADBdMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQCFAdGmeMIYrV4twsA8FLt3ZBvn5vdMA0GCSqGSIb3DQEB
...
4QTULf9IDxS7/pxXb0P63ij+jIPB8WRD5hm6uYna/niWxMlEfFlwyBSEK+5VtIRT
z5jrZEplI7a3qsdCYPICWSQWn5oxg1L7uskWBBtwyFrMGHIC9BtMx3wNATix9Ni7
HUoc0oXZyWhjn4jKqdmj2bSrfk2BqU5I
|
-
Decrypt the message with the following command:
|
›_ Console
|
openssl cms -decrypt -in encryptedRSAsignedmessage.txt -inkey "pkcs11:token=<token_label>;object=<key_label>" -out decryptedRSAsignedmessage.txt
|