0

Does anyone here regularly use Emacs to interact with GPG encrypted files and, if so, what has your experience been?

The Problem: I've been using Emacs (on OS X) to regularly edit a couple of GPG encrypted files; however, in doing so, I've had multiple instances in which the correct password returns "gpg: decryption failed: Bad session key".

Note, that this result is not corrected by using gpgconf to restart the service or reset the password cache. In these instances, it appears also as if the hashes between the files differs as well, though I have not confirmed this to myself without a doubt. The only fix that I've been able to achieve is to restore the file using a backup version; however, this does not seem to be a sustainable solution.

Additionally, I'm always using the same computer, so I'm assuming there's not a conflict in GPG/GPG dependency version (which I believe has been noted to cause the same issue), unless somehow the GPG version differs between that used by Emacs and Homebrew. Note, I use homebrew emacs-plus from https://github.com/d12frosted/homebrew-emacs-plus.

The Question: Is it possible that the Emacs interaction with GPG is corrupting the encryption header? I receive the GPG password prompt from the command line or no other indication of an error from GPG (or Emacs), other than the aforementioned error. Else, what could the cause be?

Let me know what y'all think - thanks!

  • 1
    What version of gpg & emacs are you using? – Melioratus Feb 27 '19 at 3:23
  • I have not had issues, and regularly edit encrypted files. I use emacs 26.1 on mac, not from homebrew but from emacsformacosx.com – InHarmsWay Feb 27 '19 at 12:38
  • I see you've tried gpgconf but try gpgconf --reload gpg-agent and rebooting. I'd also try running without gpg-agent. (Is gpg-agent even used on macOS?) – nega Feb 27 '19 at 17:29
  • I'm currently using Emacs 27.0.50 and GPG/OpenGPG 2.2.12. I've tried gpgconf --reload gpg-agents and rebooting previously, which certainly works when a password is entered incorrectly; however, it hasn't worked in the above scenario. I've tried running without gpg-agent with no change in outcome as well. – atabico Feb 28 '19 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.