فهرست منبع

refactor app tag

Jonathan Turner 9 سال پیش
والد
کامیت
0bd461fc52
5فایلهای تغییر یافته به همراه26 افزوده شده و 4 حذف شده
  1. 17 0
      asn1tools/tools.go
  2. 5 0
      client/APExchange.go
  3. 1 1
      messages/APReq.go
  4. 2 2
      messages/KDCReq.go
  5. 1 1
      types/Ticket.go

+ 17 - 0
asn1tools/tools.go

@@ -1,6 +1,10 @@
 // Tools for managing ASN1 marshaled data.
 package asn1tools
 
+import (
+	"github.com/jcmturner/asn1"
+)
+
 // Get the ASN1 encoded bytes for the length 'l'
 //
 // There are two forms: short (for lengths between 0 and 127), and long definite (for lengths between 0 and 2^1008 -1).
@@ -49,6 +53,18 @@ func GetNumberBytesInLengthHeader(b []byte) int {
 	return 1 + int(b[1]) - 128
 }
 
+func AddASNAppTag(b []byte, tag int) []byte {
+	r := asn1.RawValue{
+		Class:      asn1.ClassApplication,
+		IsCompound: true,
+		Tag:        tag,
+		Bytes:      b,
+	}
+	ab, _ := asn1.Marshal(r)
+	return ab
+}
+
+/*
 // The Marshal method of golang's asn1 package does not enable you to define wrapping the output in an application tag.
 // This method adds that wrapping tag.
 func AddASNAppTag(b []byte, tag int) []byte {
@@ -65,3 +81,4 @@ func AddASNAppTag(b []byte, tag int) []byte {
 	b = append([]byte{byte(96 + tag)}, b...)
 	return b
 }
+*/

+ 5 - 0
client/APExchange.go

@@ -0,0 +1,5 @@
+package client
+
+func (cl *Client) APExchange() {
+
+}

+ 1 - 1
messages/APReq.go

@@ -106,7 +106,7 @@ func (a *APReq) Marshal() ([]byte, error) {
 		return b, err
 	}
 	m.Ticket = asn1.RawValue{
-		Class:      2,
+		Class:      asn1.ClassContextSpecific,
 		IsCompound: true,
 		Tag:        3,
 		Bytes:      b,

+ 2 - 2
messages/KDCReq.go

@@ -288,7 +288,7 @@ func (k *ASReq) Marshal() ([]byte, error) {
 		return mk, err
 	}
 	m.ReqBody = asn1.RawValue{
-		Class:      2,
+		Class:      asn1.ClassContextSpecific,
 		IsCompound: true,
 		Tag:        4,
 		Bytes:      b,
@@ -314,7 +314,7 @@ func (k *TGSReq) Marshal() ([]byte, error) {
 		return mk, err
 	}
 	m.ReqBody = asn1.RawValue{
-		Class:      2,
+		Class:      asn1.ClassContextSpecific,
 		IsCompound: true,
 		Tag:        4,
 		Bytes:      b,

+ 1 - 1
types/Ticket.go

@@ -113,7 +113,7 @@ func MarshalTicketSequence(tkts []Ticket) (asn1.RawValue, error) {
 	btkts = append(asn1tools.MarshalLengthBytes(len(btkts)), btkts...)
 	btkts = append([]byte{byte(32 + asn1.TagSequence)}, btkts...)
 	raw.Bytes = btkts
-	// If we need to create teh full bytes then identifier octect is "context-specific" = 128 + "constructed" + 32 + the wrapping explicit tag (11)
+	// If we need to create teh full bytes then identifier octet is "context-specific" = 128 + "constructed" + 32 + the wrapping explicit tag (11)
 	//fmt.Fprintf(os.Stderr, "mRaw fb: %v\n", raw.FullBytes)
 	return raw, nil
 }