Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot change password of private key #211

Open
skylarmt opened this issue Jul 20, 2021 · 0 comments
Open

Cannot change password of private key #211

skylarmt opened this issue Jul 20, 2021 · 0 comments

Comments

@skylarmt
Copy link

skylarmt commented Jul 20, 2021

The following code is supposed to import and unlock a private key with a password, and then export the private key with a different password. However, the exported key uses the same password as the original key, and is in fact completely identical.

kbpgp.KeyManager.import_from_armored_pgp({
        armored: armoredkey
}, function (err, key) {
    if (!err) {
        if (key.is_pgp_locked()) {
            key.unlock_pgp({
                passphrase: "origpass"
            }, function (err) {
                if (!err) {
                    exportKey(key);
                } else {
                    console.error(err);
                }
            });
        } else {
            console.log("Loaded private key w/o passphrase");
             exportKey(key);
        }
    } else {
        console.error(err);
    }
});

function exportKey(key) {
    keymgr.export_pgp_private({
        passphrase: "newpass"
    }, function (err, pgp_private) {
        if (err) {
            console.error(err);
        } else {
            console.log(pgp_private);
            console.log("Private key backup saved.");
        }
    });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant