Skip to content

Commit

Permalink
Merge branch 'jake/channel-bindings' into dev
Browse files Browse the repository at this point in the history
Interface support for channel bindings
  • Loading branch information
jake-scott committed Sep 8, 2024
2 parents df1d358 + bf1d7d3 commit 550f57d
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 8 deletions.
Binary file removed examples/go/gss-client/gss-client
Binary file not shown.
Binary file modified examples/testvectors/rack.kt
Binary file not shown.
Binary file modified examples/testvectors/robot.cc
Binary file not shown.
6 changes: 3 additions & 3 deletions v3/channelbinding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package gssapi

import "net"

type gssAddressFamily int
type GssAddressFamily int

const (
GssAddrFamilyUNSPEC gssAddressFamily = 0
GssAddrFamilyLOCAL gssAddressFamily = 1 << iota
GssAddrFamilyUNSPEC GssAddressFamily = 0
GssAddrFamilyLOCAL GssAddressFamily = 1 << iota
GssAddrFamilyINET
GssAddrFamilyIMPLINK
GssAddrFamilyPUP
Expand Down
16 changes: 16 additions & 0 deletions v3/ctxflags.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ const (
ContextFlagConf // confidentiality available
ContextFlagInteg // integrity available
ContextFlagAnon // do not transfer initiator identity to acceptor

// extensions
ContextFlagChannelBound = 0x800 // require channel bindings

// Microsoft extensions - see RFC 4757 § 7.1
ContextFlagDceStyle = 0x1000 // add extra AP-REP from client to server after receiving server's AP-REP
ContextFlagIdentify = 0x2000 // server should identify the client but not impersonate it
ContextFlagExtendedError = 0x4000 // return Windows status code in Kerberos error messages
)

// FlagList returns a slice of individual flags derived from the
Expand Down Expand Up @@ -48,6 +56,14 @@ func FlagName(f ContextFlag) string {
return "Integrity"
case ContextFlagAnon:
return "Anonymous"
case ContextFlagChannelBound:
return "Channel Bindings"
case ContextFlagDceStyle:
return "DCE style"
case ContextFlagIdentify:
return "Identify only"
case ContextFlagExtendedError:
return "Extended errors"
}

return "Unknown"
Expand Down
17 changes: 12 additions & 5 deletions v3/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ func NewProvider(name string) Provider {
type QoP uint

type InitSecContextOptions struct {
Credential Credential
Mech GssMech
Flags ContextFlag
Lifetime time.Duration
Credential Credential
Mech GssMech
Flags ContextFlag
Lifetime time.Duration
ChannelBinding *ChannelBinding
}

type InitSecContextOption func(o *InitSecContextOptions)
Expand Down Expand Up @@ -75,6 +76,12 @@ func WithInitiatorLifetime(life time.Duration) InitSecContextOption {
}
}

func WithChannelBinding(cb *ChannelBinding) InitSecContextOption {
return func(o *InitSecContextOptions) {
o.ChannelBinding = cb
}
}

// Provider is the interface that defines the top level GSSAPI functions that
// create name, credential and security contexts
type Provider interface {
Expand Down Expand Up @@ -125,7 +132,7 @@ type Provider interface {
//
// A partially established context may allow the creation of protected messages.
// Check the [SecContextInfo.ProtectionReady] flag by calling [SecContext.Inquire()].
AcceptSecContext(cred Credential, inputToken []byte) (SecContext, []byte, error) // RFC 2743 § 2.2.2
AcceptSecContext(cred Credential, inputToken []byte, cb *ChannelBinding) (SecContext, []byte, error) // RFC 2743 § 2.2.2

// ImportSecContext corresponds to the GSS_Import_sec_context function from RFC 2743 § 2.2.9
// Parameters:
Expand Down

0 comments on commit 550f57d

Please sign in to comment.