Browse Source

golint fixes

Jonathan Turner 9 years ago
parent
commit
51e436274b
67 changed files with 174 additions and 115 deletions
  1. 1 0
      README.md
  2. 1 1
      client/ASExchange.go
  3. 4 4
      client/TGSExchange.go
  4. 6 6
      client/cache.go
  5. 7 5
      client/client.go
  6. 6 6
      client/session.go
  7. 5 5
      config/krb5conf.go
  8. 2 1
      credentials/credentials.go
  9. 1 0
      crypto/aes128-cts-hmac-sha1-96.go
  10. 1 1
      crypto/aes128-cts-hmac-sha1-96_test.go
  11. 1 0
      crypto/aes128-cts-hmac-sha256-128.go
  12. 1 1
      crypto/aes128-cts-hmac-sha256-128_test.go
  13. 1 0
      crypto/aes256-cts-hmac-sha1-96.go
  14. 1 1
      crypto/aes256-cts-hmac-sha1-96_test.go
  15. 1 0
      crypto/aes256-cts-hmac-sha384-192.go
  16. 1 1
      crypto/aes256-cts-hmac-sha384-192_test.go
  17. 1 1
      crypto/common/common.go
  18. 8 2
      crypto/crypto.go
  19. 1 0
      crypto/des3-cbc-sha1-kd.go
  20. 1 1
      crypto/etype/etype.go
  21. 10 6
      crypto/rfc8009/keyDerivation.go
  22. 1 0
      gssapi/ContextFlags.go
  23. 2 2
      gssapi/MechType.go
  24. 3 2
      gssapi/NegotiationToken.go
  25. 2 0
      gssapi/gssapi.go
  26. 1 0
      gssapi/krb5Token.go
  27. 10 10
      keytab/keytab.go
  28. 2 1
      krberror/error.go
  29. 2 2
      messages/APRep.go
  30. 1 1
      messages/APReq.go
  31. 4 4
      messages/KDCRep.go
  32. 4 4
      messages/KDCReq.go
  33. 3 3
      messages/KRBCred.go
  34. 2 2
      messages/KRBError.go
  35. 2 2
      messages/KRBPriv.go
  36. 2 2
      messages/KRBSafe.go
  37. 3 0
      messages/Ticket.go
  38. 1 1
      mstypes/claims_set_metadata.go
  39. 1 0
      mstypes/filetime.go
  40. 2 2
      mstypes/group_membership.go
  41. 1 1
      mstypes/kerb_sid_and_attributes.go
  42. 1 1
      mstypes/rpc_unicode_string.go
  43. 2 2
      mstypes/sid.go
  44. 2 0
      mstypes/user_session_key.go
  45. 1 0
      ndr/error.go
  46. 2 0
      ndr/ndr.go
  47. 1 1
      pac/client_claims.go
  48. 1 1
      pac/client_info.go
  49. 4 4
      pac/credentials_info.go
  50. 1 1
      pac/device_claims.go
  51. 1 1
      pac/device_info.go
  52. 2 2
      pac/kerb_validation_info.go
  53. 1 1
      pac/pac_info_buffer.go
  54. 1 1
      pac/pac_type.go
  55. 1 1
      pac/s4u_delegation_info.go
  56. 1 0
      pac/signature_data.go
  57. 1 1
      pac/upn_dns_info.go
  58. 1 1
      service/cache.go
  59. 6 6
      service/http.go
  60. 1 1
      service/http_test.go
  61. 3 1
      types/Authenticator.go
  62. 11 5
      types/AuthorizationData.go
  63. 4 3
      types/Cryptosystem.go
  64. 2 0
      types/HostAddress.go
  65. 10 0
      types/PAData.go
  66. 1 0
      types/PrincipalName.go
  67. 2 0
      types/TypedData.go

+ 1 - 0
README.md

