Discuss this help topic in SecureBlackbox Forum
Decrypt data with X.509 certificates
To decrypt data encrypted in accordance with PKCS#7 standard, use TElMessageDecryptor class.
TElMessageDecryptor decryptor = new TElMessageDecryptor();
decryptor.CertStorage = storage;
int res = decryptor.Decrypt(encryptedDataStream, plainDataStream);
When the call succeeds, plainDataStream will contain the decrypted message.
Check the res value returned by Decrypt() to ensure the decryption was successful.
The value of 0 indicates success, any other value reports a SecureBlackbox error code described here.
After decryption completes, you can check the decryptor object's properties to find out the algorithm that was used to encrypt the data (Algorithm property) and the index of the exact certificate in the storage that was used to decrypt it (UsedCertificate). If decryption fails due to the absence of the certificate in the storage, you can check the CertIDs[] property to search for the required certificate locally.