importEncryptedPkcs8DerOrThrow
importEncryptedPkcs8DerOrThrow
Import a private key from DER-encoded PBES2-encrypted PKCS#8 EncryptedPrivateKeyInfo.
Decrypts the PBES2 envelope using the provided password, then imports the key.
When algorithm is omitted, it is inferred from the decrypted key's own privateKeyAlgorithm (see importPkcs8DerOrThrow).
ts
function importEncryptedPkcs8DerOrThrow(
der: Uint8Array,
password: string,
algorithm?: PrivateKeyImportInput,
options?: ImportEncryptedKeyOptions,
): Promise<CryptoKey>Parameters
der:Uint8Array— DER-encoded EncryptedPrivateKeyInfo bytespassword:string— Decryption passwordalgorithm?:PrivateKeyImportInput— Optional expected algorithm; must match decrypted key when givenoptions?:ImportEncryptedKeyOptions— KDF work-factor limit
Throws
Error— If DER is malformed, password is wrong, the PBKDF2 iteration count exceedsoptions.maxKdfIterations, or algorithm doesn't match
See also
exportEncryptedPkcs8Derfor the inverse operation