Generated from Manticore v1.1.5 • 201 packages. View on pkg.go.dev

messages

import "github.com/TheManticoreProject/Manticore/network/kerberos/v5/messages"

Package messages provides Kerberos protocol message types and constants as defined in RFC 4120 and related specifications.

Index

Constants

Kerberos message type constants (RFC 4120 Section 7.5.7).

const (
    // MsgTypeASReq is the Authentication Service Request message type.
    MsgTypeASReq = 10
    // MsgTypeASRep is the Authentication Service Reply message type.
    MsgTypeASRep = 11
    // MsgTypeTGSReq is the Ticket Granting Service Request message type.
    MsgTypeTGSReq = 12
    // MsgTypeTGSRep is the Ticket Granting Service Reply message type.
    MsgTypeTGSRep = 13
    // MsgTypeAPReq is the Application Request message type.
    MsgTypeAPReq = 14
    // MsgTypeAPRep is the Application Reply message type.
    MsgTypeAPRep = 15
    // MsgTypeError is the KRB-ERROR message type.
    MsgTypeError = 30
)

Principal name type constants (RFC 4120 Section 6.2).

const (
    // NameTypePrincipal is the general principal name type (NT-PRINCIPAL).
    NameTypePrincipal = 1
    // NameTypeSRVInst is the service instance name type (NT-SRV-INST).
    NameTypeSRVInst = 2
    // NameTypeSRVHST is the service with host name type (NT-SRV-HST).
    NameTypeSRVHST = 3
    // NameTypeEnterprise is the enterprise name type (NT-ENTERPRISE).
    NameTypeEnterprise = 10
)

Encryption type constants (RFC 3961, RFC 3962, RFC 4757).

const (
    // ETypeRC4HMAC is the RC4-HMAC encryption type (etype 23), per RFC 4757.
    ETypeRC4HMAC = 23
    // ETypeAES128CTSHMACSHA196 is AES-128-CTS-HMAC-SHA1-96 (etype 17), per RFC 3962.
    ETypeAES128CTSHMACSHA196 = 17
    // ETypeAES256CTSHMACSHA196 is AES-256-CTS-HMAC-SHA1-96 (etype 18), per RFC 3962.
    ETypeAES256CTSHMACSHA196 = 18
)

Pre-authentication data type constants (RFC 4120 Section 7.5.2).

const (
    // PATGSReq is the TGS-REQ pre-auth type (PA-TGS-REQ).
    PATGSReq = 1
    // PAEncTimestamp is the encrypted timestamp pre-auth type (PA-ENC-TIMESTAMP).
    PAEncTimestamp = 2
    // PAETypeInfo2 is the encryption type info version 2 pre-auth type (PA-ETYPE-INFO2).
    PAETypeInfo2 = 19
    // PAPACRequest is the Microsoft PA-PAC-REQUEST pre-auth type (MS-KILE).
    // Required by Windows KDCs to avoid silent dropping of AS-REQs without pre-auth.
    PAPACRequest = 128
)

KDC error code constants (RFC 4120 Section 7.5.9).

const (
    // ErrNone indicates no error.
    ErrNone = 0
    // ErrCPrincipalUnknown is KDC_ERR_C_PRINCIPAL_UNKNOWN: client not found in database.
    ErrCPrincipalUnknown = 6
    // ErrKDCUnavailable is KRB_ERR_GENERIC: KDC unavailable.
    ErrKDCUnavailable = 13
    // ErrPreauthRequired is KDC_ERR_PREAUTH_REQUIRED: pre-authentication required.
    ErrPreauthRequired = 25
)

AP options bit position constants (RFC 4120 Section 5.5.1).

const (
    // APOptionUseSessionKey requests use of session key instead of service key.
    APOptionUseSessionKey = 1
    // APOptionMutualAuth requests mutual authentication.
    APOptionMutualAuth = 2
)

Ticket flag bit position constants (RFC 4120 Section 2.1).

