]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests/krb5: Fix DES3CBC random_to_key()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 18 Oct 2023 02:59:56 +0000 (15:59 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 19 Oct 2023 21:37:36 +0000 (21:37 +0000)
Because ‘keybytes’ is an immutable bytes object, ‘keybytes[7] = …’ has
no hope of working.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
python/samba/tests/krb5/kcrypto.py

index 98b8465f3abffbccae1072632682e4c7023ef5a8..c0a09908ea90f1480f6fa59dfb106b83fe5ea32f 100755 (executable)
@@ -283,7 +283,7 @@ class _DES3CBC(_SimplifiedEnctype):
             lastbyte = parity(sum((seed[i] & 1) << i + 1 for i in range(7)))
             keybytes = firstbytes + bytes([lastbyte])
             if _is_weak_des_key(keybytes):
-                keybytes[7] = bytes([keybytes[7] ^ 0xF0])
+                keybytes = firstbytes + bytes([lastbyte ^ 0xF0])
             return keybytes
 
         if len(seed) != 21: