소스 검색

S4UDelegationInfo using ndr decoder

Jonathan Turner 7 년 전
부모
커밋
fe9c54a4f9
1개의 변경된 파일9개의 추가작업 그리고 38개의 파일을 삭제
  1. 9 38
      pac/s4u_delegation_info.go

+ 9 - 38
pac/s4u_delegation_info.go

@@ -1,55 +1,26 @@
 package pac
 package pac
 
 
 import (
 import (
+	"bytes"
 	"fmt"
 	"fmt"
 
 
-	"gopkg.in/jcmturner/gokrb5.v5/mstypes"
-	"gopkg.in/jcmturner/rpc.v0/ndr"
+	"gopkg.in/jcmturner/rpc.v1/mstypes"
+	"gopkg.in/jcmturner/rpc.v1/ndr"
 )
 )
 
 
 // S4UDelegationInfo implements https://msdn.microsoft.com/en-us/library/cc237944.aspx
 // S4UDelegationInfo implements https://msdn.microsoft.com/en-us/library/cc237944.aspx
 type S4UDelegationInfo struct {
 type S4UDelegationInfo struct {
 	S4U2proxyTarget      mstypes.RPCUnicodeString // 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
 	TransitedListSize    uint32
-	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
+	S4UTransitedServices []mstypes.RPCUnicodeString `ndr:"pointer,conformant"` // 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
 // Unmarshal bytes into the S4UDelegationInfo struct
-func (k *S4UDelegationInfo) Unmarshal(b []byte) error {
-	ch, _, p, err := ndr.ReadHeaders(&b)
+func (k *S4UDelegationInfo) Unmarshal(b []byte) (err error) {
+	dec := ndr.NewDecoder(bytes.NewReader(b))
+	err = dec.Decode(k)
 	if err != nil {
 	if err != nil {
-		return fmt.Errorf("error parsing byte stream headers: %v", err)
+		err = fmt.Errorf("error unmarshaling S4UDelegationInfo: %v", err)
 	}
 	}
-	e := &ch.Endianness
-
-	//The next 4 bytes are an RPC unique pointer referent. We just skip these
-	p += 4
-
-	k.S4U2proxyTarget, err = mstypes.ReadRPCUnicodeString(&b, &p, e)
-	if err != nil {
-		return err
-	}
-	k.TransitedListSize = ndr.ReadUint32(&b, &p, e)
-	if k.TransitedListSize > 0 {
-		ts := make([]mstypes.RPCUnicodeString, k.TransitedListSize, k.TransitedListSize)
-		for i := range ts {
-			ts[i], err = mstypes.ReadRPCUnicodeString(&b, &p, e)
-			if err != nil {
-				return err
-			}
-		}
-		for i := range ts {
-			ts[i].UnmarshalString(&b, &p, e)
-		}
-		k.S4UTransitedServices = ts
-	}
-
-	//Check that there is only zero padding left
-	for _, v := range b[p:] {
-		if v != 0 {
-			return ndr.Malformed{EText: "non-zero padding left over at end of data stream"}
-		}
-	}
-
-	return nil
+	return
 }
 }