@@ -196,6 +196,7 @@ if ok, creds, err := serivce.ValidateAPREQ(mt.APReq, kt, r.RemoteAddr); ok {
 * [HTTP-Based Cross-Platform Authentication by Using the Negotiate Protocol - Part 2](https://msdn.microsoft.com/en-us/library/ms995330.aspx)
 * [HTTP-Based Cross-Platform Authentication by Using the Negotiate Protocol - Part 2](https://msdn.microsoft.com/en-us/library/ms995330.aspx)
 * [Microsoft PAC Validation](https://blogs.msdn.microsoft.com/openspecification/2009/04/24/understanding-microsoft-kerberos-pac-validation/)
 * [Microsoft PAC Validation](https://blogs.msdn.microsoft.com/openspecification/2009/04/24/understanding-microsoft-kerberos-pac-validation/)
 * [Microsoft Kerberos Protocol Extensions](https://msdn.microsoft.com/en-us/library/cc233855.aspx)
 * [Microsoft Kerberos Protocol Extensions](https://msdn.microsoft.com/en-us/library/cc233855.aspx)
+* [Windows Data Types](https://msdn.microsoft.com/en-us/library/cc230273.aspx)
 
 
 ### Useful Links
 ### Useful Links
 * https://en.wikipedia.org/wiki/Ciphertext_stealing#CBC_ciphertext_stealing
 * https://en.wikipedia.org/wiki/Ciphertext_stealing#CBC_ciphertext_stealing

+ 1 - 1
client/ASExchange.go

@@ -57,7 +57,7 @@ func (cl *Client) ASExchange() error {
 	if ok, err := ASRep.IsValid(cl.Config, cl.Credentials, ASReq); !ok {
 	if ok, err := ASRep.IsValid(cl.Config, cl.Credentials, ASReq); !ok {
 		return krberror.Errorf(err, krberror.KRBMSG_ERROR, "AS Exchange Error: AS_REP is not valid")
 		return krberror.Errorf(err, krberror.KRBMSG_ERROR, "AS Exchange Error: AS_REP is not valid")
 	}
 	}
-	cl.Session = &Session{
+	cl.session = &session{
 		AuthTime:             ASRep.DecryptedEncPart.AuthTime,
 		AuthTime:             ASRep.DecryptedEncPart.AuthTime,
 		EndTime:              ASRep.DecryptedEncPart.EndTime,
 		EndTime:              ASRep.DecryptedEncPart.EndTime,
 		RenewTill:            ASRep.DecryptedEncPart.RenewTill,
 		RenewTill:            ASRep.DecryptedEncPart.RenewTill,

+ 4 - 4
client/TGSExchange.go

@@ -13,7 +13,7 @@ import (
 // TGSExchange performs a TGS exchange to retrieve a ticket to the specified SPN.
 // TGSExchange performs a TGS exchange to retrieve a ticket to the specified SPN.
 // The ticket retrieved is added to the client's cache.
 // The ticket retrieved is added to the client's cache.
 func (cl *Client) TGSExchange(spn types.PrincipalName, tkt messages.Ticket, sessionKey types.EncryptionKey, renewal bool) (tgsReq messages.TGSReq, tgsRep messages.TGSRep, err error) {
 func (cl *Client) TGSExchange(spn types.PrincipalName, tkt messages.Ticket, sessionKey types.EncryptionKey, renewal bool) (tgsReq messages.TGSReq, tgsRep messages.TGSRep, err error) {
-	if cl.Session == nil {
+	if cl.session == nil {
 		return tgsReq, tgsRep, errors.New("TGS Exchange Error: client does not have a session. Client needs to login first")
 		return tgsReq, tgsRep, errors.New("TGS Exchange Error: client does not have a session. Client needs to login first")
 	}
 	}
 	tgsReq, err = messages.NewTGSReq(cl.Credentials.CName, cl.Config, tkt, sessionKey, spn, renewal)
 	tgsReq, err = messages.NewTGSReq(cl.Credentials.CName, cl.Config, tkt, sessionKey, spn, renewal)
@@ -53,7 +53,7 @@ func (cl *Client) GetServiceTicket(spn string) (messages.Ticket, types.Encryptio
 		return tkt, skey, nil
 		return tkt, skey, nil
 	}
 	}
 	// Ensure TGT still valid
 	// Ensure TGT still valid
-	if time.Now().UTC().After(cl.Session.EndTime) {
+	if time.Now().UTC().After(cl.session.EndTime) {
 		err := cl.updateTGT()
 		err := cl.updateTGT()
 		if err != nil {
 		if err != nil {
 			return tkt, skey, err
 			return tkt, skey, err
@@ -64,11 +64,11 @@ func (cl *Client) GetServiceTicket(spn string) (messages.Ticket, types.Encryptio
 		NameType:   nametype.KRB_NT_PRINCIPAL,
 		NameType:   nametype.KRB_NT_PRINCIPAL,
 		NameString: s,
 		NameString: s,
 	}
 	}
-	_, tgsRep, err := cl.TGSExchange(princ, cl.Session.TGT, cl.Session.SessionKey, false)
+	_, tgsRep, err := cl.TGSExchange(princ, cl.session.TGT, cl.session.SessionKey, false)
 	if err != nil {
 	if err != nil {
 		return tkt, skey, err
 		return tkt, skey, err
 	}
 	}
-	cl.Cache.AddEntry(
+	cl.Cache.addEntry(
 		tgsRep.Ticket,
 		tgsRep.Ticket,
 		tgsRep.DecryptedEncPart.AuthTime,
 		tgsRep.DecryptedEncPart.AuthTime,
 		tgsRep.DecryptedEncPart.StartTime,
 		tgsRep.DecryptedEncPart.StartTime,

+ 6 - 6
client/cache.go

@@ -7,12 +7,12 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-// Client ticket cache.
+// Cache for client tickets.
 type Cache struct {
 type Cache struct {
 	Entries map[string]CacheEntry
 	Entries map[string]CacheEntry
 }
 }
 
 
-// Ticket cache entry.
+// CacheEntry holds details for a client cache entry.
 type CacheEntry struct {
 type CacheEntry struct {
 	Ticket     messages.Ticket
 	Ticket     messages.Ticket
 	AuthTime   time.Time
 	AuthTime   time.Time
@@ -30,13 +30,13 @@ func NewCache() *Cache {
 }
 }
 
 
 // GetEntry returns a cache entry that matches the SPN.
 // GetEntry returns a cache entry that matches the SPN.
-func (c *Cache) GetEntry(spn string) (CacheEntry, bool) {
+func (c *Cache) getEntry(spn string) (CacheEntry, bool) {
 	e, ok := (*c).Entries[spn]
 	e, ok := (*c).Entries[spn]
 	return e, ok
 	return e, ok
 }
 }
 
 
 // AddEntry adds a ticket to the cache.
 // AddEntry adds a ticket to the cache.
-func (c *Cache) AddEntry(tkt messages.Ticket, authTime, startTime, endTime, renewTill time.Time, sessionKey types.EncryptionKey) CacheEntry {
+func (c *Cache) addEntry(tkt messages.Ticket, authTime, startTime, endTime, renewTill time.Time, sessionKey types.EncryptionKey) CacheEntry {
 	spn := strings.Join(tkt.SName.NameString, "/")
 	spn := strings.Join(tkt.SName.NameString, "/")
 	(*c).Entries[spn] = CacheEntry{
 	(*c).Entries[spn] = CacheEntry{
 		Ticket:     tkt,
 		Ticket:     tkt,
@@ -57,7 +57,7 @@ func (c *Cache) RemoveEntry(spn string) {
 // GetCachedTicket returns a ticket from the cache for the SPN.
 // GetCachedTicket returns a ticket from the cache for the SPN.
 // Only a ticket that is currently valid will be returned.
 // Only a ticket that is currently valid will be returned.
 func (cl *Client) GetCachedTicket(spn string) (messages.Ticket, types.EncryptionKey, bool) {
 func (cl *Client) GetCachedTicket(spn string) (messages.Ticket, types.EncryptionKey, bool) {
-	if e, ok := cl.Cache.GetEntry(spn); ok {
+	if e, ok := cl.Cache.getEntry(spn); ok {
 		//If within time window of ticket return it
 		//If within time window of ticket return it
 		if time.Now().UTC().After(e.StartTime) && time.Now().UTC().Before(e.EndTime) {
 		if time.Now().UTC().After(e.StartTime) && time.Now().UTC().Before(e.EndTime) {
 			return e.Ticket, e.SessionKey, true
 			return e.Ticket, e.SessionKey, true
@@ -81,7 +81,7 @@ func (cl *Client) RenewTicket(e CacheEntry) (CacheEntry, error) {
 	if err != nil {
 	if err != nil {
 		return e, err
 		return e, err
 	}
 	}
-	e = cl.Cache.AddEntry(
+	e = cl.Cache.addEntry(
 		tgsRep.Ticket,
 		tgsRep.Ticket,
 		tgsRep.DecryptedEncPart.AuthTime,
 		tgsRep.DecryptedEncPart.AuthTime,
 		tgsRep.DecryptedEncPart.StartTime,
 		tgsRep.DecryptedEncPart.StartTime,

+ 7 - 5
client/client.go

@@ -7,16 +7,18 @@ import (
 	"github.com/jcmturner/gokrb5/keytab"
 	"github.com/jcmturner/gokrb5/keytab"
 )
 )
 
 
-// Client struct.
+// Client side configuration and state.
 type Client struct {
 type Client struct {
 	Credentials *credentials.Credentials
 	Credentials *credentials.Credentials
 	Config      *config.Config
 	Config      *config.Config
 	GoKrb5Conf  *Config
 	GoKrb5Conf  *Config
-	Session     *Session
+	session     *session
 	Cache       *Cache
 	Cache       *Cache
 }
 }
 
 
-// GoKRB5 specific client configurations.
+// Config struct holds GoKRB5 specific client configurations.
+// Set Disable_PA_FX_FAST to true to force this behaviour off.
+// Set Assume_PA_ENC_TIMESTAMP_Required to send the PA_ENC_TIMESTAMP pro-actively rather than waiting for a KRB_ERROR response from the KDC indicating it is required.
 type Config struct {
 type Config struct {
 	Disable_PA_FX_FAST               bool
 	Disable_PA_FX_FAST               bool
 	Assume_PA_ENC_TIMESTAMP_Required bool
 	Assume_PA_ENC_TIMESTAMP_Required bool
@@ -29,7 +31,7 @@ func NewClientWithPassword(username, realm, password string) Client {
 		Credentials: creds.WithPassword(password),
 		Credentials: creds.WithPassword(password),
 		Config:      config.NewConfig(),
 		Config:      config.NewConfig(),
 		GoKrb5Conf:  &Config{},
 		GoKrb5Conf:  &Config{},
-		Session:     &Session{},
+		session:     &session{},
 		Cache:       NewCache(),
 		Cache:       NewCache(),
 	}
 	}
 }
 }
@@ -41,7 +43,7 @@ func NewClientWithKeytab(username, realm string, kt keytab.Keytab) Client {
 		Credentials: creds.WithKeytab(kt),
 		Credentials: creds.WithKeytab(kt),
 		Config:      config.NewConfig(),
 		Config:      config.NewConfig(),
 		GoKrb5Conf:  &Config{},
 		GoKrb5Conf:  &Config{},
-		Session:     &Session{},
+		session:     &session{},
 		Cache:       NewCache(),
 		Cache:       NewCache(),
 	}
 	}
 }
 }

+ 6 - 6
client/session.go

@@ -9,7 +9,7 @@ import (
 )
 )
 
 
 // Client session struct.
 // Client session struct.
-type Session struct {
+type session struct {
 	AuthTime             time.Time
 	AuthTime             time.Time
 	EndTime              time.Time
 	EndTime              time.Time
 	RenewTill            time.Time
 	RenewTill            time.Time
@@ -24,7 +24,7 @@ func (cl *Client) EnableAutoSessionRenewal() {
 	go func() {
 	go func() {
 		for {
 		for {
 			//Wait until one minute before endtime
 			//Wait until one minute before endtime
-			w := (cl.Session.EndTime.Sub(time.Now().UTC()) * 5) / 6
+			w := (cl.session.EndTime.Sub(time.Now().UTC()) * 5) / 6
 			if w < 0 {
 			if w < 0 {
 				return
 				return
 			}
 			}
@@ -38,13 +38,13 @@ func (cl *Client) EnableAutoSessionRenewal() {
 func (cl *Client) RenewTGT() error {
 func (cl *Client) RenewTGT() error {
 	spn := types.PrincipalName{
 	spn := types.PrincipalName{
 		NameType:   nametype.KRB_NT_SRV_INST,
 		NameType:   nametype.KRB_NT_SRV_INST,
-		NameString: []string{"krbtgt", cl.Session.TGT.Realm},
+		NameString: []string{"krbtgt", cl.session.TGT.Realm},
 	}
 	}
-	_, tgsRep, err := cl.TGSExchange(spn, cl.Session.TGT, cl.Session.SessionKey, true)
+	_, tgsRep, err := cl.TGSExchange(spn, cl.session.TGT, cl.session.SessionKey, true)
 	if err != nil {
 	if err != nil {
 		return krberror.Errorf(err, krberror.KRBMSG_ERROR, "Error renewing TGT")
 		return krberror.Errorf(err, krberror.KRBMSG_ERROR, "Error renewing TGT")
 	}
 	}
-	cl.Session = &Session{
+	cl.session = &session{
 		AuthTime:             tgsRep.DecryptedEncPart.AuthTime,
 		AuthTime:             tgsRep.DecryptedEncPart.AuthTime,
 		EndTime:              tgsRep.DecryptedEncPart.EndTime,
 		EndTime:              tgsRep.DecryptedEncPart.EndTime,
 		RenewTill:            tgsRep.DecryptedEncPart.RenewTill,
 		RenewTill:            tgsRep.DecryptedEncPart.RenewTill,
@@ -56,7 +56,7 @@ func (cl *Client) RenewTGT() error {
 }
 }
 
 
 func (cl *Client) updateTGT() error {
 func (cl *Client) updateTGT() error {
-	if time.Now().UTC().Before(cl.Session.RenewTill) {
+	if time.Now().UTC().Before(cl.session.RenewTill) {
 		err := cl.RenewTGT()
 		err := cl.RenewTGT()
 		if err != nil {
 		if err != nil {
 			return err
 			return err

+ 5 - 5
config/krb5conf.go

@@ -1,4 +1,4 @@
-// Implements KRB5 client and service configuration as described at https://web.mit.edu/kerberos/krb5-latest/doc/admin/conf_files/krb5_conf.html
+// Package config implements KRB5 client and service configuration as described at https://web.mit.edu/kerberos/krb5-latest/doc/admin/conf_files/krb5_conf.html
 package config
 package config
 
 
 import (
 import (
@@ -17,7 +17,7 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-// Struct representing the KRB5 configuration.
+// Config represents the KRB5 configuration.
 type Config struct {
 type Config struct {
 	LibDefaults *LibDefaults
 	LibDefaults *LibDefaults
 	Realms      []Realm
 	Realms      []Realm
@@ -39,7 +39,7 @@ func NewConfig() *Config {
 	}
 	}
 }
 }
 
 
-// Struct representing the [libdefaults] section of the configuration.
+// LibDefaults represents the [libdefaults] section of the configuration.
 type LibDefaults struct {
 type LibDefaults struct {
 	Allow_weak_crypto bool //default false
 	Allow_weak_crypto bool //default false
 	// ap_req_checksum_type int //unlikely to support this
 	// ap_req_checksum_type int //unlikely to support this
@@ -295,7 +295,7 @@ func (l *LibDefaults) parseLines(lines []string) error {
 	return nil
 	return nil
 }
 }
 
 
-// Struct representing an entry in the [realms] section of the configuration.
+// Realm represents an entry in the [realms] section of the configuration.
 type Realm struct {
 type Realm struct {
 	Realm        string
 	Realm        string
 	Admin_server []string
 	Admin_server []string
@@ -389,7 +389,7 @@ func parseRealms(lines []string) ([]Realm, error) {
 	return realms, nil
 	return realms, nil
 }
 }
 
 
-// Mapping of domains to realms representing the [domain_realm] section of the configuration.
+// DomainRealm maps the domains to realms representing the [domain_realm] section of the configuration.
 type DomainRealm map[string]string
 type DomainRealm map[string]string
 
 
 // Parse the lines of the [domain_realm] section of the configuration and add to the mapping.
 // Parse the lines of the [domain_realm] section of the configuration and add to the mapping.

+ 2 - 1
credentials/credentials.go

@@ -1,4 +1,4 @@
-// Credentials for Kerberos 5 authentication.
+// Package credentials provides credentials management for Kerberos 5 authentication.
 package credentials
 package credentials
 
 
 import (
 import (
@@ -20,6 +20,7 @@ type Credentials struct {
 	Attributes map[string]interface{}
 	Attributes map[string]interface{}
 }
 }
 
 
+// ADCredentials contains information obtained from the PAC.
 type ADCredentials struct {
 type ADCredentials struct {
 	EffectiveName       string
 	EffectiveName       string
 	FullName            string
 	FullName            string

+ 1 - 0
crypto/aes128-cts-hmac-sha1-96.go

@@ -58,6 +58,7 @@ import (
 //|    hmac-sha1-96-aes256                16                   96      |
 //|    hmac-sha1-96-aes256                16                   96      |
 //+--------------------------------------------------------------------+
 //+--------------------------------------------------------------------+
 
 
+// Aes128CtsHmacSha96 implements Kerberos encryption type aes128-cts-hmac-sha1-96
 type Aes128CtsHmacSha96 struct {
 type Aes128CtsHmacSha96 struct {
 }
 }
 
 

+ 1 - 1
crypto/aes128-cts-hmac-sha1-96_test.go

@@ -33,7 +33,7 @@ func TestAes128CtsHmacSha196_StringToKey(t *testing.T) {
 	for i, test := range tests {
 	for i, test := range tests {
 
 
 		assert.Equal(t, test.pbkdf2, hex.EncodeToString(rfc3962.StringToPBKDF2(test.phrase, test.salt, test.iterations, e)), "PBKDF2 not as expected")
 		assert.Equal(t, test.pbkdf2, hex.EncodeToString(rfc3962.StringToPBKDF2(test.phrase, test.salt, test.iterations, e)), "PBKDF2 not as expected")
-		k, err := e.StringToKey(test.phrase, test.salt, common.IterationsToS2kparams(test.iterations))
+		k, err := e.StringToKey(test.phrase, test.salt, common.IterationsToS2Kparams(test.iterations))
 		if err != nil {
 		if err != nil {
 			t.Errorf("Error in processing string to key for test %d: %v", i, err)
 			t.Errorf("Error in processing string to key for test %d: %v", i, err)
 		}
 		}

+ 1 - 0
crypto/aes128-cts-hmac-sha256-128.go

@@ -13,6 +13,7 @@ import (
 
 
 // RFC https://tools.ietf.org/html/rfc8009
 // RFC https://tools.ietf.org/html/rfc8009
 
 
+// Aes128CtsHmacSha256128 implements Kerberos encryption type aes128-cts-hmac-sha256-128
 type Aes128CtsHmacSha256128 struct {
 type Aes128CtsHmacSha256128 struct {
 }
 }
 
 

+ 1 - 1
crypto/aes128-cts-hmac-sha256-128_test.go

@@ -27,7 +27,7 @@ func TestAes128CtsHmacSha256128_StringToKey(t *testing.T) {
 		saltp := rfc8009.GetSaltP(test.salt, "aes128-cts-hmac-sha256-128")
 		saltp := rfc8009.GetSaltP(test.salt, "aes128-cts-hmac-sha256-128")
 		assert.Equal(t, test.saltp, hex.EncodeToString(([]byte(saltp))), "SaltP not as expected")
 		assert.Equal(t, test.saltp, hex.EncodeToString(([]byte(saltp))), "SaltP not as expected")
 
 
-		k, _ := e.StringToKey(test.phrase, test.salt, common.IterationsToS2kparams(test.iterations))
+		k, _ := e.StringToKey(test.phrase, test.salt, common.IterationsToS2Kparams(test.iterations))
 		assert.Equal(t, test.key, hex.EncodeToString(k), "String to Key not as expected")
 		assert.Equal(t, test.key, hex.EncodeToString(k), "String to Key not as expected")
 
 
 	}
 	}

+ 1 - 0
crypto/aes256-cts-hmac-sha1-96.go

@@ -58,6 +58,7 @@ import (
 //|    hmac-sha1-96-aes256                16                   96      |
 //|    hmac-sha1-96-aes256                16                   96      |
 //+--------------------------------------------------------------------+
 //+--------------------------------------------------------------------+
 
 
+// Aes256CtsHmacSha96 implements Kerberos encryption type aes256-cts-hmac-sha1-96
 type Aes256CtsHmacSha96 struct {
 type Aes256CtsHmacSha96 struct {
 }
 }
 
 

+ 1 - 1
crypto/aes256-cts-hmac-sha1-96_test.go

@@ -33,7 +33,7 @@ func TestAes256CtsHmacSha196_StringToKey(t *testing.T) {
 	for i, test := range tests {
 	for i, test := range tests {
 
 
 		assert.Equal(t, test.pbkdf2, hex.EncodeToString(rfc3962.StringToPBKDF2(test.phrase, test.salt, test.iterations, e)), "PBKDF2 not as expected")
 		assert.Equal(t, test.pbkdf2, hex.EncodeToString(rfc3962.StringToPBKDF2(test.phrase, test.salt, test.iterations, e)), "PBKDF2 not as expected")
-		k, err := e.StringToKey(test.phrase, test.salt, common.IterationsToS2kparams(test.iterations))
+		k, err := e.StringToKey(test.phrase, test.salt, common.IterationsToS2Kparams(test.iterations))
 		if err != nil {
 		if err != nil {
 			t.Errorf("Error in processing string to key for test %d: %v", i, err)
 			t.Errorf("Error in processing string to key for test %d: %v", i, err)
 		}
 		}

+ 1 - 0
crypto/aes256-cts-hmac-sha384-192.go

@@ -13,6 +13,7 @@ import (
 
 
 // RFC https://tools.ietf.org/html/rfc8009
 // RFC https://tools.ietf.org/html/rfc8009
 
 
+// Aes256CtsHmacSha384192 implements Kerberos encryption type aes256-cts-hmac-sha384-192
 type Aes256CtsHmacSha384192 struct {
 type Aes256CtsHmacSha384192 struct {
 }
 }
 
 

+ 1 - 1
crypto/aes256-cts-hmac-sha384-192_test.go

@@ -27,7 +27,7 @@ func TestAes256CtsHmacSha384192_StringToKey(t *testing.T) {
 		saltp := rfc8009.GetSaltP(test.salt, "aes256-cts-hmac-sha384-192")
 		saltp := rfc8009.GetSaltP(test.salt, "aes256-cts-hmac-sha384-192")
 		assert.Equal(t, test.saltp, hex.EncodeToString(([]byte(saltp))), "SaltP not as expected")
 		assert.Equal(t, test.saltp, hex.EncodeToString(([]byte(saltp))), "SaltP not as expected")
 
 
-		k, _ := e.StringToKey(test.phrase, test.salt, common.IterationsToS2kparams(test.iterations))
+		k, _ := e.StringToKey(test.phrase, test.salt, common.IterationsToS2Kparams(test.iterations))
 		assert.Equal(t, test.key, hex.EncodeToString(k), "String to Key not as expected")
 		assert.Equal(t, test.key, hex.EncodeToString(k), "String to Key not as expected")
 	}
 	}
 }
 }

+ 1 - 1
crypto/common/common.go

@@ -139,7 +139,7 @@ func getUsage(un uint32, o byte) []byte {
 }
 }
 
 
 // IterationsToS2Kparams converts the number of iterations as an integer to a string representation.
 // IterationsToS2Kparams converts the number of iterations as an integer to a string representation.
-func IterationsToS2kparams(i int) string {
+func IterationsToS2Kparams(i int) string {
 	b := make([]byte, 4, 4)
 	b := make([]byte, 4, 4)
 	binary.BigEndian.PutUint32(b, uint32(i))
 	binary.BigEndian.PutUint32(b, uint32(i))
 	return hex.EncodeToString(b)
 	return hex.EncodeToString(b)

+ 8 - 2
crypto/crypto.go

@@ -1,4 +1,4 @@
-// Cryptographic packages for Kerberos 5 implementation.
+// Package crypto implements cryptographic functions for Kerberos 5 implementation.
 package crypto
 package crypto
 
 
 import (
 import (
@@ -11,6 +11,7 @@ import (
 	"github.com/jcmturner/gokrb5/types"
 	"github.com/jcmturner/gokrb5/types"
 )
 )
 
 
+// GetEtype returns an instances of the required etype struct for the etype ID.
 func GetEtype(id int) (etype.EType, error) {
 func GetEtype(id int) (etype.EType, error) {
 	switch id {
 	switch id {
 	case etypeID.AES128_CTS_HMAC_SHA1_96:
 	case etypeID.AES128_CTS_HMAC_SHA1_96:
@@ -33,6 +34,7 @@ func GetEtype(id int) (etype.EType, error) {
 	}
 	}
 }
 }
 
 
+// GetChksumEtype returns an instances of the required etype struct for the checksum ID.
 func GetChksumEtype(id int) (etype.EType, error) {
 func GetChksumEtype(id int) (etype.EType, error) {
 	switch id {
 	switch id {
 	case chksumtype.HMAC_SHA1_96_AES128:
 	case chksumtype.HMAC_SHA1_96_AES128:
@@ -55,6 +57,7 @@ func GetChksumEtype(id int) (etype.EType, error) {
 	}
 	}
 }
 }
 
 
+// GetKeyFromPassword generates an encryption key from the principal's password.
 func GetKeyFromPassword(passwd string, cname types.PrincipalName, realm string, etypeID int, pas types.PADataSequence) (types.EncryptionKey, etype.EType, error) {
 func GetKeyFromPassword(passwd string, cname types.PrincipalName, realm string, etypeID int, pas types.PADataSequence) (types.EncryptionKey, etype.EType, error) {
 	var key types.EncryptionKey
 	var key types.EncryptionKey
 	et, err := GetEtype(etypeID)
 	et, err := GetEtype(etypeID)
@@ -122,7 +125,8 @@ func GetKeyFromPassword(passwd string, cname types.PrincipalName, realm string,
 	return key, et, nil
 	return key, et, nil
 }
 }
 
 
-// Pass a usage value of zero to use the key provided directly rather than deriving one
+// GetEncryptedData encrypts the data provided and returns and EncryptedData type.
+// Pass a usage value of zero to use the key provided directly rather than deriving one.
 func GetEncryptedData(plainBytes []byte, key types.EncryptionKey, usage uint32, kvno int) (types.EncryptedData, error) {
 func GetEncryptedData(plainBytes []byte, key types.EncryptionKey, usage uint32, kvno int) (types.EncryptedData, error) {
 	var ed types.EncryptedData
 	var ed types.EncryptedData
 	et, err := GetEtype(key.KeyType)
 	et, err := GetEtype(key.KeyType)
@@ -142,10 +146,12 @@ func GetEncryptedData(plainBytes []byte, key types.EncryptionKey, usage uint32,
 	return ed, nil
 	return ed, nil
 }
 }
 
 
+// DecryptEncPart decrypts the EncryptedData.
 func DecryptEncPart(ed types.EncryptedData, key types.EncryptionKey, usage uint32) ([]byte, error) {
 func DecryptEncPart(ed types.EncryptedData, key types.EncryptionKey, usage uint32) ([]byte, error) {
 	return DecryptMessage(ed.Cipher, key, usage)
 	return DecryptMessage(ed.Cipher, key, usage)
 }
 }
 
 
+// DecryptMessage decrypts the ciphertext and verifies the integrity.
 func DecryptMessage(ciphertext []byte, key types.EncryptionKey, usage uint32) ([]byte, error) {
 func DecryptMessage(ciphertext []byte, key types.EncryptionKey, usage uint32) ([]byte, error) {
 	et, err := GetEtype(key.KeyType)
 	et, err := GetEtype(key.KeyType)
 	if err != nil {
 	if err != nil {

+ 1 - 0
crypto/des3-cbc-sha1-kd.go

@@ -49,6 +49,7 @@ import (
    sixteen (16).  The hmac-sha1-des3-kd checksum algorithm is assigned a
    sixteen (16).  The hmac-sha1-des3-kd checksum algorithm is assigned a
    checksum type number of twelve (12)*/
    checksum type number of twelve (12)*/
 
 
+// Des3CbcSha1Kd implements Kerberos encryption type des3-cbc-hmac-sha1-kd
 type Des3CbcSha1Kd struct {
 type Des3CbcSha1Kd struct {
 }
 }
 
 

+ 1 - 1
crypto/etype/etype.go

@@ -3,7 +3,7 @@ package etype
 
 
 import "hash"
 import "hash"
 
 
-// Interface defining the Encryption Type.
+// EType is the interface defining the Encryption Type.
 type EType interface {
 type EType interface {
 	GetETypeID() int
 	GetETypeID() int
 	GetHashID() int
 	GetHashID() int

+ 10 - 6
crypto/rfc8009/keyDerivation.go

@@ -14,11 +14,14 @@ const (
 	s2kParamsZero = 32768
 	s2kParamsZero = 32768
 )
 )
 
 
+// DeriveRandom for key derivation as defined in RFC 8009
 func DeriveRandom(protocolKey, usage []byte, e etype.EType) ([]byte, error) {
 func DeriveRandom(protocolKey, usage []byte, e etype.EType) ([]byte, error) {
 	h := e.GetHashFunc()()
 	h := e.GetHashFunc()()
 	return KDF_HMAC_SHA2(protocolKey, []byte("prf"), usage, h.Size(), e), nil
 	return KDF_HMAC_SHA2(protocolKey, []byte("prf"), usage, h.Size(), e), nil
 }
 }
 
 
+// DeriveKey derives a key from the protocol key based on the usage and the etype's specific methods.
+//
 // https://tools.ietf.org/html/rfc8009#section-5
 // https://tools.ietf.org/html/rfc8009#section-5
 //
 //
 // If the enctype is aes128-cts-hmac-sha256-128:
 // If the enctype is aes128-cts-hmac-sha256-128:
@@ -63,10 +66,12 @@ func DeriveKey(protocolKey, label []byte, e etype.EType) []byte {
 	return e.RandomToKey(KDF_HMAC_SHA2(protocolKey, label, context, kl, e))
 	return e.RandomToKey(KDF_HMAC_SHA2(protocolKey, label, context, kl, e))
 }
 }
 
 
+// RandomToKey returns a key from the bytes provided according to the definition in RFC 8009.
 func RandomToKey(b []byte) []byte {
 func RandomToKey(b []byte) []byte {
 	return b
 	return b
 }
 }
 
 
+// StringToKey returns a key derived from the string provided according to the definition in RFC 8009.
 func StringToKey(secret, salt, s2kparams string, e etype.EType) ([]byte, error) {
 func StringToKey(secret, salt, s2kparams string, e etype.EType) ([]byte, error) {
 	i, err := S2KparamsToItertions(s2kparams)
 	i, err := S2KparamsToItertions(s2kparams)
 	if err != nil {
 	if err != nil {
@@ -75,11 +80,13 @@ func StringToKey(secret, salt, s2kparams string, e etype.EType) ([]byte, error)
 	return StringToKeyIter(secret, salt, int(i), e)
 	return StringToKeyIter(secret, salt, int(i), e)
 }
 }
 
 
+// StringToKeyIter returns a key derived from the string provided according to the definition in RFC 8009.
 func StringToKeyIter(secret, salt string, iterations int, e etype.EType) ([]byte, error) {
 func StringToKeyIter(secret, salt string, iterations int, e etype.EType) ([]byte, error) {
 	tkey := e.RandomToKey(StringToPBKDF2(secret, salt, iterations, e))
 	tkey := e.RandomToKey(StringToPBKDF2(secret, salt, iterations, e))
 	return e.DeriveKey(tkey, []byte("kerberos"))
 	return e.DeriveKey(tkey, []byte("kerberos"))
 }
 }
 
 
+// StringToPBKDF2 generates an encryption key from a pass phrase and salt string using the PBKDF2 function from PKCS #5 v2.0
 func StringToPBKDF2(secret, salt string, iterations int, e etype.EType) []byte {
 func StringToPBKDF2(secret, salt string, iterations int, e etype.EType) []byte {
 	kl := e.GetKeyByteSize()
 	kl := e.GetKeyByteSize()
 	if e.GetETypeID() == etypeID.AES256_CTS_HMAC_SHA384_192 {
 	if e.GetETypeID() == etypeID.AES256_CTS_HMAC_SHA384_192 {
@@ -88,7 +95,7 @@ func StringToPBKDF2(secret, salt string, iterations int, e etype.EType) []byte {
 	return pbkdf2.Key([]byte(secret), []byte(salt), iterations, kl, e.GetHashFunc())
 	return pbkdf2.Key([]byte(secret), []byte(salt), iterations, kl, e.GetHashFunc())
 }
 }
 
 
-// https://tools.ietf.org/html/rfc8009#section-3
+// KDF_HMAC_SHA2 key derivation: https://tools.ietf.org/html/rfc8009#section-3
 func KDF_HMAC_SHA2(protocolKey, label, context []byte, kl int, e etype.EType) []byte {
 func KDF_HMAC_SHA2(protocolKey, label, context []byte, kl int, e etype.EType) []byte {
 	//k: Length in bits of the key to be outputted, expressed in big-endian binary representation in 4 bytes.
 	//k: Length in bits of the key to be outputted, expressed in big-endian binary representation in 4 bytes.
 	k := make([]byte, 4, 4)
 	k := make([]byte, 4, 4)
@@ -108,6 +115,7 @@ func KDF_HMAC_SHA2(protocolKey, label, context []byte, kl int, e etype.EType) []
 	return mac.Sum(nil)[:(kl / 8)]
 	return mac.Sum(nil)[:(kl / 8)]
 }
 }
 
 
+// GetSaltP returns the salt value based on the etype name: https://tools.ietf.org/html/rfc8009#section-4
 func GetSaltP(salt, ename string) string {
 func GetSaltP(salt, ename string) string {
 	b := []byte(ename)
 	b := []byte(ename)
 	b = append(b, byte(uint8(0)))
 	b = append(b, byte(uint8(0)))
@@ -115,12 +123,8 @@ func GetSaltP(salt, ename string) string {
 	return string(b)
 	return string(b)
 }
 }
 
 
+// S2KparamsToItertions converts the string representation of iterations to an integer for RFC 8009.
 func S2KparamsToItertions(s2kparams string) (int, error) {
 func S2KparamsToItertions(s2kparams string) (int, error) {
-	//process s2kparams string
-	//The parameter string is four octets indicating an unsigned
-	//number in big-endian order.  This is the number of iterations to be
-	//performed.  If the value is 00 00 00 00, the number of iterations to
-	//be performed is 4,294,967,296 (2**32).
 	var i uint32
 	var i uint32
 	if len(s2kparams) != 8 {
 	if len(s2kparams) != 8 {
 		return s2kParamsZero, errors.New("Invalid s2kparams length")
 		return s2kParamsZero, errors.New("Invalid s2kparams length")

+ 1 - 0
gssapi/ContextFlags.go

@@ -24,6 +24,7 @@ const (
 	integFlag    = 6
 	integFlag    = 6
 )
 )
 
 
+// ContextFlags flags for GSSAPI
 type ContextFlags asn1.BitString
 type ContextFlags asn1.BitString
 
 
 // NewContextFlags creates a new ContextFlags instance.
 // NewContextFlags creates a new ContextFlags instance.

+ 2 - 2
gssapi/MechType.go

@@ -2,8 +2,8 @@ package gssapi
 
 
 import "github.com/jcmturner/asn1"
 import "github.com/jcmturner/asn1"
 
 
-// MechType OID for Kerberos 5
+// MechTypeOID_Krb5 is the MechType OID for Kerberos 5
 var MechTypeOID_Krb5 = asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}
 var MechTypeOID_Krb5 = asn1.ObjectIdentifier{1, 2, 840, 113554, 1, 2, 2}
 
 
-// MechType OID for MS legacy Kerberos 5
+// MechTypeOID_MSLegacyKrb5 is the MechType OID for MS legacy Kerberos 5
 var MechTypeOID_MSLegacyKrb5 = asn1.ObjectIdentifier{1, 2, 840, 48018, 1, 2, 2}
 var MechTypeOID_MSLegacyKrb5 = asn1.ObjectIdentifier{1, 2, 840, 48018, 1, 2, 2}

+ 3 - 2
gssapi/NegotiationToken.go

@@ -43,7 +43,7 @@ NegTokenResp ::= SEQUENCE {
 }
 }
 */
 */
 
 
-// Negotiation Token - Init
+// NegTokenInit implements Negotiation Token of type Init
 type NegTokenInit struct {
 type NegTokenInit struct {
 	MechTypes    []asn1.ObjectIdentifier `asn1:"explicit,tag:0"`
 	MechTypes    []asn1.ObjectIdentifier `asn1:"explicit,tag:0"`
 	ReqFlags     ContextFlags            `asn1:"explicit,optional,tag:1"`
 	ReqFlags     ContextFlags            `asn1:"explicit,optional,tag:1"`
@@ -51,7 +51,7 @@ type NegTokenInit struct {
 	MechTokenMIC []byte                  `asn1:"explicit,optional,tag:3"`
 	MechTokenMIC []byte                  `asn1:"explicit,optional,tag:3"`
 }
 }
 
 
-// Negotiation Token - Resp/Targ
+// NegTokenResp implements Negotiation Token of type Resp/Targ
 type NegTokenResp struct {
 type NegTokenResp struct {
 	NegState      asn1.Enumerated       `asn1:"explicit,tag:0"`
 	NegState      asn1.Enumerated       `asn1:"explicit,tag:0"`
 	SupportedMech asn1.ObjectIdentifier `asn1:"explicit,optional,tag:1"`
 	SupportedMech asn1.ObjectIdentifier `asn1:"explicit,optional,tag:1"`
@@ -59,6 +59,7 @@ type NegTokenResp struct {
 	MechListMIC   []byte                `asn1:"explicit,optional,tag:3"`
 	MechListMIC   []byte                `asn1:"explicit,optional,tag:3"`
 }
 }
 
 
+// NegTokenTarg implements Negotiation Token of type Resp/Targ
 type NegTokenTarg NegTokenResp
 type NegTokenTarg NegTokenResp
 
 
 // UnmarshalNegToken umarshals and returns either a NegTokenInit or a NegTokenResp.
 // UnmarshalNegToken umarshals and returns either a NegTokenInit or a NegTokenResp.

+ 2 - 0
gssapi/gssapi.go

@@ -11,8 +11,10 @@ import (
 	"github.com/jcmturner/gokrb5/types"
 	"github.com/jcmturner/gokrb5/types"
 )
 )
 
 
+// SPNEGO_OID is the OID for SPNEGO header type.
 var SPNEGO_OID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 2}
 var SPNEGO_OID = asn1.ObjectIdentifier{1, 3, 6, 1, 5, 5, 2}
 
 
+// SPNEGO header struct
 type SPNEGO struct {
 type SPNEGO struct {
 	Init         bool
 	Init         bool
 	Resp         bool
 	Resp         bool

+ 1 - 0
gssapi/krb5Token.go

@@ -26,6 +26,7 @@ const (
 	GSS_C_INTEG_FLAG    = 32
 	GSS_C_INTEG_FLAG    = 32
 )
 )
 
 
+// MechToken implementation for GSSAPI
 type MechToken struct {
 type MechToken struct {
 	OID      asn1.ObjectIdentifier
 	OID      asn1.ObjectIdentifier
 	TokID    []byte
 	TokID    []byte

+ 10 - 10
keytab/keytab.go

@@ -15,12 +15,12 @@ import (
 // Keytab struct.
 // Keytab struct.
 type Keytab struct {
 type Keytab struct {
 	Version uint16
 	Version uint16
-	Entries []Entry
+	Entries []entry
 }
 }
 
 
 // Keytab entry struct.
 // Keytab entry struct.
-type Entry struct {
-	Principal Principal
+type entry struct {
+	Principal principal
 	Timestamp time.Time
 	Timestamp time.Time
 	KVNO8     uint8
 	KVNO8     uint8
 	Key       types.EncryptionKey
 	Key       types.EncryptionKey
@@ -28,7 +28,7 @@ type Entry struct {
 }
 }
 
 
 // Keytab entry principal struct.
 // Keytab entry principal struct.
-type Principal struct {
+type principal struct {
 	NumComponents int16
 	NumComponents int16
 	Realm         string
 	Realm         string
 	Components    []string
 	Components    []string
@@ -37,7 +37,7 @@ type Principal struct {
 
 
 // NewKeytab creates new, empty Keytab type.
 // NewKeytab creates new, empty Keytab type.
 func NewKeytab() Keytab {
 func NewKeytab() Keytab {
-	var e []Entry
+	var e []entry
 	return Keytab{
 	return Keytab{
 		Version: 0,
 		Version: 0,
 		Entries: e,
 		Entries: e,
@@ -69,9 +69,9 @@ func (kt *Keytab) GetEncryptionKey(nameString []string, realm string, kvno, etyp
 }
 }
 
 
 // Create a new Keytab entry.
 // Create a new Keytab entry.
-func newKeytabEntry() Entry {
+func newKeytabEntry() entry {
 	var b []byte
 	var b []byte
-	return Entry{
+	return entry{
 		Principal: newPrincipal(),
 		Principal: newPrincipal(),
 		Timestamp: time.Time{},
 		Timestamp: time.Time{},
 		KVNO8:     0,
 		KVNO8:     0,
@@ -84,9 +84,9 @@ func newKeytabEntry() Entry {
 }
 }
 
 
 // Create a new principal.
 // Create a new principal.
-func newPrincipal() Principal {
+func newPrincipal() principal {
 	var c []string
 	var c []string
-	return Principal{
+	return principal{
 		NumComponents: 0,
 		NumComponents: 0,
 		Realm:         "",
 		Realm:         "",
 		Components:    c,
 		Components:    c,
@@ -176,7 +176,7 @@ func Parse(b []byte) (kt Keytab, err error) {
 }
 }
 
 
 // Parse the Keytab bytes of a principal into a Keytab entry's principal.
 // Parse the Keytab bytes of a principal into a Keytab entry's principal.
-func parse_principal(b []byte, p *int, kt *Keytab, ke *Entry, e *binary.ByteOrder) (err error) {
+func parse_principal(b []byte, p *int, kt *Keytab, ke *entry, e *binary.ByteOrder) (err error) {
 	ke.Principal.NumComponents = read_int16(b, p, e)
 	ke.Principal.NumComponents = read_int16(b, p, e)
 	if kt.Version == 1 {
 	if kt.Version == 1 {
 		//In version 1 the number of components includes the realm. Minus 1 to make consistent with version 2
 		//In version 1 the number of components includes the realm. Minus 1 to make consistent with version 2

+ 2 - 1
krberror/error.go

@@ -1,4 +1,4 @@
-// Error handling.
+// Package krberror provides error type and functions for gokrb5.
 package krberror
 package krberror
 
 
 import (
 import (
@@ -16,6 +16,7 @@ const (
 	KRBMSG_ERROR     = "KRBMessage_Handling_Error"
 	KRBMSG_ERROR     = "KRBMessage_Handling_Error"
 )
 )
 
 
+// Krberror is an error type for gokrb5
 type Krberror struct {
 type Krberror struct {
 	RootCause string
 	RootCause string
 	EText     []string
 	EText     []string

+ 2 - 2
messages/APRep.go

@@ -25,14 +25,14 @@ EncAPRepPart    ::= [APPLICATION 27] SEQUENCE {
 }
 }
 */
 */
 
 
-// RFC 4120 KRB_AP_REP: https://tools.ietf.org/html/rfc4120#section-5.5.2.
+// APRep implements RFC 4120 KRB_AP_REP: https://tools.ietf.org/html/rfc4120#section-5.5.2.
 type APRep struct {
 type APRep struct {
 	PVNO    int                 `asn1:"explicit,tag:0"`
 	PVNO    int                 `asn1:"explicit,tag:0"`
 	MsgType int                 `asn1:"explicit,tag:1"`
 	MsgType int                 `asn1:"explicit,tag:1"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:2"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:2"`
 }
 }
 
 
-// Encrypted part of KRB_AP_REP.
+// EncAPRepPart is the encrypted part of KRB_AP_REP.
 type EncAPRepPart struct {
 type EncAPRepPart struct {
 	CTime          time.Time           `asn1:"generalized,explicit,tag:0"`
 	CTime          time.Time           `asn1:"generalized,explicit,tag:0"`
 	Cusec          int                 `asn1:"explicit,tag:1"`
 	Cusec          int                 `asn1:"explicit,tag:1"`

+ 1 - 1
messages/APReq.go

@@ -36,7 +36,7 @@ type marshalAPReq struct {
 	Authenticator types.EncryptedData `asn1:"explicit,tag:4"`
 	Authenticator types.EncryptedData `asn1:"explicit,tag:4"`
 }
 }
 
 
-// RFC 4120 KRB_AP_REQ: https://tools.ietf.org/html/rfc4120#section-5.5.1.
+// APReq implements RFC 4120 KRB_AP_REQ: https://tools.ietf.org/html/rfc4120#section-5.5.1.
 type APReq struct {
 type APReq struct {
 	PVNO          int                 `asn1:"explicit,tag:0"`
 	PVNO          int                 `asn1:"explicit,tag:0"`
 	MsgType       int                 `asn1:"explicit,tag:1"`
 	MsgType       int                 `asn1:"explicit,tag:1"`

+ 4 - 4
messages/KDCRep.go

@@ -30,7 +30,7 @@ type marshalKDCRep struct {
 	EncPart types.EncryptedData `asn1:"explicit,tag:6"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:6"`
 }
 }
 
 
-// KRB_KDC_REP struct fields.
+// KDCRepFields represents the KRB_KDC_REP fields.
 type KDCRepFields struct {
 type KDCRepFields struct {
 	PVNO             int
 	PVNO             int
 	MsgType          int
 	MsgType          int
@@ -42,17 +42,17 @@ type KDCRepFields struct {
 	DecryptedEncPart EncKDCRepPart
 	DecryptedEncPart EncKDCRepPart
 }
 }
 
 
-// RFC 4120 KRB_AS_REP: https://tools.ietf.org/html/rfc4120#section-5.4.2.
+// ASRep implements RFC 4120 KRB_AS_REP: https://tools.ietf.org/html/rfc4120#section-5.4.2.
 type ASRep struct {
 type ASRep struct {
 	KDCRepFields
 	KDCRepFields
 }
 }
 
 
-// RFC 4120 KRB_TGS_REP: https://tools.ietf.org/html/rfc4120#section-5.4.2.
+// TGSRep implements RFC 4120 KRB_TGS_REP: https://tools.ietf.org/html/rfc4120#section-5.4.2.
 type TGSRep struct {
 type TGSRep struct {
 	KDCRepFields
 	KDCRepFields
 }
 }
 
 
-// Encrypted part of KRB_KDC_REP.
+// EncKDCRepPart is the encrypted part of KRB_KDC_REP.
 type EncKDCRepPart struct {
 type EncKDCRepPart struct {
 	Key           types.EncryptionKey  `asn1:"explicit,tag:0"`
 	Key           types.EncryptionKey  `asn1:"explicit,tag:0"`
 	LastReqs      []LastReq            `asn1:"explicit,tag:1"`
 	LastReqs      []LastReq            `asn1:"explicit,tag:1"`

+ 4 - 4
messages/KDCReq.go

@@ -29,7 +29,7 @@ type marshalKDCReq struct {
 	ReqBody asn1.RawValue        `asn1:"explicit,tag:4"`
 	ReqBody asn1.RawValue        `asn1:"explicit,tag:4"`
 }
 }
 
 
-// KRB_KDC_REQ struct fields.
+// KDCReqFields represents the KRB_KDC_REQ fields.
 type KDCReqFields struct {
 type KDCReqFields struct {
 	PVNO    int
 	PVNO    int
 	MsgType int
 	MsgType int
@@ -38,12 +38,12 @@ type KDCReqFields struct {
 	Renewal bool
 	Renewal bool
 }
 }
 
 
-// RFC 4120 KRB_AS_REQ: https://tools.ietf.org/html/rfc4120#section-5.4.1.
+// ASReq implements RFC 4120 KRB_AS_REQ: https://tools.ietf.org/html/rfc4120#section-5.4.1.
 type ASReq struct {
 type ASReq struct {
 	KDCReqFields
 	KDCReqFields
 }
 }
 
 
-// RFC 4120 KRB_TGS_REQ: https://tools.ietf.org/html/rfc4120#section-5.4.1.
+// TGSReq implements RFC 4120 KRB_TGS_REQ: https://tools.ietf.org/html/rfc4120#section-5.4.1.
 type TGSReq struct {
 type TGSReq struct {
 	KDCReqFields
 	KDCReqFields
 }
 }
@@ -64,7 +64,7 @@ type marshalKDCReqBody struct {
 	AdditionalTickets asn1.RawValue `asn1:"explicit,optional,tag:11"`
 	AdditionalTickets asn1.RawValue `asn1:"explicit,optional,tag:11"`
 }
 }
 
 
-// KRB_KDC_REQ request body.
+// KDCReqBody implements the KRB_KDC_REQ request body.
 type KDCReqBody struct {
 type KDCReqBody struct {
 	KDCOptions        asn1.BitString      `asn1:"explicit,tag:0"`
 	KDCOptions        asn1.BitString      `asn1:"explicit,tag:0"`
 	CName             types.PrincipalName `asn1:"explicit,optional,tag:1"`
 	CName             types.PrincipalName `asn1:"explicit,optional,tag:1"`

+ 3 - 3
messages/KRBCred.go

@@ -19,7 +19,7 @@ type marshalKRBCred struct {
 	EncPart types.EncryptedData `asn1:"explicit,tag:3"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:3"`
 }
 }
 
 
-// RFC 4120 KRB_CRED: https://tools.ietf.org/html/rfc4120#section-5.8.1.
+// KRBCred implements RFC 4120 KRB_CRED: https://tools.ietf.org/html/rfc4120#section-5.8.1.
 type KRBCred struct {
 type KRBCred struct {
 	PVNO             int
 	PVNO             int
 	MsgType          int
 	MsgType          int
@@ -28,7 +28,7 @@ type KRBCred struct {
 	DecryptedEncPart EncKrbCredPart
 	DecryptedEncPart EncKrbCredPart
 }
 }
 
 
-// Encrypted part of KRB_CRED.
+// EncKrbCredPart is the encrypted part of KRB_CRED.
 type EncKrbCredPart struct {
 type EncKrbCredPart struct {
 	TicketInfo []KrbCredInfo     `asn1:"explicit,tag:0"`
 	TicketInfo []KrbCredInfo     `asn1:"explicit,tag:0"`
 	Nouce      int               `asn1:"optional,explicit,tag:1"`
 	Nouce      int               `asn1:"optional,explicit,tag:1"`
@@ -38,7 +38,7 @@ type EncKrbCredPart struct {
 	RAddress   types.HostAddress `asn1:"optional,explicit,tag:5"`
 	RAddress   types.HostAddress `asn1:"optional,explicit,tag:5"`
 }
 }
 
 
-// KRB_CRED_INFO part of KRB_CRED.
+// KrbCredInfo is the KRB_CRED_INFO part of KRB_CRED.
 type KrbCredInfo struct {
 type KrbCredInfo struct {
 	Key       types.EncryptionKey `asn1:"explicit,tag:0"`
 	Key       types.EncryptionKey `asn1:"explicit,tag:0"`
 	PRealm    string              `asn1:"generalstring,optional,explicit,tag:1"`
 	PRealm    string              `asn1:"generalstring,optional,explicit,tag:1"`

+ 2 - 2
messages/KRBError.go

@@ -1,4 +1,4 @@
-// Package message implements Kerberos 5 message types and methods.
+// Package messages implements Kerberos 5 message types and methods.
 package messages
 package messages
 
 
 import (
 import (
@@ -13,7 +13,7 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-// RFC 4120 KRB_ERROR: https://tools.ietf.org/html/rfc4120#section-5.9.1.
+// KRBError implements RFC 4120 KRB_ERROR: https://tools.ietf.org/html/rfc4120#section-5.9.1.
 type KRBError struct {
 type KRBError struct {
 	PVNO      int                 `asn1:"explicit,tag:0"`
 	PVNO      int                 `asn1:"explicit,tag:0"`
 	MsgType   int                 `asn1:"explicit,tag:1"`
 	MsgType   int                 `asn1:"explicit,tag:1"`

+ 2 - 2
messages/KRBPriv.go

@@ -10,14 +10,14 @@ import (
 	"time"
 	"time"
 )
 )
 
 
-// RFC 4120 KRB_PRIV: https://tools.ietf.org/html/rfc4120#section-5.7.1.
+// KRBPriv implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.7.1.
 type KRBPriv struct {
 type KRBPriv struct {
 	PVNO    int                 `asn1:"explicit,tag:0"`
 	PVNO    int                 `asn1:"explicit,tag:0"`
 	MsgType int                 `asn1:"explicit,tag:1"`
 	MsgType int                 `asn1:"explicit,tag:1"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:3"`
 	EncPart types.EncryptedData `asn1:"explicit,tag:3"`
 }
 }
 
 
-// Encrypted part of KRB_PRIV.
+// EncKrbPrivPart is the encrypted part of KRB_PRIV.
 type EncKrbPrivPart struct {
 type EncKrbPrivPart struct {
 	UserData       []byte            `asn1:"explicit,tag:0"`
 	UserData       []byte            `asn1:"explicit,tag:0"`
 	Timestamp      time.Time         `asn1:"generalized,optional,explicit,tag:1"`
 	Timestamp      time.Time         `asn1:"generalized,optional,explicit,tag:1"`

+ 2 - 2
messages/KRBSafe.go

@@ -28,7 +28,7 @@ KRB-SAFE-BODY   ::= SEQUENCE {
 }
 }
 */
 */
 
 
-// RFC 4120 KRB_SAFE: https://tools.ietf.org/html/rfc4120#section-5.6.1.
+// KRBSafe implements RFC 4120 KRB_SAFE: https://tools.ietf.org/html/rfc4120#section-5.6.1.
 type KRBSafe struct {
 type KRBSafe struct {
 	PVNO     int            `asn1:"explicit,tag:0"`
 	PVNO     int            `asn1:"explicit,tag:0"`
 	MsgType  int            `asn1:"explicit,tag:1"`
 	MsgType  int            `asn1:"explicit,tag:1"`
@@ -36,7 +36,7 @@ type KRBSafe struct {
 	Cksum    types.Checksum `asn1:"explicit,tag:3"`
 	Cksum    types.Checksum `asn1:"explicit,tag:3"`
 }
 }
 
 
-// KRB_SAFE_BODY of KRB_SAFE.
+// KRBSafeBody implements the KRB_SAFE_BODY of KRB_SAFE.
 type KRBSafeBody struct {
 type KRBSafeBody struct {
 	UserData       []byte            `asn1:"explicit,tag:0"`
 	UserData       []byte            `asn1:"explicit,tag:0"`
 	Timestamp      time.Time         `asn1:"generalized,optional,explicit,tag:1"`
 	Timestamp      time.Time         `asn1:"generalized,optional,explicit,tag:1"`

+ 3 - 0
messages/Ticket.go

@@ -21,6 +21,7 @@ import (
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Section: 5.3
 // Section: 5.3
 
 
+// Ticket implements the Kerberos ticket.
 type Ticket struct {
 type Ticket struct {
 	TktVNO           int                 `asn1:"explicit,tag:0"`
 	TktVNO           int                 `asn1:"explicit,tag:0"`
 	Realm            string              `asn1:"generalstring,explicit,tag:1"`
 	Realm            string              `asn1:"generalstring,explicit,tag:1"`
@@ -29,6 +30,7 @@ type Ticket struct {
 	DecryptedEncPart EncTicketPart       `asn1:"optional"` // Not part of ASN1 bytes so marked as optional so unmarshalling works
 	DecryptedEncPart EncTicketPart       `asn1:"optional"` // Not part of ASN1 bytes so marked as optional so unmarshalling works
 }
 }
 
 
+// EncTicketPart is the encrypted part of the Ticket.
 type EncTicketPart struct {
 type EncTicketPart struct {
 	Flags             asn1.BitString          `asn1:"explicit,tag:0"`
 	Flags             asn1.BitString          `asn1:"explicit,tag:0"`
 	Key               types.EncryptionKey     `asn1:"explicit,tag:1"`
 	Key               types.EncryptionKey     `asn1:"explicit,tag:1"`
@@ -43,6 +45,7 @@ type EncTicketPart struct {
 	AuthorizationData types.AuthorizationData `asn1:"explicit,optional,tag:10"`
 	AuthorizationData types.AuthorizationData `asn1:"explicit,optional,tag:10"`
 }
 }
 
 
+// TransitedEncoding part of the ticket's encrypted part.
 type TransitedEncoding struct {
 type TransitedEncoding struct {
 	TRType   int    `asn1:"explicit,tag:0"`
 	TRType   int    `asn1:"explicit,tag:0"`
 	Contents []byte `asn1:"explicit,tag:1"`
 	Contents []byte `asn1:"explicit,tag:1"`

+ 1 - 1
mstypes/claims_set_metadata.go

@@ -5,7 +5,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/hh554073.aspx
+// ClaimsSetMetadata implements https://msdn.microsoft.com/en-us/library/hh554073.aspx
 type ClaimsSetMetadata struct {
 type ClaimsSetMetadata struct {
 	ULClaimsSetSize             uint32
 	ULClaimsSetSize             uint32
 	ClaimsSet                   []byte
 	ClaimsSet                   []byte

+ 1 - 0
mstypes/filetime.go

@@ -19,6 +19,7 @@ This gives the number of 100 nano second period from January 1, 1601, Coordinate
 
 
 const UNIX_EPOCH_DIFF = 116444736000000000
 const UNIX_EPOCH_DIFF = 116444736000000000
 
 
+// FileTime implements the Microsoft FILETIME type https://msdn.microsoft.com/en-us/library/cc230324.aspx
 type FileTime struct {
 type FileTime struct {
 	LowDateTime  uint32
 	LowDateTime  uint32
 	HighDateTime uint32
 	HighDateTime uint32

+ 2 - 2
mstypes/group_membership.go

@@ -5,7 +5,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237945.aspx
+// GroupMembership implements https://msdn.microsoft.com/en-us/library/cc237945.aspx
 // RelativeID : A 32-bit unsigned integer that contains the RID of a particular group.
 // RelativeID : A 32-bit unsigned integer that contains the RID of a particular group.
 // The possible values for the Attributes flags are identical to those specified in KERB_SID_AND_ATTRIBUTES
 // The possible values for the Attributes flags are identical to those specified in KERB_SID_AND_ATTRIBUTES
 type GroupMembership struct {
 type GroupMembership struct {
@@ -23,7 +23,7 @@ func Read_GroupMembership(b *[]byte, p *int, e *binary.ByteOrder) GroupMembershi
 	}
 	}
 }
 }
 
 
-// https://msdn.microsoft.com/en-us/library/hh536344.aspx
+// DomainGroupMembership implements https://msdn.microsoft.com/en-us/library/hh536344.aspx
 // DomainId: A SID structure that contains the SID for the domain.This member is used in conjunction with the GroupIds members to create group SIDs for the device.
 // DomainId: A SID structure that contains the SID for the domain.This member is used in conjunction with the GroupIds members to create group SIDs for the device.
 // GroupCount: A 32-bit unsigned integer that contains the number of groups within the domain to which the account belongs.
 // GroupCount: A 32-bit unsigned integer that contains the number of groups within the domain to which the account belongs.
 // GroupIds: A pointer to a list of GROUP_MEMBERSHIP structures that contain the groups to which the account belongs in the domain. The number of groups in this list MUST be equal to GroupCount.
 // GroupIds: A pointer to a list of GROUP_MEMBERSHIP structures that contain the groups to which the account belongs in the domain. The number of groups in this list MUST be equal to GroupCount.

+ 1 - 1
mstypes/kerb_sid_and_attributes.go

@@ -14,7 +14,7 @@ const (
 	//All other bits MUST be set to zero and MUST be  ignored on receipt.
 	//All other bits MUST be set to zero and MUST be  ignored on receipt.
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237947.aspx
+// KerbSidAndAttributes implements https://msdn.microsoft.com/en-us/library/cc237947.aspx
 type KerbSidAndAttributes struct {
 type KerbSidAndAttributes struct {
 	SID        RPC_SID // A pointer to an RPC_SID structure.
 	SID        RPC_SID // A pointer to an RPC_SID structure.
 	Attributes uint32
 	Attributes uint32

+ 1 - 1
mstypes/rpc_unicode_string.go

@@ -5,7 +5,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc230365.aspx
+// RPC_UnicodeString implements https://msdn.microsoft.com/en-us/library/cc230365.aspx
 type RPC_UnicodeString struct {
 type RPC_UnicodeString 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.
 	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.
 	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.

+ 2 - 2
mstypes/sid.go

@@ -7,7 +7,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc230364.aspx
+// RPC_SID implements https://msdn.microsoft.com/en-us/library/cc230364.aspx
 type RPC_SID struct {
 type RPC_SID struct {
 	Revision            uint8                      // An 8-bit unsigned integer that specifies the revision level of the SID. This value MUST be set to 0x01.
 	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.
 	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,7 +15,7 @@ type RPC_SID 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.
 	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.
 }
 }
 
 
-// https://msdn.microsoft.com/en-us/library/cc230372.aspx
+// RPC_SIDIdentifierAuthority implements https://msdn.microsoft.com/en-us/library/cc230372.aspx
 type RPC_SIDIdentifierAuthority struct {
 type RPC_SIDIdentifierAuthority struct {
 	Value []byte // 6 bytes
 	Value []byte // 6 bytes
 }
 }

+ 2 - 0
mstypes/user_session_key.go

@@ -5,10 +5,12 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
+// CypherBlock implements https://msdn.microsoft.com/en-us/library/cc237040.aspx
 type CypherBlock struct {
 type CypherBlock struct {
 	Data []byte // size = 8
 	Data []byte // size = 8
 }
 }
 
 
+// UserSessionKey implements https://msdn.microsoft.com/en-us/library/cc237080.aspx
 type UserSessionKey struct {
 type UserSessionKey struct {
 	Data []CypherBlock // size = 2
 	Data []CypherBlock // size = 2
 }
 }

+ 1 - 0
ndr/error.go

@@ -2,6 +2,7 @@ package ndr
 
 
 import "fmt"
 import "fmt"
 
 
+// Malformed implements the error interface for malformed NDR encoding errors.
 type Malformed struct {
 type Malformed struct {
 	EText string
 	EText string
 }
 }

+ 2 - 0
ndr/ndr.go

@@ -40,6 +40,7 @@ const (
 	IBM                  = 3
 	IBM                  = 3
 )
 )
 
 
+// CommonHeader implements the NDR common header: https://msdn.microsoft.com/en-us/library/cc243889.aspx
 type CommonHeader struct {
 type CommonHeader struct {
 	Version           uint8
 	Version           uint8
 	Endianness        binary.ByteOrder
 	Endianness        binary.ByteOrder
@@ -49,6 +50,7 @@ type CommonHeader struct {
 	Filler       []byte
 	Filler       []byte
 }
 }
 
 
+// PrivateHeader implements the NDR private header: https://msdn.microsoft.com/en-us/library/cc243919.aspx
 type PrivateHeader struct {
 type PrivateHeader struct {
 	ObjectBufferLength uint32
 	ObjectBufferLength uint32
 	Filler             []byte
 	Filler             []byte

+ 1 - 1
pac/client_claims.go

@@ -6,7 +6,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/hh536365.aspx
+// ClientClaimsInfo implements https://msdn.microsoft.com/en-us/library/hh536365.aspx
 type ClientClaimsInfo struct {
 type ClientClaimsInfo struct {
 	Claims mstypes.ClaimsSetMetadata
 	Claims mstypes.ClaimsSetMetadata
 }
 }

+ 1 - 1
pac/client_info.go

@@ -6,7 +6,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237951.aspx
+// ClientInfo implements https://msdn.microsoft.com/en-us/library/cc237951.aspx
 type ClientInfo struct {
 type ClientInfo struct {
 	ClientID   mstypes.FileTime // A FILETIME structure in little-endian format that contains the Kerberos initial ticket-granting ticket TGT authentication time
 	ClientID   mstypes.FileTime // A FILETIME structure in little-endian format that contains the Kerberos initial ticket-granting ticket TGT authentication time
 	NameLength uint16           // An unsigned 16-bit integer in little-endian format that specifies the length, in bytes, of the Name field.
 	NameLength uint16           // An unsigned 16-bit integer in little-endian format that specifies the length, in bytes, of the Name field.

+ 4 - 4
pac/credentials_info.go

@@ -12,7 +12,7 @@ import (
 
 
 // https://msdn.microsoft.com/en-us/library/cc237931.aspx
 // https://msdn.microsoft.com/en-us/library/cc237931.aspx
 
 
-// https://msdn.microsoft.com/en-us/library/cc237953.aspx
+// CredentialsInfo implements https://msdn.microsoft.com/en-us/library/cc237953.aspx
 type CredentialsInfo struct {
 type CredentialsInfo struct {
 	Version                      uint32 // A 32-bit unsigned integer in little-endian format that defines the version. MUST be 0x00000000.
 	Version                      uint32 // A 32-bit unsigned integer in little-endian format that defines the version. MUST be 0x00000000.
 	EType                        uint32
 	EType                        uint32
@@ -56,7 +56,7 @@ func (c *CredentialsInfo) DecryptEncPart(k types.EncryptionKey, e *binary.ByteOr
 	return nil
 	return nil
 }
 }
 
 
-// https://msdn.microsoft.com/en-us/library/cc237952.aspx
+// CredentialData implements https://msdn.microsoft.com/en-us/library/cc237952.aspx
 // This structure is encrypted prior to being encoded in any other structures.
 // This structure is encrypted prior to being encoded in any other structures.
 // Encryption is performed by first serializing the data structure via Network Data Representation (NDR) encoding, as specified in [MS-RPCE].
 // Encryption is performed by first serializing the data structure via Network Data Representation (NDR) encoding, as specified in [MS-RPCE].
 // Once serialized, the data is encrypted using the key and cryptographic system selected through the AS protocol and the KRB_AS_REP message
 // Once serialized, the data is encrypted using the key and cryptographic system selected through the AS protocol and the KRB_AS_REP message
@@ -79,7 +79,7 @@ func Read_PAC_CredentialData(b *[]byte, p *int, e *binary.ByteOrder) CredentialD
 	}
 	}
 }
 }
 
 
-// https://msdn.microsoft.com/en-us/library/cc237956.aspx
+// SECPKG_SupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237956.aspx
 type SECPKG_SupplementalCred struct {
 type SECPKG_SupplementalCred struct {
 	PackageName    mstypes.RPC_UnicodeString
 	PackageName    mstypes.RPC_UnicodeString
 	CredentialSize uint32
 	CredentialSize uint32
@@ -101,7 +101,7 @@ func Read_SECPKG_SupplementalCred(b *[]byte, p *int, e *binary.ByteOrder) SECPKG
 	}
 	}
 }
 }
 
 
-// https://msdn.microsoft.com/en-us/library/cc237949.aspx
+// NTLM_SupplementalCred implements https://msdn.microsoft.com/en-us/library/cc237949.aspx
 type NTLM_SupplementalCred struct {
 type NTLM_SupplementalCred struct {
 	Version    uint32 // A 32-bit unsigned integer that defines the credential version.This field MUST be 0x00000000.
 	Version    uint32 // A 32-bit unsigned integer that defines the credential version.This field MUST be 0x00000000.
 	Flags      uint32
 	Flags      uint32

+ 1 - 1
pac/device_claims.go

@@ -6,7 +6,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/hh554226.aspx
+// DeviceClaimsInfo implements https://msdn.microsoft.com/en-us/library/hh554226.aspx
 type DeviceClaimsInfo struct {
 type DeviceClaimsInfo struct {
 	Claims mstypes.ClaimsSetMetadata
 	Claims mstypes.ClaimsSetMetadata
 }
 }

+ 1 - 1
pac/device_info.go

@@ -6,7 +6,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/hh536402.aspx
+// DeviceInfo implements https://msdn.microsoft.com/en-us/library/hh536402.aspx
 type DeviceInfo struct {
 type DeviceInfo struct {
 	UserID            uint32                          // A 32-bit unsigned integer that contains the RID of the account. If the UserId member equals 0x00000000, the first group SID in this member is the SID for this account.
 	UserID            uint32                          // A 32-bit unsigned integer that contains the RID of the account. If the UserId member equals 0x00000000, the first group SID in this member is the SID for this account.
 	PrimaryGroupID    uint32                          // A 32-bit unsigned integer that contains the RID for the primary group to which this account belongs.
 	PrimaryGroupID    uint32                          // A 32-bit unsigned integer that contains the RID for the primary group to which this account belongs.

+ 2 - 2
pac/kerb_validation_info.go

@@ -1,4 +1,4 @@
-// Microsoft Privilege Attribute Certificate (PAC) processing.
+// Package pac implements Microsoft Privilege Attribute Certificate (PAC) processing.
 package pac
 package pac
 
 
 import (
 import (
@@ -23,7 +23,7 @@ const (
 	USERFLAG_AUTH_LMCHALLENGERESP_KEY_NTCHALLENGERESP = 18 // The LMv2 response from the LmChallengeResponseFields ([MS-NLMP] section 2.2.1.3) was used for authentication and the NTLMv2 response from the NtChallengeResponseFields ([MS-NLMP] section 2.2.1.3) was used session key generation.
 	USERFLAG_AUTH_LMCHALLENGERESP_KEY_NTCHALLENGERESP = 18 // The LMv2 response from the LmChallengeResponseFields ([MS-NLMP] section 2.2.1.3) was used for authentication and the NTLMv2 response from the NtChallengeResponseFields ([MS-NLMP] section 2.2.1.3) was used session key generation.
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237948.aspx
+// KerbValidationInfo implement https://msdn.microsoft.com/en-us/library/cc237948.aspx
 // The KERB_VALIDATION_INFO structure defines the user's logon and authorization information
 // The KERB_VALIDATION_INFO structure defines the user's logon and authorization information
 // provided by the DC. The KERB_VALIDATION_INFO structure is a subset of the
 // provided by the DC. The KERB_VALIDATION_INFO structure is a subset of the
 // NETLOGON_VALIDATION_SAM_INFO4 structure ([MS-NRPC] section 2.2.1.4.13).
 // NETLOGON_VALIDATION_SAM_INFO4 structure ([MS-NRPC] section 2.2.1.4.13).

+ 1 - 1
pac/pac_info_buffer.go

@@ -18,7 +18,7 @@ const (
 	ULTYPE_PAC_DEVICE_CLAIMS_INFO    = 15
 	ULTYPE_PAC_DEVICE_CLAIMS_INFO    = 15
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237954.aspx
+// InfoBuffer implements the PAC Info Buffer: https://msdn.microsoft.com/en-us/library/cc237954.aspx
 type InfoBuffer struct {
 type InfoBuffer struct {
 	ULType       uint32 // A 32-bit unsigned integer in little-endian format that describes the type of data present in the buffer contained at Offset.
 	ULType       uint32 // A 32-bit unsigned integer in little-endian format that describes the type of data present in the buffer contained at Offset.
 	CBBufferSize uint32 // A 32-bit unsigned integer in little-endian format that contains the size, in bytes, of the buffer in the PAC located at Offset.
 	CBBufferSize uint32 // A 32-bit unsigned integer in little-endian format that contains the size, in bytes, of the buffer in the PAC located at Offset.

+ 1 - 1
pac/pac_type.go

@@ -10,7 +10,7 @@ import (
 	"github.com/jcmturner/gokrb5/types"
 	"github.com/jcmturner/gokrb5/types"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237950.aspx
+// PACType implements: https://msdn.microsoft.com/en-us/library/cc237950.aspx
 type PACType struct {
 type PACType struct {
 	CBuffers           uint32
 	CBuffers           uint32
 	Version            uint32
 	Version            uint32

+ 1 - 1
pac/s4u_delegation_info.go

@@ -6,7 +6,7 @@ import (
 	"github.com/jcmturner/gokrb5/ndr"
 	"github.com/jcmturner/gokrb5/ndr"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/cc237944.aspx
+// S4U_DelegationInfo implements https://msdn.microsoft.com/en-us/library/cc237944.aspx
 type S4U_DelegationInfo struct {
 type S4U_DelegationInfo struct {
 	S4U2proxyTarget      mstypes.RPC_UnicodeString // The name of the principal to whom the application can forward the ticket.
 	S4U2proxyTarget      mstypes.RPC_UnicodeString // The name of the principal to whom the application can forward the ticket.
 	TransitedListSize    uint32
 	TransitedListSize    uint32

+ 1 - 0
pac/signature_data.go

@@ -30,6 +30,7 @@ The cryptographic system that is used to calculate the checksum depends on which
 - Does not support RC4-HMAC, AES128-CTS-HMAC-SHA1-96 or AES256-CTS-HMAC-SHA1-96 -->  None. The checksum operation will fail.
 - Does not support RC4-HMAC, AES128-CTS-HMAC-SHA1-96 or AES256-CTS-HMAC-SHA1-96 -->  None. The checksum operation will fail.
 */
 */
 
 
+// SignatureData implements https://msdn.microsoft.com/en-us/library/cc237955.aspx
 type SignatureData struct {
 type SignatureData struct {
 	SignatureType  uint32 // A 32-bit unsigned integer value in little-endian format that defines the cryptographic system used to calculate the checksum. This MUST be one of the following checksum types: KERB_CHECKSUM_HMAC_MD5 (signature size = 16), HMAC_SHA1_96_AES128 (signature size = 12), HMAC_SHA1_96_AES256 (signature size = 12).
 	SignatureType  uint32 // A 32-bit unsigned integer value in little-endian format that defines the cryptographic system used to calculate the checksum. This MUST be one of the following checksum types: KERB_CHECKSUM_HMAC_MD5 (signature size = 16), HMAC_SHA1_96_AES128 (signature size = 12), HMAC_SHA1_96_AES256 (signature size = 12).
 	Signature      []byte // Size depends on the type. See comment above.
 	Signature      []byte // Size depends on the type. See comment above.

+ 1 - 1
pac/upn_dns_info.go

@@ -6,7 +6,7 @@ import (
 	"sort"
 	"sort"
 )
 )
 
 
-// https://msdn.microsoft.com/en-us/library/dd240468.aspx
+// UPN_DNSInfo implements https://msdn.microsoft.com/en-us/library/dd240468.aspx
 type UPN_DNSInfo struct {
 type UPN_DNSInfo struct {
 	UPNLength           uint16 // An unsigned 16-bit integer in little-endian format that specifies the length, in bytes, of the UPN field.
 	UPNLength           uint16 // An unsigned 16-bit integer in little-endian format that specifies the length, in bytes, of the UPN field.
 	UPNOffset           uint16 // An unsigned 16-bit integer in little-endian format that contains the offset to the beginning of the buffer, in bytes, from the beginning of the UPN_DNS_INFO structure.
 	UPNOffset           uint16 // An unsigned 16-bit integer in little-endian format that contains the offset to the beginning of the buffer, in bytes, from the beginning of the UPN_DNS_INFO structure.

+ 1 - 1
service/cache.go

@@ -32,7 +32,7 @@ recently seen authenticators.*/
 // Cache for tickets received from clients keyed by fully qualified client name. Used to track replay of tickets.
 // Cache for tickets received from clients keyed by fully qualified client name. Used to track replay of tickets.
 type Cache map[string]clientEntries
 type Cache map[string]clientEntries
 
 
-// Entries for client details sent to the service.
+// clientEntries holds entries of client details sent to the service.
 type clientEntries struct {
 type clientEntries struct {
 	ReplayMap map[time.Time]replayCacheEntry
 	ReplayMap map[time.Time]replayCacheEntry
 	SeqNumber int
 	SeqNumber int

+ 6 - 6
service/http.go

@@ -14,12 +14,12 @@ import (
 type ctxKey int
 type ctxKey int
 
 
 const (
 const (
-	// The response on successful authentication always has this header. Capturing as const so we don't have marshaling and encoding overhead.
+	// SPNEGO_NegTokenResp_Krb_Accept_Completed - The response on successful authentication always has this header. Capturing as const so we don't have marshaling and encoding overhead.
 	SPNEGO_NegTokenResp_Krb_Accept_Completed = "Negotiate oRQwEqADCgEAoQsGCSqGSIb3EgECAg=="
 	SPNEGO_NegTokenResp_Krb_Accept_Completed = "Negotiate oRQwEqADCgEAoQsGCSqGSIb3EgECAg=="
-	// The response on a failed authentication always has this rejection header. Capturing as const so we don't have marshaling and encoding overhead.
+	// SPNEGO_NegTokenResp_Reject - The response on a failed authentication always has this rejection header. Capturing as const so we don't have marshaling and encoding overhead.
 	SPNEGO_NegTokenResp_Reject        = "Negotiate oQcwBaADCgEC"
 	SPNEGO_NegTokenResp_Reject        = "Negotiate oQcwBaADCgEC"
-	CREDENTIALS_CTXKEY         ctxKey = 0
-	AUTHENTICATED_CTXKEY       ctxKey = 1
+	CTXKey_Credentials         ctxKey = 0
+	CTXKey_Authenticated       ctxKey = 1
 )
 )
 
 
 // SPNEGOKRB5Authenticate is a Kerberos SPNEGO authentication HTTP handler wrapper.
 // SPNEGOKRB5Authenticate is a Kerberos SPNEGO authentication HTTP handler wrapper.
@@ -66,8 +66,8 @@ func SPNEGOKRB5Authenticate(f http.Handler, kt keytab.Keytab, sa string, l *log.
 
 
 		if ok, creds, err := ValidateAPREQ(mt.APReq, kt, sa, r.RemoteAddr); ok {
 		if ok, creds, err := ValidateAPREQ(mt.APReq, kt, sa, r.RemoteAddr); ok {
 			ctx := r.Context()
 			ctx := r.Context()
-			ctx = context.WithValue(ctx, CREDENTIALS_CTXKEY, creds)
-			ctx = context.WithValue(ctx, AUTHENTICATED_CTXKEY, true)
+			ctx = context.WithValue(ctx, CTXKey_Credentials, creds)
+			ctx = context.WithValue(ctx, CTXKey_Authenticated, true)
 			if l != nil {
 			if l != nil {
 				l.Printf("%v %s@%s - SPNEGO authentication succeeded", r.RemoteAddr, creds.Username, creds.Realm)
 				l.Printf("%v %s@%s - SPNEGO authentication succeeded", r.RemoteAddr, creds.Username, creds.Realm)
 			}
 			}

+ 1 - 1
service/http_test.go

@@ -129,6 +129,6 @@ func httpServer() *httptest.Server {
 func testAppHandler(w http.ResponseWriter, r *http.Request) {
 func testAppHandler(w http.ResponseWriter, r *http.Request) {
 	w.WriteHeader(http.StatusOK)
 	w.WriteHeader(http.StatusOK)
 	ctx := r.Context()
 	ctx := r.Context()
-	fmt.Fprintf(w, "<html>\nTEST.GOKRB5 Handler\nAuthenticed user: %s\nUser's realm: %s\n</html>", ctx.Value(CREDENTIALS_CTXKEY).(credentials.Credentials).Username, ctx.Value(CREDENTIALS_CTXKEY).(credentials.Credentials).Realm)
+	fmt.Fprintf(w, "<html>\nTEST.GOKRB5 Handler\nAuthenticed user: %s\nUser's realm: %s\n</html>", ctx.Value(CTXKey_Credentials).(credentials.Credentials).Username, ctx.Value(CTXKey_Credentials).(credentials.Credentials).Realm)
 	return
 	return
 }
 }

+ 3 - 1
types/Authenticator.go

@@ -1,4 +1,4 @@
-// Kerberos 5 data types.
+// Package types provides Kerberos 5 data types.
 package types
 package types
 
 
 import (
 import (
@@ -31,6 +31,8 @@ authorization-data      [8] AuthorizationData OPTIONAL
 
 
 */
 */
 
 
+// Authenticator - A record containing information that can be shown to have been recently generated using the session key known only by the client and server.
+// https://tools.ietf.org/html/rfc4120#section-5.5.1
 type Authenticator struct {
 type Authenticator struct {
 	AVNO              int               `asn1:"explicit,tag:0"`
 	AVNO              int               `asn1:"explicit,tag:0"`
 	CRealm            string            `asn1:"generalstring,explicit,tag:1"`
 	CRealm            string            `asn1:"generalstring,explicit,tag:1"`

+ 11 - 5
types/AuthorizationData.go

@@ -75,20 +75,19 @@ the ASN.1 structure that follows the subsection heading.
 
 
 */
 */
 
 
+// AuthorizationData implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6
 type AuthorizationData []AuthorizationDataEntry
 type AuthorizationData []AuthorizationDataEntry
 
 
+// AuthorizationDataEntry implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6
 type AuthorizationDataEntry struct {
 type AuthorizationDataEntry struct {
 	ADType int    `asn1:"explicit,tag:0"`
 	ADType int    `asn1:"explicit,tag:0"`
 	ADData []byte `asn1:"explicit,tag:1"`
 	ADData []byte `asn1:"explicit,tag:1"`
 }
 }
 
 
+// ADIfRelevant implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6.1
 type ADIfRelevant AuthorizationData
 type ADIfRelevant AuthorizationData
 
 
-type ADAndOr struct {
-	ConditionCount int               `asn1:"explicit,tag:0"`
-	Elements       AuthorizationData `asn1:"explicit,tag:1"`
-}
-
+// ADKDCIssued implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6.2
 type ADKDCIssued struct {
 type ADKDCIssued struct {
 	ADChecksum Checksum          `asn1:"explicit,tag:0"`
 	ADChecksum Checksum          `asn1:"explicit,tag:0"`
 	IRealm     string            `asn1:"optional,generalstring,explicit,tag:1"`
 	IRealm     string            `asn1:"optional,generalstring,explicit,tag:1"`
@@ -96,6 +95,13 @@ type ADKDCIssued struct {
 	Elements   AuthorizationData `asn1:"explicit,tag:3"`
 	Elements   AuthorizationData `asn1:"explicit,tag:3"`
 }
 }
 
 
+// ADAndOr implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6.3
+type ADAndOr struct {
+	ConditionCount int               `asn1:"explicit,tag:0"`
+	Elements       AuthorizationData `asn1:"explicit,tag:1"`
+}
+
+// ADMandatoryForKDC implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.6.4
 type ADMandatoryForKDC AuthorizationData
 type ADMandatoryForKDC AuthorizationData
 
 
 // Unmarshal bytes into the ADKDCIssued.
 // Unmarshal bytes into the ADKDCIssued.

+ 4 - 3
types/Cryptosystem.go

@@ -7,20 +7,21 @@ import (
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Section: 5.2.9
 // Section: 5.2.9
 
 
-// Reference: https://www.ietf.org/rfc/rfc3961.txt
-
+// EncryptedData implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.9
 type EncryptedData struct {
 type EncryptedData struct {
 	EType  int    `asn1:"explicit,tag:0"`
 	EType  int    `asn1:"explicit,tag:0"`
 	KVNO   int    `asn1:"explicit,optional,tag:1"`
 	KVNO   int    `asn1:"explicit,optional,tag:1"`
 	Cipher []byte `asn1:"explicit,tag:2"`
 	Cipher []byte `asn1:"explicit,tag:2"`
 }
 }
 
 
-//AKA KeyBlock
+// EncryptionKey implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.9
+// AKA KeyBlock
 type EncryptionKey struct {
 type EncryptionKey struct {
 	KeyType  int    `asn1:"explicit,tag:0"`
 	KeyType  int    `asn1:"explicit,tag:0"`
 	KeyValue []byte `asn1:"explicit,tag:1"`
 	KeyValue []byte `asn1:"explicit,tag:1"`
 }
 }
 
 
+// Checksum implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.9
 type Checksum struct {
 type Checksum struct {
 	CksumType int    `asn1:"explicit,tag:0"`
 	CksumType int    `asn1:"explicit,tag:0"`
 	Checksum  []byte `asn1:"explicit,tag:1"`
 	Checksum  []byte `asn1:"explicit,tag:1"`

+ 2 - 0
types/HostAddress.go

@@ -46,8 +46,10 @@ const (
 	AddrType_IPv6            = 24
 	AddrType_IPv6            = 24
 )
 )
 
 
+// HostAddresses implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.5
 type HostAddresses []HostAddress
 type HostAddresses []HostAddress
 
 
+// HostAddress implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.5
 type HostAddress struct {
 type HostAddress struct {
 	AddrType int    `asn1:"explicit,tag:0"`
 	AddrType int    `asn1:"explicit,tag:0"`
 	Address  []byte `asn1:"explicit,tag:1"`
 	Address  []byte `asn1:"explicit,tag:1"`

+ 10 - 0
types/PAData.go

@@ -9,17 +9,22 @@ import (
 	"time"
 	"time"
 )
 )
 
 
+// PAData implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7
 type PAData struct {
 type PAData struct {
 	PADataType  int    `asn1:"explicit,tag:1"`
 	PADataType  int    `asn1:"explicit,tag:1"`
 	PADataValue []byte `asn1:"explicit,tag:2"`
 	PADataValue []byte `asn1:"explicit,tag:2"`
 }
 }
 
 
+// PADataSequence implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7
 type PADataSequence []PAData
 type PADataSequence []PAData
 
 
+// MethodData implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.9.1
 type MethodData []PAData
 type MethodData []PAData
 
 
+// PAEncTimestamp implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.2
 type PAEncTimestamp EncryptedData
 type PAEncTimestamp EncryptedData
 
 
+// PAEncTSEnc implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.2
 type PAEncTSEnc struct {
 type PAEncTSEnc struct {
 	PATimestamp time.Time `asn1:"generalized,explicit,tag:0"`
 	PATimestamp time.Time `asn1:"generalized,explicit,tag:0"`
 	PAUSec      int       `asn1:"explicit,optional,tag:1"`
 	PAUSec      int       `asn1:"explicit,optional,tag:1"`
@@ -49,21 +54,26 @@ func GetPAEncTSEncAsnMarshalled() ([]byte, error) {
 	return b, nil
 	return b, nil
 }
 }
 
 
+// ETypeInfoEntry implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.4
 type ETypeInfoEntry struct {
 type ETypeInfoEntry struct {
 	EType int    `asn1:"explicit,tag:0"`
 	EType int    `asn1:"explicit,tag:0"`
 	Salt  []byte `asn1:"explicit,optional,tag:1"`
 	Salt  []byte `asn1:"explicit,optional,tag:1"`
 }
 }
 
 
+// ETypeInfo implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.4
 type ETypeInfo []ETypeInfoEntry
 type ETypeInfo []ETypeInfoEntry
 
 
+// ETypeInfo2Entry implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.5
 type ETypeInfo2Entry struct {
 type ETypeInfo2Entry struct {
 	EType     int    `asn1:"explicit,tag:0"`
 	EType     int    `asn1:"explicit,tag:0"`
 	Salt      string `asn1:"explicit,optional,generalstring,tag:1"`
 	Salt      string `asn1:"explicit,optional,generalstring,tag:1"`
 	S2KParams []byte `asn1:"explicit,optional,tag:2"`
 	S2KParams []byte `asn1:"explicit,optional,tag:2"`
 }
 }
 
 
+// ETypeInfo2 implements RFC 4120 types: https://tools.ietf.org/html/rfc4120#section-5.2.7.5
 type ETypeInfo2 []ETypeInfo2Entry
 type ETypeInfo2 []ETypeInfo2Entry
 
 
+// PAReqEncPARep PA Data Type
 type PAReqEncPARep struct {
 type PAReqEncPARep struct {
 	ChksumType int    `asn1:"explicit,tag:0"`
 	ChksumType int    `asn1:"explicit,tag:0"`
 	Chksum     []byte `asn1:"explicit,tag:1"`
 	Chksum     []byte `asn1:"explicit,tag:1"`

+ 1 - 0
types/PrincipalName.go

@@ -5,6 +5,7 @@ import "strings"
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Reference: https://www.ietf.org/rfc/rfc4120.txt
 // Section: 5.2.2
 // Section: 5.2.2
 
 
+// PrincipalName implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.2.2
 type PrincipalName struct {
 type PrincipalName struct {
 	NameType   int      `asn1:"explicit,tag:0"`
 	NameType   int      `asn1:"explicit,tag:0"`
 	NameString []string `asn1:"generalstring,explicit,tag:1"`
 	NameString []string `asn1:"generalstring,explicit,tag:1"`

+ 2 - 0
types/TypedData.go

@@ -2,11 +2,13 @@ package types
 
 
 import "github.com/jcmturner/asn1"
 import "github.com/jcmturner/asn1"
 
 
+// TypedData implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.9.1
 type TypedData struct {
 type TypedData struct {
 	DataType  int    `asn1:"explicit,tag:0"`
 	DataType  int    `asn1:"explicit,tag:0"`
 	DataValue []byte `asn1:"optional,explicit,tag:1"`
 	DataValue []byte `asn1:"optional,explicit,tag:1"`
 }
 }
 
 
+// TypedDataSequence implements RFC 4120 type: https://tools.ietf.org/html/rfc4120#section-5.9.1
 type TypedDataSequence []TypedData
 type TypedDataSequence []TypedData
 
 
 // Unmarshal bytes into the TypedDataSequence.
 // Unmarshal bytes into the TypedDataSequence.