Add documentation for PreAuthData

bug/bundler_fix
jvazquez-r7 2014-12-09 19:57:16 -06:00
parent 0a6e42968b
commit cc909ba402
1 changed files with 26 additions and 1 deletions

View File

@ -4,9 +4,19 @@ module Rex
module Model
module Field
class PreAuthData < Element
# @!attribute type
# @return [Fixnum] The padata type
attr_accessor :type
# @!attribute value
# @return [String] The padata value
attr_accessor :value
# Decodes a Rex::Proto::Kerberos::Model::Field::PreAuthData
#
# @param input [String, OpenSSL::ASN1::Sequence] the input to decode from
# @return [self] if decoding succeeds
# @raise [RuntimeError] if decoding doesn't succeed
def decode(input)
case input
when String
@ -14,7 +24,7 @@ module Rex
when OpenSSL::ASN1::Sequence
decode_asn1(input)
else
raise ::RuntimeError, 'Failed to decode Principal Name, invalid input'
raise ::RuntimeError, 'Failed to decode PreAuthData, invalid input'
end
self
@ -26,22 +36,37 @@ module Rex
private
# Decodes a Rex::Proto::Kerberos::Model::Field::PreAuthData
#
# @param input [String] the input to decode from
def decode_string(input)
asn1 = OpenSSL::ASN1.decode(input)
decode_asn1(asn1)
end
# Decodes a Rex::Proto::Kerberos::Model::Type::PreAuthData from an
# OpenSSL::ASN1::Sequence
#
# @param input [OpenSSL::ASN1::Sequence] the input to decode from
def decode_asn1(input)
seq_values = input.value
self.type = decode_asn1_type(seq_values[0])
self.value = decode_asn1_value(seq_values[1])
end
# Decodes the type from an OpenSSL::ASN1::ASN1Data
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Fixnum]
def decode_asn1_type(input)
input.value[0].value.to_i
end
# Decodes the value from an OpenSSL::ASN1::ASN1Data
#
# @param input [OpenSSL::ASN1::ASN1Data] the input to decode from
# @return [Fixnum]
def decode_asn1_value(input)
input.value[0].value
end