/// <inheritdoc /> public byte[] Decrypt(byte[] data) { try { var env = new System.Security.Cryptography.Pkcs.EnvelopedCms(); env.Decode(data); env.Decrypt(_allSenderCertificates); var decryptedData = env.ContentInfo.Content; var sig = new System.Security.Cryptography.Pkcs.SignedCms(); sig.Decode(decryptedData); sig.CheckSignature(true); var verifiedData = sig.ContentInfo.Content; return verifiedData; } catch (Exception ex) { throw new ExtraEncryptionException("No certificate for decryption found.", ex); } }
/// <inheritdoc /> public byte[] Decrypt(byte[] data) { try { var env = new System.Security.Cryptography.Pkcs.EnvelopedCms(); env.Decode(data); env.Decrypt(_allSenderCertificates); var decryptedData = env.ContentInfo.Content; var sig = new System.Security.Cryptography.Pkcs.SignedCms(); sig.Decode(decryptedData); sig.CheckSignature(true); var verifiedData = sig.ContentInfo.Content; return(verifiedData); } catch (Exception ex) { throw new ExtraEncryptionException("No certificate for decryption found.", ex); } }