Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initiator members public #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions initiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
)

type Initiator interface {
oid() asn1.ObjectIdentifier
initSecContext() ([]byte, error) // GSS_Init_sec_context
acceptSecContext(sc []byte) ([]byte, error) // GSS_Accept_sec_context
sum(bs []byte) []byte // GSS_getMIC
sessionKey() []byte // QueryContextAttributes(ctx, SECPKG_ATTR_SESSION_KEY, &out)
OID() asn1.ObjectIdentifier
InitSecContext() ([]byte, error) // GSS_Init_sec_context
AcceptSecContext(sc []byte) ([]byte, error) // GSS_Accept_sec_context
Sum(bs []byte) []byte // GSS_getMIC
SessionKey() []byte // QueryContextAttributes(ctx, SECPKG_ATTR_SESSION_KEY, &out)
}

// NTLMInitiator implements session-setup through NTLMv2.
Expand All @@ -29,11 +29,11 @@ type NTLMInitiator struct {
seqNum uint32
}

func (i *NTLMInitiator) oid() asn1.ObjectIdentifier {
func (i *NTLMInitiator) OID() asn1.ObjectIdentifier {
return spnego.NlmpOid
}

func (i *NTLMInitiator) initSecContext() ([]byte, error) {
func (i *NTLMInitiator) InitSecContext() ([]byte, error) {
i.ntlm = &ntlm.Client{
User: i.User,
Password: i.Password,
Expand All @@ -49,20 +49,20 @@ func (i *NTLMInitiator) initSecContext() ([]byte, error) {
return nmsg, nil
}

func (i *NTLMInitiator) acceptSecContext(sc []byte) ([]byte, error) {
func (i *NTLMInitiator) AcceptSecContext(sc []byte) ([]byte, error) {
amsg, err := i.ntlm.Authenticate(sc)
if err != nil {
return nil, err
}
return amsg, nil
}

func (i *NTLMInitiator) sum(bs []byte) []byte {
func (i *NTLMInitiator) Sum(bs []byte) []byte {
mic, _ := i.ntlm.Session().Sum(bs, i.seqNum)
return mic
}

func (i *NTLMInitiator) sessionKey() []byte {
func (i *NTLMInitiator) SessionKey() []byte {
return i.ntlm.Session().SessionKey()
}

Expand Down
12 changes: 6 additions & 6 deletions spnego.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type spnegoClient struct {
func newSpnegoClient(mechs []Initiator) *spnegoClient {
mechTypes := make([]asn1.ObjectIdentifier, len(mechs))
for i, mech := range mechs {
mechTypes[i] = mech.oid()
mechTypes[i] = mech.OID()
}
return &spnegoClient{
mechs: mechs,
Expand All @@ -28,7 +28,7 @@ func (c *spnegoClient) oid() asn1.ObjectIdentifier {
}

func (c *spnegoClient) initSecContext() (negTokenInitBytes []byte, err error) {
mechToken, err := c.mechs[0].initSecContext()
mechToken, err := c.mechs[0].InitSecContext()
if err != nil {
return nil, err
}
Expand All @@ -52,7 +52,7 @@ func (c *spnegoClient) acceptSecContext(negTokenRespBytes []byte) (negTokenRespB
}
}

responseToken, err := c.selectedMech.acceptSecContext(negTokenResp.ResponseToken)
responseToken, err := c.selectedMech.AcceptSecContext(negTokenResp.ResponseToken)
if err != nil {
return nil, err
}
Expand All @@ -62,7 +62,7 @@ func (c *spnegoClient) acceptSecContext(negTokenRespBytes []byte) (negTokenRespB
return nil, err
}

mechListMIC := c.selectedMech.sum(ms)
mechListMIC := c.selectedMech.Sum(ms)

negTokenRespBytes1, err = spnego.EncodeNegTokenResp(1, nil, responseToken, mechListMIC)
if err != nil {
Expand All @@ -73,9 +73,9 @@ func (c *spnegoClient) acceptSecContext(negTokenRespBytes []byte) (negTokenRespB
}

func (c *spnegoClient) sum(bs []byte) []byte {
return c.selectedMech.sum(bs)
return c.selectedMech.Sum(bs)
}

func (c *spnegoClient) sessionKey() []byte {
return c.selectedMech.sessionKey()
return c.selectedMech.SessionKey()
}