open-keychain / open-keychain

OpenKeychain is an OpenPGP implementation for Android.
https://www.openkeychain.org
GNU General Public License v3.0
2.23k stars 480 forks source link

Error message "Bad data" during attempt to import key. #2726

Open pierrou-andreas opened 3 years ago

pierrou-andreas commented 3 years ago

Expected Behavior

A successfully imported private key.

Current Behavior

Error message "Bad data" during attempt to import key. I've tried to export it from GPG with and without password, ascii-coded and raw.

Possible Solution

Maybe a more informative error message would be helpful.

Steps to Reproduce (for bugs)

I have a private key generated by GPG in Linux. I have successfully managed to import this key before (though it was a few years ago, so I don't remember how), but this key expired so I had to extend it and try to import it again to OpenKeyChain. This time, however, (after extending the key) I didn't find any way to succeed. :( Does OpenKeyChain accept extended keys? It's difficult to reproduce this exact scenario and I'm a newbie to GPG and OpenKeyChain, but if you give me suggestions about how to produce similar scenarios, I will try it out and report the results.

  1. gpg --armor --export-secret-keys my.email@address > mykey1.asc
  2. Transfer mykey1.asc to a location accessible by my Android phone (my Nextcloud server + Nextcloud app).
  3. In OpenKeyChain, try to import key from file.
  4. "Bad data" :(

Context

I often use OpenKeyChain together with the app "Password Store" to fill in passwords in different apps on my phone, so I would be happy to help developers finding bugs to improve the product.

Your Environment

cweickhmann commented 3 years ago

Just observed the same behaviour today.

Environment:

atom686 commented 3 years ago

Same for me. Exporting the key from GPG suite. Importing - "Bad data". Tried to import via clipboard - it imports, but is considered external key, not mine. Not sure how to verify it.

jimaraujo6786 commented 3 years ago

Same issue.

Your Environment: Desktop OS: Win10 Desktop GPG version: 2.2.27 Android Version: 11 Device Model: Pixel 3 OpenKeychain Version: 5.7.5 From Google Play or F-Droid?: F-Droid

regenpfeifer commented 3 years ago

I am observing the same problem.

Desktop OS: Linux Ubuntu 20.04 LTS Desktop GPG version: 2.2.19 Android version: 11 Device: Huawei P30 Pro OpenKeychain version: 5.7.5 F-Droid

pierrou-andreas commented 3 years ago

Same for me. Exporting the key from GPG suite. Importing - "Bad data". Tried to import via clipboard - it imports, but is considered external key, not mine. Not sure how to verify it.

Hmm, I couldn't import it even from the clipboard on my Android phone. :-/

neilzone commented 3 years ago

Same here:

Desktop OS: Debian Buster 11 Desktop GPG version: 2.2.27 Android version: 10 (/e/) Device: OnePlus 6T OpenKeychain version: 5.7.5 From Aurora Store

cweickhmann commented 3 years ago

Is anyone on this? It really bugs me (pun intended). Would you need help? Where should one possibly look?

cognomaton commented 3 years ago

Potential workaround via Decrypt with OpenKeychain:

This procedure worked for me using gpg2 v2.1.11 and OpenKeychain v5.7.5 (from f-droid.org)

Note: this did not work for me using gpg v1.4.20

Good luck!

I hope this workaround works for all who get the "Bad data" failure, and that this information helps our amazing developers fix the underlying problem. (No, I don't know why it worked for me. It merely did.)

Developers & Maintainers: Thank you for giving us, and maintaining this app! Users: Please show your appreciation to our developers & maintainers.

neilzone commented 3 years ago

Thanks @cognomaton - this worked for me.

(My gpg version is 2.2.27, and using the gpg command alone sufficed.)

pierrou-andreas commented 2 years ago

Potential workaround via Decrypt with OpenKeychain

Now I also tried this workaround. I actually works! Great news! Thanks @cognomaton and all of the developers of OpenKeyChain!

cweickhmann commented 2 years ago

Thanks a lot, that did in fact work. I'm using gpg2 v 2.2.19. Is this a gpg1 vs. gpg2 problem?

cognomaton commented 2 years ago

@cweickhmann, I don't know if it's a gpg v1 vs v2 problem. It didn't work for me on gpg v1.4.20. But other v1 versions may well work. Developers might have more insight into this.