Add pure Go DES crypt(3) password hashing support - #15
Open
fpesce wants to merge 1 commit into
Open
Conversation
- Add des_crypt package implementing POSIX traditional 13-character DES crypt(3) - Add crypt.DES constant and fallback auto-detection in NewFromHash / IsHashSupported - Implement strict 13-character hash validator with 2-bit zero-mask check - Zero Cgo dependencies, constant-time verification, and full unit test suite - BSD-2-Clause license (engine authored by Francois Pesce)
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.
Pull Request: Add Pure Go Traditional DES crypt(3) Support
Target Repository:
github.com/GehirnInc/cryptBase Branch:
masterFeature Branch:
feature/des-cryptAuthor: Francois Pesce
License: BSD-2-Clause
Title
Add pure Go traditional DES crypt(3) password hashing supportDescription
Summary
This pull request adds support for the classic 13-character UNIX DES-based
crypt(3)password hashing algorithm in pure Go.While
GehirnInc/cryptsupports MD5, SHA-256, SHA-512, and Apache APR1 password hashing schemes, it currently lacks support for the foundational 13-character DES algorithm. Following the closure and rejection of crypt(3) password hashing proposals ingolang.org/x/crypto(Proposal #14274), third-party libraries in the Go ecosystem serve as the primary solution for UNIX credential verification. This PR completes the functional scope ofGehirnInc/cryptto provide full POSIXcrypt(3)compatibility without Cgo dependencies.What Changed
des_cryptSubpackage:crypt(3)Feistel cipher based on my (not AI, this was done 7 years ago for a personal project) implementation (github.com/fpesce/go-des-crypt), contributed under BSD 2-Clause.crypt.Crypterinterface (Generate,Verify,Cost,SetSalt).Validate(hash string) bool) ensuring standard 64-symbol alphabet (./0-9A-Za-z) and checking the 2-bit zero-mask on the 13th character for 64-bit DES block compliance.crypto/randwhen salt is empty.< 8bytes.crypto/subtle.ConstantTimeCompare.cryptPackage Updates:crypt.DESconstant toCryptenum.RegisterFallback(c Crypt, f func() Crypter, validator func(string) bool)to support prefixless algorithm registration.NewFromHash()andIsHashSupported()to check modular prefixes first, falling back to registered non-prefix validators (allowing transparent auto-detection of 13-character DES hashes)."foob"/"ar"->"arlEKn0OzVJn.","test"/"PQ"->"PQl1.p7BcJRuM").crypt_test.goverifying auto-detection and API availability.README.rstwith algorithm list, examples, and security advisories.Security Consideration
Traditional DES
crypt(3)provides only 56 bits of key strength and is cryptographically obsolete for modern credential storage. This implementation is provided strictly for legacy password verification, retro-computing, and data migration.Verification & Testing
go test -v -race ./...All packages pass with 100% test coverage for new components and zero data races.