xref: /freebsd/crypto/krb5/doc/formats/ccache_file_format.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert.. _ccache_file_format:
2*7f2fe78bSCy Schubert
3*7f2fe78bSCy SchubertCredential cache file format
4*7f2fe78bSCy Schubert============================
5*7f2fe78bSCy Schubert
6*7f2fe78bSCy SchubertThere are four versions of the file format used by the FILE credential
7*7f2fe78bSCy Schubertcache type.  The first byte of the file always has the value 5, and
8*7f2fe78bSCy Schubertthe value of the second byte contains the version number (1 through
9*7f2fe78bSCy Schubert4).  Versions 1 and 2 of the file format use native byte order for integer
10*7f2fe78bSCy Schubertrepresentations.  Versions 3 and 4 always use big-endian byte order.
11*7f2fe78bSCy Schubert
12*7f2fe78bSCy SchubertAfter the two-byte version indicator, the file has three parts: the
13*7f2fe78bSCy Schubertheader (in version 4 only), the default principal name, and a sequence
14*7f2fe78bSCy Schubertof credentials.
15*7f2fe78bSCy Schubert
16*7f2fe78bSCy Schubert
17*7f2fe78bSCy SchubertHeader format
18*7f2fe78bSCy Schubert-------------
19*7f2fe78bSCy Schubert
20*7f2fe78bSCy SchubertThe header appears only in format version 4.  It begins with a 16-bit
21*7f2fe78bSCy Schubertinteger giving the length of the entire header, followed by a sequence
22*7f2fe78bSCy Schubertof fields.  Each field consists of a 16-bit tag, a 16-bit length, and
23*7f2fe78bSCy Schuberta value of the given length.  A file format implementation should
24*7f2fe78bSCy Schubertignore fields with unknown tags.
25*7f2fe78bSCy Schubert
26*7f2fe78bSCy SchubertAt this time there is only one defined header field.  Its tag value is
27*7f2fe78bSCy Schubert1, its length is always 8, and its contents are two 32-bit integers
28*7f2fe78bSCy Schubertgiving the seconds and microseconds of the time offset of the KDC
29*7f2fe78bSCy Schubertrelative to the client.  Adding this offset to the current time on the
30*7f2fe78bSCy Schubertclient should give the current time on the KDC, if that offset has not
31*7f2fe78bSCy Schubertchanged since the initial authentication.
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy Schubert
34*7f2fe78bSCy Schubert.. _cache_principal_format:
35*7f2fe78bSCy Schubert
36*7f2fe78bSCy SchubertPrincipal format
37*7f2fe78bSCy Schubert----------------
38*7f2fe78bSCy Schubert
39*7f2fe78bSCy SchubertThe default principal is marshalled using the following informal
40*7f2fe78bSCy Schubertgrammar::
41*7f2fe78bSCy Schubert
42*7f2fe78bSCy Schubert    principal ::=
43*7f2fe78bSCy Schubert        name type (32 bits) [omitted in version 1]
44*7f2fe78bSCy Schubert        count of components (32 bits) [includes realm in version 1]
45*7f2fe78bSCy Schubert        realm (data)
46*7f2fe78bSCy Schubert        component1 (data)
47*7f2fe78bSCy Schubert        component2 (data)
48*7f2fe78bSCy Schubert        ...
49*7f2fe78bSCy Schubert
50*7f2fe78bSCy Schubert    data ::=
51*7f2fe78bSCy Schubert        length (32 bits)
52*7f2fe78bSCy Schubert        value (length bytes)
53*7f2fe78bSCy Schubert
54*7f2fe78bSCy SchubertThere is no external framing on the default principal, so it must be
55*7f2fe78bSCy Schubertparsed according to the above grammar in order to find the sequence of
56*7f2fe78bSCy Schubertcredentials which follows.
57*7f2fe78bSCy Schubert
58*7f2fe78bSCy Schubert
59*7f2fe78bSCy Schubert.. _ccache_credential_format:
60*7f2fe78bSCy Schubert
61*7f2fe78bSCy SchubertCredential format
62*7f2fe78bSCy Schubert-----------------
63*7f2fe78bSCy Schubert
64*7f2fe78bSCy SchubertThe credential format uses the following informal grammar (referencing
65*7f2fe78bSCy Schubertthe ``principal`` and ``data`` types from the previous section)::
66*7f2fe78bSCy Schubert
67*7f2fe78bSCy Schubert    credential ::=
68*7f2fe78bSCy Schubert        client (principal)
69*7f2fe78bSCy Schubert        server (principal)
70*7f2fe78bSCy Schubert        keyblock (keyblock)
71*7f2fe78bSCy Schubert        authtime (32 bits)
72*7f2fe78bSCy Schubert        starttime (32 bits)
73*7f2fe78bSCy Schubert        endtime (32 bits)
74*7f2fe78bSCy Schubert        renew_till (32 bits)
75*7f2fe78bSCy Schubert        is_skey (1 byte, 0 or 1)
76*7f2fe78bSCy Schubert        ticket_flags (32 bits)
77*7f2fe78bSCy Schubert        addresses (addresses)
78*7f2fe78bSCy Schubert        authdata (authdata)
79*7f2fe78bSCy Schubert        ticket (data)
80*7f2fe78bSCy Schubert        second_ticket (data)
81*7f2fe78bSCy Schubert
82*7f2fe78bSCy Schubert    keyblock ::=
83*7f2fe78bSCy Schubert        enctype (16 bits) [repeated twice in version 3]
84*7f2fe78bSCy Schubert        data
85*7f2fe78bSCy Schubert
86*7f2fe78bSCy Schubert    addresses ::=
87*7f2fe78bSCy Schubert        count (32 bits)
88*7f2fe78bSCy Schubert        address1
89*7f2fe78bSCy Schubert        address2
90*7f2fe78bSCy Schubert        ...
91*7f2fe78bSCy Schubert
92*7f2fe78bSCy Schubert    address ::=
93*7f2fe78bSCy Schubert        addrtype (16 bits)
94*7f2fe78bSCy Schubert        data
95*7f2fe78bSCy Schubert
96*7f2fe78bSCy Schubert    authdata ::=
97*7f2fe78bSCy Schubert        count (32 bits)
98*7f2fe78bSCy Schubert        authdata1
99*7f2fe78bSCy Schubert        authdata2
100*7f2fe78bSCy Schubert        ...
101*7f2fe78bSCy Schubert
102*7f2fe78bSCy Schubert    authdata ::=
103*7f2fe78bSCy Schubert        ad_type (16 bits)
104*7f2fe78bSCy Schubert        data
105*7f2fe78bSCy Schubert
106*7f2fe78bSCy SchubertThere is no external framing on a marshalled credential, so it must be
107*7f2fe78bSCy Schubertparsed according to the above grammar in order to find the next
108*7f2fe78bSCy Schubertcredential.  There is also no count of credentials or marker at the
109*7f2fe78bSCy Schubertend of the sequence of credentials; the sequence ends when the file
110*7f2fe78bSCy Schubertends.
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy Schubert
113*7f2fe78bSCy SchubertCredential cache configuration entries
114*7f2fe78bSCy Schubert--------------------------------------
115*7f2fe78bSCy Schubert
116*7f2fe78bSCy SchubertConfiguration entries are encoded as credential entries.  The client
117*7f2fe78bSCy Schubertprincipal of the entry is the default principal of the cache.  The
118*7f2fe78bSCy Schubertserver principal has the realm ``X-CACHECONF:`` and two or three
119*7f2fe78bSCy Schubertcomponents, the first of which is ``krb5_ccache_conf_data``.  The
120*7f2fe78bSCy Schubertserver principal's second component is the configuration key.  The
121*7f2fe78bSCy Schubertthird component, if it exists, is a principal to which the
122*7f2fe78bSCy Schubertconfiguration key is associated.  The configuration value is stored in
123*7f2fe78bSCy Schubertthe ticket field of the entry.  All other entry fields are zeroed.
124*7f2fe78bSCy Schubert
125*7f2fe78bSCy SchubertPrograms using credential caches must be aware of configuration
126*7f2fe78bSCy Schubertentries for several reasons:
127*7f2fe78bSCy Schubert
128*7f2fe78bSCy Schubert* A program which displays the contents of a cache should not
129*7f2fe78bSCy Schubert  generally display configuration entries.
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert* The ticket field of a configuration entry is not (usually) a valid
132*7f2fe78bSCy Schubert  encoding of a Kerberos ticket.  An implementation must not treat the
133*7f2fe78bSCy Schubert  cache file as malformed if it cannot decode the ticket field.
134*7f2fe78bSCy Schubert
135*7f2fe78bSCy Schubert* Configuration entries have an endtime field of 0 and might therefore
136*7f2fe78bSCy Schubert  always be considered expired, but they should not be treated as
137*7f2fe78bSCy Schubert  unimportant as a result.  For instance, a program which copies
138*7f2fe78bSCy Schubert  credentials from one cache to another should not omit configuration
139*7f2fe78bSCy Schubert  entries because of the endtime.
140*7f2fe78bSCy Schubert
141*7f2fe78bSCy SchubertThe following configuration keys are currently used in MIT krb5:
142*7f2fe78bSCy Schubert
143*7f2fe78bSCy Schubertfast_avail
144*7f2fe78bSCy Schubert    The presence of this key with a non-empty value indicates that the
145*7f2fe78bSCy Schubert    KDC asserted support for FAST (see :rfc:`6113`) during the initial
146*7f2fe78bSCy Schubert    authentication, using the negotiation method described in
147*7f2fe78bSCy Schubert    :rfc:`6806` section 11.  This key is not associated with any
148*7f2fe78bSCy Schubert    principal.
149*7f2fe78bSCy Schubert
150*7f2fe78bSCy Schubertpa_config_data
151*7f2fe78bSCy Schubert    The value of this key contains a JSON object representation of
152*7f2fe78bSCy Schubert    parameters remembered by the preauthentication mechanism used
153*7f2fe78bSCy Schubert    during the initial authentication.  These parameters may be used
154*7f2fe78bSCy Schubert    when refreshing credentials.  This key is associated with the
155*7f2fe78bSCy Schubert    server principal of the initial authentication (usually the local
156*7f2fe78bSCy Schubert    krbtgt principal of the client realm).
157*7f2fe78bSCy Schubert
158*7f2fe78bSCy Schubertpa_type
159*7f2fe78bSCy Schubert    The value of this key is the ASCII decimal representation of the
160*7f2fe78bSCy Schubert    preauth type number used during the initial authentication.  This
161*7f2fe78bSCy Schubert    key is associated with the server principal of the initial
162*7f2fe78bSCy Schubert    authentication.
163*7f2fe78bSCy Schubert
164*7f2fe78bSCy Schubertproxy_impersonator
165*7f2fe78bSCy Schubert    The presence of this key indicates that the cache is a synthetic
166*7f2fe78bSCy Schubert    delegated credential for use with S4U2Proxy.  The value is the
167*7f2fe78bSCy Schubert    name of the intermediate service whose TGT can be used to make
168*7f2fe78bSCy Schubert    S4U2Proxy requests for target services.  This key is not
169*7f2fe78bSCy Schubert    associated with any principal.
170*7f2fe78bSCy Schubert
171*7f2fe78bSCy Schubertrefresh_time
172*7f2fe78bSCy Schubert    The presence of this key indicates that the cache was acquired by
173*7f2fe78bSCy Schubert    the GSS mechanism using a client keytab.  The value is the ASCII
174*7f2fe78bSCy Schubert    decimal representation of a timestamp at which the GSS mechanism
175*7f2fe78bSCy Schubert    should attempt to refresh the credential cache from the client
176*7f2fe78bSCy Schubert    keytab.
177*7f2fe78bSCy Schubert
178*7f2fe78bSCy Schubertstart_realm
179*7f2fe78bSCy Schubert    This key indicates the realm of the ticket-granting ticket to be
180*7f2fe78bSCy Schubert    used for TGS requests, when making a referrals request or
181*7f2fe78bSCy Schubert    beginning a cross-realm request.  If it is not present, the client
182*7f2fe78bSCy Schubert    realm is used.
183