Class: Rex::Proto::Kerberos::Model::ApRep

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

Overview

This class provides a representation of a Kerberos AP-REP (response) data definition

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

#enc_partRex::Proto::Kerberos::Model::EncryptedData

Returns The encrypted part of the response.

Returns:



18
19
20
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 18

def enc_part
  @enc_part
end

#msg_typeInteger

Returns The type of a protocol message.

Returns:

  • (Integer)

    The type of a protocol message



15
16
17
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 15

def msg_type
  @msg_type
end

#pvnoInteger

Returns The protocol version number.

Returns:

  • (Integer)

    The protocol version number



12
13
14
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 12

def pvno
  @pvno
end

Instance Method Details

#decode(input) ⇒ self

Decodes the Rex::Proto::Kerberos::Model::ApRep from an input

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 25

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

  self
end

#decrypt_enc_part(key) ⇒ Object



59
60
61
62
63
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 59

def decrypt_enc_part(key)
  data = enc_part.decrypt_asn1(key, Rex::Proto::Kerberos::Crypto::KeyUsage::AP_REP_ENCPART)

  result = Rex::Proto::Kerberos::Model::EncApRepPart::decode(data)
end

#encodeString

Encodes the Rex::Proto::Kerberos::Model::ApReq into an ASN.1 String

Returns:

  • (String)


41
42
43
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 41

def encode
  to_asn1.to_der
end

#to_asn1OpenSSL::ASN1::ASN1Data

Returns The ap_req ASN1Data.

Returns:

  • (OpenSSL::ASN1::ASN1Data)

    The ap_req ASN1Data



46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rex/proto/kerberos/model/ap_rep.rb', line 46

def to_asn1
  elems = []

  elems << OpenSSL::ASN1::ASN1Data.new([encode_pvno], 0, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_msg_type], 1, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_enc_part], 2, :CONTEXT_SPECIFIC)

  seq = OpenSSL::ASN1::Sequence.new(elems)

  seq_asn1 = OpenSSL::ASN1::ASN1Data.new([seq], AP_REP, :APPLICATION)
  seq_asn1
end