@@ -62,10 +62,6 @@ def _preauthError(entries):
6262 return {12 : der .octetString (der .sequenceOf ([paData ]))}
6363
6464
65- def _selectEtype (offered , hints ):
66- """getTGT's etype choice: the client's own preference order, restricted to what it offered."""
67-
68- return next ((_ for _ in offered if _ in hints and _ in ENCTYPES ), None )
6965
7066
7167class TestKerberosAES (unittest .TestCase ):
@@ -219,12 +215,14 @@ def test_hint_cannot_override_pinned_salt(self):
219215 self .assertEqual (client ._hintFor (hints , 17 , None , "DEFAULT" ), ("DEFAULT" , None ))
220216
221217 def test_etype_selection_honours_client_preference (self ):
222- # a spoofed hint must not be able to pull the client onto an etype it never offered, and the
223- # client's own preference order wins over the KDC's
218+ # Exercises the REAL getTGT selection ( client._selectEtype, not a copy): a spoofed hint must
219+ # not pull the client onto an etype it never offered, and our own preference order wins.
224220 hints = client ._preauthHints (_preauthError ([_etypeInfo2Entry (23 ), _etypeInfo2Entry (18 )]))
225- self .assertEqual (_selectEtype ((18 , 17 ), hints ), 18 ) # KDC listed rc4 first
226- self .assertEqual (_selectEtype ((17 , 18 ), hints ), 18 ) # only 18 is hinted
227- self .assertIsNone (_selectEtype ((18 , 17 ), client ._preauthHints (_preauthError ([_etypeInfo2Entry (23 )]))))
221+ self .assertEqual (client ._selectEtype ((18 , 17 ), hints ), 18 ) # 18 offered+hinted
222+ self .assertEqual (client ._selectEtype ((17 , 18 ), hints ), 18 ) # KDC listed rc4(23) first, we still pick our offered+hinted 18
223+ # KDC hints ONLY rc4(23), which we did NOT offer -> must fall back to our top offered (18), never 23
224+ onlyRc4 = client ._preauthHints (_preauthError ([_etypeInfo2Entry (23 )]))
225+ self .assertEqual (client ._selectEtype ((18 , 17 ), onlyRc4 ), 18 )
228226
229227 def test_authenticator_timestamps_are_unique (self ):
230228 # an acceptor's replay cache keys on (ctime, cusec), and a threaded scan mints one per request
0 commit comments