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

EnvelopeThe DER-encoded EnvelopedData structure
PrivateKeyDERDER-encoded PKCS#8 or SEC 1 private key of a recipient: RSA, EC (P-256, P-384, Brainpool) or SM2
PlaintextReceives the decrypted, padding-stripped payload; empty on failure

Return values

TrueThe content-encryption key was unwrapped and the payload decrypted
FalseThe 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

See also

PLBuildPurePubSecEnvelope, PLDecryptPKCS8PrivateKey