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

New str2saltedsha512 function for OS X Passwords #27

Merged

Conversation

glarizza
Copy link

@glarizza glarizza commented Jan 9, 2012

OS X 10.7 introduced salted-SHA512 password hashes as opposed to the
older LANMAN + SHA1 hashes. To assist in generating properly-formatted
password hashes, this commit adds the str2saltedsha512() function which
accepts a single string argument (the password) and returns a
salted-SHA512 password hash which can be fed as the password attribute
of a user resource in OS X 10.7.

Spec tests are also added to ensure that functionality isn't broken with
future commits.

OS X 10.7 introduced salted-SHA512 password hashes as opposed to the
older LANMAN + SHA1 hashes. To assist in generating properly-formatted
password hashes, this commit adds the str2saltedsha512() function which
accepts a single string argument (the password) and returns a
salted-SHA512 password hash which can be fed as the password attribute
of a user resource in OS X 10.7.

Spec tests are also added to ensure that functionality isn't broken with
future commits.

password = arguments[0]

unless password.is_a?(String)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's a good idea to use is_a?(String) here. We might pass in something that's a kind of String like object but isn't a String itself.

It'll probably be more dynamic if we just use the object's to_s method to convert it to a string representation, whatever the heck it is.

The spec tests should then cover our expectations about how different input objects behave.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, on second thought the explicit catching of the String is probably a better UX if the user accidentally passes in a Hash or Array.

jeffmccune pushed a commit that referenced this pull request Jan 9, 2012
New str2saltedsha512 function for OS X Passwords
@jeffmccune jeffmccune merged commit 3ef8692 into puppetlabs:master Jan 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants