1*7f2fe78bSCy SchubertKDC cookie format 2*7f2fe78bSCy Schubert================= 3*7f2fe78bSCy Schubert 4*7f2fe78bSCy Schubert:rfc:`6113` section 5.2 specifies a pa-data type PA-FX-COOKIE, which 5*7f2fe78bSCy Schubertclients are required to reflect back to the KDC during 6*7f2fe78bSCy Schubertpre-authentication. The MIT krb5 KDC uses the following formats for 7*7f2fe78bSCy Schubertcookies. 8*7f2fe78bSCy Schubert 9*7f2fe78bSCy Schubert 10*7f2fe78bSCy SchubertTrivial cookie (version 0) 11*7f2fe78bSCy Schubert-------------------------- 12*7f2fe78bSCy Schubert 13*7f2fe78bSCy SchubertIf there is no pre-authentication mechanism state information to save, 14*7f2fe78bSCy Schuberta trivial cookie containing the value "MIT" is used. A trivial cookie 15*7f2fe78bSCy Schubertis needed to indicate that the conversation can continue. 16*7f2fe78bSCy Schubert 17*7f2fe78bSCy Schubert 18*7f2fe78bSCy SchubertSecure cookie (version 1) 19*7f2fe78bSCy Schubert------------------------- 20*7f2fe78bSCy Schubert 21*7f2fe78bSCy SchubertIn release 1.14 and later, a secure cookie can be sent if there is any 22*7f2fe78bSCy Schubertmechanism state to save for the next request. A secure cookie 23*7f2fe78bSCy Schubertcontains the concatenation of the following: 24*7f2fe78bSCy Schubert 25*7f2fe78bSCy Schubert* the four bytes "MIT1" 26*7f2fe78bSCy Schubert* a four-byte big-endian kvno value 27*7f2fe78bSCy Schubert* an :rfc:`3961` ciphertext 28*7f2fe78bSCy Schubert 29*7f2fe78bSCy SchubertThe ciphertext is encrypted in the cookie key with key usage 30*7f2fe78bSCy Schubertnumber 513. The cookie key is derived from a key in the local krbtgt 31*7f2fe78bSCy Schubertprincipal entry for the realm (e.g. ``krbtgt/KRBTEST.COM@KRBTEST.COM`` 32*7f2fe78bSCy Schubertif the request is to the ``KRBTEST.COM`` realm). The first krbtgt key 33*7f2fe78bSCy Schubertfor the indicated kvno value is combined with the client principal as 34*7f2fe78bSCy Schubertfollows:: 35*7f2fe78bSCy Schubert 36*7f2fe78bSCy Schubert cookie-key <- random-to-key(PRF+(tgt-key, "COOKIE" | client-princ)) 37*7f2fe78bSCy Schubert 38*7f2fe78bSCy Schubertwhere **random-to-key** is the :rfc:`3961` random-to-key operation for 39*7f2fe78bSCy Schubertthe krbtgt key's encryption type, **PRF+** is defined in :rfc:`6113`, 40*7f2fe78bSCy Schubertand ``|`` denotes concatenation. *client-princ* is the request client 41*7f2fe78bSCy Schubertprincipal name with realm, marshalled according to :rfc:`1964` section 42*7f2fe78bSCy Schubert2.1.1. 43*7f2fe78bSCy Schubert 44*7f2fe78bSCy SchubertThe plain text of the encrypted part of a cookie is the DER encoding 45*7f2fe78bSCy Schubertof the following ASN.1 type:: 46*7f2fe78bSCy Schubert 47*7f2fe78bSCy Schubert SecureCookie ::= SEQUENCE { 48*7f2fe78bSCy Schubert time INTEGER, 49*7f2fe78bSCy Schubert data SEQUENCE OF PA-DATA, 50*7f2fe78bSCy Schubert ... 51*7f2fe78bSCy Schubert } 52*7f2fe78bSCy Schubert 53*7f2fe78bSCy SchubertThe time field represents the cookie creation time; for brevity, it is 54*7f2fe78bSCy Schubertencoded as an integer giving the POSIX timestamp rather than as an 55*7f2fe78bSCy SchubertASN.1 GeneralizedTime value. The data field contains one element for 56*7f2fe78bSCy Schuberteach pre-authentication type which requires saved state. For 57*7f2fe78bSCy Schubertmechanisms which have separate request and reply types, the request 58*7f2fe78bSCy Schuberttype is used; this allows the KDC to determine whether a cookie is 59*7f2fe78bSCy Schubertrelevant to a request by comparing the request pa-data types to the 60*7f2fe78bSCy Schubertcookie data types. 61*7f2fe78bSCy Schubert 62*7f2fe78bSCy SchubertSPAKE cookie format (version 1) 63*7f2fe78bSCy Schubert------------------------------- 64*7f2fe78bSCy Schubert 65*7f2fe78bSCy SchubertInside the SecureCookie wrapper, a data value of type 151 contains 66*7f2fe78bSCy Schubertstate for SPAKE pre-authentication. This data is the concatenation of 67*7f2fe78bSCy Schubertthe following: 68*7f2fe78bSCy Schubert 69*7f2fe78bSCy Schubert* a two-byte big-endian version number with the value 1 70*7f2fe78bSCy Schubert* a two-byte big-endian stage number 71*7f2fe78bSCy Schubert* a four-byte big-endian group number 72*7f2fe78bSCy Schubert* a four-byte big-endian length and data for the SPAKE value 73*7f2fe78bSCy Schubert* a four-byte big-endian length and data for the transcript hash 74*7f2fe78bSCy Schubert* zero or more second factor records, each consisting of: 75*7f2fe78bSCy Schubert - a four-byte big-endian second-factor type 76*7f2fe78bSCy Schubert - a four-byte big-endian length and data 77*7f2fe78bSCy Schubert 78*7f2fe78bSCy SchubertThe stage value is 0 if the cookie was sent with a challenge message. 79*7f2fe78bSCy SchubertOtherwise it is 1 for the first encdata message sent by the KDC during 80*7f2fe78bSCy Schubertan exchange, 2 for the second, etc.. 81*7f2fe78bSCy Schubert 82*7f2fe78bSCy SchubertThe group value indicates the group number used in the SPAKE challenge. 83*7f2fe78bSCy Schubert 84*7f2fe78bSCy SchubertFor a stage-0 cookie, the SPAKE value is the KDC private key, 85*7f2fe78bSCy Schubertrepresented in the scalar marshalling form of the group. For other 86*7f2fe78bSCy Schubertcookies, the SPAKE value is the SPAKE result K, represented in the 87*7f2fe78bSCy Schubertgroup element marshalling form. 88*7f2fe78bSCy Schubert 89*7f2fe78bSCy SchubertFor a stage-0 cookie, the transcript hash is the intermediate hash 90*7f2fe78bSCy Schubertafter updating with the client support message (if one was sent) and 91*7f2fe78bSCy Schubertchallenge. For other cookies it is the final hash. 92*7f2fe78bSCy Schubert 93*7f2fe78bSCy SchubertFor a stage-0 cookie, there may be any number of second-factor 94*7f2fe78bSCy Schubertrecords, including none; a second-factor type need not create a state 95*7f2fe78bSCy Schubertfield if it does not need one, and no record is created for SF-NONE. 96*7f2fe78bSCy SchubertFor other cookies, there must be exactly one second-factor record 97*7f2fe78bSCy Schubertcorresponding to the factor type chosen by the client. 98