Class: Rex::Proto::Kerberos::Model::EncryptionKey

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

Overview

This class provides a representation of a Kerberos EncryptionKey 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

#keyInteger

Returns The type of encryption key.

Returns:

  • (Integer)

    The type of encryption key



13
# File 'lib/rex/proto/kerberos/model/encryption_key.rb', line 13

attr_accessor :type

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

#valueString

Returns the key itself.

Returns:

  • (String)

    the key itself



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

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object



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

def ==(other)
  type == other.type &&
    value == other.value
end

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::EncryptionKey

Parameters:

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

    the input to decode from

Returns:

  • (self)

    if decoding succeeds

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/proto/kerberos/model/encryption_key.rb', line 28

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 EncryptionKey, invalid input'
  end

  self
end

#encodeString

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

Returns:

  • (String)


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

def encode
  elems = []
  elems << OpenSSL::ASN1::ASN1Data.new([encode_type], 0, :CONTEXT_SPECIFIC)
  elems << OpenSSL::ASN1::ASN1Data.new([encode_value], 1, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new(elems)

  seq.to_der
end