xref: /freebsd/crypto/krb5/doc/html/formats/cookie.html (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert
2*7f2fe78bSCy Schubert<!DOCTYPE html>
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy Schubert<html>
5*7f2fe78bSCy Schubert  <head>
6*7f2fe78bSCy Schubert    <meta charset="utf-8" />
7*7f2fe78bSCy Schubert    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
8*7f2fe78bSCy Schubert
9*7f2fe78bSCy Schubert    <title>KDC cookie format &#8212; MIT Kerberos Documentation</title>
10*7f2fe78bSCy Schubert    <link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
11*7f2fe78bSCy Schubert    <link rel="stylesheet" type="text/css" href="../_static/agogo.css" />
12*7f2fe78bSCy Schubert    <link rel="stylesheet" type="text/css" href="../_static/kerb.css" />
13*7f2fe78bSCy Schubert    <script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
14*7f2fe78bSCy Schubert    <script src="../_static/jquery.js"></script>
15*7f2fe78bSCy Schubert    <script src="../_static/underscore.js"></script>
16*7f2fe78bSCy Schubert    <script src="../_static/doctools.js"></script>
17*7f2fe78bSCy Schubert    <link rel="author" title="About these documents" href="../about.html" />
18*7f2fe78bSCy Schubert    <link rel="index" title="Index" href="../genindex.html" />
19*7f2fe78bSCy Schubert    <link rel="search" title="Search" href="../search.html" />
20*7f2fe78bSCy Schubert    <link rel="copyright" title="Copyright" href="../copyright.html" />
21*7f2fe78bSCy Schubert    <link rel="next" title="PKINIT freshness tokens" href="freshness_token.html" />
22*7f2fe78bSCy Schubert    <link rel="prev" title="Replay cache file format" href="rcache_file_format.html" />
23*7f2fe78bSCy Schubert  </head><body>
24*7f2fe78bSCy Schubert    <div class="header-wrapper">
25*7f2fe78bSCy Schubert        <div class="header">
26*7f2fe78bSCy Schubert
27*7f2fe78bSCy Schubert
28*7f2fe78bSCy Schubert            <h1><a href="../index.html">MIT Kerberos Documentation</a></h1>
29*7f2fe78bSCy Schubert
30*7f2fe78bSCy Schubert            <div class="rel">
31*7f2fe78bSCy Schubert
32*7f2fe78bSCy Schubert        <a href="../index.html" title="Full Table of Contents"
33*7f2fe78bSCy Schubert            accesskey="C">Contents</a> |
34*7f2fe78bSCy Schubert        <a href="rcache_file_format.html" title="Replay cache file format"
35*7f2fe78bSCy Schubert            accesskey="P">previous</a> |
36*7f2fe78bSCy Schubert        <a href="freshness_token.html" title="PKINIT freshness tokens"
37*7f2fe78bSCy Schubert            accesskey="N">next</a> |
38*7f2fe78bSCy Schubert        <a href="../genindex.html" title="General Index"
39*7f2fe78bSCy Schubert            accesskey="I">index</a> |
40*7f2fe78bSCy Schubert        <a href="../search.html" title="Enter search criteria"
41*7f2fe78bSCy Schubert            accesskey="S">Search</a> |
42*7f2fe78bSCy Schubert    <a href="mailto:krb5-bugs@mit.edu?subject=Documentation__KDC cookie format">feedback</a>
43*7f2fe78bSCy Schubert            </div>
44*7f2fe78bSCy Schubert        </div>
45*7f2fe78bSCy Schubert    </div>
46*7f2fe78bSCy Schubert
47*7f2fe78bSCy Schubert    <div class="content-wrapper">
48*7f2fe78bSCy Schubert      <div class="content">
49*7f2fe78bSCy Schubert        <div class="document">
50*7f2fe78bSCy Schubert
51*7f2fe78bSCy Schubert      <div class="documentwrapper">
52*7f2fe78bSCy Schubert        <div class="bodywrapper">
53*7f2fe78bSCy Schubert          <div class="body" role="main">
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy Schubert  <section id="kdc-cookie-format">
56*7f2fe78bSCy Schubert<h1>KDC cookie format<a class="headerlink" href="#kdc-cookie-format" title="Permalink to this headline">¶</a></h1>
57*7f2fe78bSCy Schubert<p><span class="target" id="index-0"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc6113.html"><strong>RFC 6113</strong></a> section 5.2 specifies a pa-data type PA-FX-COOKIE, which
58*7f2fe78bSCy Schubertclients are required to reflect back to the KDC during
59*7f2fe78bSCy Schubertpre-authentication.  The MIT krb5 KDC uses the following formats for
60*7f2fe78bSCy Schubertcookies.</p>
61*7f2fe78bSCy Schubert<section id="trivial-cookie-version-0">
62*7f2fe78bSCy Schubert<h2>Trivial cookie (version 0)<a class="headerlink" href="#trivial-cookie-version-0" title="Permalink to this headline">¶</a></h2>
63*7f2fe78bSCy Schubert<p>If there is no pre-authentication mechanism state information to save,
64*7f2fe78bSCy Schuberta trivial cookie containing the value “MIT” is used.  A trivial cookie
65*7f2fe78bSCy Schubertis needed to indicate that the conversation can continue.</p>
66*7f2fe78bSCy Schubert</section>
67*7f2fe78bSCy Schubert<section id="secure-cookie-version-1">
68*7f2fe78bSCy Schubert<h2>Secure cookie (version 1)<a class="headerlink" href="#secure-cookie-version-1" title="Permalink to this headline">¶</a></h2>
69*7f2fe78bSCy Schubert<p>In release 1.14 and later, a secure cookie can be sent if there is any
70*7f2fe78bSCy Schubertmechanism state to save for the next request.  A secure cookie
71*7f2fe78bSCy Schubertcontains the concatenation of the following:</p>
72*7f2fe78bSCy Schubert<ul class="simple">
73*7f2fe78bSCy Schubert<li><p>the four bytes “MIT1”</p></li>
74*7f2fe78bSCy Schubert<li><p>a four-byte big-endian kvno value</p></li>
75*7f2fe78bSCy Schubert<li><p>an <span class="target" id="index-1"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc3961.html"><strong>RFC 3961</strong></a> ciphertext</p></li>
76*7f2fe78bSCy Schubert</ul>
77*7f2fe78bSCy Schubert<p>The ciphertext is encrypted in the cookie key with key usage
78*7f2fe78bSCy Schubertnumber 513.  The cookie key is derived from a key in the local krbtgt
79*7f2fe78bSCy Schubertprincipal entry for the realm (e.g. <code class="docutils literal notranslate"><span class="pre">krbtgt/KRBTEST.COM&#64;KRBTEST.COM</span></code>
80*7f2fe78bSCy Schubertif the request is to the <code class="docutils literal notranslate"><span class="pre">KRBTEST.COM</span></code> realm).  The first krbtgt key
81*7f2fe78bSCy Schubertfor the indicated kvno value is combined with the client principal as
82*7f2fe78bSCy Schubertfollows:</p>
83*7f2fe78bSCy Schubert<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">cookie</span><span class="o">-</span><span class="n">key</span> <span class="o">&lt;-</span> <span class="n">random</span><span class="o">-</span><span class="n">to</span><span class="o">-</span><span class="n">key</span><span class="p">(</span><span class="n">PRF</span><span class="o">+</span><span class="p">(</span><span class="n">tgt</span><span class="o">-</span><span class="n">key</span><span class="p">,</span> <span class="s2">&quot;COOKIE&quot;</span> <span class="o">|</span> <span class="n">client</span><span class="o">-</span><span class="n">princ</span><span class="p">))</span>
84*7f2fe78bSCy Schubert</pre></div>
85*7f2fe78bSCy Schubert</div>
86*7f2fe78bSCy Schubert<p>where <strong>random-to-key</strong> is the <span class="target" id="index-2"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc3961.html"><strong>RFC 3961</strong></a> random-to-key operation for
87*7f2fe78bSCy Schubertthe krbtgt key’s encryption type, <strong>PRF+</strong> is defined in <span class="target" id="index-3"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc6113.html"><strong>RFC 6113</strong></a>,
88*7f2fe78bSCy Schubertand <code class="docutils literal notranslate"><span class="pre">|</span></code> denotes concatenation.  <em>client-princ</em> is the request client
89*7f2fe78bSCy Schubertprincipal name with realm, marshalled according to <span class="target" id="index-4"></span><a class="rfc reference external" href="https://tools.ietf.org/html/rfc1964.html"><strong>RFC 1964</strong></a> section
90*7f2fe78bSCy Schubert2.1.1.</p>
91*7f2fe78bSCy Schubert<p>The plain text of the encrypted part of a cookie is the DER encoding
92*7f2fe78bSCy Schubertof the following ASN.1 type:</p>
93*7f2fe78bSCy Schubert<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SecureCookie</span> <span class="p">:</span><span class="o">:=</span> <span class="n">SEQUENCE</span> <span class="p">{</span>
94*7f2fe78bSCy Schubert    <span class="n">time</span>     <span class="n">INTEGER</span><span class="p">,</span>
95*7f2fe78bSCy Schubert    <span class="n">data</span>     <span class="n">SEQUENCE</span> <span class="n">OF</span> <span class="n">PA</span><span class="o">-</span><span class="n">DATA</span><span class="p">,</span>
96*7f2fe78bSCy Schubert    <span class="o">...</span>
97*7f2fe78bSCy Schubert<span class="p">}</span>
98*7f2fe78bSCy Schubert</pre></div>
99*7f2fe78bSCy Schubert</div>
100*7f2fe78bSCy Schubert<p>The time field represents the cookie creation time; for brevity, it is
101*7f2fe78bSCy Schubertencoded as an integer giving the POSIX timestamp rather than as an
102*7f2fe78bSCy SchubertASN.1 GeneralizedTime value.  The data field contains one element for
103*7f2fe78bSCy Schuberteach pre-authentication type which requires saved state.  For
104*7f2fe78bSCy Schubertmechanisms which have separate request and reply types, the request
105*7f2fe78bSCy Schuberttype is used; this allows the KDC to determine whether a cookie is
106*7f2fe78bSCy Schubertrelevant to a request by comparing the request pa-data types to the
107*7f2fe78bSCy Schubertcookie data types.</p>
108*7f2fe78bSCy Schubert</section>
109*7f2fe78bSCy Schubert<section id="spake-cookie-format-version-1">
110*7f2fe78bSCy Schubert<h2>SPAKE cookie format (version 1)<a class="headerlink" href="#spake-cookie-format-version-1" title="Permalink to this headline">¶</a></h2>
111*7f2fe78bSCy Schubert<p>Inside the SecureCookie wrapper, a data value of type 151 contains
112*7f2fe78bSCy Schubertstate for SPAKE pre-authentication.  This data is the concatenation of
113*7f2fe78bSCy Schubertthe following:</p>
114*7f2fe78bSCy Schubert<ul class="simple">
115*7f2fe78bSCy Schubert<li><p>a two-byte big-endian version number with the value 1</p></li>
116*7f2fe78bSCy Schubert<li><p>a two-byte big-endian stage number</p></li>
117*7f2fe78bSCy Schubert<li><p>a four-byte big-endian group number</p></li>
118*7f2fe78bSCy Schubert<li><p>a four-byte big-endian length and data for the SPAKE value</p></li>
119*7f2fe78bSCy Schubert<li><p>a four-byte big-endian length and data for the transcript hash</p></li>
120*7f2fe78bSCy Schubert<li><p>zero or more second factor records, each consisting of:
121*7f2fe78bSCy Schubert- a four-byte big-endian second-factor type
122*7f2fe78bSCy Schubert- a four-byte big-endian length and data</p></li>
123*7f2fe78bSCy Schubert</ul>
124*7f2fe78bSCy Schubert<p>The stage value is 0 if the cookie was sent with a challenge message.
125*7f2fe78bSCy SchubertOtherwise it is 1 for the first encdata message sent by the KDC during
126*7f2fe78bSCy Schubertan exchange, 2 for the second, etc..</p>
127*7f2fe78bSCy Schubert<p>The group value indicates the group number used in the SPAKE challenge.</p>
128*7f2fe78bSCy Schubert<p>For a stage-0 cookie, the SPAKE value is the KDC private key,
129*7f2fe78bSCy Schubertrepresented in the scalar marshalling form of the group.  For other
130*7f2fe78bSCy Schubertcookies, the SPAKE value is the SPAKE result K, represented in the
131*7f2fe78bSCy Schubertgroup element marshalling form.</p>
132*7f2fe78bSCy Schubert<p>For a stage-0 cookie, the transcript hash is the intermediate hash
133*7f2fe78bSCy Schubertafter updating with the client support message (if one was sent) and
134*7f2fe78bSCy Schubertchallenge.  For other cookies it is the final hash.</p>
135*7f2fe78bSCy Schubert<p>For a stage-0 cookie, there may be any number of second-factor
136*7f2fe78bSCy Schubertrecords, including none; a second-factor type need not create a state
137*7f2fe78bSCy Schubertfield if it does not need one, and no record is created for SF-NONE.
138*7f2fe78bSCy SchubertFor other cookies, there must be exactly one second-factor record
139*7f2fe78bSCy Schubertcorresponding to the factor type chosen by the client.</p>
140*7f2fe78bSCy Schubert</section>
141*7f2fe78bSCy Schubert</section>
142*7f2fe78bSCy Schubert
143*7f2fe78bSCy Schubert
144*7f2fe78bSCy Schubert            <div class="clearer"></div>
145*7f2fe78bSCy Schubert          </div>
146*7f2fe78bSCy Schubert        </div>
147*7f2fe78bSCy Schubert      </div>
148*7f2fe78bSCy Schubert        </div>
149*7f2fe78bSCy Schubert        <div class="sidebar">
150*7f2fe78bSCy Schubert
151*7f2fe78bSCy Schubert    <h2>On this page</h2>
152*7f2fe78bSCy Schubert    <ul>
153*7f2fe78bSCy Schubert<li><a class="reference internal" href="#">KDC cookie format</a><ul>
154*7f2fe78bSCy Schubert<li><a class="reference internal" href="#trivial-cookie-version-0">Trivial cookie (version 0)</a></li>
155*7f2fe78bSCy Schubert<li><a class="reference internal" href="#secure-cookie-version-1">Secure cookie (version 1)</a></li>
156*7f2fe78bSCy Schubert<li><a class="reference internal" href="#spake-cookie-format-version-1">SPAKE cookie format (version 1)</a></li>
157*7f2fe78bSCy Schubert</ul>
158*7f2fe78bSCy Schubert</li>
159*7f2fe78bSCy Schubert</ul>
160*7f2fe78bSCy Schubert
161*7f2fe78bSCy Schubert    <br/>
162*7f2fe78bSCy Schubert    <h2>Table of contents</h2>
163*7f2fe78bSCy Schubert    <ul class="current">
164*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../user/index.html">For users</a></li>
165*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../admin/index.html">For administrators</a></li>
166*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../appdev/index.html">For application developers</a></li>
167*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../plugindev/index.html">For plugin module developers</a></li>
168*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../build/index.html">Building Kerberos V5</a></li>
169*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../basic/index.html">Kerberos V5 concepts</a></li>
170*7f2fe78bSCy Schubert<li class="toctree-l1 current"><a class="reference internal" href="index.html">Protocols and file formats</a><ul class="current">
171*7f2fe78bSCy Schubert<li class="toctree-l2"><a class="reference internal" href="ccache_file_format.html">Credential cache file format</a></li>
172*7f2fe78bSCy Schubert<li class="toctree-l2"><a class="reference internal" href="keytab_file_format.html">Keytab file format</a></li>
173*7f2fe78bSCy Schubert<li class="toctree-l2"><a class="reference internal" href="rcache_file_format.html">Replay cache file format</a></li>
174*7f2fe78bSCy Schubert<li class="toctree-l2 current"><a class="current reference internal" href="#">KDC cookie format</a></li>
175*7f2fe78bSCy Schubert<li class="toctree-l2"><a class="reference internal" href="freshness_token.html">PKINIT freshness tokens</a></li>
176*7f2fe78bSCy Schubert</ul>
177*7f2fe78bSCy Schubert</li>
178*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../mitK5features.html">MIT Kerberos features</a></li>
179*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../build_this.html">How to build this documentation from the source</a></li>
180*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../about.html">Contributing to the MIT Kerberos Documentation</a></li>
181*7f2fe78bSCy Schubert<li class="toctree-l1"><a class="reference internal" href="../resources.html">Resources</a></li>
182*7f2fe78bSCy Schubert</ul>
183*7f2fe78bSCy Schubert
184*7f2fe78bSCy Schubert    <br/>
185*7f2fe78bSCy Schubert    <h4><a href="../index.html">Full Table of Contents</a></h4>
186*7f2fe78bSCy Schubert    <h4>Search</h4>
187*7f2fe78bSCy Schubert    <form class="search" action="../search.html" method="get">
188*7f2fe78bSCy Schubert      <input type="text" name="q" size="18" />
189*7f2fe78bSCy Schubert      <input type="submit" value="Go" />
190*7f2fe78bSCy Schubert      <input type="hidden" name="check_keywords" value="yes" />
191*7f2fe78bSCy Schubert      <input type="hidden" name="area" value="default" />
192*7f2fe78bSCy Schubert    </form>
193*7f2fe78bSCy Schubert
194*7f2fe78bSCy Schubert        </div>
195*7f2fe78bSCy Schubert        <div class="clearer"></div>
196*7f2fe78bSCy Schubert      </div>
197*7f2fe78bSCy Schubert    </div>
198*7f2fe78bSCy Schubert
199*7f2fe78bSCy Schubert    <div class="footer-wrapper">
200*7f2fe78bSCy Schubert        <div class="footer" >
201*7f2fe78bSCy Schubert            <div class="right" ><i>Release: 1.21.3</i><br />
202*7f2fe78bSCy Schubert                &copy; <a href="../copyright.html">Copyright</a> 1985-2024, MIT.
203*7f2fe78bSCy Schubert            </div>
204*7f2fe78bSCy Schubert            <div class="left">
205*7f2fe78bSCy Schubert
206*7f2fe78bSCy Schubert        <a href="../index.html" title="Full Table of Contents"
207*7f2fe78bSCy Schubert            >Contents</a> |
208*7f2fe78bSCy Schubert        <a href="rcache_file_format.html" title="Replay cache file format"
209*7f2fe78bSCy Schubert            >previous</a> |
210*7f2fe78bSCy Schubert        <a href="freshness_token.html" title="PKINIT freshness tokens"
211*7f2fe78bSCy Schubert            >next</a> |
212*7f2fe78bSCy Schubert        <a href="../genindex.html" title="General Index"
213*7f2fe78bSCy Schubert            >index</a> |
214*7f2fe78bSCy Schubert        <a href="../search.html" title="Enter search criteria"
215*7f2fe78bSCy Schubert            >Search</a> |
216*7f2fe78bSCy Schubert    <a href="mailto:krb5-bugs@mit.edu?subject=Documentation__KDC cookie format">feedback</a>
217*7f2fe78bSCy Schubert            </div>
218*7f2fe78bSCy Schubert        </div>
219*7f2fe78bSCy Schubert    </div>
220*7f2fe78bSCy Schubert
221*7f2fe78bSCy Schubert  </body>
222*7f2fe78bSCy Schubert</html>