common: Add support for the new extended private key format.
authorJustus Winter <justus@g10code.com>
Fri, 8 Apr 2016 17:21:12 +0000 (19:21 +0200)
committerJustus Winter <justus@g10code.com>
Thu, 21 Apr 2016 12:38:53 +0000 (14:38 +0200)
commit12af2630cf4d1a39179179925fac8f2cce7504ff
tree80af197fe8c5b17f037bb9c6edad5a97e4a33d29
parentc6d1f2f08c68efe7e80887219064a8ce6365128f
common: Add support for the new extended private key format.

* agent/findkey.c (write_extended_private_key): New function.
(agent_write_private_key): Detect if an existing file is in extended
format and update the key within if it is.
(read_key_file): Handle the new format.
* agent/keyformat.txt: Document the new format.
* common/Makefile.am: Add the new files.
* common/private-keys.c: New file.
* common/private-keys.h: Likewise.
* common/t-private-keys.c: Likewise.
* common/util.h (alphap, alnump): New macros.
* tests/migrations: Add test demonstrating that we can cope with the
new format.

--
GnuPG 2.3+ will use a new format to store private keys that is both
more flexible and easier to read and edit by human beings.  The new
format stores name,value-pairs using the common mail and http header
convention.

This patch adds the parser and support code and prepares GnuPG 2.1 for
the new format.

Signed-off-by: Justus Winter <justus@g10code.com>
14 files changed:
agent/findkey.c
agent/keyformat.txt
common/Makefile.am
common/private-keys.c [new file with mode: 0644]
common/private-keys.h [new file with mode: 0644]
common/t-private-keys.c [new file with mode: 0644]
common/util.h
tests/migrations/Makefile.am
tests/migrations/extended-private-key-format.gpghome/private-keys-v1.d/13FDB8809B17C5547779F9D205C45F47CE0217CE.key.asc [new file with mode: 0644]
tests/migrations/extended-private-key-format.gpghome/private-keys-v1.d/343D8AF79796EE107D645A2787A9D9252F924E6F.key.asc [new file with mode: 0644]
tests/migrations/extended-private-key-format.gpghome/private-keys-v1.d/8B5ABF3EF9EB8D96B91A0B8C2C4401C91C834C34.key.asc [new file with mode: 0644]
tests/migrations/extended-private-key-format.gpghome/pubring.kbx.asc [new file with mode: 0644]
tests/migrations/extended-private-key-format.gpghome/trustdb.gpg.asc [new file with mode: 0644]
tests/migrations/extended-private-key-format.test [new file with mode: 0755]