1

the main question of this message is how to get the true ciphertext from S/MIME file?

I created RSA keys and encrypted a message with S/MIME as follow :

1) generate private key : openssl genrsa -out maCle.pem 1024

2) create certificate(public key) : openssl req -new -x509 -key privkey.pem -out certif.pem -days 1095

3) encrypt using smime : openssl smime -encrypt -in plaintext -text -out mail.msg certif.pem

mail.msg looks like:

MIME-Version: 1.0
Content-Disposition: attachment; filename="smime.p7m"
Content-Type: application/x-pkcs7-mime; smime-type=enveloped-data; name="smime.p7m"
Content-Transfer-Encoding: base64

MIIBnQYJKoZIhvcNAQcDoIIBjjCCAYoCAQAxggEwMIIBLAIBADCBlDCBhjELMAkG
A1UEBhMCRlIxEjAQBgNVBAgMCUZSQU5DRVNFQjEQMA4GA1UEBwwHQ0lUWVNFQjEP
MA0GA1UECgwGT1JHU0VCMRQwEgYDVQQLDAtPUkdVTklUTkFNRTEPMA0GA1UEAwwG
U0VCU0VCMRkwFwYJKoZIhvcNAQkBFgpTRUJTRUJBRERSAgkAvllfFuC1s/owDQYJ
KoZIhvcNAQEBBQAEgYCzD+ShH91R3PEFTFJzcmW5Ie91AT9vHHCVJ1Sb78/oUHVi
PjS3PJyMD55MWGX+FmC/XYxtMNROP6CJ4nQIh6CmQIzXse/Yvg8WQOEJepC6AmDS
0b2xdQmiDO4Zb9C6ZUjWyH9KzOTwdZC+xm0WdAdB/psTXOL1api8P54H+hti9zBR
BgkqhkiG9w0BBwEwGgYIKoZIhvcNAwIwDgICAKAECBUxiu2WmkuFgCjdkDzatfYg
YwvXLmFl135Txjb0GEfl5EhV2zvXB6PLMFscOa6SOioR

when I decode the base64 from mail.msg I can see informations that are in my certificate (certif.pem). So it seems mail.msg contains a certificate which is NOT encrypted (is that right?) So how can I extract this certificate and how can I extract the true ciphertext that matches with my plaintext?

I thought the certificate in mail.msg was the same in certif.pem but the beginning doesn't match except the first three characters :

certif.pem : MIIC3DCCAkWgAwI...
mail.msg   : MIIBnQYJKoZIhvc...

so what is this certificate?

CodesInChaos
  • 25,121
  • 2
  • 90
  • 129
user2199104
  • 61
  • 1
  • 5

1 Answers1

1

the following command do what I want :

openssl smime -in msg -pk7out -out msg.pk7
openssl asn1parse -in msg.pk7
user2199104
  • 61
  • 1
  • 5