Decrypt encrypted RSA Private Key on the Browser side

2.4k Views Asked by At

I have an encrypted private RSA key:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,B92E0E3A7B... // <--- IV here.
...
-----END RSA PRIVATE KEY-----

I need to decrypt it via a passphrase, basically I need the equivalent of

openssl rsa -in <encrypted_private.key>  -out <decrypted_private.key>

on the browser side with an Angular based client, using webcrypto and pkijs.

1

There are 1 best solutions below

1
sagat On BEST ANSWER

So for anyone who will in the future maybe face the same issue like I did:

PKI.js is providing an examples folder in their repo: OpenSSLPrivateKeyEncryption

In there you will find a method called decrypt. With the code I were able to decrypt my AES-CBC Private key.