Class: PacketGen::Header::IKE::Cert
- Inherits:
-
Payload
- Object
- Types::Fields
- Base
- Payload
- PacketGen::Header::IKE::Cert
- Defined in:
- lib/packetgen/header/ike/cert.rb
Overview
This class handles Certificate payloads.
A Cert payload consists of the IKE generic payload header (see Payload) and some specific fields:
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Payload |C| RESERVED | Payload Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Cert Encoding | |
+-+-+-+-+-+-+-+-+ +
| |
~ Certificate Data ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
and Payload#content (Certificate Data).
Create a Cert payload
# Create a IKE packet with a Cert payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::Cert', encoding: 'X509_CERT_SIG')
certs = cert.to_der << ca_cert.to_der
pkt.ike_cert.content.read certs
pkt.calc_length
Direct Known Subclasses
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
37- ENCODINGS =
{ 'PKCS7_WRAPPED_X509' => 1, 'PGP' => 2, 'DNS_SIGNED_KEY' => 3, 'X509_CERT_SIG' => 4, 'KERBEROS_TOKEN' => 6, 'X509_CRL' => 7, 'X509_ARL' => 8, 'SPKI_CERT' => 9, 'X509_CERT_ATTR' => 10, 'HASH_URL_X509_CERT' => 12, 'HASH_URL_X509_BUNDLE' => 13 }.freeze
Instance Attribute Summary collapse
-
#encoding ⇒ Integer
8-bit certificate encoding.
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Attributes inherited from Base
Instance Method Summary collapse
-
#human_encoding ⇒ String
Get encoding name.
-
#initialize(options = {}) ⇒ Cert
constructor
A new instance of Cert.
Methods inherited from Payload
#base_read, #calc_length, #read
Methods inherited from Base
#added_to_packet, bind, bind_header, calculate_and_set_length, #header_id, inherited, #ip_header, known_headers, #ll_header, #method_name, #parse?, #protocol_name, protocol_name
Methods inherited from Types::Fields
#[], #[]=, #bits_on, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, fields, #fields, #force_binary, inherited, #inspect, #is_optional?, #is_present?, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
Constructor Details
#initialize(options = {}) ⇒ Cert
Returns a new instance of Cert.
61 62 63 64 |
# File 'lib/packetgen/header/ike/cert.rb', line 61 def initialize(={}) super self.encoding = [:encoding] if [:encoding] end |
Instance Attribute Details
#encoding ⇒ Integer
8-bit certificate encoding
59 |
# File 'lib/packetgen/header/ike/cert.rb', line 59 define_field_before :content, :encoding, Types::Int8Enum, enum: ENCODINGS |
Instance Method Details
#human_encoding ⇒ String
Get encoding name
68 69 70 |
# File 'lib/packetgen/header/ike/cert.rb', line 68 def human_encoding self[:encoding].to_human end |