Class: PacketGen::Header::IKE::Cert

Inherits:
Payload show all
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:

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

Author:

  • Sylvain Daubert

Since:

  • 2.0.0

Direct Known Subclasses

CertReq

Constant Summary collapse

PAYLOAD_TYPE =

Payload type number

Since:

  • 2.0.0

37
ENCODINGS =

Since:

  • 2.0.0

{
  '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

Attributes inherited from Payload

#content, #critical, #flags, #hreserved, #length, #next

Attributes inherited from Base

#packet

Instance Method Summary collapse

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.

Since:

  • 2.0.0



61
62
63
64
# File 'lib/packetgen/header/ike/cert.rb', line 61

def initialize(options={})
  super
  self.encoding = options[:encoding] if options[:encoding]
end

Instance Attribute Details

#encodingInteger

8-bit certificate encoding

Returns:

  • (Integer)


59
# File 'lib/packetgen/header/ike/cert.rb', line 59

define_field_before :content, :encoding, Types::Int8Enum, enum: ENCODINGS

Instance Method Details

#human_encodingString

Get encoding name

Returns:

  • (String)

Since:

  • 2.0.0



68
69
70
# File 'lib/packetgen/header/ike/cert.rb', line 68

def human_encoding
  self[:encoding].to_human
end