Authenticator.go 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package types
  2. import (
  3. "fmt"
  4. "github.com/jcmturner/asn1"
  5. "github.com/jcmturner/gokrb5/iana/asnAppTag"
  6. "time"
  7. )
  8. /*Authenticator ::= [APPLICATION 2] SEQUENCE {
  9. authenticator-vno [0] INTEGER (5),
  10. crealm [1] Realm,
  11. cname [2] PrincipalName,
  12. cksum [3] Checksum OPTIONAL,
  13. cusec [4] Microseconds,
  14. ctime [5] KerberosTime,
  15. subkey [6] EncryptionKey OPTIONAL,
  16. seq-number [7] UInt32 OPTIONAL,
  17. authorization-data [8] AuthorizationData OPTIONAL
  18. }
  19. cksum
  20. This field contains a checksum of the application data that
  21. accompanies the KRB_AP_REQ, computed using a key usage value of 10
  22. in normal application exchanges, or 6 when used in the TGS-REQ
  23. PA-TGS-REQ AP-DATA field.
  24. */
  25. type Authenticator struct {
  26. AVNO int `asn1:"explicit,tag:0"`
  27. CRealm string `asn1:"generalstring,explicit,tag:1"`
  28. CName PrincipalName `asn1:"explicit,tag:2"`
  29. Cksum Checksum `asn1:"explicit,optional,tag:3"`
  30. Cusec int `asn1:"explicit,tag:4"`
  31. CTime time.Time `asn1:"generalized,explicit,tag:5"`
  32. SubKey EncryptionKey `asn1:"explicit,optional,tag:6"`
  33. SeqNumber int `asn1:"explicit,optional,tag:7"`
  34. AuthorizationData AuthorizationData `asn1:"explicit,optional,tag:8"`
  35. }
  36. func (a *Authenticator) Unmarshal(b []byte) error {
  37. _, err := asn1.UnmarshalWithParams(b, a, fmt.Sprintf("application,explicit,tag:%v", asnAppTag.Authenticator))
  38. return err
  39. }