@sentinel-one/decrypt-ssh-private
v0.0.10
Published
Decrypts ssh keys in the browser
Downloads
755
Maintainers
Readme
decrypt-ssh-private
A TS library that decrypts ssh keys in the browser.
Based on the nodejs node-sshpk and uses forge where possible.
Credit:
The authors of node-sshpk.
Special thanks to Ido Kotler (Sentinelone Innovative security researcher) for technical guidance and help in implementation 💣.
API:
import { decryptPrivateSSHKey } from '../lib/main';
import { ErrorClassification, ResultT } from '../lib/error-classifier';
const result: ResultT<ErrorClassification, string> = decryptPrivateSSHKey(encryptedSSHKey, { passphrase: '123456' });
result
.ok((output: string) => {
console.log(output);
return result;
})
.err((err: ErrorClassification) => {
// do something with the classified error
console.log(err);
return result;
});
Util functions
- isValidSSHKey(pem: string): boolean // Checks that a given PEM format is valid or not
if (isValidSSHKey('invalid key')) {
// do sothing
};
To see it decrypts in the browser just build and serve the example:
esbuild-browser && npx http-server