const (
    // TicketFlagForwardable marks the ticket as forwardable.
    TicketFlagForwardable = 1
    // TicketFlagForwarded marks the ticket as forwarded.
    TicketFlagForwarded = 2
    // TicketFlagProxiable marks the ticket as proxiable.
    TicketFlagProxiable = 3
    // TicketFlagProxy marks the ticket as a proxy ticket.
    TicketFlagProxy = 4
    // TicketFlagPreAuthent marks the ticket as pre-authenticated.
    TicketFlagPreAuthent = 6
    // TicketFlagInitial marks the ticket as an initial ticket.
    TicketFlagInitial = 7
    // TicketFlagRenewable marks the ticket as renewable.
    TicketFlagRenewable = 8
)

KerberosV5 is the Kerberos protocol version number.

const KerberosV5 = 5

type APReq

APReq is a Kerberos AP-REQ (Application Request) message, APPLICATION[14], as defined in RFC 4120 Section 5.5.1. It is sent by the client to a service as part of mutual authentication, and is also embedded in TGS-REQ PA-DATA (PA-TGS-REQ).

type APReq struct {
    // PVNO is the Kerberos protocol version (always 5).
    PVNO int
    // MsgType is the message type (always MsgTypeAPReq = 14).
    MsgType int
    // APOptions contains bit flags controlling the AP exchange.
    APOptions asn1.BitString
    // Ticket is the service ticket (parsed form).
    Ticket Ticket
    // TicketRaw holds raw APPLICATION[1] bytes from the KDC, used verbatim in Marshal
    // to avoid re-encoding the ticket (which might differ from the KDC's original encoding).
    TicketRaw []byte
    // Authenticator is the encrypted Authenticator proving the client's identity.
    Authenticator EncryptedData
}

func (*APReq) Marshal

func (r *APReq) Marshal() ([]byte, error)

Marshal encodes the AP-REQ as an ASN.1 APPLICATION[14] wrapped SEQUENCE.

func (*APReq) Unmarshal

func (r *APReq) Unmarshal(data []byte) (int, error)

Unmarshal decodes an AP-REQ from an ASN.1 APPLICATION[14] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type ASRep

ASRep is a Kerberos AS-REP (Authentication Service Reply) message, APPLICATION[11], as defined in RFC 4120 Section 5.4.2. It is sent by the KDC in response to a successful AS-REQ.

type ASRep struct {
    // PVNO is the Kerberos protocol version (always 5).
    PVNO int
    // MsgType is the message type (always MsgTypeASRep = 11).
    MsgType int
    // PAData contains pre-authentication data (rarely set in AS-REP).
    PAData []PAData
    // CRealm is the realm of the client.
    CRealm string
    // CName is the client's principal name as returned by the KDC.
    CName PrincipalName
    // Ticket is the issued Ticket Granting Ticket (parsed).
    Ticket Ticket
    // TicketRaw holds the raw APPLICATION[1] ticket bytes as received from the KDC.
    // Use these verbatim in AP-REQ to avoid re-encoding differences.
    TicketRaw []byte
    // EncPart is the encrypted reply body, decryptable with the client's key.
    EncPart EncryptedData
}

func (*ASRep) Marshal

func (r *ASRep) Marshal() ([]byte, error)

Marshal encodes the AS-REP as an ASN.1 APPLICATION[11] wrapped SEQUENCE.

func (*ASRep) Unmarshal

func (r *ASRep) Unmarshal(data []byte) (int, error)

Unmarshal decodes an AS-REP from an ASN.1 APPLICATION[11] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type ASReq

ASReq is a Kerberos AS-REQ (Authentication Service Request) message, APPLICATION[10], as defined in RFC 4120 Section 5.4.1. It is sent by the client to the KDC to request a TGT.

type ASReq struct {
    // PVNO is the Kerberos protocol version (always 5).
    PVNO int
    // MsgType is the message type (always MsgTypeASReq = 10).
    MsgType int
    // PAData contains pre-authentication data (e.g. PA-ENC-TIMESTAMP).
    PAData []PAData
    // ReqBody is the KDC request body containing client/server names and options.
    ReqBody KDCReqBody
}

func (*ASReq) Marshal

func (r *ASReq) Marshal() ([]byte, error)

Marshal encodes the AS-REQ as an ASN.1 APPLICATION[10] wrapped SEQUENCE.

func (*ASReq) Unmarshal

