mirror of
https://github.com/samba-team/samba.git
synced 2025-12-21 20:23:50 +03:00
tests/krb5: Introduce helper method for creating invalid length checksums
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14642 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Andrew Bartlett
parent
cda50b5c50
commit
9d142dc3a4
@@ -314,17 +314,20 @@ class WrongLengthChecksumKey(Krb5EncryptionKey):
|
||||
|
||||
self._length = length
|
||||
|
||||
def make_checksum(self, usage, plaintext, ctype=None):
|
||||
checksum = super().make_checksum(usage, plaintext, ctype)
|
||||
|
||||
diff = self._length - len(checksum)
|
||||
@classmethod
|
||||
def _adjust_to_length(cls, checksum, length):
|
||||
diff = length - len(checksum)
|
||||
if diff > 0:
|
||||
checksum += bytes(diff)
|
||||
elif diff < 0:
|
||||
checksum = checksum[:self._length]
|
||||
checksum = checksum[:length]
|
||||
|
||||
return checksum
|
||||
|
||||
def make_checksum(self, usage, plaintext, ctype=None):
|
||||
checksum = super().make_checksum(usage, plaintext, ctype)
|
||||
return self._adjust_to_length(checksum, self._length)
|
||||
|
||||
|
||||
class KerberosCredentials(Credentials):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user