1 /* keyblob.h - Defs to describe a keyblob
2 * Copyright (C) 2009 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
23 /* The header block is the actual core of G13. Here is the format:
25 u8 Packet type. Value is 61 (0x3d).
26 u8 Constant value 255 (0xff).
27 u32 Length of the following structure
28 b10 Value: "GnuPG/G13\x00".
29 u8 Version. Value is 1.
32 u8 OS Flag: reserved, should be 0.
33 u32 Length of the entire header. This includes all bytes
34 starting at the packet type and ending with the last
35 padding byte of the header.
36 u8 Number of copies of this header (1..255).
37 u8 Number of copies of this header at the end of the
38 container (usually 0).
40 n bytes: OpenPGP encrypted and optionally signed message.
41 n bytes: CMS encrypted and optionally signed packet. Such a CMS
42 packet will be enclosed in a a private flagged OpenPGP
43 packet. Either the OpenPGP encrypted packet as described
44 above, the CMS encrypted or both packets must exist. The
45 encapsulation packet has this structure:
46 u8 Packet type. Value is 61 (0x3d).
47 u8 Constant value 255 (0xff).
48 u32 Length of the following structure
49 b10 Value: "GnuPG/CMS\x00".
50 b(n) Regular CMS structure.
51 n bytes: Padding. The structure resembles an OpenPGP packet.
52 u8 Packet type. Value is 61 (0x3d).
53 u8 Constant value 255 (0xff).
54 u32 Length of the following structure
55 b10 Value: "GnuPG/PAD\x00".
57 Given this structure the minimum padding is 16 bytes.
59 n bytes: File system container.
60 (optionally followed by copies on the header).
64 #define KEYBLOB_TAG_BLOBVERSION 0
65 /* This tag is used to describe the version of the keyblob. It must
66 be the first tag in a keyblob and may only occur once. Its value
67 is a single byte giving the blob version. The only defined version
70 #define KEYBLOB_TAG_CONTTYPE 1
71 /* This tag gives the type of the container. The value is a two byte
72 big endian integer giving the type of the container as described by
73 the CONTTYPE_ constants. */
75 #define KEYBLOB_TAG_DETACHED 2
76 /* Indicates that the actual storage is not in the same file as the
77 keyblob. If a value is given it is expected to be the GUID of the
80 #define KEYBLOB_TAG_KEYNO 16
81 /* This tag indicates a new key. The value is a 4 byte big endian
82 integer giving the key number. If the container type does only
83 need one key this key number should be 0. */
85 #define KEYBLOB_TAG_ENCALGO 17
86 /* Describes the algorithm of the key. It must follow a KEYNO tag.
87 The value is a 2 byte big endian algorithm number. The algorithm
88 numbers used are those from Libgcrypt (e.g. AES 128 is described by
89 the value 7). This tag is optional. */
91 #define KEYBLOB_TAG_ENCKEY 18
92 /* This tag gives the actual encryption key. It must follow a KEYNO
93 tag. The value is the plain key. */
95 #define KEYBLOB_TAG_MACALGO 19
96 /* Describes the MAC algorithm. It must follow a KEYNO tag. The
97 value is a 2 byte big endian algorithm number describing the MAC
98 algorithm with a value of 1 indicating HMAC. It is followed by
99 data specific to the MAC algorithm. In case of HMAC this data is a
100 2 byte big endian integer with the Libgcrypt algorithm id of the
103 #define KEYBLOB_TAG_MACKEY 20
104 /* This tag gives the actual MACing key. It must follow a KEYNO tag.
105 The value is the key used for MACing. */
108 #define KEYBLOB_TAG_FILLER 0xffff
109 /* This tag may be used for alignment and padding porposes. The value
114 #define CONTTYPE_ENCFS 1
115 /* A EncFS based backend. This requires a whole directory which
116 includes the encrypted files. Metadata is not encrypted. */
119 #define CONTTYPE_TRUECRYPT 21571
120 /* A Truecrypt (www.truecrypt.org) based container. Due to the design
121 of truecrypt this requires a second datafile because it is not
122 possible to to prepend a truecrypt container with our keyblob. */
127 #endif /*G13_KEYBLOB_H*/