def unhack_octets(s):
"""Reverse the operation done by `hack_octets'."""
pad = (len(s) + 3)&3 - len(s)
- return BN.b64decode(s + '='*pad, '+$')
+ try:
+ return BN.b64decode(s + '='*pad, '+$')
+ except TypeError:
+ raise AuthenticationFailed, 'BADNONCE'
def auth_tag(sec, stamp, user):
"""Compute a tag using secret SEC on `STAMP.USER'."""