Add PreAuthEncTimeStamp#encode support

bug/bundler_fix
jvazquez-r7 2014-12-10 19:30:21 -06:00
parent 3accdb705b
commit b89dee03c6
3 changed files with 34 additions and 2 deletions

View File

@ -33,8 +33,16 @@ module Rex
self
end
# Encodes a Rex::Proto::Kerberos::Model::Field::PreAuthEncTimeStamp into an
# ASN.1 String
#
# @return [String]
def encode
raise ::RuntimeError, 'EncryptedData encoding is not supported'
pa_time_stamp_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pa_time_stamp], 0, :CONTEXT_SPECIFIC)
pausec_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_pausec], 1, :CONTEXT_SPECIFIC)
seq = OpenSSL::ASN1::Sequence.new([pa_time_stamp_asn1, pausec_asn1])
seq.to_der
end
# Decrypts a Rex::Proto::Kerberos::Model::Field::PreAuthEncTimeStamp
@ -64,6 +72,23 @@ module Rex
private
# Encodes the pa_time_stamp
#
# @return [OpenSSL::ASN1::GeneralizedTime]
def encode_pa_time_stamp
OpenSSL::ASN1::GeneralizedTime.new(pa_time_stamp)
end
# Encodes the pausec
#
# @return [OpenSSL::ASN1::Integer]
def encode_pausec
int_bn = OpenSSL::BN.new(pausec)
int = OpenSSL::ASN1::Integer(int_bn)
int
end
# Decodes a Rex::Proto::Kerberos::Model::Field::PreAuthEncTimeStamp
#
# @param input [String] the input to decode from

View File

@ -148,4 +148,11 @@ describe Rex::Proto::Kerberos::Model::Field::PreAuthEncTimeStamp do
end
end
describe "#encode" do
it "encodes Rex::Proto::Kerberos::Model::Field::PreAuthEncTimeStamp correctly" do
pre_auth_enc_time_stamp.decode(time_stamp_raw)
expect(pre_auth_enc_time_stamp.encode).to eq(time_stamp_raw)
end
end
end

View File

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