1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-09 09:51:02 +01:00

serialize private key to pkcs8 format

This commit is contained in:
Kyle Spearrin 2017-03-10 20:49:50 -05:00
parent 14e290c489
commit ed9d26fd1b

View File

@ -183,14 +183,15 @@ angular
return; return;
} }
var privateKey = forge.pki.privateKeyToAsn1(keypair.privateKey); var privateKeyAsn1 = forge.pki.privateKeyToAsn1(keypair.privateKey);
var privateKeyBytes = forge.asn1.toDer(privateKey).getBytes(); var privateKeyPkcs8 = forge.pki.wrapRsaPrivateKey(privateKeyAsn1);
var privateKeyEnc = _service.encrypt(privateKeyBytes, key, 'raw'); var privateKeyBytes = forge.asn1.toDer(privateKeyPkcs8).getBytes();
var privateKeyEncBytes = _service.encrypt(privateKeyBytes, key, 'raw');
var publicKey = forge.pki.publicKeyToAsn1(keypair.publicKey); var publicKeyAsn1 = forge.pki.publicKeyToAsn1(keypair.publicKey);
var publicKeyBytes = forge.asn1.toDer(publicKey).getBytes(); var publicKeyBytes = forge.asn1.toDer(publicKeyAsn1).getBytes();
callback(forge.util.encode64(publicKeyBytes), privateKeyEnc, null); callback(forge.util.encode64(publicKeyBytes), privateKeyEncBytes, null);
}); });
}; };