Skip to content

Commit 7525ae7

Browse files
committed
Fixed aes_cbc_hmac_decrypt
1 parent 68ca059 commit 7525ae7

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/jwkest/extra.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
from __future__ import division
2+
3+
from jwkest.jws import JWSException
4+
25
try:
36
from builtins import bytes
47
except ImportError:
@@ -20,6 +23,11 @@
2023
}
2124

2225

26+
class VerificationFailure(JWSException):
27+
pass
28+
29+
30+
2331
# PKCS#5 padding, since it's not in PyCrypto
2432
def pkcs5pad(x):
2533
"""
@@ -124,9 +132,9 @@ def aes_cbc_hmac_decrypt(key, iv, aad, ct, tag):
124132
if candidate == tag:
125133
cipher = AES.new(ke, AES.MODE_CBC, iv)
126134
pt = pkcs5trim(cipher.decrypt(ct))
127-
return pt, True
135+
return pt
128136
else:
129-
return None, False
137+
raise VerificationFailure('AES-CBC HMAC')
130138

131139

132140
def concat_sha256(secret, dk_len, other_info):

0 commit comments

Comments
 (0)