Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#17481 closed Bug (fixed)

leading zeros are missing from result of pbkdf2

Reported by: bhuztez Owned by: nobody
Component: Core (Other) Version: 1.4-alpha-1
Severity: Release blocker Keywords:
Cc: bhuztez@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Here is an example.

>>> import hashlib
>>> from django.utils import crypto
>>> from M2Crypto import EVP
>>> EVP.pbkdf2(chr(186), 'salt', 1, 20)
'\x00S\xd3\xb9\x1a\x7f\x1eT\xef\xfe\xbdmhw\x1e\x8an\x0b,['
>>> crypto.pbkdf2(chr(186), 'salt', 1, 20, digest=hashlib.sha1)
'S\xd3\xb9\x1a\x7f\x1eT\xef\xfe\xbdmhw\x1e\x8an\x0b,['
>>> 

Attachments (2)

pbkdf2.diff (1.0 KB ) - added by bhuztez 13 years ago.
17481-2.diff (1.8 KB ) - added by Claude Paroz 13 years ago.
Same patch with test

Download all attachments as: .zip

Change History (8)

comment:1 by bhuztez, 13 years ago

Cc: bhuztez@… added

comment:2 by Aymeric Augustin, 13 years ago

Component: UncategorizedCore (Other)
Triage Stage: UnreviewedAccepted

Confirmed with this totally over-engineered snippet:

>>> import difflib
>>> import hashlib
>>> from django.utils import crypto
>>> from M2Crypto import EVP
>>> for i in range(255):
...     expected = repr(EVP.pbkdf2(chr(i), 'salt', 1, 20))
...     actual = repr(crypto.pbkdf2(chr(i), 'salt', 1, 20, digest=hashlib.sha1))
...     if expected != actual:
...         for l in difflib.unified_diff([expected], [actual], str(i), str(i)):
...             print l.rstrip("\n")
... 
--- 186
+++ 186
@@ -1 +1 @@
-'\x00S\xd3\xb9\x1a\x7f\x1eT\xef\xfe\xbdmhw\x1e\x8an\x0b,['
+'S\xd3\xb9\x1a\x7f\x1eT\xef\xfe\xbdmhw\x1e\x8an\x0b,['
--- 241
+++ 241
@@ -1 +1 @@
-'\x00\xf6(/Vb\x82\xd7\xb7OJ\xfe\x8e\xf6N\x95\x12\xc5\x9b\x9f'
+'\xf6(/Vb\x82\xd7\xb7OJ\xfe\x8e\xf6N\x95\x12\xc5\x9b\x9f'

by bhuztez, 13 years ago

Attachment: pbkdf2.diff added

comment:3 by Aymeric Augustin, 13 years ago

Has patch: set
Needs tests: set

by Claude Paroz, 13 years ago

Attachment: 17481-2.diff added

Same patch with test

comment:4 by Claude Paroz, 13 years ago

Needs tests: unset

comment:5 by Paul McMillan, 13 years ago

Resolution: fixed
Status: newclosed

In [17418]:

(The changeset message doesn't reference this ticket)

comment:6 by Aymeric Augustin, 13 years ago

In [17513]:

Added documentation for r17418. Refs #17481.

Note: See TracTickets for help on using tickets.
Back to Top