Page MenuHome GnuPG

Keyring corruption when deleting keys
Closed, DuplicatePublic

Description

To reproduce apply that patch to make gnupg use the old keyring format:

diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 9e681bf92..4d515c4ed 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -320,7 +320,7 @@
 
   (srandom (getpid))
   (make-test-data "random_seed" 600)
-
+  (create-file "pubring.gpg")
   (log "Creating configuration files")
   (create-file "gpg.conf"
               "no-greeting"

and do make -Ctests/openpgp check XTESTS=delete-keys.scm.

The test will delete the subkey EB467DCA4AD7676A6A62B2ABABAB28A247BE2775 of key 'one', which will incorrectly delete the identity key of 'one' and attribute the subkey to whatever key is stored right before that key:

--- /tmp/before	2017-05-04 13:14:28.451368923 +0200
+++ /tmp/after	2017-05-04 13:14:28.479369110 +0200
@@ -1232,37 +1232,7 @@
 	data: [159 bits]
 # off=24498 ctb=b0 tag=12 hlen=2 plen=6
 :trust packet: sig flag=00 sigcache=03
-# off=24506 ctb=99 tag=6 hlen=3 plen=418
-:public key packet:
-	version 4, algo 17, created 1072837896, expires 0
-	pkey[0]: [1024 bits]
-	pkey[1]: [160 bits]
-	pkey[2]: [1024 bits]
-	pkey[3]: [1023 bits]
-	keyid: 0EF77096D74C5F22
-# off=24927 ctb=b0 tag=12 hlen=2 plen=12
-:trust packet: key upd=0 src=0
-# off=24941 ctb=b4 tag=13 hlen=2 plen=35
-:user ID packet: "Test one (pp=def) <one@example.com>"
-# off=24978 ctb=b0 tag=12 hlen=2 plen=12
-:trust packet: uid upd=0 src=0
-# off=24992 ctb=88 tag=2 hlen=2 plen=90
-:signature packet: algo 17, keyid 0EF77096D74C5F22
-	version 4, created 1072837896, md5len 0, sigclass 0x13
-	digest algo 2, begin of digest 50 ee
-	hashed subpkt 2 len 4 (sig created 2003-12-31)
-	hashed subpkt 27 len 1 (key flags: 03)
-	hashed subpkt 11 len 1 (pref-sym-algos: 2)
-	hashed subpkt 21 len 2 (pref-hash-algos: 2 3)
-	hashed subpkt 22 len 2 (pref-zip-algos: 2 1)
-	hashed subpkt 30 len 1 (features: 01)
-	hashed subpkt 23 len 1 (keyserver preferences: 80)
-	subpkt 16 len 8 (issuer key ID 0EF77096D74C5F22)
-	data: [156 bits]
-	data: [159 bits]
-# off=25084 ctb=b0 tag=12 hlen=2 plen=6
-:trust packet: sig flag=00 sigcache=03
-# off=25092 ctb=88 tag=2 hlen=2 plen=90
+# off=24506 ctb=88 tag=2 hlen=2 plen=90
 :signature packet: algo 17, keyid 0EF77096D74C5F22
 	version 4, created 1072837896, md5len 0, sigclass 0x13
 	digest algo 2, begin of digest 50 ee
@@ -1276,16 +1246,16 @@
 	subpkt 16 len 8 (issuer key ID 0EF77096D74C5F22)
 	data: [159 bits]
 	data: [158 bits]
-# off=25184 ctb=b0 tag=12 hlen=2 plen=6
+# off=24598 ctb=b0 tag=12 hlen=2 plen=6
 :trust packet: sig flag=00 sigcache=03
-# off=25192 ctb=b9 tag=14 hlen=3 plen=269
+# off=24606 ctb=b9 tag=14 hlen=3 plen=269
 :public sub key packet:
 	version 4, algo 16, created 1072837901, expires 0
 	pkey[0]: [1024 bits]
 	pkey[1]: [3 bits]
 	pkey[2]: [1023 bits]
 	keyid: ABAB28A247BE2775
-# off=25464 ctb=88 tag=2 hlen=2 plen=73
+# off=24878 ctb=88 tag=2 hlen=2 plen=73
 :signature packet: algo 17, keyid 0EF77096D74C5F22
 	version 4, created 1072837901, md5len 0, sigclass 0x18
 	digest algo 2, begin of digest 70 78
@@ -1294,9 +1264,9 @@
 	subpkt 16 len 8 (issuer key ID 0EF77096D74C5F22)
 	data: [160 bits]
 	data: [160 bits]
-# off=25539 ctb=b0 tag=12 hlen=2 plen=6
+# off=24953 ctb=b0 tag=12 hlen=2 plen=6
 :trust packet: sig flag=00 sigcache=03
$ gpg -k --with-colons zulu
tru::1:1493897501:0:3:1:5
pub:-:1024:17:6BC4778054ACD246:920892875:::-:::scaESCA:::::::
fpr:::::::::23FD347A419429BACCD5E72D6BC4778054ACD246:
uid:-::::920892875::3339692E396929C8D659BEB39A5B747691809809::Zulu Test (demo key) <zulu@example.net>:
sub:-:1024:16:EF9DC276A172C881:920892914::::::e::::::
fpr:::::::::2DCA5A1392DE06ED4FCB8C53EF9DC276A172C881:
sub:i:1024:16:ABAB28A247BE2775:1072837901::::::::::::
fpr:::::::::EB467DCA4AD7676A6A62B2ABABAB28A247BE2775: