rfc2865: add CHAP password verification helpers#143
Open
jamiesun wants to merge 1 commit into
Open
Conversation
rfc2865 exposed accessors for the CHAP-Password and CHAP-Challenge attributes but no way to verify a CHAP (RFC 1994 / RFC 2865) response against a known password. MS-CHAP and MS-CHAPv2 helpers already exist in rfc2759, but plain CHAP did not, so servers handling equipment that uses standard CHAP (for example some Huawei switches) had to implement the MD5 check themselves. Add CHAPMatch, which checks a raw CHAP-Password value against a password and challenge in constant time, and CHAPVerify, a packet-level convenience that pulls the CHAP-Password and CHAP-Challenge attributes (falling back to the packet Authenticator as the challenge, per RFC 2865, Section 2.2). Closes layeh#96 Co-authored-by: Copilot <[email protected]>
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.
Summary
rfc2865exposedCHAPPasswordandCHAPChallengeaccessors but offered no way to actually verify a CHAP login (plain CHAP, not MS-CHAP). This adds the missing helper, mirroring the hand-written helper style already used byrfc2759(MS-CHAPv2).CHAP verification per RFC 2865 §2.2:
CHAP-Passwordvalue isCHAP-Identifier || MD5(CHAP-Identifier || password || challenge), where the challenge is theCHAP-Challengeattribute if present, otherwise the Request Authenticator.API
Both use
crypto/subtle.ConstantTimeCompare.CHAPVerifyfalls back to the packet Authenticator when noCHAP-Challengeattribute is present.Changes
rfc2865/chap.go(new):CHAPMatch,CHAPVerify.rfc2865/chap_test.go(new): match, with-challenge, authenticator-as-challenge, and missing-attribute cases.The generated
rfc2865/generated.gois untouched;go generateonly rewrites that file.Closes #96