Class: Rex::Proto::Kerberos::Model::PreAuthS4uX509User
- Defined in:
- lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb
Overview
This class provides a representation of the PA-S4U-X509-USER structure as defined in the Kerberos protocol.
Constant Summary
Constants included from Rex::Proto::Kerberos::Model
AP_REP, AP_REQ, AS_REP, AS_REQ, AUTHENTICATOR, ENC_AP_REP_PART, ENC_KRB_CRED_PART, KRB_CRED, KRB_ERROR, TGS_REP, TGS_REQ, TICKET, VERSION
Instance Attribute Summary collapse
-
#checksum ⇒ Rex::Proto::Kerberos::Model::Checksum
The checksum.
-
#user_id ⇒ Rex::Proto::Kerberos::Model::S4uUserId
The user ID.
Instance Method Summary collapse
-
#decode(input) ⇒ self
Decodes the PA-S4U-X509-USER structure from an input.
-
#decode_asn1(input) ⇒ Object
Decodes the PA-S4U-X509-USER structure from an OpenSSL::ASN1::Sequence.
-
#decode_string(input) ⇒ Object
Decodes the PA-S4U-X509-USER structure from a String.
-
#encode ⇒ String
Encodes the PA-S4U-X509-USER structure into an ASN.1 String.
- #get_checksum(key, data) ⇒ Object
-
#initialize(key, impersonate, impersonate_type, realm, nonce, e_type: Rex::Proto::Kerberos::Crypto::Encryption::AES256) ⇒ PreAuthS4uX509User
constructor
Initializes the PA-S4U-X509-USER structure.
Methods inherited from Element
attr_accessor, attributes, #attributes, decode
Constructor Details
#initialize(key, impersonate, impersonate_type, realm, nonce, e_type: Rex::Proto::Kerberos::Crypto::Encryption::AES256) ⇒ PreAuthS4uX509User
Initializes the PA-S4U-X509-USER structure
34 35 36 37 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 34 def initialize(key, impersonate, impersonate_type, realm, nonce, e_type: Rex::Proto::Kerberos::Crypto::Encryption::AES256) self.user_id = Rex::Proto::Kerberos::Model::S4uUserId.new(impersonate, impersonate_type, realm, nonce) self.checksum = Rex::Proto::Kerberos::Model::Checksum.new(type: Rex::Proto::Kerberos::Crypto::Encryption::DES3_CBC_SHA1, checksum: get_checksum(key.value, user_id.encode)) end |
Instance Attribute Details
#checksum ⇒ Rex::Proto::Kerberos::Model::Checksum
Returns The checksum.
17 18 19 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 17 def checksum @checksum end |
#user_id ⇒ Rex::Proto::Kerberos::Model::S4uUserId
Returns The user ID.
14 15 16 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 14 def user_id @user_id end |
Instance Method Details
#decode(input) ⇒ self
Decodes the PA-S4U-X509-USER structure from an input
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 57 def decode(input) case input when String decode_string(input) when OpenSSL::ASN1::ASN1Data decode_asn1(input) else raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode PA-S4U-X509-USER, invalid input' end self end |
#decode_asn1(input) ⇒ Object
Decodes the PA-S4U-X509-USER structure from an OpenSSL::ASN1::Sequence
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 81 def decode_asn1(input) seq_values = input.value seq_values.each do |val| case val.tag when 0 self.user_id = S4uUserId.decode(val.value[0]) when 1 self.checksum = Checksum.new.decode(val.value[0]) else raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode PA-S4U-X509-USER SEQUENCE' end end end |
#decode_string(input) ⇒ Object
Decodes the PA-S4U-X509-USER structure from a String
73 74 75 76 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 73 def decode_string(input) asn1 = OpenSSL::ASN1.decode(input) decode_asn1(asn1) end |
#encode ⇒ String
Encodes the PA-S4U-X509-USER structure into an ASN.1 String
42 43 44 45 46 47 48 49 50 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 42 def encode elems = [] elems << OpenSSL::ASN1::ASN1Data.new([user_id.encode], 0, :CONTEXT_SPECIFIC) elems << OpenSSL::ASN1::ASN1Data.new([checksum.encode], 1, :CONTEXT_SPECIFIC) seq = OpenSSL::ASN1::Sequence.new(elems) seq.to_der end |
#get_checksum(key, data) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/rex/proto/kerberos/model/pre_auth_s4u_x509_user.rb', line 19 def get_checksum(key, data) checksum_type = Rex::Proto::Kerberos::Crypto::Checksum::SHA1_AES256 cksum_key_usage = Rex::Proto::Kerberos::Crypto::KeyUsage::PA_S4U_X509_USER checksummer = Rex::Proto::Kerberos::Crypto::Checksum::from_checksum_type(checksum_type) checksummer.checksum(key, cksum_key_usage, data) end |