class Rex::Proto::Kerberos::Model::AuthorizationData
This class provides a representation of a Kerberos
AuthorizationData
data definition.
Attributes
elements[RW]
@!attribute elements
@return [Hash{Symbol => <Fixnum, String>}] The type of the authorization data @option [Fixnum] :type @option [String] :data
Public Instance Methods
decode(input)
click to toggle source
Rex::Proto::Kerberos::Model::AuthorizationData
decoding isn't supported
@raise [NotImplementedError]
# File lib/rex/proto/kerberos/model/authorization_data.rb, line 18 def decode(input) raise ::NotImplementedError, 'Authorization Data decoding not supported' end
encode()
click to toggle source
Encodes a Rex::Proto::Kerberos::Model::AuthorizationData
into an ASN.1 String
@return [String]
# File lib/rex/proto/kerberos/model/authorization_data.rb, line 25 def encode seqs = [] elements.each do |elem| elems = [] type_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_type(elem[:type])], 0, :CONTEXT_SPECIFIC) elems << type_asn1 data_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_data(elem[:data])], 1, :CONTEXT_SPECIFIC) elems << data_asn1 seqs << OpenSSL::ASN1::Sequence.new(elems) end seq = OpenSSL::ASN1::Sequence.new(seqs) seq.to_der end
encrypt(etype, key)
click to toggle source
Encrypts the Rex::Proto::Kerberos::Model::AuthorizationData
@param etype [Fixnum] the crypto schema to encrypt @param key [String] the key to encrypt @return [String] the encrypted result @raise [NotImplementedError] if encryption schema isn't supported
# File lib/rex/proto/kerberos/model/authorization_data.rb, line 47 def encrypt(etype, key) data = self.encode res = '' case etype when RC4_HMAC res = encrypt_rc4_hmac(data, key, 5) else raise ::NotImplementedError, 'EncryptedData schema is not supported' end res end
Private Instance Methods
encode_data(data)
click to toggle source
Encodes the data
@return [OpenSSL::ASN1::OctetString]
# File lib/rex/proto/kerberos/model/authorization_data.rb, line 77 def encode_data(data) OpenSSL::ASN1::OctetString.new(data) end
encode_type(type)
click to toggle source
Encodes the type
@return [OpenSSL::ASN1::Integer]
# File lib/rex/proto/kerberos/model/authorization_data.rb, line 67 def encode_type(type) bn = OpenSSL::BN.new(type.to_s) int = OpenSSL::ASN1::Integer.new(bn) int end