func (r *ASReq) Unmarshal(data []byte) (int, error)

Unmarshal decodes an AS-REQ from an ASN.1 APPLICATION[10] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type Authenticator

Authenticator is a Kerberos Authenticator (APPLICATION[2]), as defined in RFC 4120 Section 5.5.1. It is encrypted within an AP-REQ and proves the client’s identity.

type Authenticator struct {
    // AVno is the Authenticator version number (always 5).
    AVno int
    // CRealm is the realm of the client.
    CRealm string
    // CName is the client's principal name.
    CName PrincipalName
    // CUSec is the microseconds component of CTime.
    CUSec int
    // CTime is the client's current time (must match server time within clock skew).
    CTime time.Time
    // SubKey is an optional client-chosen sub-session key.
    SubKey *EncryptionKey
    // SeqNumber is the optional sequence number.
    SeqNumber int
}

func (*Authenticator) Marshal

func (a *Authenticator) Marshal() ([]byte, error)

Marshal encodes the Authenticator as an ASN.1 APPLICATION[2] wrapped SEQUENCE.

func (*Authenticator) Unmarshal

func (a *Authenticator) Unmarshal(data []byte) (int, error)

Unmarshal decodes an Authenticator from an ASN.1 APPLICATION[2] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type AuthorizationData

AuthorizationData is an authorization-data element, as defined in RFC 4120 Section 5.2.6.

type AuthorizationData struct {
    // ADType identifies the authorization-data type.
    ADType int `asn1:"explicit,tag:0"`
    // ADData contains the type-specific authorization data.
    ADData []byte `asn1:"explicit,tag:1"`
}

type Checksum

Checksum contains a cryptographic checksum as defined in RFC 4120 Section 5.2.9.

type Checksum struct {
    // CKSumType identifies the checksum algorithm.
    CKSumType int `asn1:"explicit,tag:0"`
    // Checksum contains the raw checksum bytes.
    Checksum []byte `asn1:"explicit,tag:1"`
}

type ETypeInfo2

ETypeInfo2 is a sequence of ETypeInfo2Entry values returned in PA-ETYPE-INFO2. The KDC uses this to tell the client which encryption types and salts to use.

type ETypeInfo2 []ETypeInfo2Entry

func (ETypeInfo2) Marshal

func (e ETypeInfo2) Marshal() ([]byte, error)

Marshal encodes ETypeInfo2 as an ASN.1 SEQUENCE OF.

func (*ETypeInfo2) Unmarshal

func (e *ETypeInfo2) Unmarshal(data []byte) (int, error)

Unmarshal decodes ETypeInfo2 from an ASN.1 SEQUENCE OF. Returns the number of bytes consumed from data.

type ETypeInfo2Entry

ETypeInfo2Entry is a single entry in a PA-ETYPE-INFO2 pre-authentication element, as defined in RFC 4120 Section 5.2.7.5. It specifies an encryption type and optional salt/parameters for string-to-key derivation.

type ETypeInfo2Entry struct {
    // EType identifies the encryption type.
    EType int `asn1:"explicit,tag:0"`
    // Salt is the optional salt string for string-to-key derivation.
    Salt string `asn1:"explicit,tag:1,optional,utf8"`
    // S2KParams contains optional string-to-key parameters (e.g. iteration count).
    S2KParams []byte `asn1:"explicit,tag:2,optional"`
}

type EncASRepPart

EncASRepPart is the decrypted enc-part of an AS-REP (APPLICATION 25), as defined in RFC 4120 Section 5.4.2. It contains the session key and ticket metadata.

type EncASRepPart struct {
    // Key is the session key for use with the issued ticket.
    Key EncryptionKey
    // Nonce must match the nonce in the AS-REQ.
    Nonce int
    // Flags contains the ticket flags.
    Flags asn1.BitString
    // AuthTime is the time the client was authenticated.
    AuthTime time.Time
    // StartTime is the ticket's start time (optional).
    StartTime time.Time
    // EndTime is the ticket's expiry time.
    EndTime time.Time
    // RenewTill is the renewable lifetime end time (optional).
    RenewTill time.Time
    // SRealm is the realm of the service.
    SRealm string
    // SName is the service principal name.
    SName PrincipalName
}

