Class: Rex::Proto::Kerberos::Model::HostAddress

Inherits:
Element
  • Object
show all
Defined in:
lib/rex/proto/kerberos/model/host_address.rb

Overview

This class provides a representation for Kerberos pre authenticated data

https://datatracker.ietf.org/doc/html/rfc4120#section-5.2.5
HostAddress     ::= SEQUENCE  {
        addr-type       [0] Int32,
        address         [1] OCTET STRING
 }

Constant Summary

Constants included from Rex::Proto::Kerberos::Model

AP_REP, AP_REQ, AS_REP, AS_REQ, AUTHENTICATOR, ENC_AP_REP_PART, ENC_KRB_CRED_PART, KRB_CRED, KRB_ERROR, TGS_REP, TGS_REQ, TICKET, VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Element

attr_accessor, attributes, #attributes, decode, #initialize

Constructor Details

This class inherits a constructor from Rex::Proto::Kerberos::Model::Element

Instance Attribute Details

#addressString

Returns The address value.

Returns:

  • (String)

    The address value



16
17
18
# File 'lib/rex/proto/kerberos/model/host_address.rb', line 16

def address
  @address
end

#typeRex::Proto::Kerberos::Model::AddressType, Integer

Returns The address addr-type.

Returns:



13
14
15
# File 'lib/rex/proto/kerberos/model/host_address.rb', line 13

def type
  @type
end

Instance Method Details

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::HostAddress

Parameters:

  • input (String, OpenSSL::ASN1::Sequence)

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rex/proto/kerberos/model/host_address.rb', line 23

def decode(input)
  case input
  when String
    decode_string(input)
  when OpenSSL::ASN1::Sequence
    decode_asn1(input)
  else
    raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode HostAddress, invalid input'
  end

  self
end

#encodeString

Encodes a Rex::Proto::Kerberos::Model::HostAddress into an ASN.1 String

Returns:

  • (String)


39
40
41
# File 'lib/rex/proto/kerberos/model/host_address.rb', line 39

def encode
  to_asn1.to_der
end

#to_asn1OpenSSL::ASN1::ASN1Data

Encodes a Rex::Proto::Kerberos::Model::HostAddress into ASN.1

Returns:

  • (OpenSSL::ASN1::ASN1Data)

    The HostAddress ASN1Data



46
47
48
49
50
51
52
# File 'lib/rex/proto/kerberos/model/host_address.rb', line 46

def to_asn1
  type_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_type], 0, :CONTEXT_SPECIFIC)
  address_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_address], 1, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new([type_asn1, address_asn1])

  seq
end