Opened 3 years ago

Closed 3 years ago

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

Download all attachments as: .zip

Change History (8)

comment:1 Changed 3 years ago by bhuztez

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

comment:2 Changed 3 years ago by aaugustin

  • Component changed from Uncategorized to Core (Other)
  • Triage Stage changed from Unreviewed to Accepted

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 3 years ago by bhuztez

comment:3 Changed 3 years ago by aaugustin

  • Has patch set
  • Needs tests set

Changed 3 years ago by claudep

Same patch with test

comment:4 Changed 3 years ago by claudep

  • Needs tests unset

comment:5 Changed 3 years ago by PaulM

  • Resolution set to fixed
  • Status changed from new to closed

In [17418]:

(The changeset message doesn't reference this ticket)

comment:6 Changed 3 years ago by aaugustin

In [17513]:

Added documentation for r17418. Refs #17481.

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