func (*EncASRepPart) Unmarshal

func (e *EncASRepPart) Unmarshal(data []byte) (int, error)

Unmarshal decodes an EncASRepPart from an ASN.1 APPLICATION[25] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type EncTGSRepPart

EncTGSRepPart is the decrypted enc-part of a TGS-REP (APPLICATION 26), as defined in RFC 4120 Section 5.4.2. It has the same structure as EncASRepPart but a different APPLICATION tag.

type EncTGSRepPart struct {
    // Key is the session key for use with the service ticket.
    Key EncryptionKey
    // Nonce must match the nonce in the TGS-REQ.
    Nonce int
    // Flags contains the ticket flags.
    Flags asn1.BitString
    // AuthTime is the time of original authentication.
    AuthTime time.Time
    // StartTime is the ticket's start time (optional).
    StartTime time.Time
    // EndTime is the ticket's expiry time.
    EndTime time.Time
    // RenewTill is the renewable lifetime end time (optional).
    RenewTill time.Time
    // SRealm is the realm of the service.
    SRealm string
    // SName is the service principal name.
    SName PrincipalName
}

func (*EncTGSRepPart) Unmarshal

func (e *EncTGSRepPart) Unmarshal(data []byte) (int, error)

Unmarshal decodes an EncTGSRepPart from an ASN.1 APPLICATION[26] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type EncryptedData

EncryptedData holds a Kerberos encrypted blob, as defined in RFC 4120 Section 5.2.9. The actual encryption algorithm and key are identified by EType.

type EncryptedData struct {
    // EType identifies the encryption algorithm used.
    EType int `asn1:"explicit,tag:0"`
    // KvNo is the optional key version number.
    KvNo int `asn1:"explicit,tag:1,optional"`
    // Cipher contains the encrypted bytes.
    Cipher []byte `asn1:"explicit,tag:2"`
}

type EncryptionKey

EncryptionKey holds a Kerberos encryption key as defined in RFC 4120 Section 5.2.9.

type EncryptionKey struct {
    // KeyType identifies the encryption algorithm.
    KeyType int `asn1:"explicit,tag:0"`
    // KeyValue contains the raw key bytes.
    KeyValue []byte `asn1:"explicit,tag:1"`
}

type HostAddress

HostAddress represents a network address, as defined in RFC 4120 Section 5.2.5.

type HostAddress struct {
    // AddrType identifies the address type (e.g. 2 = IPv4, 24 = IPv6).
    AddrType int `asn1:"explicit,tag:0"`
    // Address contains the raw address bytes.
    Address []byte `asn1:"explicit,tag:1"`
}

type KDCOptions

KDCOptions is a bit string encoding KDC request options flags, as defined in RFC 4120 Section 5.4.1.

type KDCOptions = asn1.BitString

type KDCReqBody

KDCReqBody is the body of a KDC request (AS-REQ or TGS-REQ), as defined in RFC 4120 Section 5.4.1.

type KDCReqBody struct {
    // KDCOptions contains bit flags controlling the KDC request behavior.
    KDCOptions asn1.BitString `asn1:"explicit,tag:0"`
    // CName is the client principal name (present in AS-REQ, absent in TGS-REQ).
    CName PrincipalName `asn1:"explicit,tag:1,optional"`
    // Realm is the realm for the request (crealm in AS-REQ, srealm in TGS-REQ).
    Realm string `asn1:"explicit,tag:2,generalstring"`
    // SName is the server principal name being requested.
    SName PrincipalName `asn1:"explicit,tag:3,optional"`
    // From is the requested start time for the ticket (optional).
    From time.Time `asn1:"explicit,tag:4,optional,generalized"`
    // Till is the requested expiry time for the ticket.
    Till time.Time `asn1:"explicit,tag:5,generalized"`
    // RTime is the requested renewable lifetime end time (optional).
    RTime time.Time `asn1:"explicit,tag:6,optional,generalized"`
    // Nonce is a random number used to detect replays.
    Nonce int `asn1:"explicit,tag:7"`
    // EType lists the client's supported encryption types, in preference order.
    EType []int `asn1:"explicit,tag:8"`
    // Addresses restricts the ticket to specific network addresses (optional).
    Addresses []HostAddress `asn1:"explicit,tag:9,optional"`
    // EncAuthData contains encrypted authorization data (optional, TGS-REQ).
    EncAuthData EncryptedData `asn1:"explicit,tag:10,optional"`
    // AdditTickets contains additional tickets (optional, for TGS renewal/forwarding).
    AdditTickets []Ticket `asn1:"explicit,tag:11,optional"`
}

