Added display and API for SSH fingerprints

This commit is contained in:
2023-09-29 02:15:06 -04:00
parent 8649c75eac
commit 89928841bc
10 changed files with 257 additions and 148 deletions

View File

@@ -26,8 +26,7 @@ function arrayBufferToBase64(buffer) {
}
function generateKeyPair(alg, size, name) {
return window.crypto.subtle
.generateKey(
return window.crypto.subtle.generateKey(
{
name: "RSASSA-PKCS1-v1_5",
modulusLength: 2048, // can be 1024, 2048, or 4096
@@ -36,17 +35,11 @@ function generateKeyPair(alg, size, name) {
},
extractable,
["sign", "verify"]
)
.then(key => {
const privateKey = window.crypto.subtle
.exportKey("jwk", key.privateKey)
.then(encodePrivateKey)
.then(wrap)
.then(rsaPrivateKey);
).then(key => {
const privateKey = window.crypto.subtle.exportKey("jwk", key.privateKey).then(encodePrivateKey).then(wrap).then(rsaPrivateKey);
const publicKey = window.crypto.subtle.exportKey("jwk", key.publicKey).then(jwk => encodePublicKey(jwk, name));
return Promise.all([privateKey, publicKey]);
});
}
// module.exports = { arrayBufferToBase64, generateKeyPair };
// module.exports = { arrayBufferToBase64, generateKeyPair };