Bladeren bron

constants tidy

Jonathan Turner 9 jaren geleden
bovenliggende
commit
bd7edac7dc
3 gewijzigde bestanden met toevoegingen van 10 en 35 verwijderingen
  1. 5 2
      messages/KDCRep_test.go
  2. 5 3
      messages/KDCReq.go
  3. 0 30
      types/constants.go

+ 5 - 2
messages/KDCRep_test.go

@@ -3,6 +3,7 @@ package messages
 import (
 	"encoding/hex"
 	"fmt"
+	"github.com/jcmturner/gokrb5/credentials"
 	"github.com/jcmturner/gokrb5/iana/etype"
 	"github.com/jcmturner/gokrb5/iana/msgtype"
 	"github.com/jcmturner/gokrb5/keytab"
@@ -248,7 +249,8 @@ func TestUnmarshalASRepDecodeAndDecrypt(t *testing.T) {
 	if err != nil {
 		t.Fatalf("keytab parse error: %v\n", err)
 	}
-	err = asRep.DecryptEncPartWithKeytab(kt)
+	cred := credentials.NewCredentials(test_user)
+	err = asRep.DecryptEncPart(cred.WithKeytab(kt))
 	if err != nil {
 		t.Fatalf("Decryption of AS_REP EncPart failed: %v", err)
 	}
@@ -295,7 +297,8 @@ func TestUnmarshalASRepDecodeAndDecrypt_withPassword(t *testing.T) {
 	assert.Equal(t, 1, asRep.Ticket.EncPart.KVNO, "Ticket encrypted part KVNO not as expected")
 	assert.Equal(t, etype.AES256_CTS_HMAC_SHA1_96, asRep.EncPart.EType, "Etype of encrypted part not as expected")
 	assert.Equal(t, 0, asRep.EncPart.KVNO, "Encrypted part KVNO not as expected")
-	err = asRep.DecryptEncPartWithPassword(test_user_password)
+	cred := credentials.NewCredentials(test_user)
+	err = asRep.DecryptEncPart(cred.WithPassword(test_user_password))
 	if err != nil {
 		t.Fatalf("Decryption of AS_REP EncPart failed: %v", err)
 	}

+ 5 - 3
messages/KDCReq.go

@@ -11,6 +11,8 @@ import (
 	"github.com/jcmturner/gokrb5/iana"
 	"github.com/jcmturner/gokrb5/iana/asnAppTag"
 	"github.com/jcmturner/gokrb5/iana/msgtype"
+	"github.com/jcmturner/gokrb5/iana/nametype"
+	"github.com/jcmturner/gokrb5/iana/patype"
 	"github.com/jcmturner/gokrb5/types"
 	"math/rand"
 	"time"
@@ -67,7 +69,7 @@ type KDCReqBody struct {
 func NewASReq(c *config.Config, username string) ASReq {
 	pas := types.PADataSequence{
 		types.PAData{
-			PADataType: types.PA_REQ_ENC_PA_REP,
+			PADataType: patype.PA_REQ_ENC_PA_REP,
 		},
 	}
 	nonce := int(rand.Int31())
@@ -81,11 +83,11 @@ func NewASReq(c *config.Config, username string) ASReq {
 			KDCOptions: c.LibDefaults.Kdc_default_options,
 			Realm:      c.LibDefaults.Default_realm,
 			CName: types.PrincipalName{
-				NameType:   types.KRB_NT_PRINCIPAL,
+				NameType:   nametype.KRB_NT_PRINCIPAL,
 				NameString: []string{username},
 			},
 			SName: types.PrincipalName{
-				NameType:   types.KRB_NT_SRV_INST,
+				NameType:   nametype.KRB_NT_SRV_INST,
 				NameString: []string{"krbtgt", c.LibDefaults.Default_realm},
 			},
 			Till:  t.Add(c.LibDefaults.Ticket_lifetime),

+ 0 - 30
types/constants.go

@@ -1,30 +0,0 @@
-package types
-
-const (
-	//PA Types
-	PA_TGS_REQ       = 1
-	PA_ENC_TIMESTAMP = 2
-	PA_PW_SALT       = 3
-	PA_ETYPE_INFO    = 11
-	PA_ETYPE_INFO2   = 19
-	//From RFC 6113
-	PA_FX_COOKIE           = 133
-	PA_AUTHENTICATION_SET  = 134
-	PA_AUTH_SET_SELECTED   = 135
-	PA_FX_FAST             = 136
-	PA_FX_ERROR            = 137
-	PA_ENCRYPTED_CHALLENGE = 138
-	//RFC6806 Section 11
-	PA_REQ_ENC_PA_REP = 149
-
-	//Name types
-	KRB_NT_UNKNOWN        = 0  //Name type not known
-	KRB_NT_PRINCIPAL      = 1  //Just the name of the principal as in DCE,  or for users
-	KRB_NT_SRV_INST       = 2  //Service and other unique instance (krbtgt)
-	KRB_NT_SRV_HST        = 3  //Service with host name as instance (telnet, rcommands)
-	KRB_NT_SRV_XHST       = 4  //Service with host as remaining components
-	KRB_NT_UID            = 5  //Unique ID
-	KRB_NT_X500_PRINCIPAL = 6  //Encoded X.509 Distinguished name [RFC2253]
-	KRB_NT_SMTP_NAME      = 7  //Name in form of SMTP email name (e.g., user@example.com)
-	KRB_NT_ENTERPRISE     = 10 //Enterprise name; may be mapped to principal name
-)