I also recently wanted to use the PBKDF2 hashing function to generate cryptographic keys from a user password (that is actually what is was for, though a password crypt function is also a good use).

I found the Filter::Crypto module which does use this function but only internally in embedded C code (also for password to key hashing). It does not make it available within perl itself.

Also recently I found another perl module, Crypt::PBKDF2 which actually implements this hashing function completely in perl. However it has 8 or or very non-standard perm module dependencies, which in turn has many many more non-standard perl module dependencies. In other words just to get this module working you have to go though dependency hell! It also provides extra library functions that would have been been better implements using normal simple perl functions rather than given as separate module functions.

I resolved the problem for the time being by compiling a trival C program to allow me to call the OpenSSL library implementation of this hashing function PKCS5_PBKDF2_HMAC_SHA1(). I can then open2() that simple program and pipe the users password in (with the appropriate salt, and iterative count) to get the required hashed result.

The trivial C program was created from a file found on the OpenSSL cryptography mailing lists, and its source is available from my web site

pbkdf2.c

The perl script I use it in is also available at

encrypt.pl

Its a file encrypt/decrypt program similar to but more secure than the openssl enc file encryption.

I will be looking at using the hashing function provided above, though it says two functions when only one is provided (missing the hmac_sha1() function), and comparing it to the OpenSSL implementation to so how compatible it really is. I'll try to let you know. Any suggestions or comments about the provided code also welcome. Anthony Thyssen <A.Thyssen@griffith.edu.au>


In reply to Re: PBKDF2 crypt by anthony_thyssen
in thread PBKDF2 crypt by dsheroh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.