metasploit-framework/lib/rex/proto/kerberos/credential_cache/key_block.rb

63 lines
1.5 KiB
Ruby
Raw Normal View History

# -*- coding: binary -*-
2014-12-18 05:16:58 +00:00
module Rex
module Proto
module Kerberos
module CredentialCache
# This class provides a representation of a credential keys stored in the Kerberos Credential Cache.
2014-12-18 06:30:47 +00:00
class KeyBlock < Element
# @!attribute key_type
# @return [Fixnum]
2014-12-18 06:30:47 +00:00
attr_accessor :key_type
# @!attribute e_type
# @return [Fixnum]
2014-12-18 06:30:47 +00:00
attr_accessor :e_type
# @!attribute key_value
# @return [String]
2014-12-18 06:30:47 +00:00
attr_accessor :key_value
# Encodes the Rex::Proto::Kerberos::CredentialCache::KeyBlock into an String
#
# @return [String] encoded key
2014-12-18 06:30:47 +00:00
def encode
encoded = ''
encoded << encode_key_type
encoded << encode_e_type
encoded << encode_key_value
encoded
end
private
# Encodes the key_type field
#
# @return [String]
2014-12-18 06:30:47 +00:00
def encode_key_type
[key_type].pack('n')
end
# Encodes the e_type field
#
# @return [String]
2014-12-18 06:30:47 +00:00
def encode_e_type
[e_type].pack('n')
end
# Encodes the key_value field
#
# @return [String]
2014-12-18 06:30:47 +00:00
def encode_key_value
encoded = ''
encoded << [key_value.length].pack('n')
encoded << key_value
encoded
end
2014-12-18 05:16:58 +00:00
end
end
end
end
end