You are not logged in.

#1 2014-11-30 11:26:50

tsh
Member
From: Munich
Registered: 2014-07-25
Posts: 41
Website

[SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

I use GnuPG and Emacs to encrypt password lists.  After the recent upgrade of gnupg to 2.1.0-4, decryption of files works in Emacs, but encryption does not work if any changes were to be saved in these files.  I keep getting this error:

Opening output file: [pub u 1024 17 3B6F8AF143C21F3B 1320594077 1509822256 nil u nil ...], 15

Is anyone experiencing this?

Last edited by tsh (2014-12-23 09:12:21)

Offline

#2 2014-11-30 17:01:59

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,803

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

Decrypting /home/ewaller/foo.gpg...done
Saving file /home/ewaller/foo.gpg...
Opening output file: [pub u 2048 1 BB013C6B8FA274C9 1322179510 nil nil u nil ...], 15

Yes.  I noticed it last week, but have not had time to look into it sad


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Online

#3 2014-11-30 23:00:52

ndegruchy
Member
From: United States
Registered: 2014-11-30
Posts: 5
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

I first noticed it with Magit and signing commits. It also happens when you try

M-x epa-list-keys

I get "Args out of range: ["pub", "u", "3072", "17" ...]"

Last edited by ndegruchy (2014-11-30 23:01:03)

Offline

#4 2014-12-01 09:24:51

tsh
Member
From: Munich
Registered: 2014-07-25
Posts: 41
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

OK, thank you for your inputs.  I raised a bug report: https://bugs.archlinux.org/task/42972

Offline

#5 2014-12-01 13:26:05

geekinthesticks
Member
From: England
Registered: 2011-09-21
Posts: 143
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

Happened to me too. Sometimes trying to save the file deletes it. Thank goodness for git!

Offline

#6 2014-12-03 10:26:53

rekahsoft
Member
Registered: 2010-07-18
Posts: 33
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

There is a bug in the debbugs emacs tracker for the epa-list-keys function but there are many others affects. This is because in gnupg 2.1 it changes its output (slightly) for listing keys and encrytption. The following functions I have found to be affected (and obviously any functions that use these functions will also be broken):

  • epa-list-keys

  • epa-list-secret-keys

  • epa-encrypt-file

  • epa-encrypt-region

I know the epa-list-keys fuinction has been fixed in both the emacs 25 branch and has been backported to the 24.x branch. Anyone have any idea about the encrypt function? They are really handy and I would like the ability to use them once more instead of switching back and forth to a term (in emacs of course) to encryt things. Also I haven't found any issue with the signing, verification and decryption functions.

If anyone knows of a temporary work around I'd love to hear it. Would it hurt anything to downgrade gnupg until this issue is resolved? I've tried the emacs 25 branch from git and the list-keys issue is fixed..at the time I didn't know encryption was broken too so I didn't test it.

Last edited by rekahsoft (2014-12-03 10:27:34)

Offline

#7 2014-12-03 16:49:51

madmad
Member
Registered: 2014-12-03
Posts: 1

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

The error is in epg--list-keys-1, which the patch upstream fixes.
As a temporary workaround you can just eval the following, which is the function with the patch applied.

(defun epg--list-keys-1 (context name mode)
  (let ((args (append (if (epg-context-home-directory context)
			  (list "--homedir"
				(epg-context-home-directory context)))
		      '("--with-colons" "--no-greeting" "--batch"
			"--with-fingerprint" "--with-fingerprint")
		      (unless (eq (epg-context-protocol context) 'CMS)
			'("--fixed-list-mode"))))
	(list-keys-option (if (memq mode '(t secret))
			      "--list-secret-keys"
			    (if (memq mode '(nil public))
				"--list-keys"
			      "--list-sigs")))
	(coding-system-for-read 'binary)
	keys string field index)
    (if name
	(progn
	  (unless (listp name)
	    (setq name (list name)))
	  (while name
	    (setq args (append args (list list-keys-option (car name)))
		  name (cdr name))))
      (setq args (append args (list list-keys-option))))
    (with-temp-buffer
      (apply #'call-process
	     (epg-context-program context)
	     nil (list t nil) nil args)
      (goto-char (point-min))
      (while (re-search-forward "^[a-z][a-z][a-z]:.*" nil t)
	(setq keys (cons (make-vector 15 nil) keys)
	      string (match-string 0)
	      index 0
	      field 0)
	(while (and (< field (length (car keys)))
		    (eq index
			(string-match "\\([^:]+\\)?:" string index)))
	  (setq index (match-end 0))
	  (aset (car keys) field (match-string 1 string))
	  (setq field (1+ field))))
      (nreverse keys))))

Offline

#8 2014-12-04 11:06:58

rekahsoft
Member
Registered: 2010-07-18
Posts: 33
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

Thanks madmad! Totally solved the issue for now. Looking forward to being able to take this hack out of my emacs config. Hopefully it'll get in the next 24 minor release. Cheers!

Offline

#9 2014-12-14 18:18:39

lompik
Member
Registered: 2014-12-14
Posts: 4

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

Solved for me too.

Offline

#10 2014-12-23 09:10:30

tsh
Member
From: Munich
Registered: 2014-07-25
Posts: 41
Website

Re: [SOLVED] gnupg-2.1.0-4 breaks encryption via Emacs

I compiled emacs-git from AUR with emacs-24 branch and this bug is fixed there.

Offline

Board footer

Powered by FluxBB