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