type KRBError

KRBError is a Kerberos KRB-ERROR message (APPLICATION[30]), as defined in RFC 4120 Section 5.9.1. It is sent by the KDC when an error occurs processing a request.

type KRBError struct {
    // PVNO is the Kerberos protocol version.
    PVNO int
    // MsgType is the message type (MsgTypeError = 30).
    MsgType int
    // STime is the server time at which the error occurred.
    STime time.Time
    // SUSec is the microsecond component of STime.
    SUSec int
    // ErrorCode identifies the specific error.
    ErrorCode int
    // Realm is the server's realm.
    Realm string
    // SName is the server's principal name.
    SName PrincipalName
    // EText is a human-readable error description.
    EText string
    // EData contains additional structured error information.
    EData []byte
}

func (*KRBError) Error

func (e *KRBError) Error() string

Error implements the error interface, returning a description of the KRB error.

func (*KRBError) Marshal

func (e *KRBError) Marshal() ([]byte, error)

Marshal encodes the KRBError as an ASN.1 APPLICATION[30] wrapped SEQUENCE.

func (*KRBError) Unmarshal

func (e *KRBError) Unmarshal(data []byte) (int, error)

Unmarshal decodes a KRBError from an ASN.1 APPLICATION[30] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type KerberosTime

KerberosTime represents a Kerberos timestamp (GeneralizedTime without fractional seconds). It is stored as a standard Go time.Time value.

type KerberosTime = time.Time

type LastReq

LastReq is a last-request entry as defined in RFC 4120 Section 5.4.2.

type LastReq struct {
    // LRType identifies the type of last request.
    LRType int `asn1:"explicit,tag:0"`
    // LRValue is the time of the last request.
    LRValue time.Time `asn1:"explicit,tag:1,generalized"`
}

type PAData

PAData is a pre-authentication data element, as defined in RFC 4120 Section 5.2.7.

type PAData struct {
    // PADataType identifies the pre-authentication data type.
    PADataType int `asn1:"explicit,tag:1"`
    // PADataValue contains the pre-authentication data bytes.
    PADataValue []byte `asn1:"explicit,tag:2"`
}

type PAEncTSEnc

PAEncTSEnc is the plaintext body of a PA-ENC-TIMESTAMP pre-authentication element, as defined in RFC 4120 Section 5.2.7.2. It is encrypted with the client’s key and used to prove knowledge of the password.

type PAEncTSEnc struct {
    // PATimestamp is the client's current time.
    PATimestamp time.Time `asn1:"explicit,tag:0,generalized"`
    // PAUSec is the optional microseconds component of PATimestamp.
    PAUSec int `asn1:"explicit,tag:1,optional"`
}

func (*PAEncTSEnc) Marshal

func (p *PAEncTSEnc) Marshal() ([]byte, error)

Marshal encodes PAEncTSEnc as a plain ASN.1 SEQUENCE (no APPLICATION wrapper).

func (*PAEncTSEnc) Unmarshal

func (p *PAEncTSEnc) Unmarshal(data []byte) (int, error)

Unmarshal decodes PAEncTSEnc from a plain ASN.1 SEQUENCE. Returns the number of bytes consumed from data.

type PrincipalName

PrincipalName contains a name-type and a sequence of name strings, as defined in RFC 4120 Section 5.2.2.

type PrincipalName struct {
    // NameType specifies the type of name (e.g. NT-PRINCIPAL = 1).
    NameType int `asn1:"explicit,tag:0"`
    // NameString contains the sequence of name components.
    NameString []string `asn1:"explicit,tag:1"`
}

type PrincipalNameMarshal

PrincipalNameMarshal is the wire representation of PrincipalName for marshaling. It uses []asn1.RawValue (GeneralString) instead of []string, which Go’s asn1 would incorrectly encode as PrintableString.

