Opened 5 years ago

Closed 5 years ago

Last modified 5 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 5 years ago.
17481-2.diff (1.8 KB) - added by Claude Paroz 5 years ago.
Same patch with test

Download all attachments as: .zip

Change History (8)

comment:1 Changed 5 years ago by bhuztez

Cc: bhuztez@… added
Needs documentation: unset
Needs tests: unset
Patch needs improvement: unset

comment:2 Changed 5 years ago by Aymeric Augustin

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'

Changed 5 years ago by bhuztez

Attachment: pbkdf2.diff added

comment:3 Changed 5 years ago by Aymeric Augustin

Has patch: set
Needs tests: set

Changed 5 years ago by Claude Paroz

Attachment: 17481-2.diff added

Same patch with test

comment:4 Changed 5 years ago by Claude Paroz

Needs tests: unset

comment:5 Changed 5 years ago by Paul McMillan

Resolution: fixed
Status: newclosed

In [17418]:

(The changeset message doesn't reference this ticket)

comment:6 Changed 5 years ago by Aymeric Augustin

In [17513]:

Added documentation for r17418. Refs #17481.

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