# define:
# * checksum
# * verify (if verification is not just checksum-and-compare)
+ # * checksum_len
@classmethod
def verify(cls, key, keyusage, text, cksum):
expected = cls.checksum(key, keyusage, text)
raise ValueError('Wrong key type for checksum')
super(_SimplifiedChecksum, cls).verify(key, keyusage, text, cksum)
+ @classmethod
+ def checksum_len(cls):
+ return cls.macsize
+
class _SHA1AES128(_SimplifiedChecksum):
macsize = 12
raise ValueError('Wrong key type for checksum')
super(_HMACMD5, cls).verify(key, keyusage, text, cksum)
+ @classmethod
+ def checksum_len(cls):
+ return hashes.MD5.digest_size
+
class _MD5(_ChecksumProfile):
@classmethod
# This is unkeyed!
return SIMPLE_HASH(text, hashes.MD5)
+ @classmethod
+ def checksum_len(cls):
+ return hashes.MD5.digest_size
+
class _SHA1(_ChecksumProfile):
@classmethod
# This is unkeyed!
return SIMPLE_HASH(text, hashes.SHA1)
+ @classmethod
+ def checksum_len(cls):
+ return hashes.SHA1.digest_size
+
class _CRC32(_ChecksumProfile):
@classmethod
cksum = (~crc32(text, 0xffffffff)) & 0xffffffff
return pack('<I', cksum)
+ @classmethod
+ def checksum_len(cls):
+ return 4
+
_enctype_table = {
Enctype.DES3: _DES3CBC,
c.verify(key, keyusage, text, cksum)
+def checksum_len(cksumtype):
+ c = _get_checksum_profile(cksumtype)
+ return c.checksum_len()
+
+
def prfplus(key, pepper, ln):
# Produce ln bytes of output using the RFC 6113 PRF+ function.
out = b''