]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - crypto/heimdal/doc/doxyout/krb5/man/man3/krb5_fileformats.3
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / crypto / heimdal / doc / doxyout / krb5 / man / man3 / krb5_fileformats.3
1 .TH "krb5_fileformats" 3 "11 Jan 2012" "Version 1.5.2" "HeimdalKerberos5library" \" -*- nroff -*-
2 .ad l
3 .nh
4 .SH NAME
5 krb5_fileformats \- File formats 
6 .SH "File formats"
7 .PP
8 This section documents the diffrent file formats that are used in Heimdal and other Kerberos implementations.
9 .SS "keytab"
10 The keytab binary format is not a standard format. The format has evolved and may continue to. It is however understood by several Kerberos implementations including Heimdal, MIT, Sun's Java ktab and are created by the ktpass.exe utility from Windows. So it has established itself as the defacto format for storing Kerberos keys.
11 .PP
12 The following C-like structure definitions illustrate the MIT keytab file format. All values are in network byte order. All text is ASCII.
13 .PP
14 .PP
15 .nf
16    keytab {
17        uint16_t file_format_version;                    # 0x502
18        keytab_entry entries[*];
19    };
20
21    keytab_entry {
22        int32_t size;
23        uint16_t num_components;   # subtract 1 if version 0x501
24        counted_octet_string realm;
25        counted_octet_string components[num_components];
26        uint32_t name_type;       # not present if version 0x501
27        uint32_t timestamp;
28        uint8_t vno8;
29        keyblock key;
30        uint32_t vno; #only present if >= 4 bytes left in entry
31        uint32_t flags; #only present if >= 4 bytes left in entry
32    };
33
34    counted_octet_string {
35        uint16_t length;
36        uint8_t data[length];
37    };
38
39    keyblock {
40        uint16_t type;
41        counted_octet_string;
42    };
43 .fi
44 .PP
45 .PP
46 All numbers are stored in network byteorder (big endian) format.
47 .PP
48 The keytab file format begins with the 16 bit file_format_version which at the time this document was authored is 0x502. The format of older keytabs is described at the end of this document.
49 .PP
50 The file_format_version is immediately followed by an array of keytab_entry structures which are prefixed with a 32 bit size indicating the number of bytes that follow in the entry. Note that the size should be evaluated as signed. This is because a negative value indicates that the entry is in fact empty (e.g. it has been deleted) and that the negative value of that negative value (which is of course a positive value) is the offset to the next keytab_entry. Based on these size values alone the entire keytab file can be traversed.
51 .PP
52 The size is followed by a 16 bit num_components field indicating the number of counted_octet_string components in the components array.
53 .PP
54 The num_components field is followed by a counted_octet_string representing the realm of the principal.
55 .PP
56 A counted_octet_string is simply an array of bytes prefixed with a 16 bit length. For the realm and name components, the counted_octet_string bytes are ASCII encoded text with no zero terminator.
57 .PP
58 Following the realm is the components array that represents the name of the principal. The text of these components may be joined with slashs to construct the typical SPN representation. For example, the service principal HTTP/www.foo.net@FOO.NET would consist of name components 'HTTP' followed by 'www.foo.net'.
59 .PP
60 Following the components array is the 32 bit name_type (e.g. 1 is KRB5_NT_PRINCIPAL, 2 is KRB5_NT_SRV_INST, 5 is KRB5_NT_UID, etc). In practice the name_type is almost certainly 1 meaning KRB5_NT_PRINCIPAL.
61 .PP
62 The 32 bit timestamp indicates the time the key was established for that principal. The value represents the number of seconds since Jan 1, 1970.
63 .PP
64 The 8 bit vno8 field is the version number of the key. This value is overridden by the 32 bit vno field if it is present. The vno8 field is filled with the lower 8 bits of the 32 bit protocol kvno field.
65 .PP
66 The keyblock structure consists of a 16 bit value indicating the encryption type and is a counted_octet_string containing the key. The encryption type is the same as the Kerberos standard (e.g. 3 is des-cbc-md5, 23 is arcfour-hmac-md5, etc).
67 .PP
68 The last field of the keytab_entry structure is optional. If the size of the keytab_entry indicates that there are at least 4 bytes remaining, a 32 bit value representing the key version number is present. This value supersedes the 8 bit vno8 value preceeding the keyblock.
69 .PP
70 Older keytabs with a file_format_version of 0x501 are different in three ways:
71 .PP
72 .IP "\(bu" 2
73 All integers are in host byte order [1].
74 .IP "\(bu" 2
75 The num_components field is 1 too large (i.e. after decoding, decrement by 1).
76 .IP "\(bu" 2
77 The 32 bit name_type field is not present.
78 .PP
79 .PP
80 [1] The file_format_version field should really be treated as two separate 8 bit quantities representing the major and minor version number respectively.
81 .SS "Heimdal database dump file"
82 Format of the Heimdal text dump file as of Heimdal 0.6.3:
83 .PP
84 Each line in the dump file is one entry in the database.
85 .PP
86 Each field of a line is separated by one or more spaces, with the exception of fields consisting of principals containing spaces, where space can be quoted with \\ and \\ is quoted by \\.
87 .PP
88 Fields and their types are:
89 .PP
90 .PP
91 .nf
92         Quoted princial (quote character is \) [string]
93         Keys [keys]
94         Created by [event]
95         Modified by [event optional]
96         Valid start time [time optional]
97         Valid end time [time optional]
98         Password end valid time [time optional]
99         Max lifetime of ticket [time optional]
100         Max renew time of ticket [integer optional]
101         Flags [hdb flags]
102         Generation number [generation optional]
103         Extensions [extentions optional]
104 .fi
105 .PP
106 .PP
107 Fields following these silently are ignored.
108 .PP
109 All optional fields will be skipped if they fail to parse (or comprise the optional field marker of '-', w/o quotes).
110 .PP
111 Example:
112 .PP
113 .PP
114 .nf
115  fred\@CODE.COM 27:1:16:e8b4c8fc7e60b9e641dcf4cff3f08a701d982a2f89ba373733d26ca59ba6c789666f6b8bfcf169412bb1e5dceb9b33cda29f3412:-:1:3:4498a933881178c744f4232172dcd774c64e81fa6d05ecdf643a7e390624a0ebf3c7407a:-:1:2:b01934b13eb795d76f3a80717d469639b4da0cfb644161340ef44fdeb375e54d684dbb85:-:1:1:ea8e16d8078bf60c781da90f508d4deccba70595258b9d31888d33987cd31af0c9cced2e:- 20020415130120:admin\@CODE.COM 20041221112428:fred\@CODE.COM - - - 86400 604800 126 20020415130120:793707:28 -
116 .fi
117 .PP
118 .PP
119 Encoding of types are as follows:
120 .PP
121 .IP "\(bu" 2
122 keys
123 .PP
124 .PP
125 .PP
126 .nf
127  kvno:[masterkvno:keytype:keydata:salt]{zero or more separated by :}
128 .fi
129 .PP
130 .PP
131 kvno is the key version number.
132 .PP
133 keydata is hex-encoded
134 .PP
135 masterkvno is the kvno of the database master key. If this field is empty, the kadmin load and merge operations will encrypt the key data with the master key if there is one. Otherwise the key data will be imported asis.
136 .PP
137 salt is encoded as '-' (no/default salt) or
138 .PP
139 .PP
140 .nf
141  salt-type /
142  salt-type / 'string'
143  salt-type / hex-encoded-data
144 .fi
145 .PP
146 .PP
147 keytype is the protocol enctype number; see enum ENCTYPE in include/krb5_asn1.h for values.
148 .PP
149 Example: 
150 .PP
151 .nf
152  27:1:16:e8b4c8fc7e60b9e641dcf4cff3f08a701d982a2f89ba373733d26ca59ba6c789666f6b8bfcf169412bb1e5dceb9b33cda29f3412:-:1:3:4498a933881178c744f4232172dcd774c64e81fa6d05ecdf643a7e390624a0ebf3c7407a:-:1:2:b01934b13eb795d76f3a80717d469639b4da0cfb644161340ef44fdeb375e54d684dbb85:-:1:1:ea8e16d8078bf60c781da90f508d4deccba70595258b9d31888d33987cd31af0c9cced2e:-
153
154 .fi
155 .PP
156 .PP
157 .PP
158 .nf
159  kvno=27,{key: masterkvno=1,keytype=des3-cbc-sha1,keydata=..., default salt}...
160 .fi
161 .PP
162 .PP
163 .IP "\(bu" 2
164 time
165 .PP
166 .PP
167 Format of the time is: YYYYmmddHHMMSS, corresponding to strftime format '%Y%m%d%k%M%S'.
168 .PP
169 Time is expressed in UTC.
170 .PP
171 Time can be optional (using -), when the time 0 is used.
172 .PP
173 Example:
174 .PP
175 .PP
176 .nf
177  20041221112428
178 .fi
179 .PP
180 .PP
181 .IP "\(bu" 2
182 event
183 .PP
184 .PP
185 .PP
186 .nf
187         time:principal
188 .fi
189 .PP
190 .PP
191 time is as given in format time
192 .PP
193 principal is a string. Not quoting it may not work in earlier versions of Heimdal.
194 .PP
195 Example: 
196 .PP
197 .nf
198  20041221112428:bloggs\@CODE.COM
199
200 .fi
201 .PP
202 .PP
203 .IP "\(bu" 2
204 hdb flags
205 .PP
206 .PP
207 Integer encoding of HDB flags, see HDBFlags in lib/hdb/hdb.asn1. Each bit in the integer is the same as the bit in the specification.
208 .PP
209 .IP "\(bu" 2
210 generation:
211 .PP
212 .PP
213 .PP
214 .nf
215  time:usec:gen
216 .fi
217 .PP
218 .PP
219 usec is a the microsecond, integer. gen is generation number, integer.
220 .PP
221 The generation can be defaulted (using '-') or the empty string
222 .PP
223 .IP "\(bu" 2
224 extensions:
225 .PP
226 .PP
227 .PP
228 .nf
229  first-hex-encoded-HDB-Extension[:second-...]
230 .fi
231 .PP
232 .PP
233 HDB-extension is encoded the DER encoded HDB-Extension from lib/hdb/hdb.asn1. Consumers HDB extensions should be aware that unknown entires needs to be preserved even thought the ASN.1 data content might be unknown. There is a critical flag in the data to show to the KDC that the entry MUST be understod if the entry is to be used.