Class: Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

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

Overview

This class is a representation of a PA-ENC-TIMESTAMP, an encrypted timestamp sent as pre authenticated data

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

#pa_time_stampTime

Returns client’s time.

Returns:

  • (Time)

    client's time



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

def pa_time_stamp
  @pa_time_stamp
end

#pausecInteger

Returns optional microseconds client’s time.

Returns:

  • (Integer)

    optional microseconds client's time



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

def pausec
  @pausec
end

Instance Method Details

#decode(input) ⇒ self

Decodes a Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

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/pre_auth_enc_time_stamp.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 PreAuthEncTimeStamp, invalid input'
  end

  self
end

#encodeString

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

Returns:

  • (String)


40
41
42
43
44
45
46
# File 'lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp.rb', line 40

def encode
  pa_time_stamp_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pa_time_stamp], 0, :CONTEXT_SPECIFIC)
  pausec_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pausec], 1, :CONTEXT_SPECIFIC)
  seq = OpenSSL::ASN1::Sequence.new([pa_time_stamp_asn1, pausec_asn1])

  seq.to_der
end

#encrypt(etype, key) ⇒ String

Encrypts the Rex::Proto::Kerberos::Model::PreAuthEncTimeStamp

Parameters:

  • etype (Integer)

    the crypto schema to encrypt

  • key (String)

    the key to encrypt

Returns:

  • (String)

    the encrypted result

Raises:

  • (NotImplementedError)

    if encryption schema isn't supported



54
55
56
57
58
# File 'lib/rex/proto/kerberos/model/pre_auth_enc_time_stamp.rb', line 54

def encrypt(etype, key)
  data = self.encode
  encryptor = Rex::Proto::Kerberos::Crypto::Encryption::from_etype(etype)
  encryptor.encrypt(data, key, Rex::Proto::Kerberos::Crypto::KeyUsage::AS_REQ_PA_ENC_TIMESTAMP)
end