Skip to content

Implement channel binding support for SCRAM-PLUS - #12

Closed
xdg wants to merge 2 commits into
masterfrom
channel-binding
Closed

Implement channel binding support for SCRAM-PLUS#12
xdg wants to merge 2 commits into
masterfrom
channel-binding

Conversation

@xdg

@xdg xdg commented Nov 14, 2025

Copy link
Copy Markdown
Collaborator

This commit adds comprehensive channel binding support to enable SCRAM-PLUS authentication variants.

Core Changes:

  • Added ChannelBindingType enumeration (tls-unique, tls-server-end-point, tls-exporter)
  • Added ChannelBinding struct to hold binding type and data
  • Implemented WithChannelBinding() methods for Client and Server
  • Updated parsers to handle gs2-cbind-flag "p=" format
  • Client conversations now include channel binding data in authentication
  • Server conversations validate channel binding during authentication

RFCs Implemented:

  • RFC 5802: SCRAM protocol with channel binding
  • RFC 5929: Channel Bindings for TLS (tls-unique, tls-server-end-point)
  • RFC 9266: Channel Bindings for TLS 1.3 (tls-exporter)

@xdg
xdg requested a review from Copilot November 14, 2025 13:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements comprehensive channel binding support for SCRAM-PLUS authentication, enabling cryptographic binding of SCRAM authentication to underlying TLS connections as specified in RFC 5802, RFC 5929, and RFC 9266.

Key changes:

  • Added ChannelBinding type system with support for three binding types: tls-unique, tls-server-end-point, and tls-exporter
  • Extended client and server with WithChannelBinding() configuration methods
  • Updated authentication protocol parsers and conversation logic to handle channel binding negotiation and validation

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
common.go Introduces ChannelBindingType enum and ChannelBinding struct with helper methods
client.go Adds WithChannelBinding() method and passes binding to conversations
client_conv.go Updates client conversation to include channel binding data in authentication messages
server.go Adds WithChannelBinding() method and passes binding to conversations
server_conv.go Implements server-side channel binding validation logic
parse.go Extends parser to handle p=<cb-type> format in GS2 header
doc.go Updates package documentation with channel binding usage examples
README.md Adds channel binding overview and client example
CHANGELOG.md Documents new channel binding feature
channel_binding_test.go Comprehensive test suite for channel binding functionality

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread server_conv.go
var expectedCBind []byte
if sc.clientCBFlag == "p" {
// Client used channel binding - expect gs2 header + channel binding data
expectedCBind = append([]byte(sc.gs2Header), sc.channelBinding.Data...)

Copilot AI Nov 14, 2025

Copy link

Choose a reason for hiding this comment

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

The append operation on line 145 can cause aliasing issues. If []byte(sc.gs2Header) has unused capacity, appending may modify the underlying array that could be shared. Use an explicit slice creation or copy to ensure independence.

Suggested change
expectedCBind = append([]byte(sc.gs2Header), sc.channelBinding.Data...)
b := make([]byte, len(sc.gs2Header))
copy(b, sc.gs2Header)
expectedCBind = append(b, sc.channelBinding.Data...)

Copilot uses AI. Check for mistakes.
Add typed constants for all server error values defined in RFC-5802 and
RFC-7677, replacing inline string literals with named constants. This
improves code maintainability, prevents typos, and provides better
documentation for all valid server error responses.

Changes:
- Add complete set of server error constants to common.go
- Replace all "e=..." literals in server_conv.go with typed constants
- All tests pass with no behavioral changes
@xdg
xdg force-pushed the channel-binding branch 8 times, most recently from 35f9742 to 619086e Compare November 17, 2025 03:04
This commit adds comprehensive channel binding support to enable SCRAM-PLUS
authentication variants, addressing issue #10.

Core Changes:
- Added ChannelBindingType enumeration (tls-unique, tls-server-end-point, tls-exporter)
- Added ChannelBinding struct to hold binding type and data
- Implemented WithChannelBinding() methods for Client and Server
- Updated parsers to handle gs2-cbind-flag "p=<cb-type>" format
- Client conversations now include channel binding data in authentication
- Server conversations validate channel binding during authentication

RFCs Implemented:
- RFC 5802: SCRAM protocol with channel binding
- RFC 5929: Channel Bindings for TLS (tls-unique, tls-server-end-point)
- RFC 9266: Channel Bindings for TLS 1.3 (tls-exporter)
@xdg-go xdg-go deleted a comment from Copilot AI Nov 17, 2025
@xdg

xdg commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator Author

Taking this down while I rework the API.

@xdg xdg closed this Nov 17, 2025
@Neustradamus

Copy link
Copy Markdown

@xdg: Excellent, good job, please inform when it will be perfect for you!

@Neustradamus

Neustradamus commented Nov 17, 2025

Copy link
Copy Markdown

@xdg: PS: When it will be done, please update the "About" description, and add topic with all SCRAM supported versions:

In more scram topic:
rfc5802
rfc7677
rfc5929
rfc9266
scram-sha-1
scram-sha-256
scram-sha-512
scram-sha-1-plus
scram-sha-256-plus
scram-sha-512-plus
tls-unique
tls-server-end-point
tls-exporter

Note: I-Drafts:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants