Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/rex/proto/kerberos/model/ap_req.rb
Views: 11766
# -*- coding: binary -*-12module Rex3module Proto4module Kerberos5module Model6# This class provides a representation of a KRB_AP_REQ definition, containing the Kerberos protocol version number,7# the message type KRB_AP_REQ, an options field to indicate any options in use, and the ticket and authenticator8# themselves9class ApReq < Element10# @!attribute pvno11# @return [Integer] The protocol version number12attr_accessor :pvno13# @!attribute msg_type14# @return [Integer] The type of the protocol message15attr_accessor :msg_type16# @!attribute options17# @return [Integer] request options, affects processing18attr_accessor :options19# @!attribute ticket20# @return [Rex::Proto::Kerberos::Model::Ticket] The ticket authenticating the client to the server21attr_accessor :ticket22# @!attribute authenticator23# @return [Rex::Proto::Kerberos::Model::EncryptedData] This contains the authenticator, which includes the24# client's choice of a subkey25attr_accessor :authenticator2627# Rex::Proto::Kerberos::Model::ApReq decoding isn't supported28#29# @raise [NotImplementedError]30def decode(input)31raise ::NotImplementedError, 'AP-REQ decoding not supported'32end3334# Encodes the Rex::Proto::Kerberos::Model::ApReq into an ASN.1 String35#36# @return [String]37def encode38to_asn1.to_der39end4041# @return [OpenSSL::ASN1::ASN1Data] The ap_req ASN1Data42def to_asn143elems = []4445elems << OpenSSL::ASN1::ASN1Data.new([encode_pvno], 0, :CONTEXT_SPECIFIC)46elems << OpenSSL::ASN1::ASN1Data.new([encode_msg_type], 1, :CONTEXT_SPECIFIC)47elems << OpenSSL::ASN1::ASN1Data.new([encode_options], 2, :CONTEXT_SPECIFIC)48elems << OpenSSL::ASN1::ASN1Data.new([encode_ticket], 3, :CONTEXT_SPECIFIC)49elems << OpenSSL::ASN1::ASN1Data.new([encode_authenticator], 4, :CONTEXT_SPECIFIC)5051seq = OpenSSL::ASN1::Sequence.new(elems)5253seq_asn1 = OpenSSL::ASN1::ASN1Data.new([seq], AP_REQ, :APPLICATION)54seq_asn155end5657private5859# Encodes the pvno field60#61# @return [OpenSSL::ASN1::Integer]62def encode_pvno63bn = OpenSSL::BN.new(pvno.to_s)64int = OpenSSL::ASN1::Integer.new(bn)6566int67end6869# Encodes the msg_type field70#71# @return [OpenSSL::ASN1::Integer]72def encode_msg_type73bn = OpenSSL::BN.new(msg_type.to_s)74int = OpenSSL::ASN1::Integer.new(bn)7576int77end7879# Encodes the options field80#81# @return [OpenSSL::ASN1::BitString]82def encode_options83OpenSSL::ASN1::BitString.new([options].pack('N'))84end8586# Encodes the ticket field87#88# @return [String]89def encode_ticket90ticket.encode91end9293# Encodes the authenticator field94#95# @return [String]96def encode_authenticator97authenticator.encode98end99end100end101end102end103end104105106