puppetlabs/puppetlabs-stdlib — pull request #41 by glarizza (2012-03-03 04:30:06+00:00)
Title: Create a str2pbkdf2_hash function

In future versions of OS X, PBKDF2 passwords are utilized. This password
hashing scheme requires a plaintext password, a salt, and a value for
the number of iterations to programmatically execute the hashing scheme
before it will generate a password hash. The resultant password hash
evaluates to be a 256 character hex value, and is tied to the value of
the salt (a string) and the iterations (an integer). If the salt or the
iterations value is changed, the resultant password hash will be
different.

Because these values are so intimately related, Puppet will need to
support two additional properties for the User resource type ('salt' and
'iterations'). This function will assist Puppet users who manage
User resources in versions of OS X that support PBKDF2 passwords.

Passing a value for the plaintext password, the salt, and the
iterations, the function will return a 256-character password hash that
can be directly inserted into a User resource's password property.

Spec tests are also included to ensure that correct values are passed
and calculated.