I want to export my RSA key pair to pem, that I've created with windows.crypto.subtle API, but with AES-128-CFB encryption. I know how to do this with Node.js with the crypto package, I want to do it on the client side. How can I do that?
I would like to achive something similar to this:
const { generateKeyPair } = require('crypto');
let RSAKeyGenerator=
{
async generate(password)
{
return new Promise(function (resolve, reject) {
generateKeyPair('rsa', {
modulusLength: 2048,
publicExponent: 0x10001,
publicKeyEncoding: {
type: 'pkcs1',
format: 'pem'
},
privateKeyEncoding: {
type: 'pkcs8',
format: 'pem',
cipher: 'AES-128-CFB',
passphrase: password
}
},
function (error, publicKey, privateKey)
{
if(!error)
{
resolve({
publicKey: publicKey,
privateKey: privateKey
});
}
console.error(error);
reject({
error: error,
publicKey: null,
privateKey: null
});
});
});
}
}