Class: PacketGen::Plugin::IKE::CertReq
- Defined in:
- lib/packetgen/plugin/ike/certreq.rb
Overview
This class handles Certificate Request payloads.
A CertReq payload consists of the IKE generic payload Plugin (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::Plugin::IKE::Cert::ENCODINGS
Instance Attribute Summary
Attributes inherited from Cert
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
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
#calc_length, #initialize, protocol_name
Constructor Details
This class inherits a constructor from PacketGen::Plugin::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/plugin/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/plugin/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 |