Kaynağa Gözat

golint tidy

Jonathan Turner 8 yıl önce
ebeveyn
işleme
fe691558f6

+ 6 - 6
client/client.go

@@ -126,20 +126,20 @@ func (cl *Client) WithPassword(password string) *Client {
 // Key returns a key for the client. Preferably from a keytab and then generated from the password.
 // The KRBError would have been returned from the KDC and must be of type KDC_ERR_PREAUTH_REQUIRED.
 // If a KRBError is not available pass nil and a key will be returned from the credentials keytab.
-func (c *Client) Key(etype etype.EType, krberr messages.KRBError) (types.EncryptionKey, error) {
-	if c.Credentials.HasKeytab() && etype != nil {
-		return c.Credentials.Keytab.GetEncryptionKey(c.Credentials.CName.NameString, c.Credentials.Realm, 0, etype.GetETypeID())
-	} else if c.Credentials.HasPassword() {
+func (cl *Client) Key(etype etype.EType, krberr messages.KRBError) (types.EncryptionKey, error) {
+	if cl.Credentials.HasKeytab() && etype != nil {
+		return cl.Credentials.Keytab.GetEncryptionKey(cl.Credentials.CName.NameString, cl.Credentials.Realm, 0, etype.GetETypeID())
+	} else if cl.Credentials.HasPassword() {
 		if krberr.ErrorCode == errorcode.KDC_ERR_PREAUTH_REQUIRED {
 			var pas types.PADataSequence
 			err := pas.Unmarshal(krberr.EData)
 			if err != nil {
 				return types.EncryptionKey{}, fmt.Errorf("Could not get PAData from KRBError to generate key from password: %v", err)
 			}
-			key, _, err := crypto.GetKeyFromPassword(c.Credentials.Password, krberr.CName, krberr.CRealm, etype.GetETypeID(), pas)
+			key, _, err := crypto.GetKeyFromPassword(cl.Credentials.Password, krberr.CName, krberr.CRealm, etype.GetETypeID(), pas)
 			return key, err
 		}
-		key, _, err := crypto.GetKeyFromPassword(c.Credentials.Password, c.Credentials.CName, c.Credentials.Realm, etype.GetETypeID(), types.PADataSequence{})
+		key, _, err := crypto.GetKeyFromPassword(cl.Credentials.Password, cl.Credentials.CName, cl.Credentials.Realm, etype.GetETypeID(), types.PADataSequence{})
 		return key, err
 	}
 	return types.EncryptionKey{}, errors.New("Credential has neither keytab or password to generate key.")

+ 8 - 8
config/krb5conf.go

@@ -310,10 +310,10 @@ type Realm struct {
 // Parse the lines of a [realms] entry into the Realm struct.
 func (r *Realm) parseLines(name string, lines []string) error {
 	r.Realm = name
-	var admin_server_final bool
-	var kdc_final bool
-	var kpasswd_server_final bool
-	var master_kdc_final bool
+	var adminServerFinal bool
+	var KDCFinal bool
+	var kpasswdServerFinal bool
+	var masterKDCFinal bool
 	for _, line := range lines {
 		if strings.TrimSpace(line) == "" {
 			continue
@@ -327,7 +327,7 @@ func (r *Realm) parseLines(name string, lines []string) error {
 		v := strings.Replace(p[1], " ", "", -1)
 		switch key {
 		case "admin_server":
-			appendUntilFinal(&r.AdminServer, v, &admin_server_final)
+			appendUntilFinal(&r.AdminServer, v, &adminServerFinal)
 		case "default_domain":
 			r.DefaultDomain = v
 		case "kdc":
@@ -339,11 +339,11 @@ func (r *Realm) parseLines(name string, lines []string) error {
 					v = strings.TrimSpace(v) + ":88"
 				}
 			}
-			appendUntilFinal(&r.KDC, v, &kdc_final)
+			appendUntilFinal(&r.KDC, v, &KDCFinal)
 		case "kpasswd_server":
-			appendUntilFinal(&r.KPasswdServer, v, &kpasswd_server_final)
+			appendUntilFinal(&r.KPasswdServer, v, &kpasswdServerFinal)
 		case "master_kdc":
-			appendUntilFinal(&r.MasterKDC, v, &master_kdc_final)
+			appendUntilFinal(&r.MasterKDC, v, &masterKDCFinal)
 		default:
 			//Ignore the line
 			continue

+ 2 - 2
credentials/ccache.go

@@ -153,8 +153,8 @@ func parsePrincipal(b []byte, p *int, c *CCache, e *binary.ByteOrder) (princ pri
 		//In version 1 the number of components includes the realm. Minus 1 to make consistent with version 2
 		nc--
 	}
-	len_realm := readInt32(b, p, e)
-	princ.Realm = string(readBytes(b, p, int(len_realm), e))
+	lenRealm := readInt32(b, p, e)
+	princ.Realm = string(readBytes(b, p, int(lenRealm), e))
 	for i := 0; i < int(nc); i++ {
 		l := readInt32(b, p, e)
 		princ.PrincipalName.NameString = append(princ.PrincipalName.NameString, string(readBytes(b, p, int(l), e)))

+ 17 - 17
iana/adtype/constants.go

@@ -1,23 +1,23 @@
 // Package adtype provides Authenticator type assigned numbers.
 package adtype
 
+// Authenticator type IDs.
 const (
-	// Authenticator type IDs.
-	AD_IF_RELEVANT                    = 1
-	AD_INTENDED_FOR_SERVER            = 2
-	AD_INTENDED_FOR_APPLICATION_CLASS = 3
-	AD_KDC_ISSUED                     = 4
-	AD_AND_OR                         = 5
-	AD_MANDATORY_TICKET_EXTENSIONS    = 6
-	AD_IN_TICKET_EXTENSIONS           = 7
-	AD_MANDATORY_FOR_KDC              = 8
-	OSF_DCE                           = 64
-	SESAME                            = 65
-	AD_OSF_DCE_PKI_CERTID             = 66
-	AD_Authentication_Strength        = 70
-	AD_FX_Fast_Armor                  = 71
-	AD_FX_Fast_Used                   = 72
-	AD_WIN2K_PAC                      = 128
-	AD_ETYPE_NEGOTIATION              = 129
+	ADIfRelevant                  = 1
+	ADIntendedForServer           = 2
+	ADIntendedForApplicationClass = 3
+	ADKDCIssued                   = 4
+	ADAndOr                       = 5
+	ADMandatoryTicketExtensions   = 6
+	ADInTicketExtensions          = 7
+	ADMandatoryForKDC             = 8
+	OSFDCE                        = 64
+	SESAME                        = 65
+	ADOSFDCEPKICertID             = 66
+	ADAuthenticationStrength      = 70
+	ADFXFastArmor                 = 71
+	ADFXFastUsed                  = 72
+	ADWin2KPAC                    = 128
+	ADEtypeNegotiation            = 129
 	//Reserved values                   9-63
 )

+ 2 - 0
iana/errorcode/constants.go

@@ -3,6 +3,7 @@ package errorcode
 
 import "fmt"
 
+// Kerberos error codes.
 const (
 	KDC_ERR_NONE                          = 0  //No error
 	KDC_ERR_NAME_EXP                      = 1  //Client's entry in database has expired
@@ -74,6 +75,7 @@ const (
 	KDC_ERR_KDC_NAME_MISMATCH             = 76 //Reserved for PKINIT
 )
 
+// Lookup an error code description.
 func Lookup(i int) string {
 	if s, ok := errorcodeLookup[i]; ok {
 		return fmt.Sprintf("(%d) %s", i, s)

+ 1 - 0
iana/flags/constants.go

@@ -1,6 +1,7 @@
 // Package flags provides Kerberos 5 flag assigned numbers.
 package flags
 
+// Flag values for KRB5 messages and tickets.
 const (
 	Reserved               = 0
 	Forwardable            = 1

+ 1 - 1
iana/msgtype/constants.go

@@ -1,8 +1,8 @@
 // Package msgtype provides Kerberos 5 message type assigned numbers.
 package msgtype
 
+// KRB message type IDs.
 const (
-	// KRB message type IDs.
 	KRB_AS_REQ     = 10 //Request for initial authentication
 	KRB_AS_REP     = 11 //Response to KRB_AS_REQ request
 	KRB_TGS_REQ    = 12 //Request for authentication based on TGT

+ 2 - 2
krberror/error.go

@@ -6,9 +6,9 @@ import (
 	"strings"
 )
 
+// Error type descriptions.
 const (
-	separator = " < "
-	// Error type descriptions.
+	separator       = " < "
 	EncodingError   = "Encoding_Error"
 	NetworkingError = "Networking_Error"
 	DecryptingError = "Decrypting_Error"

+ 2 - 2
messages/Ticket.go

@@ -209,13 +209,13 @@ func (t *Ticket) DecryptEncPart(keytab keytab.Keytab, sa string) error {
 func (t *Ticket) GetPACType(keytab keytab.Keytab, sa string) (bool, pac.PACType, error) {
 	var isPAC bool
 	for _, ad := range t.DecryptedEncPart.AuthorizationData {
-		if ad.ADType == adtype.AD_IF_RELEVANT {
+		if ad.ADType == adtype.ADIfRelevant {
 			var ad2 types.AuthorizationData
 			err := ad2.Unmarshal(ad.ADData)
 			if err != nil {
 				continue
 			}
-			if ad2[0].ADType == adtype.AD_WIN2K_PAC {
+			if ad2[0].ADType == adtype.ADWin2KPAC {
 				isPAC = true
 				var pac pac.PACType
 				err = pac.Unmarshal(ad2[0].ADData)

+ 7 - 7
mstypes/claims_set_metadata.go

@@ -26,12 +26,12 @@ const (
 // Read_ClaimsSetMetadata reads a ClaimsSetMetadata from the bytes slice.
 func ReadClaimsSetMetadata(b *[]byte, p *int, e *binary.ByteOrder) ClaimsSetMetadata {
 	var c ClaimsSetMetadata
-	c.ULClaimsSetSize = ndr.Read_uint32(b, p, e)
-	c.ClaimsSet = ndr.Read_bytes(b, p, int(c.ULClaimsSetSize), e)
-	c.USCompressionFormat = ndr.Read_uint32(b, p, e)
-	c.ULUncompressedClaimsSetSize = ndr.Read_uint32(b, p, e)
-	c.USReservedType = ndr.Read_uint16(b, p, e)
-	c.ULReservedFieldSize = ndr.Read_uint32(b, p, e)
-	c.ReservedField = ndr.Read_bytes(b, p, int(c.ULReservedFieldSize), e)
+	c.ULClaimsSetSize = ndr.ReadUint32(b, p, e)
+	c.ClaimsSet = ndr.ReadBytes(b, p, int(c.ULClaimsSetSize), e)
+	c.USCompressionFormat = ndr.ReadUint32(b, p, e)
+	c.ULUncompressedClaimsSetSize = ndr.ReadUint32(b, p, e)
+	c.USReservedType = ndr.ReadUint16(b, p, e)
+	c.ULReservedFieldSize = ndr.ReadUint32(b, p, e)
+	c.ReservedField = ndr.ReadBytes(b, p, int(c.ULReservedFieldSize), e)
 	return c
 }

+ 3 - 3
mstypes/filetime.go

@@ -54,9 +54,9 @@ func GetFileTime(t time.Time) FileTime {
 }
 
 // Read_FileTime reads a FileTime from the bytes slice.
-func Read_FileTime(b *[]byte, p *int, e *binary.ByteOrder) FileTime {
-	l := ndr.Read_uint32(b, p, e)
-	h := ndr.Read_uint32(b, p, e)
+func ReadFileTime(b *[]byte, p *int, e *binary.ByteOrder) FileTime {
+	l := ndr.ReadUint32(b, p, e)
+	h := ndr.ReadUint32(b, p, e)
 	return FileTime{
 		LowDateTime:  l,
 		HighDateTime: h,

+ 4 - 4
mstypes/group_membership.go

@@ -15,8 +15,8 @@ type GroupMembership struct {
 
 // Read_GroupMembership reads a GroupMembership from the bytes slice.
 func ReadGroupMembership(b *[]byte, p *int, e *binary.ByteOrder) GroupMembership {
-	r := ndr.Read_uint32(b, p, e)
-	a := ndr.Read_uint32(b, p, e)
+	r := ndr.ReadUint32(b, p, e)
+	a := ndr.ReadUint32(b, p, e)
 	return GroupMembership{
 		RelativeID: r,
 		Attributes: a,
@@ -35,11 +35,11 @@ type DomainGroupMembership struct {
 
 // Read_DomainGroupMembership reads a DomainGroupMembership from the bytes slice.
 func Read_DomainGroupMembership(b *[]byte, p *int, e *binary.ByteOrder) (DomainGroupMembership, error) {
-	d, err := Read_RPC_SID(b, p, e)
+	d, err := ReadRPCSID(b, p, e)
 	if err != nil {
 		return DomainGroupMembership{}, err
 	}
-	c := ndr.Read_uint32(b, p, e)
+	c := ndr.ReadUint32(b, p, e)
 	g := make([]GroupMembership, c, c)
 	for i := range g {
 		g[i] = ReadGroupMembership(b, p, e)

+ 2 - 2
mstypes/kerb_sid_and_attributes.go

@@ -22,11 +22,11 @@ type KerbSidAndAttributes struct {
 
 // ReadKerbSidAndAttributes reads a KerbSidAndAttribute from the bytes slice.
 func ReadKerbSidAndAttributes(b *[]byte, p *int, e *binary.ByteOrder) (KerbSidAndAttributes, error) {
-	s, err := Read_RPC_SID(b, p, e)
+	s, err := ReadRPCSID(b, p, e)
 	if err != nil {
 		return KerbSidAndAttributes{}, err
 	}
-	a := ndr.Read_uint32(b, p, e)
+	a := ndr.ReadUint32(b, p, e)
 	return KerbSidAndAttributes{
 		SID:        s,
 		Attributes: a,

+ 12 - 12
mstypes/rpc_unicode_string.go

@@ -5,31 +5,31 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 )
 
-// RPC_UnicodeString implements https://msdn.microsoft.com/en-us/library/cc230365.aspx
-type RPC_UnicodeString struct {
+// RPCUnicodeString implements https://msdn.microsoft.com/en-us/library/cc230365.aspx
+type RPCUnicodeString struct {
 	Length        uint16 // The length, in bytes, of the string pointed to by the Buffer member, not including the terminating null character if any. The length MUST be a multiple of 2. The length SHOULD equal the entire size of the Buffer, in which case there is no terminating null character. Any method that accesses this structure MUST use the Length specified instead of relying on the presence or absence of a null character.
 	MaximumLength uint16 // The maximum size, in bytes, of the string pointed to by Buffer. The size MUST be a multiple of 2. If not, the size MUST be decremented by 1 prior to use. This value MUST not be less than Length.
 	BufferPrt     uint32 // A pointer to a string buffer. If MaximumLength is greater than zero, the buffer MUST contain a non-null value.
 	Value         string
 }
 
-// Read_RPC_UnicodeString reads a RPC_UnicodeString from the bytes slice.
-func Read_RPC_UnicodeString(b *[]byte, p *int, e *binary.ByteOrder) (RPC_UnicodeString, error) {
-	l := ndr.Read_uint16(b, p, e)
-	ml := ndr.Read_uint16(b, p, e)
+// ReadRPCUnicodeString reads a RPCUnicodeString from the bytes slice.
+func ReadRPCUnicodeString(b *[]byte, p *int, e *binary.ByteOrder) (RPCUnicodeString, error) {
+	l := ndr.ReadUint16(b, p, e)
+	ml := ndr.ReadUint16(b, p, e)
 	if ml < l || l%2 != 0 || ml%2 != 0 {
-		return RPC_UnicodeString{}, ndr.Malformed{EText: "Invalid data for RPC_UNICODE_STRING"}
+		return RPCUnicodeString{}, ndr.Malformed{EText: "Invalid data for RPC_UNICODE_STRING"}
 	}
-	ptr := ndr.Read_uint32(b, p, e)
-	return RPC_UnicodeString{
+	ptr := ndr.ReadUint32(b, p, e)
+	return RPCUnicodeString{
 		Length:        l,
 		MaximumLength: ml,
 		BufferPrt:     ptr,
 	}, nil
 }
 
-// UnmarshalString populates a golang string into the RPC_UnicodeString struct.
-func (s *RPC_UnicodeString) UnmarshalString(b *[]byte, p *int, e *binary.ByteOrder) (err error) {
-	s.Value, err = ndr.Read_ConformantVaryingString(b, p, e)
+// UnmarshalString populates a golang string into the RPCUnicodeString struct.
+func (s *RPCUnicodeString) UnmarshalString(b *[]byte, p *int, e *binary.ByteOrder) (err error) {
+	s.Value, err = ndr.ReadConformantVaryingString(b, p, e)
 	return
 }

+ 10 - 10
mstypes/sid.go

@@ -7,7 +7,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 )
 
-// RPC_SID implements https://msdn.microsoft.com/en-us/library/cc230364.aspx
+// RPCSID implements https://msdn.microsoft.com/en-us/library/cc230364.aspx
 type RPCSID struct {
 	Revision            uint8                     // An 8-bit unsigned integer that specifies the revision level of the SID. This value MUST be set to 0x01.
 	SubAuthorityCount   uint8                     // An 8-bit unsigned integer that specifies the number of elements in the SubAuthority array. The maximum number of elements allowed is 15.
@@ -15,26 +15,26 @@ type RPCSID struct {
 	SubAuthority        []uint32                  // A variable length array of unsigned 32-bit integers that uniquely identifies a principal relative to the IdentifierAuthority. Its length is determined by SubAuthorityCount.
 }
 
-// RPC_SIDIdentifierAuthority implements https://msdn.microsoft.com/en-us/library/cc230372.aspx
+// RPCSIDIdentifierAuthority implements https://msdn.microsoft.com/en-us/library/cc230372.aspx
 type RPCSIDIdentifierAuthority struct {
 	Value []byte // 6 bytes
 }
 
-// Read_RPC_SID reads a RPC_SID from the bytes slice.
-func Read_RPC_SID(b *[]byte, p *int, e *binary.ByteOrder) (RPCSID, error) {
-	size := int(ndr.Read_uint32(b, p, e)) // This is part of the NDR encoding rather than the data type.
-	r := ndr.Read_uint8(b, p)
+// ReadRPCSID reads a RPC_SID from the bytes slice.
+func ReadRPCSID(b *[]byte, p *int, e *binary.ByteOrder) (RPCSID, error) {
+	size := int(ndr.ReadUint32(b, p, e)) // This is part of the NDR encoding rather than the data type.
+	r := ndr.ReadUint8(b, p)
 	if r != uint8(1) {
 		return RPCSID{}, ndr.Malformed{EText: fmt.Sprintf("SID revision value read as %d when it must be 1", r)}
 	}
-	c := ndr.Read_uint8(b, p)
+	c := ndr.ReadUint8(b, p)
 	a := ReadRPCSIDIdentifierAuthority(b, p, e)
 	s := make([]uint32, c, c)
 	if size != len(s) {
 		return RPCSID{}, ndr.Malformed{EText: fmt.Sprintf("Number of elements (%d) within SID in the byte stream does not equal the SubAuthorityCount (%d)", size, c)}
 	}
 	for i := 0; i < len(s); i++ {
-		s[i] = ndr.Read_uint32(b, p, e)
+		s[i] = ndr.ReadUint32(b, p, e)
 	}
 	return RPCSID{
 		Revision:            r,
@@ -44,10 +44,10 @@ func Read_RPC_SID(b *[]byte, p *int, e *binary.ByteOrder) (RPCSID, error) {
 	}, nil
 }
 
-// Read_RPC_SIDIdentifierAuthority reads a RPC_SIDIdentifierAuthority from the bytes slice.
+// ReadRPCSIDIdentifierAuthority reads a RPC_SIDIdentifierAuthority from the bytes slice.
 func ReadRPCSIDIdentifierAuthority(b *[]byte, p *int, e *binary.ByteOrder) RPCSIDIdentifierAuthority {
 	return RPCSIDIdentifierAuthority{
-		Value: ndr.Read_bytes(b, p, 6, e),
+		Value: ndr.ReadBytes(b, p, 6, e),
 	}
 }
 

+ 2 - 2
mstypes/user_session_key.go

@@ -18,10 +18,10 @@ type UserSessionKey struct {
 // ReadUserSessionKey reads a UserSessionKey from the bytes slice.
 func ReadUserSessionKey(b *[]byte, p *int, e *binary.ByteOrder) UserSessionKey {
 	cb1 := CypherBlock{
-		Data: ndr.Read_bytes(b, p, 8, e),
+		Data: ndr.ReadBytes(b, p, 8, e),
 	}
 	cb2 := CypherBlock{
-		Data: ndr.Read_bytes(b, p, 8, e),
+		Data: ndr.ReadBytes(b, p, 8, e),
 	}
 	return UserSessionKey{
 		Data: []CypherBlock{cb1, cb2},

+ 47 - 47
ndr/ndr.go

@@ -27,17 +27,17 @@ Private Header - https://msdn.microsoft.com/en-us/library/cc243919.aspx
 */
 
 const (
-	PROTOCOL_VERSION     = 1
-	COMMON_HEADER_BYTES  = 8
-	PRIVATE_HEADER_BYTES = 8
-	BIG_ENDIAN           = 0
-	LITTLE_ENDIAN        = 1
-	ASCII                = 0
-	EBCDIC               = 1
-	IEEE                 = 0
-	VAX                  = 1
-	CRAY                 = 2
-	IBM                  = 3
+	protocolVersion    = 1
+	commonHeaderBytes  = 8
+	privateHeaderBytes = 8
+	bigEndian          = 0
+	littleEndian       = 1
+	ascii              = 0
+	ebcdic             = 1
+	ieee               = 0
+	vax                = 1
+	cray               = 2
+	ibm                = 3
 )
 
 // CommonHeader implements the NDR common header: https://msdn.microsoft.com/en-us/library/cc243889.aspx
@@ -72,11 +72,11 @@ func ReadHeaders(b *[]byte) (CommonHeader, PrivateHeader, int, error) {
 // GetCommonHeader processes the bytes to return the NDR Common header.
 func GetCommonHeader(b *[]byte) (CommonHeader, int, error) {
 	//The first 8 bytes comprise the Common RPC Header for type marshalling.
-	if len(*b) < COMMON_HEADER_BYTES {
+	if len(*b) < commonHeaderBytes {
 		return CommonHeader{}, 0, Malformed{EText: "Not enough bytes."}
 	}
-	if (*b)[0] != PROTOCOL_VERSION {
-		return CommonHeader{}, 0, Malformed{EText: fmt.Sprintf("Stream does not indicate a RPC Type serialization of version %v", PROTOCOL_VERSION)}
+	if (*b)[0] != protocolVersion {
+		return CommonHeader{}, 0, Malformed{EText: fmt.Sprintf("Stream does not indicate a RPC Type serialization of version %v", protocolVersion)}
 	}
 	endian := int((*b)[1] >> 4 & 0xF)
 	if endian != 0 && endian != 1 {
@@ -88,14 +88,14 @@ func GetCommonHeader(b *[]byte) (CommonHeader, int, error) {
 	}
 	var bo binary.ByteOrder
 	switch endian {
-	case LITTLE_ENDIAN:
+	case littleEndian:
 		bo = binary.LittleEndian
-	case BIG_ENDIAN:
+	case bigEndian:
 		bo = binary.BigEndian
 	}
 	l := bo.Uint16((*b)[2:4])
-	if l != COMMON_HEADER_BYTES {
-		return CommonHeader{}, 4, Malformed{EText: fmt.Sprintf("Common header does not indicate a valid length: %v instead of %v", uint8((*b)[3]), COMMON_HEADER_BYTES)}
+	if l != commonHeaderBytes {
+		return CommonHeader{}, 4, Malformed{EText: fmt.Sprintf("Common header does not indicate a valid length: %v instead of %v", uint8((*b)[3]), commonHeaderBytes)}
 	}
 
 	return CommonHeader{
@@ -111,7 +111,7 @@ func GetCommonHeader(b *[]byte) (CommonHeader, int, error) {
 // GetPrivateHeader processes the bytes to return the NDR Private header.
 func GetPrivateHeader(b *[]byte, p *int, bo *binary.ByteOrder) (PrivateHeader, error) {
 	//The next 8 bytes comprise the RPC type marshalling private header for constructed types.
-	if len(*b) < (PRIVATE_HEADER_BYTES) {
+	if len(*b) < (privateHeaderBytes) {
 		return PrivateHeader{}, Malformed{EText: "Not enough bytes."}
 	}
 	var l uint32
@@ -127,8 +127,8 @@ func GetPrivateHeader(b *[]byte, p *int, bo *binary.ByteOrder) (PrivateHeader, e
 	}, nil
 }
 
-// Read_uint8 reads bytes representing a thirty two bit integer.
-func Read_uint8(b *[]byte, p *int) (i uint8) {
+// ReadUint8 reads bytes representing a thirty two bit integer.
+func ReadUint8(b *[]byte, p *int) (i uint8) {
 	if len((*b)[*p:]) < 1 {
 		return
 	}
@@ -138,8 +138,8 @@ func Read_uint8(b *[]byte, p *int) (i uint8) {
 	return
 }
 
-// Read_uint16 reads bytes representing a thirty two bit integer.
-func Read_uint16(b *[]byte, p *int, e *binary.ByteOrder) (i uint16) {
+// ReadUint16 reads bytes representing a thirty two bit integer.
+func ReadUint16(b *[]byte, p *int, e *binary.ByteOrder) (i uint16) {
 	if len((*b)[*p:]) < 2 {
 		return
 	}
@@ -149,8 +149,8 @@ func Read_uint16(b *[]byte, p *int, e *binary.ByteOrder) (i uint16) {
 	return
 }
 
-// Read_uint32 reads bytes representing a thirty two bit integer.
-func Read_uint32(b *[]byte, p *int, e *binary.ByteOrder) (i uint32) {
+// ReadUint32 reads bytes representing a thirty two bit integer.
+func ReadUint32(b *[]byte, p *int, e *binary.ByteOrder) (i uint32) {
 	if len((*b)[*p:]) < 4 {
 		return
 	}
@@ -160,8 +160,8 @@ func Read_uint32(b *[]byte, p *int, e *binary.ByteOrder) (i uint32) {
 	return
 }
 
-// Read_uint64 reads bytes representing a thirty two bit integer.
-func Read_uint64(b *[]byte, p *int, e *binary.ByteOrder) (i uint64) {
+// ReadUint64 reads bytes representing a thirty two bit integer.
+func ReadUint64(b *[]byte, p *int, e *binary.ByteOrder) (i uint64) {
 	if len((*b)[*p:]) < 8 {
 		return
 	}
@@ -171,8 +171,8 @@ func Read_uint64(b *[]byte, p *int, e *binary.ByteOrder) (i uint64) {
 	return
 }
 
-// Read_bytes reads the number of bytes specified.
-func Read_bytes(b *[]byte, p *int, s int, e *binary.ByteOrder) (r []byte) {
+// ReadBytes reads the number of bytes specified.
+func ReadBytes(b *[]byte, p *int, s int, e *binary.ByteOrder) (r []byte) {
 	if len((*b)[*p:]) < s {
 		return
 	}
@@ -183,39 +183,39 @@ func Read_bytes(b *[]byte, p *int, s int, e *binary.ByteOrder) (r []byte) {
 	return r
 }
 
-// Read_bool reads bytes representing a boolean.
-func Read_bool(b *[]byte, p *int) bool {
+// ReadBool reads bytes representing a boolean.
+func ReadBool(b *[]byte, p *int) bool {
 	if len((*b)[*p:]) < 1 {
 		return false
 	}
-	if Read_uint8(b, p) != 0 {
+	if ReadUint8(b, p) != 0 {
 		return true
 	}
 	return false
 }
 
-// Read_IEEEfloat32 reads bytes representing a IEEE formatted 32 bit float.
-func Read_IEEEfloat32(b *[]byte, p *int, e *binary.ByteOrder) float32 {
+// ReadIEEEfloat32 reads bytes representing a IEEE formatted 32 bit float.
+func ReadIEEEfloat32(b *[]byte, p *int, e *binary.ByteOrder) float32 {
 	ensureAlignment(p, 4)
-	return math.Float32frombits(Read_uint32(b, p, e))
+	return math.Float32frombits(ReadUint32(b, p, e))
 }
 
-// Read_IEEEfloat64 reads bytes representing a IEEE formatted 64 bit float.
-func Read_IEEEfloat64(b *[]byte, p *int, e *binary.ByteOrder) float64 {
+// ReadIEEEfloat64 reads bytes representing a IEEE formatted 64 bit float.
+func ReadIEEEfloat64(b *[]byte, p *int, e *binary.ByteOrder) float64 {
 	ensureAlignment(p, 8)
-	return math.Float64frombits(Read_uint64(b, p, e))
+	return math.Float64frombits(ReadUint64(b, p, e))
 }
 
-// Read_ConformantVaryingString reads a Conformant and Varying String from the bytes slice.
+// ReadConformantVaryingString reads a Conformant and Varying String from the bytes slice.
 // A conformant and varying string is a string in which the maximum number of elements is not known beforehand and therefore is included in the representation of the string.
 // NDR represents a conformant and varying string as an ordered sequence of representations of the string elements, preceded by three unsigned long integers.
 // The first integer gives the maximum number of elements in the string, including the terminator.
 // The second integer gives the offset from the first index of the string to the first index of the actual subset being passed.
 // The third integer gives the actual number of elements being passed, including the terminator.
-func Read_ConformantVaryingString(b *[]byte, p *int, e *binary.ByteOrder) (string, error) {
-	m := Read_uint32(b, p, e) // Max element count
-	o := Read_uint32(b, p, e) // Offset
-	a := Read_uint32(b, p, e) // Actual count
+func ReadConformantVaryingString(b *[]byte, p *int, e *binary.ByteOrder) (string, error) {
+	m := ReadUint32(b, p, e) // Max element count
+	o := ReadUint32(b, p, e) // Offset
+	a := ReadUint32(b, p, e) // Actual count
 	if a > (m-o) || o > m {
 		return "", Malformed{EText: fmt.Sprintf("Not enough bytes. Max: %d, Offset: %d, Actual: %d", m, o, a)}
 	}
@@ -226,15 +226,15 @@ func Read_ConformantVaryingString(b *[]byte, p *int, e *binary.ByteOrder) (strin
 	}
 	s := make([]rune, a, a)
 	for i := 0; i < len(s); i++ {
-		s[i] = rune(Read_uint16(b, p, e))
+		s[i] = rune(ReadUint16(b, p, e))
 	}
 	ensureAlignment(p, 4)
 	return string(s), nil
 }
 
-// Read_UniDimensionalConformantArrayHeader reads a UniDimensionalConformantArrayHeader from the bytes slice.
-func Read_UniDimensionalConformantArrayHeader(b *[]byte, p *int, e *binary.ByteOrder) int {
-	return int(Read_uint32(b, p, e))
+// ReadUniDimensionalConformantArrayHeader reads a UniDimensionalConformantArrayHeader from the bytes slice.
+func ReadUniDimensionalConformantArrayHeader(b *[]byte, p *int, e *binary.ByteOrder) int {
+	return int(ReadUint32(b, p, e))
 }
 
 func ensureAlignment(p *int, byteSize int) {

+ 3 - 3
pac/client_info.go

@@ -19,15 +19,15 @@ func (k *ClientInfo) Unmarshal(b []byte) error {
 	var p int
 	var e binary.ByteOrder = binary.LittleEndian
 
-	k.ClientID = mstypes.Read_FileTime(&b, &p, &e)
-	k.NameLength = ndr.Read_uint16(&b, &p, &e)
+	k.ClientID = mstypes.ReadFileTime(&b, &p, &e)
+	k.NameLength = ndr.ReadUint16(&b, &p, &e)
 	if len(b[p:]) < int(k.NameLength) {
 		return ndr.Malformed{EText: "PAC ClientInfo length truncated"}
 	}
 	//Length divided by 2 as each run is 16bits = 2bytes
 	s := make([]rune, k.NameLength/2, k.NameLength/2)
 	for i := 0; i < len(s); i++ {
-		s[i] = rune(ndr.Read_uint16(&b, &p, &e))
+		s[i] = rune(ndr.ReadUint16(&b, &p, &e))
 	}
 	k.Name = string(s)
 

+ 33 - 33
pac/credentials_info.go

@@ -14,10 +14,10 @@ import (
 
 // CredentialsInfo implements https://msdn.microsoft.com/en-us/library/cc237953.aspx
 type CredentialsInfo struct {
-	Version                      uint32 // A 32-bit unsigned integer in little-endian format that defines the version. MUST be 0x00000000.
-	EType                        uint32
-	PAC_CredentialData_Encrypted []byte // Key usage number for encryption: KERB_NON_KERB_SALT (16)
-	PAC_CredentialData           CredentialData
+	Version                    uint32 // A 32-bit unsigned integer in little-endian format that defines the version. MUST be 0x00000000.
+	EType                      uint32
+	PACCredentialDataEncrypted []byte // Key usage number for encryption: KERB_NON_KERB_SALT (16)
+	PACCredentialData          CredentialData
 }
 
 // Unmarshal bytes into the CredentialsInfo struct
@@ -31,9 +31,9 @@ func (c *CredentialsInfo) Unmarshal(b []byte, k types.EncryptionKey) error {
 	//The next 4 bytes are an RPC unique pointer referent. We just skip these
 	p += 4
 
-	c.Version = ndr.Read_uint32(&b, &p, e)
-	c.EType = ndr.Read_uint32(&b, &p, e)
-	c.PAC_CredentialData_Encrypted = ndr.Read_bytes(&b, &p, len(b)-p, e)
+	c.Version = ndr.ReadUint32(&b, &p, e)
+	c.EType = ndr.ReadUint32(&b, &p, e)
+	c.PACCredentialDataEncrypted = ndr.ReadBytes(&b, &p, len(b)-p, e)
 
 	err = c.DecryptEncPart(k, e)
 	if err != nil {
@@ -47,12 +47,12 @@ func (c *CredentialsInfo) DecryptEncPart(k types.EncryptionKey, e *binary.ByteOr
 	if k.KeyType != int(c.EType) {
 		return fmt.Errorf("Key provided is not the correct type. Type needed: %d, type provided: %d", c.EType, k.KeyType)
 	}
-	pt, err := crypto.DecryptMessage(c.PAC_CredentialData_Encrypted, k, keyusage.KERB_NON_KERB_SALT)
+	pt, err := crypto.DecryptMessage(c.PACCredentialDataEncrypted, k, keyusage.KERB_NON_KERB_SALT)
 	if err != nil {
 		return err
 	}
 	var p int
-	c.PAC_CredentialData = Read_PAC_CredentialData(&pt, &p, e)
+	c.PACCredentialData = ReadPACCredentialData(&pt, &p, e)
 	return nil
 }
 
@@ -63,15 +63,15 @@ func (c *CredentialsInfo) DecryptEncPart(k types.EncryptionKey, e *binary.ByteOr
 // Fields (for capturing this information) and cryptographic parameters are specified in PAC_CREDENTIAL_INFO (section 2.6.1).
 type CredentialData struct {
 	CredentialCount uint32
-	Credentials     []SECPKG_SupplementalCred // Size is the value of CredentialCount
+	Credentials     []SECPKGSupplementalCred // Size is the value of CredentialCount
 }
 
-// Read_PAC_CredentialData reads a CredentialData from the byte slice.
-func Read_PAC_CredentialData(b *[]byte, p *int, e *binary.ByteOrder) CredentialData {
-	c := ndr.Read_uint32(b, p, e)
-	cr := make([]SECPKG_SupplementalCred, c, c)
+// ReadPACCredentialData reads a CredentialData from the byte slice.
+func ReadPACCredentialData(b *[]byte, p *int, e *binary.ByteOrder) CredentialData {
+	c := ndr.ReadUint32(b, p, e)
+	cr := make([]SECPKGSupplementalCred, c, c)
 	for i := range cr {
-		cr[i] = Read_SECPKG_SupplementalCred(b, p, e)
+		cr[i] = ReadSECPKGSupplementalCred(b, p, e)
 	}
 	return CredentialData{
 		CredentialCount: c,
@@ -79,43 +79,43 @@ func Read_PAC_CredentialData(b *[]byte, p *int, e *binary.ByteOrder) CredentialD
 	}
 }
 
-// SECPKG_SupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237956.aspx
-type SECPKG_SupplementalCred struct {
-	PackageName    mstypes.RPC_UnicodeString
+// SECPKGSupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237956.aspx
+type SECPKGSupplementalCred struct {
+	PackageName    mstypes.RPCUnicodeString
 	CredentialSize uint32
 	Credentials    []uint8 // Is a ptr. Size is the value of CredentialSize
 }
 
-// Read_SECPKG_SupplementalCred reads a SECPKG_SupplementalCred from the byte slice.
-func Read_SECPKG_SupplementalCred(b *[]byte, p *int, e *binary.ByteOrder) SECPKG_SupplementalCred {
-	n, _ := mstypes.Read_RPC_UnicodeString(b, p, e)
-	cs := ndr.Read_uint32(b, p, e)
+// ReadSECPKGSupplementalCred reads a SECPKGSupplementalCred from the byte slice.
+func ReadSECPKGSupplementalCred(b *[]byte, p *int, e *binary.ByteOrder) SECPKGSupplementalCred {
+	n, _ := mstypes.ReadRPCUnicodeString(b, p, e)
+	cs := ndr.ReadUint32(b, p, e)
 	c := make([]uint8, cs, cs)
 	for i := range c {
-		c[i] = ndr.Read_uint8(b, p)
+		c[i] = ndr.ReadUint8(b, p)
 	}
-	return SECPKG_SupplementalCred{
+	return SECPKGSupplementalCred{
 		PackageName:    n,
 		CredentialSize: cs,
 		Credentials:    c,
 	}
 }
 
-// NTLM_SupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237949.aspx
-type NTLM_SupplementalCred struct {
+// NTLMSupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237949.aspx
+type NTLMSupplementalCred struct {
 	Version    uint32 // A 32-bit unsigned integer that defines the credential version.This field MUST be 0x00000000.
 	Flags      uint32
 	LMPassword []byte // A 16-element array of unsigned 8-bit integers that define the LM OWF. The LmPassword member MUST be ignored if the L flag is not set in the Flags member.
 	NTPassword []byte // A 16-element array of unsigned 8-bit integers that define the NT OWF. The LtPassword member MUST be ignored if the N flag is not set in the Flags member.
 }
 
-// Read_NTLM_SupplementalCred reads a NTLM_SupplementalCred from the byte slice.
-func Read_NTLM_SupplementalCred(b *[]byte, p *int, e *binary.ByteOrder) NTLM_SupplementalCred {
-	v := ndr.Read_uint32(b, p, e)
-	f := ndr.Read_uint32(b, p, e)
-	l := ndr.Read_bytes(b, p, 16, e)
-	n := ndr.Read_bytes(b, p, 16, e)
-	return NTLM_SupplementalCred{
+// ReadNTLMSupplementalCred reads a NTLMSupplementalCred from the byte slice.
+func ReadNTLMSupplementalCred(b *[]byte, p *int, e *binary.ByteOrder) NTLMSupplementalCred {
+	v := ndr.ReadUint32(b, p, e)
+	f := ndr.ReadUint32(b, p, e)
+	l := ndr.ReadBytes(b, p, 16, e)
+	n := ndr.ReadBytes(b, p, 16, e)
+	return NTLMSupplementalCred{
 		Version:    v,
 		Flags:      f,
 		LMPassword: l,

+ 10 - 10
pac/device_info.go

@@ -30,13 +30,13 @@ func (k *DeviceInfo) Unmarshal(b []byte) error {
 	//The next 4 bytes are an RPC unique pointer referent. We just skip these
 	p += 4
 
-	k.UserID = ndr.Read_uint32(&b, &p, e)
-	k.PrimaryGroupID = ndr.Read_uint32(&b, &p, e)
-	k.AccountDomainID, err = mstypes.Read_RPC_SID(&b, &p, e)
+	k.UserID = ndr.ReadUint32(&b, &p, e)
+	k.PrimaryGroupID = ndr.ReadUint32(&b, &p, e)
+	k.AccountDomainID, err = mstypes.ReadRPCSID(&b, &p, e)
 	if err != nil {
 		return err
 	}
-	k.AccountGroupCount = ndr.Read_uint32(&b, &p, e)
+	k.AccountGroupCount = ndr.ReadUint32(&b, &p, e)
 	if k.AccountGroupCount > 0 {
 		ag := make([]mstypes.GroupMembership, k.AccountGroupCount, k.AccountGroupCount)
 		for i := range ag {
@@ -45,9 +45,9 @@ func (k *DeviceInfo) Unmarshal(b []byte) error {
 		k.AccountGroupIDs = ag
 	}
 
-	k.SIDCount = ndr.Read_uint32(&b, &p, e)
+	k.SIDCount = ndr.ReadUint32(&b, &p, e)
 	if k.SIDCount > 0 {
-		ac := ndr.Read_UniDimensionalConformantArrayHeader(&b, &p, e)
+		ac := ndr.ReadUniDimensionalConformantArrayHeader(&b, &p, e)
 		if ac != int(k.SIDCount) {
 			return fmt.Errorf("Error with size of ExtraSIDs list. Expected: %d, Actual: %d", k.SIDCount, ac)
 		}
@@ -55,12 +55,12 @@ func (k *DeviceInfo) Unmarshal(b []byte) error {
 		attr := make([]uint32, k.SIDCount, k.SIDCount)
 		ptr := make([]uint32, k.SIDCount, k.SIDCount)
 		for i := range attr {
-			ptr[i] = ndr.Read_uint32(&b, &p, e)
-			attr[i] = ndr.Read_uint32(&b, &p, e)
+			ptr[i] = ndr.ReadUint32(&b, &p, e)
+			attr[i] = ndr.ReadUint32(&b, &p, e)
 		}
 		for i := range es {
 			if ptr[i] != 0 {
-				s, err := mstypes.Read_RPC_SID(&b, &p, e)
+				s, err := mstypes.ReadRPCSID(&b, &p, e)
 				es[i] = mstypes.KerbSidAndAttributes{SID: s, Attributes: attr[i]}
 				if err != nil {
 					return ndr.Malformed{EText: fmt.Sprintf("Could not read ExtraSIDs: %v", err)}
@@ -70,7 +70,7 @@ func (k *DeviceInfo) Unmarshal(b []byte) error {
 		k.ExtraSIDs = es
 	}
 
-	k.DomainGroupCount = ndr.Read_uint32(&b, &p, e)
+	k.DomainGroupCount = ndr.ReadUint32(&b, &p, e)
 	if k.DomainGroupCount > 0 {
 		dg := make([]mstypes.DomainGroupMembership, k.DomainGroupCount, k.DomainGroupCount)
 		for i := range dg {

+ 51 - 51
pac/kerb_validation_info.go

@@ -36,12 +36,12 @@ type KerbValidationInfo struct {
 	PasswordLastSet         mstypes.FileTime
 	PasswordCanChange       mstypes.FileTime
 	PasswordMustChange      mstypes.FileTime
-	EffectiveName           mstypes.RPC_UnicodeString
-	FullName                mstypes.RPC_UnicodeString
-	LogonScript             mstypes.RPC_UnicodeString
-	ProfilePath             mstypes.RPC_UnicodeString
-	HomeDirectory           mstypes.RPC_UnicodeString
-	HomeDirectoryDrive      mstypes.RPC_UnicodeString
+	EffectiveName           mstypes.RPCUnicodeString
+	FullName                mstypes.RPCUnicodeString
+	LogonScript             mstypes.RPCUnicodeString
+	ProfilePath             mstypes.RPCUnicodeString
+	HomeDirectory           mstypes.RPCUnicodeString
+	HomeDirectoryDrive      mstypes.RPCUnicodeString
 	LogonCount              uint16
 	BadPasswordCount        uint16
 	UserID                  uint32
@@ -51,8 +51,8 @@ type KerbValidationInfo struct {
 	GroupIDs                []mstypes.GroupMembership
 	UserFlags               uint32
 	UserSessionKey          mstypes.UserSessionKey
-	LogonServer             mstypes.RPC_UnicodeString
-	LogonDomainName         mstypes.RPC_UnicodeString
+	LogonServer             mstypes.RPCUnicodeString
+	LogonDomainName         mstypes.RPCUnicodeString
 	pLogonDomainID          uint32
 	LogonDomainID           mstypes.RPCSID
 	Reserved1               []uint32 // Has 2 elements
@@ -83,59 +83,59 @@ func (k *KerbValidationInfo) Unmarshal(b []byte) (err error) {
 	//The next 4 bytes are an RPC unique pointer referent. We just skip these
 	p += 4
 
-	k.LogOnTime = mstypes.Read_FileTime(&b, &p, e)
-	k.LogOffTime = mstypes.Read_FileTime(&b, &p, e)
-	k.KickOffTime = mstypes.Read_FileTime(&b, &p, e)
-	k.PasswordLastSet = mstypes.Read_FileTime(&b, &p, e)
-	k.PasswordCanChange = mstypes.Read_FileTime(&b, &p, e)
-	k.PasswordMustChange = mstypes.Read_FileTime(&b, &p, e)
+	k.LogOnTime = mstypes.ReadFileTime(&b, &p, e)
+	k.LogOffTime = mstypes.ReadFileTime(&b, &p, e)
+	k.KickOffTime = mstypes.ReadFileTime(&b, &p, e)
+	k.PasswordLastSet = mstypes.ReadFileTime(&b, &p, e)
+	k.PasswordCanChange = mstypes.ReadFileTime(&b, &p, e)
+	k.PasswordMustChange = mstypes.ReadFileTime(&b, &p, e)
 
-	k.EffectiveName, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.FullName, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.LogonScript, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.ProfilePath, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.HomeDirectory, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.HomeDirectoryDrive, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
+	k.EffectiveName, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.FullName, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.LogonScript, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.ProfilePath, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.HomeDirectory, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.HomeDirectoryDrive, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
 	if err != nil {
 		return
 	}
 
-	k.LogonCount = ndr.Read_uint16(&b, &p, e)
-	k.BadPasswordCount = ndr.Read_uint16(&b, &p, e)
-	k.UserID = ndr.Read_uint32(&b, &p, e)
-	k.PrimaryGroupID = ndr.Read_uint32(&b, &p, e)
-	k.GroupCount = ndr.Read_uint32(&b, &p, e)
-	k.pGroupIDs = ndr.Read_uint32(&b, &p, e)
+	k.LogonCount = ndr.ReadUint16(&b, &p, e)
+	k.BadPasswordCount = ndr.ReadUint16(&b, &p, e)
+	k.UserID = ndr.ReadUint32(&b, &p, e)
+	k.PrimaryGroupID = ndr.ReadUint32(&b, &p, e)
+	k.GroupCount = ndr.ReadUint32(&b, &p, e)
+	k.pGroupIDs = ndr.ReadUint32(&b, &p, e)
 
-	k.UserFlags = ndr.Read_uint32(&b, &p, e)
+	k.UserFlags = ndr.ReadUint32(&b, &p, e)
 	k.UserSessionKey = mstypes.ReadUserSessionKey(&b, &p, e)
 
-	k.LogonServer, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
-	k.LogonDomainName, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
+	k.LogonServer, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
+	k.LogonDomainName, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
 	if err != nil {
 		return
 	}
 
-	k.pLogonDomainID = ndr.Read_uint32(&b, &p, e)
+	k.pLogonDomainID = ndr.ReadUint32(&b, &p, e)
 
 	k.Reserved1 = []uint32{
-		ndr.Read_uint32(&b, &p, e),
-		ndr.Read_uint32(&b, &p, e),
+		ndr.ReadUint32(&b, &p, e),
+		ndr.ReadUint32(&b, &p, e),
 	}
 
-	k.UserAccountControl = ndr.Read_uint32(&b, &p, e)
-	k.SubAuthStatus = ndr.Read_uint32(&b, &p, e)
-	k.LastSuccessfulILogon = mstypes.Read_FileTime(&b, &p, e)
-	k.LastFailedILogon = mstypes.Read_FileTime(&b, &p, e)
-	k.FailedILogonCount = ndr.Read_uint32(&b, &p, e)
-	k.Reserved3 = ndr.Read_uint32(&b, &p, e)
+	k.UserAccountControl = ndr.ReadUint32(&b, &p, e)
+	k.SubAuthStatus = ndr.ReadUint32(&b, &p, e)
+	k.LastSuccessfulILogon = mstypes.ReadFileTime(&b, &p, e)
+	k.LastFailedILogon = mstypes.ReadFileTime(&b, &p, e)
+	k.FailedILogonCount = ndr.ReadUint32(&b, &p, e)
+	k.Reserved3 = ndr.ReadUint32(&b, &p, e)
 
-	k.SIDCount = ndr.Read_uint32(&b, &p, e)
-	k.pExtraSIDs = ndr.Read_uint32(&b, &p, e)
+	k.SIDCount = ndr.ReadUint32(&b, &p, e)
+	k.pExtraSIDs = ndr.ReadUint32(&b, &p, e)
 
-	k.pResourceGroupDomainSID = ndr.Read_uint32(&b, &p, e)
-	k.ResourceGroupCount = ndr.Read_uint32(&b, &p, e)
-	k.pResourceGroupIDs = ndr.Read_uint32(&b, &p, e)
+	k.pResourceGroupDomainSID = ndr.ReadUint32(&b, &p, e)
+	k.ResourceGroupCount = ndr.ReadUint32(&b, &p, e)
+	k.pResourceGroupIDs = ndr.ReadUint32(&b, &p, e)
 
 	// Populate pointers
 	err = k.EffectiveName.UnmarshalString(&b, &p, e)
@@ -146,7 +146,7 @@ func (k *KerbValidationInfo) Unmarshal(b []byte) (err error) {
 	err = k.HomeDirectoryDrive.UnmarshalString(&b, &p, e)
 
 	if k.GroupCount > 0 {
-		ac := ndr.Read_UniDimensionalConformantArrayHeader(&b, &p, e)
+		ac := ndr.ReadUniDimensionalConformantArrayHeader(&b, &p, e)
 		if ac != int(k.GroupCount) {
 			return errors.New("Error with size of group list")
 		}
@@ -161,14 +161,14 @@ func (k *KerbValidationInfo) Unmarshal(b []byte) (err error) {
 	err = k.LogonDomainName.UnmarshalString(&b, &p, e)
 
 	if k.pLogonDomainID != 0 {
-		k.LogonDomainID, err = mstypes.Read_RPC_SID(&b, &p, e)
+		k.LogonDomainID, err = mstypes.ReadRPCSID(&b, &p, e)
 		if err != nil {
 			return fmt.Errorf("Error reading LogonDomainID: %v", err)
 		}
 	}
 
 	if k.SIDCount > 0 {
-		ac := ndr.Read_UniDimensionalConformantArrayHeader(&b, &p, e)
+		ac := ndr.ReadUniDimensionalConformantArrayHeader(&b, &p, e)
 		if ac != int(k.SIDCount) {
 			return fmt.Errorf("Error with size of ExtraSIDs list. Expected: %d, Actual: %d", k.SIDCount, ac)
 		}
@@ -176,12 +176,12 @@ func (k *KerbValidationInfo) Unmarshal(b []byte) (err error) {
 		attr := make([]uint32, k.SIDCount, k.SIDCount)
 		ptr := make([]uint32, k.SIDCount, k.SIDCount)
 		for i := range attr {
-			ptr[i] = ndr.Read_uint32(&b, &p, e)
-			attr[i] = ndr.Read_uint32(&b, &p, e)
+			ptr[i] = ndr.ReadUint32(&b, &p, e)
+			attr[i] = ndr.ReadUint32(&b, &p, e)
 		}
 		for i := range es {
 			if ptr[i] != 0 {
-				s, err := mstypes.Read_RPC_SID(&b, &p, e)
+				s, err := mstypes.ReadRPCSID(&b, &p, e)
 				es[i] = mstypes.KerbSidAndAttributes{SID: s, Attributes: attr[i]}
 				if err != nil {
 					return ndr.Malformed{EText: fmt.Sprintf("Could not read ExtraSIDs: %v", err)}
@@ -192,14 +192,14 @@ func (k *KerbValidationInfo) Unmarshal(b []byte) (err error) {
 	}
 
 	if k.pResourceGroupDomainSID != 0 {
-		k.ResourceGroupDomainSID, err = mstypes.Read_RPC_SID(&b, &p, e)
+		k.ResourceGroupDomainSID, err = mstypes.ReadRPCSID(&b, &p, e)
 		if err != nil {
 			return err
 		}
 	}
 
 	if k.ResourceGroupCount > 0 {
-		ac := ndr.Read_UniDimensionalConformantArrayHeader(&b, &p, e)
+		ac := ndr.ReadUniDimensionalConformantArrayHeader(&b, &p, e)
 		if ac != int(k.ResourceGroupCount) {
 			return fmt.Errorf("Error with size of ResourceGroup list. Expected: %d, Actual: %d", k.ResourceGroupCount, ac)
 		}

+ 4 - 4
pac/pac_info_buffer.go

@@ -25,11 +25,11 @@ type InfoBuffer struct {
 	Offset       uint64 // A 64-bit unsigned integer in little-endian format that contains the offset to the beginning of the buffer, in bytes, from the beginning of the PACTYPE structure. The data offset MUST be a multiple of eight. The following sections specify the format of each type of element.
 }
 
-// Read_PACInfoBuffer reads a InfoBuffer from the byte slice.
+// ReadPACInfoBuffer reads a InfoBuffer from the byte slice.
 func ReadPACInfoBuffer(b *[]byte, p *int, e *binary.ByteOrder) InfoBuffer {
-	u := ndr.Read_uint32(b, p, e)
-	s := ndr.Read_uint32(b, p, e)
-	o := ndr.Read_uint64(b, p, e)
+	u := ndr.ReadUint32(b, p, e)
+	s := ndr.ReadUint32(b, p, e)
+	o := ndr.ReadUint64(b, p, e)
 	return InfoBuffer{
 		ULType:       u,
 		CBBufferSize: s,

+ 2 - 2
pac/pac_type.go

@@ -37,8 +37,8 @@ func (pac *PACType) Unmarshal(b []byte) error {
 	zb := make([]byte, len(b), len(b))
 	copy(zb, b)
 	pac.ZeroSigData = zb
-	pac.CBuffers = ndr.Read_uint32(&b, &p, &e)
-	pac.Version = ndr.Read_uint32(&b, &p, &e)
+	pac.CBuffers = ndr.ReadUint32(&b, &p, &e)
+	pac.Version = ndr.ReadUint32(&b, &p, &e)
 	buf := make([]InfoBuffer, pac.CBuffers, pac.CBuffers)
 	for i := range buf {
 		buf[i] = ReadPACInfoBuffer(&b, &p, &e)

+ 16 - 16
pac/pac_type_test.go

@@ -9,7 +9,7 @@ import (
 	"testing"
 )
 
-func TestPAC_Type_Validate(t *testing.T) {
+func TestPACTypeValidate(t *testing.T) {
 	v := "PAC_AD_WIN2K_PAC"
 	b, err := hex.DecodeString(testdata.TestVectors[v])
 	if err != nil {
@@ -32,26 +32,26 @@ func TestPAC_Type_Validate(t *testing.T) {
 		t.Fatalf("Processing reference pac error: %v", err)
 	}
 
-	pac_invalid_server_sig := pac
+	pacInvalidServerSig := pac
 	// Check the signature to force failure
-	pac_invalid_server_sig.ServerChecksum.Signature[0] ^= 0xFF
-	pac_invalid_nil_kerb_validation_info := pac
-	pac_invalid_nil_kerb_validation_info.KerbValidationInfo = nil
-	pac_invalid_nil_server_sig := pac
-	pac_invalid_nil_server_sig.ServerChecksum = nil
-	pac_invalid_nil_kdc_sig := pac
-	pac_invalid_nil_kdc_sig.KDCChecksum = nil
-	pac_invalid_client_info := pac
-	pac_invalid_client_info.ClientInfo = nil
+	pacInvalidServerSig.ServerChecksum.Signature[0] ^= 0xFF
+	pacInvalidNilKerbValidationInfo := pac
+	pacInvalidNilKerbValidationInfo.KerbValidationInfo = nil
+	pacInvalidNilServerSig := pac
+	pacInvalidNilServerSig.ServerChecksum = nil
+	pacInvalidNilKdcSig := pac
+	pacInvalidNilKdcSig.KDCChecksum = nil
+	pacInvalid_clientInfo := pac
+	pacInvalid_clientInfo.ClientInfo = nil
 
 	var pacs = []struct {
 		pac PACType
 	}{
-		{pac_invalid_server_sig},
-		{pac_invalid_nil_kerb_validation_info},
-		{pac_invalid_nil_server_sig},
-		{pac_invalid_nil_kdc_sig},
-		{pac_invalid_client_info},
+		{pacInvalidServerSig},
+		{pacInvalidNilKerbValidationInfo},
+		{pacInvalidNilServerSig},
+		{pacInvalidNilKdcSig},
+		{pacInvalid_clientInfo},
 	}
 	for i, s := range pacs {
 		v, _ := s.pac.validate(key)

+ 6 - 6
pac/s4u_delegation_info.go

@@ -8,9 +8,9 @@ import (
 
 // S4UDelegationInfo implements https://msdn.microsoft.com/en-us/library/cc237944.aspx
 type S4UDelegationInfo struct {
-	S4U2proxyTarget      mstypes.RPC_UnicodeString // The name of the principal to whom the application can forward the ticket.
+	S4U2proxyTarget      mstypes.RPCUnicodeString // The name of the principal to whom the application can forward the ticket.
 	TransitedListSize    uint32
-	S4UTransitedServices []mstypes.RPC_UnicodeString // List of all services that have been delegated through by this client and subsequent services or servers.. Size is value of TransitedListSize
+	S4UTransitedServices []mstypes.RPCUnicodeString // List of all services that have been delegated through by this client and subsequent services or servers.. Size is value of TransitedListSize
 }
 
 // Unmarshal bytes into the S4UDelegationInfo struct
@@ -24,15 +24,15 @@ func (k *S4UDelegationInfo) Unmarshal(b []byte) error {
 	//The next 4 bytes are an RPC unique pointer referent. We just skip these
 	p += 4
 
-	k.S4U2proxyTarget, err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
+	k.S4U2proxyTarget, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
 	if err != nil {
 		return err
 	}
-	k.TransitedListSize = ndr.Read_uint32(&b, &p, e)
+	k.TransitedListSize = ndr.ReadUint32(&b, &p, e)
 	if k.TransitedListSize > 0 {
-		ts := make([]mstypes.RPC_UnicodeString, k.TransitedListSize, k.TransitedListSize)
+		ts := make([]mstypes.RPCUnicodeString, k.TransitedListSize, k.TransitedListSize)
 		for i := range ts {
-			ts[i], err = mstypes.Read_RPC_UnicodeString(&b, &p, e)
+			ts[i], err = mstypes.ReadRPCUnicodeString(&b, &p, e)
 			if err != nil {
 				return err
 			}

+ 3 - 3
pac/signature_data.go

@@ -42,7 +42,7 @@ func (k *SignatureData) Unmarshal(b []byte) ([]byte, error) {
 	var p int
 	var e binary.ByteOrder = binary.LittleEndian
 
-	k.SignatureType = ndr.Read_uint32(&b, &p, &e)
+	k.SignatureType = ndr.ReadUint32(&b, &p, &e)
 	var c int
 	switch k.SignatureType {
 	case chksumtype.KERB_CHECKSUM_HMAC_MD5_UNSIGNED:
@@ -53,8 +53,8 @@ func (k *SignatureData) Unmarshal(b []byte) ([]byte, error) {
 		c = 12
 	}
 	sp := p
-	k.Signature = ndr.Read_bytes(&b, &p, c, &e)
-	k.RODCIdentifier = ndr.Read_uint16(&b, &p, &e)
+	k.Signature = ndr.ReadBytes(&b, &p, c, &e)
+	k.RODCIdentifier = ndr.ReadUint16(&b, &p, &e)
 
 	//Check that there is only zero padding left
 	for _, v := range b[p:] {

+ 7 - 7
pac/upn_dns_info.go

@@ -27,24 +27,24 @@ func (k *UPNDNSInfo) Unmarshal(b []byte) error {
 	var p int
 	var e binary.ByteOrder = binary.LittleEndian
 
-	k.UPNLength = ndr.Read_uint16(&b, &p, &e)
-	k.UPNOffset = ndr.Read_uint16(&b, &p, &e)
-	k.DNSDomainNameLength = ndr.Read_uint16(&b, &p, &e)
-	k.DNSDomainNameOffset = ndr.Read_uint16(&b, &p, &e)
-	k.Flags = ndr.Read_uint32(&b, &p, &e)
+	k.UPNLength = ndr.ReadUint16(&b, &p, &e)
+	k.UPNOffset = ndr.ReadUint16(&b, &p, &e)
+	k.DNSDomainNameLength = ndr.ReadUint16(&b, &p, &e)
+	k.DNSDomainNameOffset = ndr.ReadUint16(&b, &p, &e)
+	k.Flags = ndr.ReadUint32(&b, &p, &e)
 	ub := b[k.UPNOffset : k.UPNOffset+k.UPNLength]
 	db := b[k.DNSDomainNameOffset : k.DNSDomainNameOffset+k.DNSDomainNameLength]
 
 	u := make([]rune, k.UPNLength/2, k.UPNLength/2)
 	for i := 0; i < len(u); i++ {
 		q := i * 2
-		u[i] = rune(ndr.Read_uint16(&ub, &q, &e))
+		u[i] = rune(ndr.ReadUint16(&ub, &q, &e))
 	}
 	k.UPN = string(u)
 	d := make([]rune, k.DNSDomainNameLength/2, k.DNSDomainNameLength/2)
 	for i := 0; i < len(d); i++ {
 		q := i * 2
-		d[i] = rune(ndr.Read_uint16(&db, &q, &e))
+		d[i] = rune(ndr.ReadUint16(&db, &q, &e))
 	}
 	k.DNSDomain = string(d)
 

+ 10 - 8
service/http.go

@@ -14,12 +14,14 @@ import (
 type ctxKey int
 
 const (
-	// SPNEGONegTokenRespKRBAcceptCompleted - The response on successful authentication always has this header. Capturing as const so we don't have marshaling and encoding overhead.
-	SPNEGONegTokenRespKRBAcceptCompleted = "Negotiate oRQwEqADCgEAoQsGCSqGSIb3EgECAg=="
-	// SPNEGONegTokenRespReject - The response on a failed authentication always has this rejection header. Capturing as const so we don't have marshaling and encoding overhead.
-	SPNEGONegTokenRespReject        = "Negotiate oQcwBaADCgEC"
-	CTXKeyAuthenticated      ctxKey = 0
-	CTXKeyCredentials        ctxKey = 1
+	// spnegoNegTokenRespKRBAcceptCompleted - The response on successful authentication always has this header. Capturing as const so we don't have marshaling and encoding overhead.
+	spnegoNegTokenRespKRBAcceptCompleted = "Negotiate oRQwEqADCgEAoQsGCSqGSIb3EgECAg=="
+	// spnegoNegTokenRespReject - The response on a failed authentication always has this rejection header. Capturing as const so we don't have marshaling and encoding overhead.
+	spnegoNegTokenRespReject = "Negotiate oQcwBaADCgEC"
+	// CTXKeyAuthenticated is the request context key holding a boolean indicating if the request has been authenticated.
+	CTXKeyAuthenticated ctxKey = 0
+	// CTXKeyCredentials is the request context key holding the credentials jcmturner/goidentity/Identity object.
+	CTXKeyCredentials ctxKey = 1
 )
 
 // SPNEGOKRB5Authenticate is a Kerberos SPNEGO authentication HTTP handler wrapper.
@@ -89,11 +91,11 @@ func rejectSPNEGO(w http.ResponseWriter, l *log.Logger, logMsg string) {
 }
 
 func SPNEGOResponseReject(w http.ResponseWriter) {
-	w.Header().Set("WWW-Authenticate", SPNEGONegTokenRespReject)
+	w.Header().Set("WWW-Authenticate", spnegoNegTokenRespReject)
 	w.WriteHeader(http.StatusUnauthorized)
 	w.Write([]byte("Unauthorised.\n"))
 }
 
 func SPNEGOResponseAcceptCompleted(w http.ResponseWriter) {
-	w.Header().Set("WWW-Authenticate", SPNEGONegTokenRespKRBAcceptCompleted)
+	w.Header().Set("WWW-Authenticate", spnegoNegTokenRespKRBAcceptCompleted)
 }

+ 4 - 4
types/Authenticator_test.go

@@ -9,7 +9,7 @@ import (
 	"time"
 )
 
-func unmarshalAuthenticator_test(t *testing.T, v string) Authenticator {
+func unmarshalAuthenticatorTest(t *testing.T, v string) Authenticator {
 	var a Authenticator
 	//t.Logf("Starting unmarshal tests of %s", v)
 	b, err := hex.DecodeString(testdata.TestVectors[v])
@@ -23,7 +23,7 @@ func unmarshalAuthenticator_test(t *testing.T, v string) Authenticator {
 	return a
 }
 func TestUnmarshalAuthenticator(t *testing.T) {
-	a := unmarshalAuthenticator_test(t, "encode_krb5_authenticator")
+	a := unmarshalAuthenticatorTest(t, "encode_krb5_authenticator")
 	//Parse the test time value into a time.Time type
 	tt, _ := time.Parse(testdata.TEST_TIME_FORMAT, testdata.TEST_TIME)
 
@@ -46,7 +46,7 @@ func TestUnmarshalAuthenticator(t *testing.T) {
 }
 
 func TestUnmarshalAuthenticator_optionalsempty(t *testing.T) {
-	a := unmarshalAuthenticator_test(t, "encode_krb5_authenticator(optionalsempty)")
+	a := unmarshalAuthenticatorTest(t, "encode_krb5_authenticator(optionalsempty)")
 	//Parse the test time value into a time.Time type
 	tt, _ := time.Parse(testdata.TEST_TIME_FORMAT, testdata.TEST_TIME)
 
@@ -60,7 +60,7 @@ func TestUnmarshalAuthenticator_optionalsempty(t *testing.T) {
 }
 
 func TestUnmarshalAuthenticator_optionalsNULL(t *testing.T) {
-	a := unmarshalAuthenticator_test(t, "encode_krb5_authenticator(optionalsNULL)")
+	a := unmarshalAuthenticatorTest(t, "encode_krb5_authenticator(optionalsNULL)")
 	//Parse the test time value into a time.Time type
 	tt, _ := time.Parse(testdata.TEST_TIME_FORMAT, testdata.TEST_TIME)
 

+ 11 - 11
types/HostAddress.go

@@ -35,15 +35,15 @@ address
 */
 
 const (
-	AddrType_IPv4            = 2
-	AddrType_Directional     = 3
-	AddrType_ChaosNet        = 5
-	AddrType_XNS             = 6
-	AddrType_ISO             = 7
-	AddrType_DECNET_Phase_IV = 12
-	AddrType_AppleTalk_DDP   = 16
-	AddrType_NetBios         = 20
-	AddrType_IPv6            = 24
+	addrTypeIPv4          = 2
+	addrTypeDirectional   = 3
+	addrTypeChaosNet      = 5
+	addrTypeXNS           = 6
+	addrTypeISO           = 7
+	addrTypeDECNETPhaseIV = 12
+	addrTypeAppleTalkDDP  = 16
+	addrTypeNetBios       = 20
+	addrTypeIPv6          = 24
 )
 
 // HostAddresses implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.5
@@ -69,9 +69,9 @@ func GetHostAddress(s string) (HostAddress, error) {
 	}
 	var ht int
 	if ip.To4() != nil {
-		ht = AddrType_IPv4
+		ht = addrTypeIPv4
 	} else if ip.To16() != nil {
-		ht = AddrType_IPv6
+		ht = addrTypeIPv6
 	} else {
 		return h, fmt.Errorf("Could not determine client's address types: %v", err)
 	}