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

Private Keys with No Passphrase #12

Closed
esenminer opened this issue Feb 5, 2018 · 2 comments
Closed

Private Keys with No Passphrase #12

esenminer opened this issue Feb 5, 2018 · 2 comments
Assignees

Comments

@esenminer
Copy link

Thank you for this library. I just wanted to point out an interesting edge case. We are using a private key which has no passphrase and the only way I could get it to find and use the key was by putting in a dummy passphrase. Without the dummy passphrase I see the log output

org.c02e.jpgpj.Decryptor: not using decryption key sec ed XXXXXXX

after I put in a dummy pass phrase

org.c02e.jpgpj.Decryptor:using decryption key sec+ed XXXXXXX

@justinludwig
Copy link
Owner

Thanks for pointing out this issue! I'm thinking the best way to handle this, since the JPGPJ API already uses an empty string for the passphrase to signal that the private part of the key should be ignored, is to formalize your dummy passphrase technique with a NO_PASSPHRASE constant in the API. That constant would be given in place of the passphrase to signal that the private part of the key should be used, but without a passphrase, like so:

new Decryptor(
    new Key(new File("path/to/my/keys/alice-pub.gpg")),
    new Key(new File("path/to/my/keys/bob-sec.gpg"), Key.NO_PASSPHRASE)
).decrypt(
    new File("path/to/ciphertext.txt.gpg"),
    new File("path/back-to/plaintext.txt")
);

Once I do that, I will update the Setting Passphrases documentation to describe how to handle passphrase-less keys with that technique.

@justinludwig justinludwig self-assigned this Apr 12, 2018
justinludwig added a commit that referenced this issue Apr 14, 2018
Add Key.NO_PASSPHRASE constant to signal that a key doesn't use a
passphrase (as well as Key/Subkey.noPassphrase property),
and add unit test to validate a passphrase-less key works
for signing and decryption.
@justinludwig
Copy link
Owner

I added that constant to the code (plus a setNoPassphrase() helper to the Key and Subkey classes), and then added a No Passphrase section to the Key Rings wiki page to document how to use passphrase-less keys.

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

2 participants