Repository navigation
Test Crypt3 - #345
Merged
Merged
Test Crypt3#345
Conversation
Crypt3 came in from the crypt3 gem in 3.2.0 without tests. Check it against that gem's known crypt(3) and Apache hashes, and cover check, generate_salt, the random salt and the other algorithms. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Crypt3came into Facets from the crypt3 gem in 3.2.0, and nothing tested it:lib/standard/facets/crypt3.rbwas the only file that mentioned it. The crypt3 repository is now retired in favour of this module, so Facets holds the only maintained copy.test/standard/test_crypt3.rbadds 13 tests:cryptgives the same md5 hashes as crypt(3) for six known password and salt pairs, and the same hash as Apache for the$apr1$magic. The vectors are the crypt3 gem's own.cryptis deterministic for a given salt across md5, sha1, sha256, sha384 and sha512, differs by algorithm, keeps the magic and salt at the front, makes a random 8 character salt when given none, and raisesArgumentErrorfor an unknown algorithm.checkaccepts the right password, rejects a wrong one, reads the magic from the hash, and depends on the algorithm.generate_saltgives the size asked for, from the crypt(3) base 64 characters.rmd160 is left out:
digest/rmd160isn't available on every Ruby in the CI matrix.No change to the library.
Testing
rubytest -Ilib/core -Ilib/standard test/standard/test_crypt3.rb: 13 tests, all passing on Ruby 3.4.9.rake test:standardpasses.openssl passwd -1.🤖 Generated with Claude Code