Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0cc7444e
Commit
0cc7444e
authored
Aug 21, 2010
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
speed hack can be implemented more cleanly by directly calling __new__
parent
bf6f31b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
8 deletions
+2
-8
Lib/hmac.py
Lib/hmac.py
+2
-8
No files found.
Lib/hmac.py
View file @
0cc7444e
...
...
@@ -12,10 +12,6 @@ trans_36 = bytes((x ^ 0x36) for x in range(256))
# hashing module used. Use digest_size from the instance of HMAC instead.
digest_size
=
None
# A unique object passed by HMAC.copy() to the HMAC constructor, in order
# that the latter return very quickly. HMAC("") in contrast is quite
# expensive.
_secret_backdoor_key
=
object
()
class
HMAC
:
"""RFC 2104 HMAC class. Also complies with RFC 4231.
...
...
@@ -36,9 +32,6 @@ class HMAC:
Note: key and msg must be bytes objects.
"""
if
key
is
_secret_backdoor_key
:
# cheap
return
if
not
isinstance
(
key
,
bytes
):
raise
TypeError
(
"expected bytes, but got %r"
%
type
(
key
).
__name__
)
...
...
@@ -89,7 +82,8 @@ class HMAC:
An update to this copy won't affect the original object.
"""
other
=
self
.
__class__
(
_secret_backdoor_key
)
# Call __new__ directly to avoid the expensive __init__.
other
=
self
.
__class__
.
__new__
(
self
.
__class__
)
other
.
digest_cons
=
self
.
digest_cons
other
.
digest_size
=
self
.
digest_size
other
.
inner
=
self
.
inner
.
copy
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment