PLDecryptPKCS8PrivateKey

Cryptography, digital signatures

Description

Decrypts a password-encrypted PKCS#8 (PBES2) private key and returns the unwrapped cleartext DER structure

Syntax

Delphi

Function PLDecryptPKCS8PrivateKey(Const PrivateKeyInput, Password: AnsiString;
  Out UnwrappedDER: AnsiString): Boolean;

Parameters

PrivateKeyInputDER-encoded encrypted PKCS#8 PrivateKeyInfo structure
PasswordThe encryption password
UnwrappedDERReceives the decrypted, padding-stripped DER structure; empty on failure

Return values

TrueThe key was decrypted and UnwrappedDER holds the cleartext DER
FalseThe input is not a PBES2 structure, the password is wrong, or the cipher is unsupported

Remarks

Parses PBES2 with its PBKDF2 key-derivation and encryption-algorithm sequences, derives the key with the embedded salt and iteration count, decrypts and strips the padding in pure Pascal

The gate behind the file-based Brainpool and SM2 identity openers, which accept encrypted PKCS#8 material

See also

PLValidateBrainpoolIdentity, PLValidateSM2Identity, PLSplitCertificateBundle