Clearsign text document with multiple keys?

Werner Koch wk at gnupg.org
Fri Jul 26 09:58:58 CEST 2013


On Fri, 26 Jul 2013 02:42, adrelanos at riseup.net said:

> can a plain text document be clear signed by multiple keys at the same
> time? (Hold by different people.)

Yes.

> One can create a plain text file a, clear sign it and get a.asc. Another
> one can clear sign a.asc and get a.asc.asc.

I think a more useful way is to have independent signatures:

  gpg --clearsign -u key1 -u key2 -u key3 file.txt

The problem is how to do this given that the 3 keys are hold by
different users.  The OpenPGP protocol allows for this but GPG has no
provisions to create such a signature.

> Is it possible to verify the document in one run and get a list of signers?

  gpg --verify fule.txt.asc

will show you the status of all 3 signatures.

Here is an example using 2 keys:

  $ fortune | gpg2 --clearsign -u alpha -u wk at gnupg.org >x

  $ cat x
  -----BEGIN PGP SIGNED MESSAGE-----
  Hash: SHA1
  
  You look like a million dollars.  All green and wrinkled.
  -----BEGIN PGP SIGNATURE-----
  Version: GnuPG v2.1.0-beta212 (GNU/Linux)
  
  iEYEARECAAYFAlHyHVkACgkQLXJ8x2hpdzT28gCgnG+PEF/8fxZIPwFz7kPgD3gw
  St8An1z98Wy8MKVce4SfId4gdeqxtak5iEYEARECAAYFAlHyHVoACgkQTwVA1Xf5
  X5WyjQCfQ3ShNQjt2bFgsjAOcy/LpvJRZXMAn3PnUZwj3NnnxIhyWYx1lNju3C/R
  =xQfe
  -----END PGP SIGNATURE-----
  
  $ gpg2 --verify x
  gpg: Good signature from "Alfa Test (demo key) <alfa at example.net>"
  gpg:                 aka "Alpha Test (demo key) <alpha at example.net>"
  gpg:                 aka "Alice (demo key)"
  gpg: WARNING: This key is not certified with a trusted signature!
  gpg:          There is no indication that the signature belongs to the owner.
  Primary key fingerprint: A0FF 4590 BB61 22ED EF6E  3C54 2D72 7CC7 6869 7734
  gpg: Signature made Fri Jul 26 08:55:22 2013 CEST using DSA key ID 77F95F95
  gpg: Good signature from "Werner Koch <wk at gnupg.org>"
  gpg:                 aka "Werner Koch <wk at g10code.com>"
  
[I removed some diagnostics from gpg's output]

If you look with "gpg --list-packets" at the signature block you will
see this:

  :signature packet: algo 17, keyid 2D727CC768697734
          version 4, created 1374821721, md5len 0, sigclass 0x01
          digest algo 2, begin of digest f6 f2
          hashed subpkt 2 len 4 (sig created 2013-07-26)
          subpkt 16 len 8 (issuer key ID 2D727CC768697734)
          data: [160 bits]
          data: [159 bits]
  :signature packet: algo 17, keyid 4F0540D577F95F95
          version 4, created 1374821722, md5len 0, sigclass 0x01
          digest algo 2, begin of digest b2 8d
          hashed subpkt 2 len 4 (sig created 2013-07-26)
          subpkt 16 len 8 (issuer key ID 4F0540D577F95F95)
          data: [159 bits]
          data: [159 bits]
  
Two standard OpenPGP signature packets.  Let's see whether we can create
such a signature in a different way:

  $ echo 'You look like a million dollars.  All green and wrinkled.' \
       | gpg2 --clearsign -u alpha >x1
  
  $ echo 'You look like a million dollars.  All green and wrinkled.' \
       | gpg2 --clearsign -u wk at gnupg.org >x2
  
  $ cat x1
  -----BEGIN PGP SIGNED MESSAGE-----
  Hash: SHA1
  
  You look like a million dollars.  All green and wrinkled.
  -----BEGIN PGP SIGNATURE-----
  Version: GnuPG v2.1.0-beta212 (GNU/Linux)
  
  iEYEARECAAYFAlHyH2QACgkQLXJ8x2hpdzQW2QCfVPNjc1j9N0XksVLBPVS78TjD
  t0UAn24dvQE4Nl+CsLzaQfbdOIaG5LWU
  =2tcx
  -----END PGP SIGNATURE-----
  
  $ cat x2
  -----BEGIN PGP SIGNED MESSAGE-----
  Hash: SHA1
  
  You look like a million dollars.  All green and wrinkled.
  -----BEGIN PGP SIGNATURE-----
  Version: GnuPG v2.1.0-beta212 (GNU/Linux)
  
  iEYEARECAAYFAlHyH20ACgkQTwVA1Xf5X5XkoACeN0g+3NGXj6TPRSzGIlTkMehD
  b2wAn0tpT67h+//gOBm+5+t3bjXIGDrT
  =+yf4
  -----END PGP SIGNATURE-----

gpg --list-packets of x1 yields:

  :signature packet: algo 17, keyid 2D727CC768697734
          version 4, created 1374822244, md5len 0, sigclass 0x01
          digest algo 2, begin of digest 16 d9
          hashed subpkt 2 len 4 (sig created 2013-07-26)
          subpkt 16 len 8 (issuer key ID 2D727CC768697734)
          data: [159 bits]
          data: [159 bits]

and of x2:

  :signature packet: algo 17, keyid 4F0540D577F95F95
          version 4, created 1374822253, md5len 0, sigclass 0x01
          digest algo 2, begin of digest e4 a0
          hashed subpkt 2 len 4 (sig created 2013-07-26)
          subpkt 16 len 8 (issuer key ID 4F0540D577F95F95)
          data: [158 bits]
          data: [159 bits]
    
That is pretty similar to the first output.  However the files x1 and x2
could have been created on two different boxes.  Let's see how we can
combine them into one signature block:

  $ sed -n '/SIGNATURE/,$ p' x1 | gpg2 --dearmor | gpgsplit --no-split >y1
  $ sed -n '/SIGNATURE/,$ p' x2 | gpg2 --dearmor | gpgsplit --no-split >y2
  $ cat y1 y2 | gpg --enarmor | sed -n '5,$ p' | grep -v -- ----- >y
  $ (sed -n '1,/SIGNATURE/ p' x1 ; echo ; cat y; \
     echo '-----END PGP SIGNATURE-----') >x

That was not too complicated.  Does it work?

  $ gpg2 --verify x
  gpg: Signature made Fri Jul 26 09:04:04 2013 CEST using DSA key ID 68697734
  gpg: Good signature from "Alfa Test (demo key) <alfa at example.net>"
  gpg:                 aka "Alpha Test (demo key) <alpha at example.net>"
  gpg:                 aka "Alice (demo key)"
  gpg: WARNING: This key is not certified with a trusted signature!
  gpg:          There is no indication that the signature belongs to the owner.
  Primary key fingerprint: A0FF 4590 BB61 22ED EF6E  3C54 2D72 7CC7 6869 7734
  gpg: Signature made Fri Jul 26 09:04:13 2013 CEST using DSA key ID 77F95F95
  gpg: Good signature from "Werner Koch <wk at gnupg.org>"
  gpg:                 aka "Werner Koch <wk at g10code.com>"
  

Yes.  Now put this into a more elegant script and you are done.  I
suggest to check that the signed texts all match before combining them
into a single clear text signature.


Salam-Shalom,

   Werner

-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.




More information about the Gnupg-users mailing list