From bafc0d5ea634277cc91fac76398c2731ce992b0e Mon Sep 17 00:00:00 2001 From: William Grant Date: Sat, 12 Mar 2011 15:46:58 +1100 Subject: [PATCH] Raise a DigestTooLarge exception if it won't fit within the requested message length. --- dkim/crypto.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dkim/crypto.py b/dkim/crypto.py index 74b1d16..4506da4 100644 --- a/dkim/crypto.py +++ b/dkim/crypto.py @@ -69,6 +69,7 @@ ASN1_RSAPrivateKey = [ class DigestTooLarge(Exception): + """The digest is too large to fit within the requested length.""" pass @@ -127,7 +128,7 @@ def EMSA_PKCS1_v1_5_encode(digest, mlen, hashid): (OCTET_STRING, digest), ])) 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