diff options
author | Kevin Turner <kevin@janrain.com> | 2006-08-31 00:14:08 +0000 |
---|---|---|
committer | Kevin Turner <kevin@janrain.com> | 2006-08-31 00:14:08 +0000 |
commit | 956192f93fbff0a7c84cf835c3e84c71a40afb01 (patch) | |
tree | b207b3fe93c470c69ccecf35c480d8cc6c699e0d /openid/association.py | |
parent | 4453b9f73f95d0055e68d4adfbd0e6b63c423b1b (diff) | |
download | openid-956192f93fbff0a7c84cf835c3e84c71a40afb01.tar.gz |
[project @ association.Association.sign: add mac definition for HMAC-SHA1-SIGNALL type.]
Diffstat (limited to 'openid/association.py')
-rw-r--r-- | openid/association.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/openid/association.py b/openid/association.py index 84372eb..4d64b4f 100644 --- a/openid/association.py +++ b/openid/association.py @@ -190,6 +190,13 @@ class Association(object): ] + _macs = { + 'HMAC-SHA1': cryptutil.hmacSha1, + 'HMAC-SHA256-SIGNALL': cryptutil.hmacSha256, + } + _macs['HMAC-SHA1-SIGNALL'] = _macs['HMAC-SHA1'] + + def fromExpiresIn(cls, expires_in, handle, secret, assoc_type): """ This is an alternate constructor used by the OpenID consumer @@ -402,13 +409,12 @@ class Association(object): @rtype: str """ kv = kvform.seqToKV(pairs) - if self.assoc_type == 'HMAC-SHA1': - mac = cryptutil.hmacSha1 - elif self.assoc_type == 'HMAC-SHA256-SIGNALL': - mac = cryptutil.hmacSha256 - else: + + try: + mac = self._macs[self.assoc_type] + except KeyError: raise ValueError( - 'Unkown association type: %r' % (self.assoc_type,)) + 'Unknown association type: %r' % (self.assoc_type,)) return mac(self.secret, kv) |