Add support for PreAuthPacRequest#encode

bug/bundler_fix
jvazquez-r7 2014-12-10 19:18:12 -06:00
parent 96c1370334
commit 3accdb705b
4 changed files with 24 additions and 3 deletions

View File

@ -31,12 +31,26 @@ module Rex
self
end
# Encodes a Rex::Proto::Kerberos::Model::Field::PreAuthPacRequest into an
# ASN.1 String
#
# @return [String]
def encode
raise ::RuntimeError, 'PreAuthPacRequest encoding unsupported'
value_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_value], 0, :CONTEXT_SPECIFIC)
seq = OpenSSL::ASN1::Sequence.new([value_asn1])
seq.to_der
end
private
# Encodes value attribute
#
# @return [OpenSSL::ASN1::Boolean]
def encode_value
OpenSSL::ASN1::Boolean.new(value)
end
# Decodes a Rex::Proto::Kerberos::Model::Field::PreAuthPacRequest
#
# @param input [String] the input to decode from

View File

@ -36,7 +36,7 @@ module Rex
self
end
# Encodes a Rex::Proto::Kerberos::Model::Type::EncryptedData into an String
# Encodes a Rex::Proto::Kerberos::Model::Type::EncryptedData into an ASN.1 String
#
# @return [String]
# @raise [RuntimeError] if encoding doesn't succeed

View File

@ -34,7 +34,8 @@ module Rex
self
end
# Encodes a Rex::Proto::Kerberos::Model::Type::PrincipalName into an String
# Encodes a Rex::Proto::Kerberos::Model::Type::PrincipalName into an
# ASN.1 String
#
# @return [String]
def encode

View File

@ -49,4 +49,10 @@ describe Rex::Proto::Kerberos::Model::Field::PreAuthPacRequest do
end
end
describe "#encode" do
it "encodes Rex::Proto::Kerberos::Model::Type::EncryptedData correctly" do
pre_auth_pac_request.decode(pac_sample)
expect(pre_auth_pac_request.encode).to eq(pac_sample)
end
end
end