Getting cipher information on S/MIME-Messages

The updated TclSMimeMessage component provides the ExtractSecurityInfo method that extracts the security algorithms, and also the included certificates. The extracted information is stored within the following properties:
EncryptionAlgorithm, HashAlgorithm, and Certificates.
The ExtractSecurityInfo method allows you to get the mentioned information before decrypting and verifying the message. However, if the message is first encrypted and then signed, you can obtain only the hash algorithm information. If the message is signed and encrypted, you will get only the encryption algorithm information. So, if you need to get both the hash and encryption algorithms, you will have to decrypt and verify the message using the DecryptAndVerify method. This method extracts the mentioned above information, as well.
//extracting the cipher information

MailMessage.Certificates.Items.Count; //extracted certificates
MailMessage.EncryptionAlgorithm; //the enryption algorithm identifier, see the comments above
MailMessage.HashAlgorithm; //the hash algorithm identifier
MailMessage.EncryptionAlgorithmName; //the friendly cipher name
MailMessage.HashAlgorithmName; //the friendly hash algorithm name

//searching certificates
certificate := MailMessage.Certificates.CertificateByEmail('');

//decrypting the message and verifying digital signatures

Add Feedback