annotate Lib/hmac.py @ 78069:a8aa77458e12 3.2

Add c_size_t and c_ssize_t to the ctypes summary table.
author Antoine Pitrou <solipsis@pitrou.net>
date Thu, 12 Jul 2012 20:31:50 +0200
parents 8e57b5d8f58f
children ddcc8ee680d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 """HMAC (Keyed-Hashing for Message Authentication) Python module.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 Implements the HMAC algorithm as described by RFC 2104.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
4 """
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
43776
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
6 import warnings as _warnings
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
7
42179
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
8 trans_5C = bytes((x ^ 0x5C) for x in range(256))
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
9 trans_36 = bytes((x ^ 0x36) for x in range(256))
19953
0f9df563b65d Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 19862
diff changeset
10
20847
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
11 # The size of the digests returned by HMAC depends on the underlying
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
12 # hashing module used. Use digest_size from the instance of HMAC instead.
20847
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
13 digest_size = None
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
14
31704
490eb64bc5c9 Speed HMAC.copy() by installing a secret backdoor argument to
Tim Peters <tim.peters@gmail.com>
parents: 23645
diff changeset
15
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
16 class HMAC:
43776
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
17 """RFC 2104 HMAC class. Also complies with RFC 4231.
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
20847
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
19 This supports the API for Cryptographic Hash Functions (PEP 247).
19953
0f9df563b65d Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 19862
diff changeset
20 """
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
21 blocksize = 64 # 512-bit HMAC; can be changed in subclasses.
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
22
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 def __init__(self, key, msg = None, digestmod = None):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 """Create a new HMAC object.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
25
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 key: key for the keyed hash object.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 msg: Initial input for the hash, if provided.
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
28 digestmod: A module supporting PEP 247. *OR*
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
29 A hashlib constructor returning a new hash object.
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
30 Defaults to hashlib.md5.
42179
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
31
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
32 Note: key and msg must be bytes objects.
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 """
31704
490eb64bc5c9 Speed HMAC.copy() by installing a secret backdoor argument to
Tim Peters <tim.peters@gmail.com>
parents: 23645
diff changeset
34
45627
24f4230baebe Fixed failing unit tests due to str/bytes mismatch.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 43776
diff changeset
35 if not isinstance(key, bytes):
24f4230baebe Fixed failing unit tests due to str/bytes mismatch.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 43776
diff changeset
36 raise TypeError("expected bytes, but got %r" % type(key).__name__)
42179
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
37
23594
c3a67ce58245 Replace '== None' with 'is None'
Raymond Hettinger <python@rcn.com>
parents: 20967
diff changeset
38 if digestmod is None:
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
39 import hashlib
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
40 digestmod = hashlib.md5
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
73165
8e57b5d8f58f Closes #13258: Use callable() built-in in the standard library.
Florent Xicluna <florent.xicluna@gmail.com>
parents: 64197
diff changeset
42 if callable(digestmod):
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
43 self.digest_cons = digestmod
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
44 else:
42179
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
45 self.digest_cons = lambda d=b'': digestmod.new(d)
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
46
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
47 self.outer = self.digest_cons()
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
48 self.inner = self.digest_cons()
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
49 self.digest_size = self.inner.digest_size
20967
bb8716095a81 Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 20847
diff changeset
50
43776
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
51 if hasattr(self.inner, 'block_size'):
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
52 blocksize = self.inner.block_size
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
53 if blocksize < 16:
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
54 _warnings.warn('block_size of %d seems too small; using our '
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
55 'default of %d.' % (blocksize, self.blocksize),
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
56 RuntimeWarning, 2)
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
57 blocksize = self.blocksize
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
58 else:
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
59 _warnings.warn('No block_size attribute on given digest object; '
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
60 'Assuming %d.' % (self.blocksize),
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
61 RuntimeWarning, 2)
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
62 blocksize = self.blocksize
b310fd2b0184 Merged revisions 58862-58885 via svnmerge from
Guido van Rossum <guido@python.org>
parents: 42902
diff changeset
63
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 if len(key) > blocksize:
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
65 key = self.digest_cons(key).digest()
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
66
42179
f4a1b76a5a63 Make hmac use bytes. Make test_hmac pass.
Guido van Rossum <guido@python.org>
parents: 41824
diff changeset
67 key = key + bytes(blocksize - len(key))
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
68 self.outer.update(key.translate(trans_5C))
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
69 self.inner.update(key.translate(trans_36))
23612
3caee2958387 Replace boolean test with is None
Raymond Hettinger <python@rcn.com>
parents: 23594
diff changeset
70 if msg is not None:
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 self.update(msg)
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
72
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 def update(self, msg):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
74 """Update this hashing object with the string msg.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
75 """
45627
24f4230baebe Fixed failing unit tests due to str/bytes mismatch.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 43776
diff changeset
76 if not isinstance(msg, bytes):
24f4230baebe Fixed failing unit tests due to str/bytes mismatch.
Alexandre Vassalotti <alexandre@peadrop.com>
parents: 43776
diff changeset
77 raise TypeError("expected bytes, but got %r" % type(msg).__name__)
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
78 self.inner.update(msg)
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
79
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 def copy(self):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
81 """Return a separate copy of this hashing object.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
82
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
83 An update to this copy won't affect the original object.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
84 """
64197
8397f2e007eb speed hack can be implemented more cleanly by directly calling __new__
Benjamin Peterson <benjamin@python.org>
parents: 64196
diff changeset
85 # Call __new__ directly to avoid the expensive __init__.
8397f2e007eb speed hack can be implemented more cleanly by directly calling __new__
Benjamin Peterson <benjamin@python.org>
parents: 64196
diff changeset
86 other = self.__class__.__new__(self.__class__)
35375
624918e1c1b2 [ sf.net patch # 1121611 ]
Gregory P. Smith <greg@mad-scientist.com>
parents: 31704
diff changeset
87 other.digest_cons = self.digest_cons
31704
490eb64bc5c9 Speed HMAC.copy() by installing a secret backdoor argument to
Tim Peters <tim.peters@gmail.com>
parents: 23645
diff changeset
88 other.digest_size = self.digest_size
20847
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
89 other.inner = self.inner.copy()
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
90 other.outer = self.outer.copy()
ec632a41ee35 [Patch #477336] Make hmac.py match PEP247, and fix the copy method() so that
Andrew M. Kuchling <amk@amk.ca>
parents: 19953
diff changeset
91 return other
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
92
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
93 def _current(self):
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
94 """Return a hash object for the current state.
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
95
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
96 To be used only internally with digest() and hexdigest().
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
97 """
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
98 h = self.outer.copy()
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
99 h.update(self.inner.digest())
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
100 return h
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
101
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
102 def digest(self):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
103 """Return the hash value of this hashing object.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
104
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
105 This returns a string containing 8-bit data. The object is
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
106 not altered in any way by this function; you can continue
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
107 updating the object after calling this function.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
108 """
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
109 h = self._current()
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
110 return h.digest()
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
111
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
112 def hexdigest(self):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
113 """Like digest(), but returns a string of hexadecimal digits instead.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
114 """
40582
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
115 h = self._current()
67287ca4e1e8 Merged revisions 53005-53303 via svnmerge from
Thomas Wouters <thomas@python.org>
parents: 35375
diff changeset
116 return h.hexdigest()
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
117
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
118 def new(key, msg = None, digestmod = None):
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
119 """Create a new hashing object and return it.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
120
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
121 key: The starting key for the hash.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
122 msg: if available, will immediately be hashed into the object's starting
19953
0f9df563b65d Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents: 19862
diff changeset
123 state.
19862
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
124
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
125 You can now feed arbitrary strings into the object using its update()
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
126 method, and can ask for the hash value at any time by calling its digest()
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
127 method.
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
128 """
36ca16dc35b9 HMAC algorithm as described by RFC 2104, by Gerhard Häring (SF patch
Guido van Rossum <guido@python.org>
parents:
diff changeset
129 return HMAC(key, msg, digestmod)