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

Add Key.encrypt(passphrase) to exported API #443

Closed
NSkelsey opened this issue Apr 23, 2016 · 2 comments
Closed

Add Key.encrypt(passphrase) to exported API #443

NSkelsey opened this issue Apr 23, 2016 · 2 comments

Comments

@NSkelsey
Copy link

NSkelsey commented Apr 23, 2016

In the API documentation we find key.prototype.decrypt. However, there is no accompanying key.prototype.encrypt for Key objects.

Either this was a specific design choice or it is genuinely missing – please advise.

The current code I use to preform key.encrypt(passphrase) looks like:

// lockKeyRing encrypts the private key material of the key using the passed 
// password. The primary key and all subkeys are encrypted with the password.
// { string -> bool }
function lockKeyRing(password) {
  var w = true;
  w = w && keyRing.privateKey.primaryKey.encrypt(password);
  keyRing.privateKey.subKeys.forEach(function(sk) {
      w = w && sk.subKey.encrypt(password);
   });
  return w;
}

Note that the keyRing here is a custom data structure.

P.S. Thanks for the library it is fantastic!

evilaliv3 added a commit that referenced this issue Apr 24, 2016
@evilaliv3
Copy link
Contributor

Thanks @NSkelsey for the suggestion; I've written a pull request that follows the same pattern of the decrypt API and that is already used by various projects like whiteout-io: https://github.com/whiteout-io/mail/blob/master/src/js/crypto/pgp.js#L204

@tanx / @toberndo what do you think?

toberndo added a commit that referenced this issue May 3, 2016
@tanx
Copy link
Member

tanx commented May 3, 2016

See #446

@tanx tanx closed this as completed May 3, 2016
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

3 participants