PLDecryptPurePubSecEnvelope
Cryptography
Description
Decrypts a PKCS#7 EnvelopedData envelope built by PLBuildPurePubSecEnvelope or another CMS producer with a recipient RSA, EC or SM2 private key
Syntax
Delphi
Function PLDecryptPurePubSecEnvelope(Const Envelope,
PrivateKeyDER: AnsiString; Out Plaintext: AnsiString): Boolean;Parameters
| Envelope | The DER-encoded EnvelopedData structure |
|---|---|
| PrivateKeyDER | DER-encoded PKCS#8 or SEC 1 private key of a recipient: RSA, EC (P-256, P-384, Brainpool) or SM2 |
| Plaintext | Receives the decrypted, padding-stripped payload; empty on failure |
Return values
| True | The content-encryption key was unwrapped and the payload decrypted |
|---|---|
| False | The envelope is malformed, the private key does not match a recipient, or the structure is unsupported |
Remarks
Parses the ContentInfo wrapper and walks the RecipientInfos set: RSA keys open key transport recipients, EC keys perform the RFC 5753 ECDH key agreement and unwrap the AES key-wrapped content key, and SM2 keys decrypt sm2encrypt recipients and verify the embedded SM3 hash; the payload is then decrypted under AES-256-CBC or SM4-CBC as indicated by the embedded cipher OID
An AES key-wrap integrity failure, an SM2 hash mismatch or invalid padding moves on to the next recipient, so a key that is not addressed by the envelope returns False
Counterpart of PLBuildPurePubSecEnvelope