Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pbkdf2 always throws an error with GHC 7.4.2 #11

Open
snakamura opened this issue Apr 23, 2014 · 2 comments
Open

pbkdf2 always throws an error with GHC 7.4.2 #11

snakamura opened this issue Apr 23, 2014 · 2 comments

Comments

@snakamura
Copy link

Just tried this snippet on GHCi 7.4.2, then it threw an error.

>>> :set -XOverloadedStrings
>>> import Crypto.PasswordStore
>>> salt <- genSaltIO
>>> pbkdf2 "test" salt 14
"*** Exception: Derived key too long.

It works fine with GHCi 7.6.3. Any ideas?

@adinapoli
Copy link
Contributor

Hi there,

this is merely the 1:1 translation from the rfc spec:

https://github.com/PeterScott/pwstore/blob/master/pwstore-fast/Crypto/PasswordStore.hs#L171

cfr this passage from the rfc:

  1. If dkLen > (2^32 - 1) * hLen, output "derived key too long" and
    stop.

https://tools.ietf.org/html/rfc2898

@chreekat
Copy link

I recommend closing this issue. Unless I'm crazy, both dkLen and hLen are set equal to each other at 32 before being passed to the helper function, so this check is degenerate anyway. (There's no recursion into the helper function, either.)

https://github.com/PeterScott/pwstore/blob/master/pwstore-fast/Crypto/PasswordStore.hs#L168

    let hLen = 32
        dkLen = hLen in go hLen dkLen
  where
    go hLen dkLen | dkLen > (2^32 - 1) * hLen = error "Derived key too long."
                  | otherwise =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants