Class: PacketGen::Header::IKE::CertReq
- Defined in:
- lib/packetgen/header/ike/certreq.rb
Overview
This class handles Certificate Request payloads.
A CertReq 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 | |
+-+-+-+-+-+-+-+-+ +
| |
~ Certification Authority ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
and Payload#content (Certification Authority).
Create a CertReq payload
# Create a IKE packet with a CertReq payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE').add('IKE::CertReq', encoding: 'X509_CERT_SIG')
pkt.ike_certreq.content.read OpenSSL::Digest::SHA1.digest(ca_cert.to_der)
pkt.calc_length
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
38
Constants inherited from Cert
PacketGen::Header::IKE::Cert::ENCODINGS
Instance Attribute Summary
Attributes inherited from Cert
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Attributes inherited from Base
Instance Method Summary collapse
-
#human_content ⇒ String
Get list of 20-byte string (SHA-1 hashes).
- #inspect ⇒ String
Methods inherited from Cert
Methods inherited from Payload
#base_read, #calc_length, #initialize, #read
Methods inherited from Base
#added_to_packet, bind, bind_header, calculate_and_set_length, #header_id, inherited, #initialize, #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, #initialize, #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
This class inherits a constructor from PacketGen::Header::IKE::Cert
Instance Method Details
#human_content ⇒ String
Get list of 20-byte string (SHA-1 hashes)
43 44 45 46 47 48 49 50 51 |
# File 'lib/packetgen/header/ike/certreq.rb', line 43 def human_content strs = [] idx = 0 while idx < content.size strs << content[idx, 20] idx += 20 end strs.map(&:inspect).join(',') end |
#inspect ⇒ String
54 55 56 57 58 59 60 |
# File 'lib/packetgen/header/ike/certreq.rb', line 54 def inspect super do |attr| next unless attr == :content str = Inspect.shift_level str << Inspect::FMT_ATTR % ['hashes', :content, human_content] end end |