type PrincipalNameMarshal struct {
    NameType   int             `asn1:"explicit,tag:0"`
    NameString []asn1.RawValue `asn1:"explicit,tag:1"`
}

func MarshalPrincipalName

func MarshalPrincipalName(pn PrincipalName) PrincipalNameMarshal

MarshalPrincipalName converts a PrincipalName to its GeneralString-encoded form.

type TGSRep

TGSRep is a Kerberos TGS-REP (Ticket Granting Service Reply) message, APPLICATION[13], as defined in RFC 4120 Section 5.4.2. It is sent by the TGS in response to a successful TGS-REQ.

type TGSRep struct {
    // PVNO is the Kerberos protocol version (always 5).
    PVNO int
    // MsgType is the message type (always MsgTypeTGSRep = 13).
    MsgType int
    // PAData contains pre-authentication data (rarely set in TGS-REP).
    PAData []PAData
    // CRealm is the realm of the client.
    CRealm string
    // CName is the client's principal name.
    CName PrincipalName
    // Ticket is the issued service ticket (parsed).
    Ticket Ticket
    // TicketRaw holds the raw APPLICATION[1] ticket bytes as received from the
    // KDC. Use these verbatim when embedding the ticket in an AP-REQ to avoid
    // re-encoding differences between Go's encoding/asn1 and the KDC's original
    // DER output (see ASRep.TicketRaw for the matching field on AS-REP).
    TicketRaw []byte
    // EncPart is the encrypted reply body, decryptable with the TGT session key.
    EncPart EncryptedData
}

func (*TGSRep) Marshal

func (r *TGSRep) Marshal() ([]byte, error)

Marshal encodes the TGS-REP as an ASN.1 APPLICATION[13] wrapped SEQUENCE.

func (*TGSRep) Unmarshal

func (r *TGSRep) Unmarshal(data []byte) (int, error)

Unmarshal decodes a TGS-REP from an ASN.1 APPLICATION[13] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type TGSReq

TGSReq is a Kerberos TGS-REQ (Ticket Granting Service Request) message, APPLICATION[12], as defined in RFC 4120 Section 5.4.1. It is sent by the client to the TGS to request a service ticket. The PA-TGS-REQ pre-authentication data must contain an AP-REQ with the TGT.

type TGSReq struct {
    // PVNO is the Kerberos protocol version (always 5).
    PVNO int
    // MsgType is the message type (always MsgTypeTGSReq = 12).
    MsgType int
    // PAData contains the PA-TGS-REQ with the AP-REQ carrying the TGT.
    PAData []PAData
    // ReqBody is the request body specifying the requested service ticket parameters.
    ReqBody KDCReqBody
}

func (*TGSReq) Marshal

func (r *TGSReq) Marshal() ([]byte, error)

Marshal encodes the TGS-REQ as an ASN.1 APPLICATION[12] wrapped SEQUENCE.

func (*TGSReq) Unmarshal

func (r *TGSReq) Unmarshal(data []byte) (int, error)

Unmarshal decodes a TGS-REQ from an ASN.1 APPLICATION[12] wrapped SEQUENCE. Returns the number of bytes consumed from data.

type Ticket

Ticket is a Kerberos ticket (APPLICATION[1]), as defined in RFC 4120 Section 5.3. It carries an encrypted session key and authorization data for a service principal.

type Ticket struct {
    // TktVno is the Kerberos version number embedded in the ticket (always 5).
    TktVno int
    // Realm is the realm of the service principal.
    Realm string
    // SName is the name of the service principal.
    SName PrincipalName
    // EncPart is the encrypted portion of the ticket.
    EncPart EncryptedData
}

func (*Ticket) Marshal

func (t *Ticket) Marshal() ([]byte, error)

Marshal encodes the Ticket as an ASN.1 APPLICATION[1] wrapped SEQUENCE.

func (*Ticket) Unmarshal

func (t *Ticket) Unmarshal(data []byte) (int, error)

Unmarshal decodes a Ticket from an ASN.1 APPLICATION[1] wrapped SEQUENCE. Returns the number of bytes consumed from data.