Raise a DigestTooLarge exception if it won't fit within the requested message length.

This commit is contained in:
William Grant
2011-03-12 15:46:58 +11:00
parent bd7a6e6933
commit bafc0d5ea6
+2 -1
View File
@@ -69,6 +69,7 @@ ASN1_RSAPrivateKey = [
class DigestTooLarge(Exception): class DigestTooLarge(Exception):
"""The digest is too large to fit within the requested length."""
pass pass
@@ -127,7 +128,7 @@ def EMSA_PKCS1_v1_5_encode(digest, mlen, hashid):
(OCTET_STRING, digest), (OCTET_STRING, digest),
])) ]))
if len(dinfo)+3 > mlen: if len(dinfo)+3 > mlen:
raise Exception("Hash too large for modulus") # XXX: DKIMException raise DigestTooLarge()
return "\x00\x01"+"\xff"*(mlen-len(dinfo)-3)+"\x00"+dinfo return "\x00\x01"+"\xff"*(mlen-len(dinfo)-3)+"\x00"+dinfo