Class: Rex::Proto::Kerberos::Model::EncryptedData
- Defined in:
- lib/rex/proto/kerberos/model/encrypted_data.rb
Overview
This class provides a representation of an encrypted message.
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
-
#cipher ⇒ String
The enciphered text.
-
#etype ⇒ Object
Returns the value of attribute etype.
-
#kvno ⇒ Integer
The version number of the key.
-
#name_type ⇒ Integer
The encryption algorithm.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#decode(input) ⇒ self
Decodes a Rex::Proto::Kerberos::Model::EncryptedData.
-
#decrypt_asn1(key, msg_type) ⇒ String
Decrypts the cipher with etype encryption schema, presuming that the data is an ASN1 structure.
-
#encode ⇒ String
Encodes a Rex::Proto::Kerberos::Model::EncryptedData into an ASN.1 String.
Methods inherited from Element
attr_accessor, attributes, #attributes, decode, #initialize
Constructor Details
This class inherits a constructor from Rex::Proto::Kerberos::Model::Element
Instance Attribute Details
#cipher ⇒ String
Returns The enciphered text.
17 18 19 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 17 def cipher @cipher end |
#etype ⇒ Object
Returns the value of attribute etype.
11 12 13 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 11 def etype @etype end |
#kvno ⇒ Integer
Returns The version number of the key.
14 15 16 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 14 def kvno @kvno end |
#name_type ⇒ Integer
Returns The encryption algorithm.
11 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 11 attr_accessor :etype |
Instance Method Details
#==(other) ⇒ Object
19 20 21 22 23 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 19 def ==(other) etype == other.etype && kvno == other.kvno && cipher == other.cipher end |
#decode(input) ⇒ self
Decodes a Rex::Proto::Kerberos::Model::EncryptedData
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 30 def decode(input) case input when String decode_string(input) when OpenSSL::ASN1::Sequence decode_asn1(input) else raise ::Rex::Proto::Kerberos::Model::Error::KerberosDecodingError, 'Failed to decode EncryptedData Name, invalid input' end self end |
#decrypt_asn1(key, msg_type) ⇒ String
Decrypts the cipher with etype encryption schema, presuming that the data is an ASN1 structure
72 73 74 75 76 77 78 79 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 72 def decrypt_asn1(key, msg_type) if cipher.nil? || cipher.empty? return '' end encryptor = Rex::Proto::Kerberos::Crypto::Encryption::from_etype(etype) encryptor.decrypt_asn1(cipher, key, msg_type) end |
#encode ⇒ String
Encodes a Rex::Proto::Kerberos::Model::EncryptedData into an ASN.1 String
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rex/proto/kerberos/model/encrypted_data.rb', line 46 def encode elems = [] etype_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_etype], 0, :CONTEXT_SPECIFIC) elems << etype_asn1 if kvno kvno_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_kvno], 1, :CONTEXT_SPECIFIC) elems << kvno_asn1 end cipher_asn1 = OpenSSL::ASN1::ASN1Data.new([encode_cipher], 2, :CONTEXT_SPECIFIC) elems << cipher_asn1 seq = OpenSSL::ASN1::Sequence.new(elems) seq.to_der end |