Class: PacketGen::Plugin::IKE::KE
- Defined in:
- lib/packetgen/plugin/ike/ke.rb
Overview
This class handles Key Exchange payloads, as defined in RFC 7296 ยง3.4
A KE payload contains a 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 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Diffie-Hellman Group Num | RESERVED |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
~ Key Exchange Data ~
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
These specific fields are:
-
#group_num (type Types::Int16),
-
#reserved (type Types::Int16),
-
and Payload#content (type Types::String).
Create a KE payload
# Create a IKE packet with a KE payload
pkt = PacketGen.gen('IP').add('UDP').add('IKE')
# group name is taken from Transform::DH_* constants
pkt.add('IKE::KE', group: 'MODP4096')
# group number may also be used
pkt.ike_ke.group = 1
pkt.calc_length
Constant Summary collapse
- PAYLOAD_TYPE =
Payload type number
34
Instance Attribute Summary collapse
-
#group_num ⇒ Integer
16-bit DH group number.
-
#reserved ⇒ Integer
16-bit reserved field.
Attributes inherited from Payload
#content, #critical, #flags, #hreserved, #length, #next
Instance Method Summary collapse
-
#group=(value) ⇒ Integer
Set group.
-
#initialize(options = {}) ⇒ KE
constructor
A new instance of KE.
Methods inherited from Payload
Constructor Details
#initialize(options = {}) ⇒ KE
Returns a new instance of KE.
53 54 55 56 |
# File 'lib/packetgen/plugin/ike/ke.rb', line 53 def initialize(={}) super self.group = [:group] if [:group] end |
Instance Attribute Details
#group_num ⇒ Integer
16-bit DH group number
47 |
# File 'lib/packetgen/plugin/ike/ke.rb', line 47 define_field_before :content, :group_num, PacketGen::Types::Int16 |
#reserved ⇒ Integer
16-bit reserved field
51 |
# File 'lib/packetgen/plugin/ike/ke.rb', line 51 define_field_before :content, :reserved, PacketGen::Types::Int16, default: 0 |
Instance Method Details
#group=(value) ⇒ Integer
Set group
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/packetgen/plugin/ike/ke.rb', line 62 def group=(value) group = case value when Integer value else cname = "DH_#{value}" Transform.const_defined?(cname) ? Transform.const_get(cname) : nil end raise ArgumentError, "unknown group #{value.inspect}" unless group self[:group_num].value = group end |