xref: /freebsd/crypto/krb5/doc/html/_sources/admin/advanced/retiring-des.rst.txt (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert.. _retiring-des:
2*7f2fe78bSCy Schubert
3*7f2fe78bSCy SchubertRetiring DES
4*7f2fe78bSCy Schubert=======================
5*7f2fe78bSCy Schubert
6*7f2fe78bSCy SchubertVersion 5 of the Kerberos protocol was originally implemented using
7*7f2fe78bSCy Schubertthe Data Encryption Standard (DES) as a block cipher for encryption.
8*7f2fe78bSCy SchubertWhile it was considered secure at the time, advancements in computational
9*7f2fe78bSCy Schubertability have rendered DES vulnerable to brute force attacks on its 56-bit
10*7f2fe78bSCy Schubertkeyspace.  As such, it is now considered insecure and should not be
11*7f2fe78bSCy Schubertused (:rfc:`6649`).
12*7f2fe78bSCy Schubert
13*7f2fe78bSCy SchubertHistory
14*7f2fe78bSCy Schubert-------
15*7f2fe78bSCy Schubert
16*7f2fe78bSCy SchubertDES was used in the original Kerberos implementation, and was the
17*7f2fe78bSCy Schubertonly cryptosystem in krb5 1.0.  Partial support for triple-DES (3DES) was
18*7f2fe78bSCy Schubertadded in version 1.1, with full support following in version 1.2.
19*7f2fe78bSCy SchubertThe Advanced Encryption Standard (AES), which supersedes DES, gained
20*7f2fe78bSCy Schubertpartial support in version 1.3.0 of krb5 and full support in version 1.3.2.
21*7f2fe78bSCy SchubertHowever, deployments of krb5 using Kerberos databases created with older
22*7f2fe78bSCy Schubertversions of krb5 will not necessarily start using strong crypto for
23*7f2fe78bSCy Schubertordinary operation without administrator intervention.
24*7f2fe78bSCy Schubert
25*7f2fe78bSCy SchubertMIT krb5 began flagging deprecated encryption types with release 1.17,
26*7f2fe78bSCy Schubertand removed DES (single-DES) support in release 1.18.  As a
27*7f2fe78bSCy Schubertconsequence, a release prior to 1.18 is required to perform these
28*7f2fe78bSCy Schubertmigrations.
29*7f2fe78bSCy Schubert
30*7f2fe78bSCy SchubertTypes of keys
31*7f2fe78bSCy Schubert-------------
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy Schubert* The database master key:  This key is not exposed to user requests,
34*7f2fe78bSCy Schubert  but is used to encrypt other key material stored in the kerberos
35*7f2fe78bSCy Schubert  database.  The database master key is currently stored as ``K/M``
36*7f2fe78bSCy Schubert  by default.
37*7f2fe78bSCy Schubert* Password-derived keys:  User principals frequently have keys
38*7f2fe78bSCy Schubert  derived from a password.  When a new password is set, the KDC
39*7f2fe78bSCy Schubert  uses various string2key functions to generate keys in the database
40*7f2fe78bSCy Schubert  for that principal.
41*7f2fe78bSCy Schubert* Keytab keys:  Application server principals generally use random
42*7f2fe78bSCy Schubert  keys which are not derived from a password.  When the database
43*7f2fe78bSCy Schubert  entry is created, the KDC generates random keys of various enctypes
44*7f2fe78bSCy Schubert  to enter in the database, which are conveyed to the application server
45*7f2fe78bSCy Schubert  and stored in a keytab.
46*7f2fe78bSCy Schubert* Session keys:  These are short-term keys generated by the KDC while
47*7f2fe78bSCy Schubert  processing client requests, with an enctype selected by the KDC.
48*7f2fe78bSCy Schubert
49*7f2fe78bSCy SchubertFor details on the various enctypes and how enctypes are selected by the KDC
50*7f2fe78bSCy Schubertfor session keys and client/server long-term keys, see :ref:`enctypes`.
51*7f2fe78bSCy SchubertWhen using the :ref:`kadmin(1)` interface to generate new long-term keys,
52*7f2fe78bSCy Schubertthe **-e** argument can be used to force a particular set of enctypes,
53*7f2fe78bSCy Schubertoverriding the KDC default values.
54*7f2fe78bSCy Schubert
55*7f2fe78bSCy Schubert.. note::
56*7f2fe78bSCy Schubert
57*7f2fe78bSCy Schubert    When the KDC is selecting a session key, it has no knowledge about the
58*7f2fe78bSCy Schubert    kerberos installation on the server which will receive the service ticket,
59*7f2fe78bSCy Schubert    only what keys are in the database for the service principal.
60*7f2fe78bSCy Schubert    In order to allow uninterrupted operation to
61*7f2fe78bSCy Schubert    clients while migrating away from DES, care must be taken to ensure that
62*7f2fe78bSCy Schubert    kerberos installations on application server machines are configured to
63*7f2fe78bSCy Schubert    support newer encryption types before keys of those new encryption types
64*7f2fe78bSCy Schubert    are created in the Kerberos database for those server principals.
65*7f2fe78bSCy Schubert
66*7f2fe78bSCy SchubertUpgrade procedure
67*7f2fe78bSCy Schubert-----------------
68*7f2fe78bSCy Schubert
69*7f2fe78bSCy SchubertThis procedure assumes that the KDC software has already been upgraded
70*7f2fe78bSCy Schubertto a modern version of krb5 that supports non-DES keys, so that the
71*7f2fe78bSCy Schubertonly remaining task is to update the actual keys used to service requests.
72*7f2fe78bSCy SchubertThe realm used for demonstrating this procedure, ZONE.MIT.EDU,
73*7f2fe78bSCy Schubertis an example of the worst-case scenario, where all keys in the realm
74*7f2fe78bSCy Schubertare DES.  The realm was initially created with a very old version of krb5,
75*7f2fe78bSCy Schubertand **supported_enctypes** in :ref:`kdc.conf(5)` was set to a value
76*7f2fe78bSCy Schubertappropriate when the KDC was installed, but was not updated as the KDC
77*7f2fe78bSCy Schubertwas upgraded:
78*7f2fe78bSCy Schubert
79*7f2fe78bSCy Schubert::
80*7f2fe78bSCy Schubert
81*7f2fe78bSCy Schubert    [realms]
82*7f2fe78bSCy Schubert            ZONE.MIT.EDU = {
83*7f2fe78bSCy Schubert                    [...]
84*7f2fe78bSCy Schubert                    master_key_type = des-cbc-crc
85*7f2fe78bSCy Schubert                    supported_enctypes = des-cbc-crc:normal des:normal des:v4 des:norealm des:onlyrealm des:afs3
86*7f2fe78bSCy Schubert            }
87*7f2fe78bSCy Schubert
88*7f2fe78bSCy SchubertThis resulted in the keys for all principals in the realm being forced
89*7f2fe78bSCy Schubertto DES-only, unless specifically requested using :ref:`kadmin(1)`.
90*7f2fe78bSCy Schubert
91*7f2fe78bSCy SchubertBefore starting the upgrade, all KDCs were running krb5 1.11,
92*7f2fe78bSCy Schubertand the database entries for some "high-value" principals were:
93*7f2fe78bSCy Schubert
94*7f2fe78bSCy Schubert::
95*7f2fe78bSCy Schubert
96*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q 'getprinc krbtgt/ZONE.MIT.EDU'
97*7f2fe78bSCy Schubert    [...]
98*7f2fe78bSCy Schubert    Number of keys: 1
99*7f2fe78bSCy Schubert    Key: vno 1, des-cbc-crc:v4
100*7f2fe78bSCy Schubert    [...]
101*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q 'getprinc kadmin/admin'
102*7f2fe78bSCy Schubert    [...]
103*7f2fe78bSCy Schubert    Number of keys: 1
104*7f2fe78bSCy Schubert    Key: vno 15, des-cbc-crc
105*7f2fe78bSCy Schubert    [...]
106*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q 'getprinc kadmin/changepw'
107*7f2fe78bSCy Schubert    [...]
108*7f2fe78bSCy Schubert    Number of keys: 1
109*7f2fe78bSCy Schubert    Key: vno 14, des-cbc-crc
110*7f2fe78bSCy Schubert    [...]
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy SchubertThe ``krbtgt/REALM`` key appears to have never been changed since creation
113*7f2fe78bSCy Schubert(its kvno is 1), and all three database entries have only a des-cbc-crc key.
114*7f2fe78bSCy Schubert
115*7f2fe78bSCy SchubertThe krbtgt key and KDC keys
116*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~
117*7f2fe78bSCy Schubert
118*7f2fe78bSCy SchubertPerhaps the biggest single-step improvement in the security of the cell
119*7f2fe78bSCy Schubertis gained by strengthening the key of the ticket-granting service principal,
120*7f2fe78bSCy Schubert``krbtgt/REALM``---if this principal's key is compromised, so is the
121*7f2fe78bSCy Schubertentire realm.  Since the server that will handle service tickets
122*7f2fe78bSCy Schubertfor this principal is the KDC itself, it is easy to guarantee that it
123*7f2fe78bSCy Schubertwill be configured to support any encryption types which might be
124*7f2fe78bSCy Schubertselected.  However, the default KDC behavior when creating new keys is to
125*7f2fe78bSCy Schubertremove the old keys, which would invalidate all existing tickets issued
126*7f2fe78bSCy Schubertagainst that principal, rendering the TGTs cached by clients useless.
127*7f2fe78bSCy SchubertInstead, a new key can be created with the old key retained, so that
128*7f2fe78bSCy Schubertexisting tickets will still function until their scheduled expiry
129*7f2fe78bSCy Schubert(see :ref:`changing_krbtgt_key`).
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert::
132*7f2fe78bSCy Schubert
133*7f2fe78bSCy Schubert    [root@casio krb5kdc]# enctypes=aes256-cts-hmac-sha1-96:normal,\
134*7f2fe78bSCy Schubert    > aes128-cts-hmac-sha1-96:normal,des3-hmac-sha1:normal,des-cbc-crc:normal
135*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q "cpw -e ${enctypes} -randkey \
136*7f2fe78bSCy Schubert    > -keepold krbtgt/ZONE.MIT.EDU"
137*7f2fe78bSCy Schubert    Authenticating as principal root/admin@ZONE.MIT.EDU with password.
138*7f2fe78bSCy Schubert    Key for "krbtgt/ZONE.MIT.EDU@ZONE.MIT.EDU" randomized.
139*7f2fe78bSCy Schubert
140*7f2fe78bSCy Schubert.. note::
141*7f2fe78bSCy Schubert
142*7f2fe78bSCy Schubert    The new ``krbtgt@REALM`` key should be propagated to replica KDCs
143*7f2fe78bSCy Schubert    immediately so that TGTs issued by the primary KDC can be used to
144*7f2fe78bSCy Schubert    issue service tickets on replica KDCs.  Replica KDCs will refuse
145*7f2fe78bSCy Schubert    requests using the new TGT kvno until the new krbtgt entry has
146*7f2fe78bSCy Schubert    been propagated to them.
147*7f2fe78bSCy Schubert
148*7f2fe78bSCy SchubertIt is necessary to explicitly specify the enctypes for the new database
149*7f2fe78bSCy Schubertentry, since **supported_enctypes** has not been changed.  Leaving
150*7f2fe78bSCy Schubert**supported_enctypes** unchanged makes a potential rollback operation
151*7f2fe78bSCy Schuberteasier, since all new keys of new enctypes are the result of explicit
152*7f2fe78bSCy Schubertadministrator action and can be easily enumerated.
153*7f2fe78bSCy SchubertUpgrading the krbtgt key should have minimal user-visible disruption other
154*7f2fe78bSCy Schubertthan that described in the note above, since only clients which list the
155*7f2fe78bSCy Schubertnew enctypes as supported will use them, per the procedure
156*7f2fe78bSCy Schubertin :ref:`session_key_selection`.
157*7f2fe78bSCy SchubertOnce the krbtgt key is updated, the session and ticket keys for user
158*7f2fe78bSCy SchubertTGTs will be strong keys, but subsequent requests
159*7f2fe78bSCy Schubertfor service tickets will still get DES keys until the service principals
160*7f2fe78bSCy Schuberthave new keys generated.  Application service
161*7f2fe78bSCy Schubertremains uninterrupted due to the key-selection procedure on the KDC.
162*7f2fe78bSCy Schubert
163*7f2fe78bSCy SchubertAfter the change, the database entry is now:
164*7f2fe78bSCy Schubert
165*7f2fe78bSCy Schubert::
166*7f2fe78bSCy Schubert
167*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q 'getprinc krbtgt/ZONE.MIT.EDU'
168*7f2fe78bSCy Schubert    [...]
169*7f2fe78bSCy Schubert    Number of keys: 5
170*7f2fe78bSCy Schubert    Key: vno 2, aes256-cts-hmac-sha1-96
171*7f2fe78bSCy Schubert    Key: vno 2, aes128-cts-hmac-sha1-96
172*7f2fe78bSCy Schubert    Key: vno 2, des3-cbc-sha1
173*7f2fe78bSCy Schubert    Key: vno 2, des-cbc-crc
174*7f2fe78bSCy Schubert    Key: vno 1, des-cbc-crc:v4
175*7f2fe78bSCy Schubert    [...]
176*7f2fe78bSCy Schubert
177*7f2fe78bSCy SchubertSince the expected disruptions from rekeying the krbtgt principal are
178*7f2fe78bSCy Schubertminor, after a short testing period, it is
179*7f2fe78bSCy Schubertappropriate to rekey the other high-value principals, ``kadmin/admin@REALM``
180*7f2fe78bSCy Schubertand ``kadmin/changepw@REALM``. These are the service principals used for
181*7f2fe78bSCy Schubertchanging user passwords and updating application keytabs.  The kadmin
182*7f2fe78bSCy Schubertand password-changing services are regular kerberized services, so the
183*7f2fe78bSCy Schubertsession-key-selection algorithm described in :ref:`session_key_selection`
184*7f2fe78bSCy Schubertapplies.  It is particularly important to have strong session keys for
185*7f2fe78bSCy Schubertthese services, since user passwords and new long-term keys are conveyed
186*7f2fe78bSCy Schubertover the encrypted channel.
187*7f2fe78bSCy Schubert
188*7f2fe78bSCy Schubert::
189*7f2fe78bSCy Schubert
190*7f2fe78bSCy Schubert    [root@casio krb5kdc]# enctypes=aes256-cts-hmac-sha1-96:normal,\
191*7f2fe78bSCy Schubert    > aes128-cts-hmac-sha1-96:normal,des3-hmac-sha1:normal
192*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q "cpw -e ${enctypes} -randkey \
193*7f2fe78bSCy Schubert    > kadmin/admin"
194*7f2fe78bSCy Schubert    Authenticating as principal root/admin@ZONE.MIT.EDU with password.
195*7f2fe78bSCy Schubert    Key for "kadmin/admin@ZONE.MIT.EDU" randomized.
196*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q "cpw -e ${enctypes} -randkey \
197*7f2fe78bSCy Schubert    > kadmin/changepw"
198*7f2fe78bSCy Schubert    Authenticating as principal root/admin@ZONE.MIT.EDU with password.
199*7f2fe78bSCy Schubert    Key for "kadmin/changepw@ZONE.MIT.EDU" randomized.
200*7f2fe78bSCy Schubert
201*7f2fe78bSCy SchubertIt is not necessary to retain a single-DES key for these services, since
202*7f2fe78bSCy Schubertpassword changes are not part of normal daily workflow, and disruption
203*7f2fe78bSCy Schubertfrom a client failure is likely to be minimal.  Furthermore, if a kerberos
204*7f2fe78bSCy Schubertclient experiences failure changing a user password or keytab key,
205*7f2fe78bSCy Schubertthis indicates that that client will become inoperative once services
206*7f2fe78bSCy Schubertare rekeyed to non-DES enctypes.  Such problems can be detected early
207*7f2fe78bSCy Schubertat this stage, giving more time for corrective action.
208*7f2fe78bSCy Schubert
209*7f2fe78bSCy SchubertAdding strong keys to application servers
210*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
211*7f2fe78bSCy Schubert
212*7f2fe78bSCy SchubertBefore switching the default enctypes for new keys over to strong enctypes,
213*7f2fe78bSCy Schubertit may be desired to test upgrading a handful of services with the
214*7f2fe78bSCy Schubertnew configuration before flipping the switch for the defaults.  This
215*7f2fe78bSCy Schubertstill requires using the **-e** argument in :ref:`kadmin(1)` to get non-default
216*7f2fe78bSCy Schubertenctypes:
217*7f2fe78bSCy Schubert
218*7f2fe78bSCy Schubert::
219*7f2fe78bSCy Schubert
220*7f2fe78bSCy Schubert    [root@casio krb5kdc]# enctypes=aes256-cts-hmac-sha1-96:normal,\
221*7f2fe78bSCy Schubert    > aes128-cts-hmac-sha1-96:normal,des3-cbc-sha1:normal,des-cbc-crc:normal
222*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin -r ZONE.MIT.EDU -p zephyr/zephyr@ZONE.MIT.EDU -k -t \
223*7f2fe78bSCy Schubert    > /etc/zephyr/krb5.keytab  -q "ktadd -e ${enctypes} \
224*7f2fe78bSCy Schubert    > -k /etc/zephyr/krb5.keytab zephyr/zephyr@ZONE.MIT.EDU"
225*7f2fe78bSCy Schubert    Authenticating as principal zephyr/zephyr@ZONE.MIT.EDU with keytab /etc/zephyr/krb5.keytab.
226*7f2fe78bSCy Schubert    Entry for principal zephyr/zephyr@ZONE.MIT.EDU with kvno 4, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:/etc/zephyr/krb5.keytab.
227*7f2fe78bSCy Schubert    Entry for principal zephyr/zephyr@ZONE.MIT.EDU with kvno 4, encryption type aes128-cts-hmac-sha1-96 added to keytab WRFILE:/etc/zephyr/krb5.keytab.
228*7f2fe78bSCy Schubert    Entry for principal zephyr/zephyr@ZONE.MIT.EDU with kvno 4, encryption type des3-cbc-sha1 added to keytab WRFILE:/etc/zephyr/krb5.keytab.
229*7f2fe78bSCy Schubert    Entry for principal zephyr/zephyr@ZONE.MIT.EDU with kvno 4, encryption type des-cbc-crc added to keytab WRFILE:/etc/zephyr/krb5.keytab.
230*7f2fe78bSCy Schubert
231*7f2fe78bSCy SchubertBe sure to remove the old keys from the application keytab, per best
232*7f2fe78bSCy Schubertpractice.
233*7f2fe78bSCy Schubert
234*7f2fe78bSCy Schubert::
235*7f2fe78bSCy Schubert
236*7f2fe78bSCy Schubert    [root@casio krb5kdc]# k5srvutil -f /etc/zephyr/krb5.keytab delold
237*7f2fe78bSCy Schubert    Authenticating as principal zephyr/zephyr@ZONE.MIT.EDU with keytab /etc/zephyr/krb5.keytab.
238*7f2fe78bSCy Schubert    Entry for principal zephyr/zephyr@ZONE.MIT.EDU with kvno 3 removed from keytab WRFILE:/etc/zephyr/krb5.keytab.
239*7f2fe78bSCy Schubert
240*7f2fe78bSCy SchubertAdding strong keys by default
241*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
242*7f2fe78bSCy SchubertOnce the high-visibility services have been rekeyed, it is probably
243*7f2fe78bSCy Schubertappropriate to change :ref:`kdc.conf(5)` to generate keys with the new
244*7f2fe78bSCy Schubertencryption types by default.  This enables server administrators to generate
245*7f2fe78bSCy Schubertnew enctypes with the **change** subcommand of :ref:`k5srvutil(1)`,
246*7f2fe78bSCy Schubertand causes user password
247*7f2fe78bSCy Schubertchanges to add new encryption types for their entries.  It will probably
248*7f2fe78bSCy Schubertbe necessary to implement administrative controls to cause all user
249*7f2fe78bSCy Schubertprincipal keys to be updated in a reasonable period of time, whether
250*7f2fe78bSCy Schubertby forcing password changes or a password synchronization service that
251*7f2fe78bSCy Schuberthas access to the current password and can add the new keys.
252*7f2fe78bSCy Schubert
253*7f2fe78bSCy Schubert::
254*7f2fe78bSCy Schubert
255*7f2fe78bSCy Schubert    [realms]
256*7f2fe78bSCy Schubert            ZONE.MIT.EDU = {
257*7f2fe78bSCy Schubert                    supported_enctypes = aes256-cts-hmac-sha1-96:normal aes128-cts-hmac-sha1-96:normal des3-cbc-sha1:normal des3-hmac-sha1:normal des-cbc-crc:normal
258*7f2fe78bSCy Schubert
259*7f2fe78bSCy Schubert.. note::
260*7f2fe78bSCy Schubert
261*7f2fe78bSCy Schubert    The krb5kdc process must be restarted for these changes to take effect.
262*7f2fe78bSCy Schubert
263*7f2fe78bSCy SchubertAt this point, all service administrators can update their services and the
264*7f2fe78bSCy Schubertservers behind them to take advantage of strong cryptography.
265*7f2fe78bSCy SchubertIf necessary, the server's krb5 installation should be configured and/or
266*7f2fe78bSCy Schubertupgraded to a version supporting non-DES keys.  See :ref:`enctypes` for
267*7f2fe78bSCy Schubertkrb5 version and configuration settings.
268*7f2fe78bSCy SchubertOnly when the service is configured to accept non-DES keys should
269*7f2fe78bSCy Schubertthe key version number be incremented and new keys generated
270*7f2fe78bSCy Schubert(``k5srvutil change && k5srvutil delold``).
271*7f2fe78bSCy Schubert
272*7f2fe78bSCy Schubert::
273*7f2fe78bSCy Schubert
274*7f2fe78bSCy Schubert    root@dr-willy:~# k5srvutil change
275*7f2fe78bSCy Schubert    Authenticating as principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with keytab /etc/krb5.keytab.
276*7f2fe78bSCy Schubert    Entry for principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with kvno 3, encryption type AES-256 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/krb5.keytab.
277*7f2fe78bSCy Schubert    Entry for principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with kvno 3, encryption type AES-128 CTS mode with 96-bit SHA-1 HMAC added to keytab WRFILE:/etc/krb5.keytab.
278*7f2fe78bSCy Schubert    Entry for principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with kvno 3, encryption type Triple DES cbc mode with HMAC/sha1 added to keytab WRFILE:/etc/krb5.keytab.
279*7f2fe78bSCy Schubert    Entry for principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with kvno 3, encryption type DES cbc mode with CRC-32 added to keytab WRFILE:/etc/krb5.keytab.
280*7f2fe78bSCy Schubert    root@dr-willy:~# klist -e -k -t /etc/krb5.keytab
281*7f2fe78bSCy Schubert    Keytab name: WRFILE:/etc/krb5.keytab
282*7f2fe78bSCy Schubert    KVNO Timestamp         Principal
283*7f2fe78bSCy Schubert    ---- ----------------- --------------------------------------------------------
284*7f2fe78bSCy Schubert       2 10/10/12 17:03:59 host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU (DES cbc mode with CRC-32)
285*7f2fe78bSCy Schubert       3 12/12/12 15:31:19 host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU (AES-256 CTS mode with 96-bit SHA-1 HMAC)
286*7f2fe78bSCy Schubert       3 12/12/12 15:31:19 host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU (AES-128 CTS mode with 96-bit SHA-1 HMAC)
287*7f2fe78bSCy Schubert       3 12/12/12 15:31:19 host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU (Triple DES cbc mode with HMAC/sha1)
288*7f2fe78bSCy Schubert       3 12/12/12 15:31:19 host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU (DES cbc mode with CRC-32)
289*7f2fe78bSCy Schubert    root@dr-willy:~# k5srvutil delold
290*7f2fe78bSCy Schubert    Authenticating as principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with keytab /etc/krb5.keytab.
291*7f2fe78bSCy Schubert    Entry for principal host/dr-willy.xvm.mit.edu@ZONE.MIT.EDU with kvno 2 removed from keytab WRFILE:/etc/krb5.keytab.
292*7f2fe78bSCy Schubert
293*7f2fe78bSCy SchubertWhen a single service principal is shared by multiple backend servers in
294*7f2fe78bSCy Schuberta load-balanced environment, it may be necessary to schedule downtime
295*7f2fe78bSCy Schubertor adjust the population in the load-balanced pool in order to propagate
296*7f2fe78bSCy Schubertthe updated keytab to all hosts in the pool with minimal service interruption.
297*7f2fe78bSCy Schubert
298*7f2fe78bSCy SchubertRemoving DES keys from usage
299*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~~
300*7f2fe78bSCy Schubert
301*7f2fe78bSCy SchubertThis situation remains something of a testing or transitory state,
302*7f2fe78bSCy Schubertas new DES keys are still being generated, and will be used if requested
303*7f2fe78bSCy Schubertby a client.  To make more progress removing DES from the realm, the KDC
304*7f2fe78bSCy Schubertshould be configured to not generate such keys by default.
305*7f2fe78bSCy Schubert
306*7f2fe78bSCy Schubert.. note::
307*7f2fe78bSCy Schubert
308*7f2fe78bSCy Schubert    An attacker posing as a client can implement a brute force attack against
309*7f2fe78bSCy Schubert    a DES key for any principal, if that key is in the current (highest-kvno)
310*7f2fe78bSCy Schubert    key list.  This attack is only possible if **allow_weak_crypto = true**
311*7f2fe78bSCy Schubert    is enabled on the KDC.  Setting the **+requires_preauth** flag on a
312*7f2fe78bSCy Schubert    principal forces this attack to be an online attack, much slower than
313*7f2fe78bSCy Schubert    the offline attack otherwise available to the attacker.  However, setting
314*7f2fe78bSCy Schubert    this flag on a service principal is not always advisable; see the entry in
315*7f2fe78bSCy Schubert    :ref:`add_principal` for details.
316*7f2fe78bSCy Schubert
317*7f2fe78bSCy SchubertThe following KDC configuration will not generate DES keys by default:
318*7f2fe78bSCy Schubert
319*7f2fe78bSCy Schubert::
320*7f2fe78bSCy Schubert
321*7f2fe78bSCy Schubert    [realms]
322*7f2fe78bSCy Schubert            ZONE.MIT.EDU = {
323*7f2fe78bSCy Schubert                    supported_enctypes = aes256-cts-hmac-sha1-96:normal aes128-cts-hmac-sha1-96:normal des3-cbc-sha1:normal des3-hmac-sha1:normal
324*7f2fe78bSCy Schubert
325*7f2fe78bSCy Schubert.. note::
326*7f2fe78bSCy Schubert
327*7f2fe78bSCy Schubert    As before, the KDC process must be restarted for this change to take
328*7f2fe78bSCy Schubert    effect.  It is best practice to update kdc.conf on all KDCs, not just the
329*7f2fe78bSCy Schubert    primary, to avoid unpleasant surprises should the primary fail and a
330*7f2fe78bSCy Schubert    replica need to be promoted.
331*7f2fe78bSCy Schubert
332*7f2fe78bSCy SchubertIt is now appropriate to remove the legacy single-DES key from the
333*7f2fe78bSCy Schubert``krbtgt/REALM`` entry:
334*7f2fe78bSCy Schubert
335*7f2fe78bSCy Schubert::
336*7f2fe78bSCy Schubert
337*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q "cpw -randkey -keepold \
338*7f2fe78bSCy Schubert    > krbtgt/ZONE.MIT.EDU"
339*7f2fe78bSCy Schubert    Authenticating as principal host/admin@ATHENA.MIT.EDU with password.
340*7f2fe78bSCy Schubert    Key for "krbtgt/ZONE.MIT.EDU@ZONE.MIT.EDU" randomized.
341*7f2fe78bSCy Schubert
342*7f2fe78bSCy SchubertAfter the maximum ticket lifetime has passed, the old database entry
343*7f2fe78bSCy Schubertshould be removed.
344*7f2fe78bSCy Schubert
345*7f2fe78bSCy Schubert::
346*7f2fe78bSCy Schubert
347*7f2fe78bSCy Schubert    [root@casio krb5kdc]# kadmin.local -r ZONE.MIT.EDU -q 'purgekeys krbtgt/ZONE.MIT.EDU'
348*7f2fe78bSCy Schubert    Authenticating as principal root/admin@ZONE.MIT.EDU with password.
349*7f2fe78bSCy Schubert    Old keys for principal "krbtgt/ZONE.MIT.EDU@ZONE.MIT.EDU" purged.
350*7f2fe78bSCy Schubert
351*7f2fe78bSCy SchubertAfter the KDC is restarted with the new **supported_enctypes**,
352*7f2fe78bSCy Schubertall user password changes and application keytab updates will not
353*7f2fe78bSCy Schubertgenerate DES keys by default.
354*7f2fe78bSCy Schubert
355*7f2fe78bSCy Schubert::
356*7f2fe78bSCy Schubert
357*7f2fe78bSCy Schubert    contents-vnder-pressvre:~> kpasswd zonetest@ZONE.MIT.EDU
358*7f2fe78bSCy Schubert    Password for zonetest@ZONE.MIT.EDU:  [enter old password]
359*7f2fe78bSCy Schubert    Enter new password:                  [enter new password]
360*7f2fe78bSCy Schubert    Enter it again:                      [enter new password]
361*7f2fe78bSCy Schubert    Password changed.
362*7f2fe78bSCy Schubert    contents-vnder-pressvre:~> kadmin -r ZONE.MIT.EDU -q 'getprinc zonetest'
363*7f2fe78bSCy Schubert    [...]
364*7f2fe78bSCy Schubert    Number of keys: 3
365*7f2fe78bSCy Schubert    Key: vno 9, aes256-cts-hmac-sha1-96
366*7f2fe78bSCy Schubert    Key: vno 9, aes128-cts-hmac-sha1-96
367*7f2fe78bSCy Schubert    Key: vno 9, des3-cbc-sha1
368*7f2fe78bSCy Schubert    [...]
369*7f2fe78bSCy Schubert
370*7f2fe78bSCy Schubert    [kaduk@glossolalia ~]$ kadmin -p kaduk@ZONE.MIT.EDU -r ZONE.MIT.EDU -k \
371*7f2fe78bSCy Schubert    > -t kaduk-zone.keytab -q 'ktadd -k kaduk-zone.keytab kaduk@ZONE.MIT.EDU'
372*7f2fe78bSCy Schubert    Authenticating as principal kaduk@ZONE.MIT.EDU with keytab kaduk-zone.keytab.
373*7f2fe78bSCy Schubert    Entry for principal kaduk@ZONE.MIT.EDU with kvno 3, encryption type aes256-cts-hmac-sha1-96 added to keytab WRFILE:kaduk-zone.keytab.
374*7f2fe78bSCy Schubert    Entry for principal kaduk@ZONE.MIT.EDU with kvno 3, encryption type aes128-cts-hmac-sha1-96 added to keytab WRFILE:kaduk-zone.keytab.
375*7f2fe78bSCy Schubert    Entry for principal kaduk@ZONE.MIT.EDU with kvno 3, encryption type des3-cbc-sha1 added to keytab WRFILE:kaduk-zone.keytab.
376*7f2fe78bSCy Schubert
377*7f2fe78bSCy SchubertOnce all principals have been re-keyed, DES support can be disabled on the
378*7f2fe78bSCy SchubertKDC (**allow_weak_crypto = false**), and client machines can remove
379*7f2fe78bSCy Schubert**allow_weak_crypto = true** from their :ref:`krb5.conf(5)` configuration
380*7f2fe78bSCy Schubertfiles, completing the migration.  **allow_weak_crypto** takes precedence over
381*7f2fe78bSCy Schubertall places where DES enctypes could be explicitly configured.  DES keys will
382*7f2fe78bSCy Schubertnot be used, even if they are present, when **allow_weak_crypto = false**.
383*7f2fe78bSCy Schubert
384*7f2fe78bSCy SchubertSupport for legacy services
385*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~
386*7f2fe78bSCy Schubert
387*7f2fe78bSCy SchubertIf there remain legacy services which do not support non-DES enctypes
388*7f2fe78bSCy Schubert(such as older versions of AFS), **allow_weak_crypto** must remain
389*7f2fe78bSCy Schubertenabled on the KDC.  Client machines need not have this setting,
390*7f2fe78bSCy Schubertthough---applications which require DES can use API calls to allow
391*7f2fe78bSCy Schubertweak crypto on a per-request basis, overriding the system krb5.conf.
392*7f2fe78bSCy SchubertHowever, having **allow_weak_crypto** set on the KDC means that any
393*7f2fe78bSCy Schubertprincipals which have a DES key in the database could still use those
394*7f2fe78bSCy Schubertkeys.  To minimize the use of DES in the realm and restrict it to just
395*7f2fe78bSCy Schubertlegacy services which require DES, it is necessary to remove all other
396*7f2fe78bSCy SchubertDES keys.  The realm has been configured such that at password and
397*7f2fe78bSCy Schubertkeytab change, no DES keys will be generated by default.  The task
398*7f2fe78bSCy Schubertthen reduces to requiring user password changes and having server
399*7f2fe78bSCy Schubertadministrators update their service keytabs.  Administrative outreach
400*7f2fe78bSCy Schubertwill be necessary, and if the desire to eliminate DES is sufficiently
401*7f2fe78bSCy Schubertstrong, the KDC administrators may choose to randkey any principals
402*7f2fe78bSCy Schubertwhich have not been rekeyed after some timeout period, forcing the
403*7f2fe78bSCy Schubertuser to contact the helpdesk for access.
404*7f2fe78bSCy Schubert
405*7f2fe78bSCy SchubertThe Database Master Key
406*7f2fe78bSCy Schubert-----------------------
407*7f2fe78bSCy Schubert
408*7f2fe78bSCy SchubertThis procedure does not alter ``K/M@REALM``, the key used to encrypt key
409*7f2fe78bSCy Schubertmaterial in the Kerberos database.  (This is the key stored in the stash file
410*7f2fe78bSCy Schuberton the KDC if stash files are used.)  However, the security risk of
411*7f2fe78bSCy Schuberta single-DES key for ``K/M`` is minimal, given that access to material
412*7f2fe78bSCy Schubertencrypted in ``K/M`` (the Kerberos database) is generally tightly controlled.
413*7f2fe78bSCy SchubertIf an attacker can gain access to the encrypted database, they likely
414*7f2fe78bSCy Schuberthave access to the stash file as well, rendering the weak cryptography
415*7f2fe78bSCy Schubertbroken by non-cryptographic means.  As such, upgrading ``K/M`` to a stronger
416*7f2fe78bSCy Schubertencryption type is unlikely to be a high-priority task.
417*7f2fe78bSCy Schubert
418*7f2fe78bSCy SchubertIs is possible to upgrade the master key used for the database, if
419*7f2fe78bSCy Schubertdesired.  Using :ref:`kdb5_util(8)`'s **add_mkey**, **use_mkey**, and
420*7f2fe78bSCy Schubert**update_princ_encryption** commands, a new master key can be added
421*7f2fe78bSCy Schubertand activated for use on new key material, and the existing entries
422*7f2fe78bSCy Schubertconverted to the new master key.
423