Sha256: d2315a21dc844bd17406ff870547ba1fe5992d95f92bec558359c1963e8b39a2

Contents?: true

Size: 1.47 KB

Versions: 7

Compression:

Stored size: 1.47 KB

Contents

# -*- coding: binary -*-

module Rex
  module Proto
    module Kerberos
      module CredentialCache

        # This class provides a representation of a credential keys stored in the Kerberos Credential Cache.
        class KeyBlock < Element
          # @!attribute key_type
          #   @return [Fixnum]
          attr_accessor :key_type
          # @!attribute e_type
          #   @return [Fixnum]
          attr_accessor :e_type
          # @!attribute key_value
          #   @return [String]
          attr_accessor :key_value

          # Encodes the Rex::Proto::Kerberos::CredentialCache::KeyBlock into an String
          #
          # @return [String] encoded key
          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]
          def encode_key_type
            [key_type].pack('n')
          end

          # Encodes the e_type field
          #
          # @return [String]
          def encode_e_type
            [e_type].pack('n')
          end

          # Encodes the key_value field
          #
          # @return [String]
          def encode_key_value
            encoded = ''
            encoded << [key_value.length].pack('n')
            encoded << key_value

            encoded
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rex-2.0.13 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.12 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.11 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.10 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.9 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.8 lib/rex/proto/kerberos/credential_cache/key_block.rb
rex-2.0.7 lib/rex/proto/kerberos/credential_cache/key_block.rb