Class: PacketGen::Plugin::IKE::Cert

Inherits:
Payload
  • Object
show all
Defined in:
lib/packetgen/plugin/ike/cert.rb

Overview

This class handles Certificate payloads.

A Cert 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 |                                               |
+-+-+-+-+-+-+-+-+                                               +
|                                                               |
~                       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

Direct Known Subclasses

CertReq

Constant Summary collapse

PAYLOAD_TYPE =

Payload type number

37
ENCODINGS =

Certificate encoding

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

Instance Method Summary collapse

Methods inherited from Payload

#calc_length, protocol_name

Constructor Details

#initialize(options = {}) ⇒ Cert

Returns a new instance of Cert.



61
62
63
64
# File 'lib/packetgen/plugin/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/plugin/ike/cert.rb', line 59

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

Instance Method Details

#human_encodingString

Get encoding name

Returns:

  • (String)


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

def human_encoding
  self[:encoding].to_human
end