| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package messages
- import (
- "fmt"
- "github.com/jcmturner/asn1"
- "github.com/jcmturner/gokrb5/iana/asnAppTag"
- "github.com/jcmturner/gokrb5/iana/msgtype"
- "github.com/jcmturner/gokrb5/types"
- "time"
- )
- /*
- AP-REP ::= [APPLICATION 15] SEQUENCE {
- pvno [0] INTEGER (5),
- msg-type [1] INTEGER (15),
- enc-part [2] EncryptedData -- EncAPRepPart
- }
- EncAPRepPart ::= [APPLICATION 27] SEQUENCE {
- ctime [0] KerberosTime,
- cusec [1] Microseconds,
- subkey [2] EncryptionKey OPTIONAL,
- seq-number [3] UInt32 OPTIONAL
- }
- */
- type APRep struct {
- PVNO int `asn1:"explicit,tag:0"`
- MsgType int `asn1:"explicit,tag:1"`
- EncPart types.EncryptedData `asn1:"explicit,tag:2"`
- }
- type EncAPRepPart struct {
- CTime time.Time `asn1:"generalized,explicit,tag:0"`
- Cusec int `asn1:"explicit,tag:1"`
- Subkey types.EncryptionKey `asn1:"optional,explicit,tag:2"`
- SequenceNumber int `asn1:"optional,explicit,tag:3"`
- }
- func (a *APRep) Unmarshal(b []byte) error {
- _, err := asn1.UnmarshalWithParams(b, a, fmt.Sprintf("application,explicit,tag:%v", asnAppTag.APREP))
- if err != nil {
- return err
- }
- expectedMsgType := msgtype.KRB_AP_REP
- if a.MsgType != expectedMsgType {
- return fmt.Errorf("Message ID does not indicate a KRB_AP_REP. Expected: %v; Actual: %v", expectedMsgType, a.MsgType)
- }
- return nil
- }
- func (a *EncAPRepPart) Unmarshal(b []byte) error {
- _, err := asn1.UnmarshalWithParams(b, a, fmt.Sprintf("application,explicit,tag:%v", asnAppTag.EncAPRepPart))
- if err != nil {
- return err
- }
- return nil
- }
|