1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-06 09:20:43 +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;
}
var privateKey = forge.pki.privateKeyToAsn1(keypair.privateKey);
var privateKeyBytes = forge.asn1.toDer(privateKey).getBytes();
var privateKeyEnc = _service.encrypt(privateKeyBytes, key, 'raw');
var privateKeyAsn1 = forge.pki.privateKeyToAsn1(keypair.privateKey);
var privateKeyPkcs8 = forge.pki.wrapRsaPrivateKey(privateKeyAsn1);
var privateKeyBytes = forge.asn1.toDer(privateKeyPkcs8).getBytes();
var privateKeyEncBytes = _service.encrypt(privateKeyBytes, key, 'raw');
var publicKey = forge.pki.publicKeyToAsn1(keypair.publicKey);
var publicKeyBytes = forge.asn1.toDer(publicKey).getBytes();
var publicKeyAsn1 = forge.pki.publicKeyToAsn1(keypair.publicKey);
var publicKeyBytes = forge.asn1.toDer(publicKeyAsn1).getBytes();
callback(forge.util.encode64(publicKeyBytes), privateKeyEnc, null);
callback(forge.util.encode64(publicKeyBytes), privateKeyEncBytes, null);
});
};