Skip to content

pbkdf2 seems to generate a wrong hash #12

@snakamura

Description

@snakamura

I tested pbkdf2 function from pwstore-fast and pbkdf packages, and found that these two libraries generated different results.

>>> Crypto.PBKDF.ByteString.sha256PBKDF2 "password" "salt" 1000 32
"c,(\DC2\228mF\EOT\DLE+\167a\142\157m}/\129(\246&kJ\ETX&M*\EOT`\183\220\179"

>>> Crypto.PasswordStore.pbkdf2 "password" (Crypto.PasswordStore.importSalt $ Data.ByteString.Base64.encode "salt") 1000
"\191>\158?\217=\248\233SG\207\231\138\139\&8\255\SUB\185g\SO]\244\&0\159%\255z\229\216\239\133U"

As a reference, I also generated a hash with pbkdf2-ruby and it generated the same result as pbkdf library.

>>> PBKDF2.new(:password=>'password', :salt=>'salt', :iterations=>1000, :hash_function => OpenSSL::Digest::SHA256, :key_length => 32).bin_string
=> "c,(\x12\xE4mF\x04\x10+\xA7a\x8E\x9Dm}/\x81(\xF6&kJ\x03&M*\x04`\xB7\xDC\xB3"

Did I miss something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions