package smb2

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)
}

// NTLMInitiator implements session-setup through NTLMv2.
// It doesn't support NTLMv1. You can use Hash instead of Password.
type NTLMInitiator struct {
	User        string
	Password    string
	Hash        []byte
	Domain      string
	Workstation string
	TargetSPN   string

	ntlm   *ntlm.Client
	seqNum uint32
}

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

func ( *NTLMInitiator) () ([]byte, error) {
	.ntlm = &ntlm.Client{
		User:        .User,
		Password:    .Password,
		Hash:        .Hash,
		Domain:      .Domain,
		Workstation: .Workstation,
		TargetSPN:   .TargetSPN,
	}
	,  := .ntlm.Negotiate()
	if  != nil {
		return nil, 
	}
	return , nil
}

func ( *NTLMInitiator) ( []byte) ([]byte, error) {
	,  := .ntlm.Authenticate()
	if  != nil {
		return nil, 
	}
	return , nil
}

func ( *NTLMInitiator) ( []byte) []byte {
	,  := .ntlm.Session().Sum(, .seqNum)
	return 
}

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

func ( *NTLMInitiator) () *ntlm.InfoMap {
	return .ntlm.Session().InfoMap()
}