Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed a bug that caused with custom digest methods and hmac key deriv…

…ation.
  • Loading branch information...
commit d3fef96cc7c220dc862cbd6e83ac0ec4e5855641 1 parent dfa3a8c
@mitsuhiko authored
Showing with 18 additions and 2 deletions.
  1. +5 −0 CHANGES
  2. +1 −1  itsdangerous.py
  3. +1 −1  setup.py
  4. +11 −0 tests.py
View
5 CHANGES
@@ -1,6 +1,11 @@
It's Dangerous Changelog
------------------------
+Version 0.17
+~~~~~~~~~~~~
+
+- Fixed a name error when overriding the digest method.
+
Version 0.16
~~~~~~~~~~~~
View
2  itsdangerous.py
@@ -210,7 +210,7 @@ def derive_key(self):
return self.digest_method(self.salt + 'signer' +
self.secret_key).digest()
elif self.key_derivation == 'hmac':
- mac = hmac.new(self.secret_key, digestmod=self.digest_mod)
+ mac = hmac.new(self.secret_key, digestmod=self.digest_method)
mac.update(self.salt)
return mac.digest()
else:
View
2  setup.py
@@ -8,7 +8,7 @@
name='itsdangerous',
author='Armin Ronacher',
author_email='armin.ronacher@active-4.com',
- version='0.16',
+ version='0.17',
url='http://github.com/mitsuhiko/itsdangerous',
py_modules=['itsdangerous'],
description='Various helpers to pass trusted data to untrusted environments.',
View
11 tests.py
@@ -1,5 +1,6 @@
import time
import pickle
+import hashlib
import unittest
from datetime import datetime
import itsdangerous as idmod
@@ -85,6 +86,16 @@ def test_load_unsafe_with_unicode_strings(self):
except idmod.BadSignature, e:
self.assertEqual(s.load_payload(unicode(e.payload)), u'hello')
+ def test_signer_kwargs(self):
+ secret_key = 'predictable-key'
+ value = 'hello'
+ s = self.make_serializer(secret_key, signer_kwargs=dict(
+ digest_method=hashlib.md5,
+ key_derivation='hmac'
+ ))
+ ts = unicode(s.dumps(value))
+ self.assertEqual(s.loads(ts), u'hello')
+
class TimedSerializerTestCase(SerializerTestCase):
serializer_class = idmod.TimedSerializer
Please sign in to comment.
Something went wrong with that request. Please try again.