packetgen-plugin-ipsec 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/specs.yml +7 -3
- data/.rubocop.yml +24 -6
- data/Gemfile +13 -6
- data/README.md +12 -6
- data/lib/packetgen/plugin/crypto.rb +32 -0
- data/lib/packetgen/plugin/esp.rb +162 -133
- data/lib/packetgen/plugin/ike/auth.rb +52 -39
- data/lib/packetgen/plugin/ike/cert.rb +1 -1
- data/lib/packetgen/plugin/ike/certreq.rb +1 -1
- data/lib/packetgen/plugin/ike/id.rb +7 -8
- data/lib/packetgen/plugin/ike/ke.rb +6 -5
- data/lib/packetgen/plugin/ike/nonce.rb +1 -1
- data/lib/packetgen/plugin/ike/notify.rb +12 -13
- data/lib/packetgen/plugin/ike/payload.rb +30 -32
- data/lib/packetgen/plugin/ike/sa.rb +41 -41
- data/lib/packetgen/plugin/ike/sk.rb +76 -74
- data/lib/packetgen/plugin/ike/ts.rb +20 -17
- data/lib/packetgen/plugin/ike/vendor_id.rb +1 -1
- data/lib/packetgen/plugin/ike.rb +37 -42
- data/lib/packetgen/plugin/ipsec_version.rb +1 -1
- data/lib/packetgen-plugin-ipsec.rb +2 -0
- data/packetgen-plugin-ipsec.gemspec +5 -4
- metadata +10 -18
- data/.travis.yml +0 -14
@@ -29,7 +29,7 @@ module PacketGen::Plugin
|
|
29
29
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
30
30
|
# ~ Integrity Checksum Data ~
|
31
31
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
32
|
-
# Encrypted payloads are set in {#content} field, as a {
|
32
|
+
# Encrypted payloads are set in {#content} field, as a {BinStruct::String}.
|
33
33
|
# All others fields are only set when decrypting a previously read SK
|
34
34
|
# payload. They also may be set manually to encrypt IKE payloads.
|
35
35
|
#
|
@@ -95,21 +95,7 @@ module PacketGen::Plugin
|
|
95
95
|
opt = { salt: '', parse: true }.merge!(options)
|
96
96
|
|
97
97
|
set_crypto cipher, opt[:intmode]
|
98
|
-
|
99
|
-
case confidentiality_mode
|
100
|
-
when 'gcm'
|
101
|
-
iv = self[:content].slice!(0, 8)
|
102
|
-
real_iv = force_binary(opt[:salt]) + iv
|
103
|
-
when 'cbc'
|
104
|
-
cipher.padding = 0
|
105
|
-
real_iv = iv = self[:content].slice!(0, 16)
|
106
|
-
when 'ctr'
|
107
|
-
iv = self[:content].slice!(0, 8)
|
108
|
-
real_iv = force_binary(opt[:salt]) + iv + [1].pack('N')
|
109
|
-
else
|
110
|
-
real_iv = iv = self[:content].slice!(0, 16)
|
111
|
-
end
|
112
|
-
cipher.iv = real_iv
|
98
|
+
iv = compute_iv_for_decrypting(opt[:salt].b, self[:content])
|
113
99
|
|
114
100
|
if authenticated?
|
115
101
|
if @icv_length.zero?
|
@@ -140,60 +126,28 @@ module PacketGen::Plugin
|
|
140
126
|
# @option options [OpenSSL::HMAC] :intmode integrity mode to use with a
|
141
127
|
# confidentiality-only cipher. Only HMAC are supported.
|
142
128
|
# @return [self]
|
143
|
-
def encrypt!(cipher, iv, options={})
|
129
|
+
def encrypt!(cipher, iv, options={}) # rubocop:disable Naming/MethodParameterName
|
144
130
|
opt = { salt: '' }.merge!(options)
|
145
131
|
|
146
132
|
set_crypto cipher, opt[:intmode]
|
147
|
-
|
148
|
-
real_iv = force_binary(opt[:salt]) + force_binary(iv)
|
149
|
-
real_iv += [1].pack('N') if confidentiality_mode == 'ctr'
|
150
|
-
cipher.iv = real_iv
|
133
|
+
compute_iv_for_encrypting iv, opt[:salt]
|
151
134
|
|
152
135
|
authenticate_if_needed iv
|
153
|
-
|
154
|
-
if
|
155
|
-
pad_length = opt[:pad_length]
|
156
|
-
padding = force_binary(opt[:padding] || ([0] * pad_length).pack('C*'))
|
157
|
-
else
|
158
|
-
pad_length = cipher.block_size
|
159
|
-
pad_length = 16 if cipher.block_size == 1 # Some AES mode returns 1...
|
160
|
-
pad_length -= (self[:body].sz + iv.size + 1) % cipher.block_size
|
161
|
-
pad_length = 0 if pad_length == 16
|
162
|
-
padding = force_binary(opt[:padding] || ([0] * pad_length).pack('C*'))
|
163
|
-
padding = padding[0, pad_length]
|
164
|
-
end
|
165
|
-
msg = self[:body].to_s + padding + PacketGen::Types::Int8.new(pad_length).to_s
|
166
|
-
encrypted_msg = encipher(msg)
|
167
|
-
cipher.final # message is already padded. No need for mode padding
|
168
|
-
|
169
|
-
if authenticated?
|
170
|
-
@icv_length = opt[:icv_length] if opt[:icv_length]
|
171
|
-
encrypted_msg << if @conf.authenticated?
|
172
|
-
@conf.auth_tag[0, @icv_length]
|
173
|
-
else
|
174
|
-
@intg.digest[0, @icv_length]
|
175
|
-
end
|
176
|
-
end
|
136
|
+
encrypted_msg = encrypt_body(iv, opt)
|
137
|
+
encrypted_msg << generate_auth_tag(opt) if authenticated?
|
177
138
|
self[:content].read(iv + encrypted_msg)
|
178
139
|
|
179
140
|
# Remove plain payloads
|
180
|
-
self[:body] =
|
181
|
-
|
182
|
-
# Remove enciphered payloads from packet
|
183
|
-
id = header_id(self)
|
184
|
-
if id < packet.headers.size - 1
|
185
|
-
(packet.headers.size - 1).downto(id + 1) do |index|
|
186
|
-
packet.headers.delete_at index
|
187
|
-
end
|
188
|
-
end
|
141
|
+
self[:body] = BinStruct::String.new
|
189
142
|
|
143
|
+
remove_enciphered_packets
|
190
144
|
self.calc_length
|
191
145
|
self
|
192
146
|
end
|
193
147
|
|
194
148
|
private
|
195
149
|
|
196
|
-
def authenticate_if_needed(iv, icv=nil)
|
150
|
+
def authenticate_if_needed(iv, icv=nil) # rubocop:disable Naming/MethodParameterName
|
197
151
|
if @conf.authenticated?
|
198
152
|
@conf.auth_tag = icv if icv
|
199
153
|
@conf.auth_data = get_ad
|
@@ -207,51 +161,99 @@ module PacketGen::Plugin
|
|
207
161
|
end
|
208
162
|
end
|
209
163
|
|
164
|
+
def encrypt_body(iv, opt) # rubocop:disable Naming/MethodParameterName
|
165
|
+
padding, pad_length = compute_padding(iv, opt)
|
166
|
+
msg = self[:body].to_s + padding.b + BinStruct::Int8.new(value: pad_length).to_s
|
167
|
+
encrypted_msg = encipher(msg)
|
168
|
+
@conf.final # message is already padded. No need for mode padding
|
169
|
+
encrypted_msg
|
170
|
+
end
|
171
|
+
|
172
|
+
def compute_padding(iv, opt) # rubocop:disable Naming/MethodParameterName
|
173
|
+
if opt[:pad_length]
|
174
|
+
pad_length = opt[:pad_length]
|
175
|
+
padding = opt[:padding] || ([0] * pad_length).pack('C*')
|
176
|
+
else
|
177
|
+
pad_length = compute_pad_length(iv)
|
178
|
+
padding = opt[:padding] || ([0] * pad_length).pack('C*')
|
179
|
+
padding = padding[0, pad_length]
|
180
|
+
end
|
181
|
+
[padding, pad_length]
|
182
|
+
end
|
183
|
+
|
184
|
+
def compute_pad_length(iv) # rubocop:disable Naming/MethodParameterName
|
185
|
+
pad_length = @conf.block_size
|
186
|
+
pad_length = 16 if @conf.block_size == 1 # Some AES mode returns 1...
|
187
|
+
pad_length -= (self[:body].sz + iv.size + 1) % @conf.block_size
|
188
|
+
pad_length = 0 if pad_length == 16
|
189
|
+
pad_length
|
190
|
+
end
|
191
|
+
|
192
|
+
def generate_auth_tag(opt)
|
193
|
+
@icv_length = opt[:icv_length] if opt[:icv_length]
|
194
|
+
if @conf.authenticated?
|
195
|
+
@conf.auth_tag[0, @icv_length]
|
196
|
+
else
|
197
|
+
@intg.digest[0, @icv_length]
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def remove_enciphered_packets
|
202
|
+
id = header_id(self)
|
203
|
+
return if id >= packet.headers.size - 1
|
204
|
+
|
205
|
+
(packet.headers.size - 1).downto(id + 1) do |index|
|
206
|
+
packet.headers.delete_at index
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
210
|
# From RFC 7206, §5.1: The associated data MUST consist of the partial
|
211
211
|
# contents of the IKEv2 message, starting from the first octet of the
|
212
212
|
# Fixed IKE Plugin through the last octet of the Payload Plugin of the
|
213
213
|
# Encrypted Payload (i.e., the fourth octet of the Encrypted Payload).
|
214
|
-
def get_ad
|
214
|
+
def get_ad # rubocop:disable Naming/AccessorMethodName
|
215
215
|
str = packet.ike.to_s[0, IKE.new.sz]
|
216
216
|
current_payload = packet.ike[:body]
|
217
217
|
until current_payload.is_a? SK
|
218
|
-
str << current_payload.to_s
|
218
|
+
str << current_payload.to_s
|
219
219
|
current_payload = current_payload[:body]
|
220
220
|
end
|
221
221
|
str << self.to_s[0, SK.new.sz]
|
222
222
|
end
|
223
223
|
|
224
224
|
def private_decrypt(options)
|
225
|
-
# decrypt
|
226
225
|
plain_msg = decipher(content.to_s)
|
227
226
|
# Remove cipher text
|
228
227
|
self[:content].read ''
|
229
228
|
|
230
229
|
# check authentication tag
|
231
|
-
if authenticated?
|
232
|
-
return false unless authenticate!
|
233
|
-
end
|
234
|
-
|
235
|
-
# remove padding
|
236
|
-
pad_len = PacketGen::Types::Int8.new.read(plain_msg[-1]).to_i
|
237
|
-
payloads = plain_msg[0, plain_msg.size - 1 - pad_len]
|
230
|
+
return false if authenticated? && !authenticate!
|
238
231
|
|
239
|
-
|
232
|
+
payloads = remove_padding(plain_msg)
|
240
233
|
if options[:parse]
|
241
|
-
|
242
|
-
cst = IKE.const_get(c)
|
243
|
-
cst.is_a?(Class) && (cst < Payload) && (cst::PAYLOAD_TYPE == self.next)
|
244
|
-
end
|
245
|
-
klass = klass.nil? ? Payload : IKE.const_get(klass.first)
|
246
|
-
firsth = klass.protocol_name
|
247
|
-
pkt = PacketGen::Packet.parse(payloads, first_header: firsth)
|
248
|
-
packet.encapsulate(pkt, parsing: true) unless pkt.nil?
|
234
|
+
parse_ike_payloads(payloads)
|
249
235
|
else
|
250
236
|
self[:body].read payloads
|
251
237
|
end
|
252
238
|
|
253
239
|
true
|
254
240
|
end
|
241
|
+
|
242
|
+
def remove_padding(msg)
|
243
|
+
pad_len = BinStruct::Int8.new.read(msg[-1]).to_i
|
244
|
+
msg[0, msg.size - 1 - pad_len]
|
245
|
+
end
|
246
|
+
|
247
|
+
def parse_ike_payloads(payloads)
|
248
|
+
klass = IKE.constants.select do |c|
|
249
|
+
cst = IKE.const_get(c)
|
250
|
+
cst.is_a?(Class) && (cst < Payload) && (self.next == cst::PAYLOAD_TYPE)
|
251
|
+
end
|
252
|
+
klass = klass.nil? ? Payload : IKE.const_get(klass.first)
|
253
|
+
firsth = klass.protocol_name
|
254
|
+
pkt = PacketGen::Packet.parse(payloads, first_header: firsth)
|
255
|
+
packet.encapsulate(pkt, parsing: true) unless pkt.nil?
|
256
|
+
end
|
255
257
|
end
|
256
258
|
end
|
257
259
|
|
@@ -25,7 +25,7 @@ module PacketGen::Plugin
|
|
25
25
|
# | |
|
26
26
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
27
27
|
# @author Sylvain Daubert
|
28
|
-
class TrafficSelector <
|
28
|
+
class TrafficSelector < BinStruct::Struct
|
29
29
|
# IPv4 traffic selector type
|
30
30
|
TS_IPV4_ADDR_RANGE = 7
|
31
31
|
# IPv6 traffic selector type
|
@@ -34,37 +34,40 @@ module PacketGen::Plugin
|
|
34
34
|
# @!attribute [r] type
|
35
35
|
# 8-bit TS type
|
36
36
|
# @return [Integer]
|
37
|
-
|
37
|
+
define_attr :type, BinStruct::Int8, default: 7
|
38
38
|
# @!attribute [r] protocol
|
39
39
|
# 8-bit protocol ID
|
40
40
|
# @return [Integer]
|
41
|
-
|
41
|
+
define_attr :protocol, BinStruct::Int8, default: 0
|
42
42
|
# @!attribute length
|
43
43
|
# 16-bit Selector Length
|
44
44
|
# @return [Integer]
|
45
|
-
|
45
|
+
define_attr :length, BinStruct::Int16
|
46
46
|
# @!attribute start_port
|
47
47
|
# 16-bit Start port
|
48
48
|
# @return [Integer]
|
49
|
-
|
49
|
+
define_attr :start_port, BinStruct::Int16, default: 0
|
50
50
|
# @!attribute end_port
|
51
51
|
# 16-bit End port
|
52
52
|
# @return [Integer]
|
53
|
-
|
53
|
+
define_attr :end_port, BinStruct::Int16, default: 65_535
|
54
54
|
# @!attribute start_addr
|
55
55
|
# starting address
|
56
56
|
# @return [IP::Addr, IPv6::Addr]
|
57
|
-
|
57
|
+
define_attr :start_addr, PacketGen::Header::IP::Addr
|
58
58
|
# @!attribute end_addr
|
59
59
|
# starting address
|
60
60
|
# @return [IP::Addr, IPv6::Addr]
|
61
|
-
|
61
|
+
define_attr :end_addr, PacketGen::Header::IP::Addr
|
62
62
|
|
63
63
|
# @param [Hash] options
|
64
|
+
# @options[Integer] :type
|
65
|
+
# @options[Integer] :protocol
|
66
|
+
# @options[Integer] :length
|
67
|
+
# @option [String] :start_addr
|
68
|
+
# @option [String] :end_addr
|
64
69
|
# @option [Range] :ports port range
|
65
|
-
|
66
|
-
# @option [Integer] :end_port end port
|
67
|
-
def initialize(options={})
|
70
|
+
def initialize(options={}) # rubocop:disable Metrics/AbcSize
|
68
71
|
super
|
69
72
|
select_addr options
|
70
73
|
self[:start_addr].from_human(options[:start_addr]) if options[:start_addr]
|
@@ -186,7 +189,7 @@ module PacketGen::Plugin
|
|
186
189
|
|
187
190
|
# Set of {TrafficSelector}, used by {TSi} and {TSr}.
|
188
191
|
# @author Sylvain Daubert
|
189
|
-
class TrafficSelectors <
|
192
|
+
class TrafficSelectors < BinStruct::Array
|
190
193
|
set_of TrafficSelector
|
191
194
|
end
|
192
195
|
|
@@ -223,22 +226,22 @@ module PacketGen::Plugin
|
|
223
226
|
# Payload type number
|
224
227
|
PAYLOAD_TYPE = 44
|
225
228
|
|
226
|
-
|
229
|
+
remove_attr :content
|
227
230
|
|
228
231
|
# @!attribute num_ts
|
229
232
|
# 8-bit Number of TSs
|
230
233
|
# @return [Integer]
|
231
|
-
|
234
|
+
define_attr_before :body, :num_ts, BinStruct::Int8
|
232
235
|
# @!attribute rsv
|
233
236
|
# 24-bit RESERVED field
|
234
237
|
# @return [Integer]
|
235
|
-
|
238
|
+
define_attr_before :body, :rsv, BinStruct::Int24
|
236
239
|
|
237
240
|
# @!attribute traffic_selectors
|
238
241
|
# Set of {TrafficSelector}
|
239
242
|
# @return {TrafficSelectors}
|
240
|
-
|
241
|
-
|
243
|
+
define_attr_before :body, :traffic_selectors, TrafficSelectors,
|
244
|
+
builder: ->(h, t) { t.new(counter: h[:num_ts]) }
|
242
245
|
alias selectors traffic_selectors
|
243
246
|
|
244
247
|
# Compute length and set {#length} field
|
@@ -11,7 +11,7 @@ module PacketGen::Plugin
|
|
11
11
|
# This class handles Vendor ID payloads, as defined in RFC 7296 §3.12.
|
12
12
|
#
|
13
13
|
# A Vendor ID payload contains a generic payload Plugin (see {Payload})
|
14
|
-
# and data field (type {
|
14
|
+
# and data field (type {BinStruct::String}):
|
15
15
|
# 1 2 3
|
16
16
|
# 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
|
17
17
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
data/lib/packetgen/plugin/ike.rb
CHANGED
@@ -13,10 +13,10 @@ module PacketGen::Plugin
|
|
13
13
|
# @!attribute non_esp_marker
|
14
14
|
# 32-bit zero marker to differentiate IKE packet over UDP port 4500 from ESP ones
|
15
15
|
# @return [Integer]
|
16
|
-
|
16
|
+
define_attr :non_esp_marker, BinStruct::Int32, default: 0
|
17
17
|
# @!attribute body
|
18
|
-
# @return [
|
19
|
-
|
18
|
+
# @return [BinStruct::String,PacketGen::Header::Base]
|
19
|
+
define_attr :body, BinStruct::String
|
20
20
|
|
21
21
|
# Check non_esp_marker field
|
22
22
|
# @see [PacketGen::Header::Base#parse?]
|
@@ -48,15 +48,15 @@ module PacketGen::Plugin
|
|
48
48
|
# | Length |
|
49
49
|
# +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|
50
50
|
# A IKE Plugin consists of:
|
51
|
-
# * a IKE SA initiator SPI ({#init_spi}, {
|
52
|
-
# * a IKE SA responder SPI ({#resp_spi}, {
|
53
|
-
# * a Next Payload field ({#next}, {
|
54
|
-
# * a Version field ({#version}, {
|
51
|
+
# * a IKE SA initiator SPI ({#init_spi}, {BinStruct::Int64} type),
|
52
|
+
# * a IKE SA responder SPI ({#resp_spi}, {BinStruct::Int64} type),
|
53
|
+
# * a Next Payload field ({#next}, {BinStruct::Int8} type),
|
54
|
+
# * a Version field ({#version}, {BinStruct::Int8} type, with first 4-bit field
|
55
55
|
# as major number, and last 4-bit field as minor number),
|
56
|
-
# * a Exchange type ({#exchange_type}, {
|
57
|
-
# * a {#flags} field ({
|
58
|
-
# * a Message ID ({#message_id}, {
|
59
|
-
# * and a {#length} ({
|
56
|
+
# * a Exchange type ({#exchange_type}, {BinStruct::Int8} type),
|
57
|
+
# * a {#flags} field ({BinStruct::Int8} type),
|
58
|
+
# * a Message ID ({#message_id}, {BinStruct::Int32} type),
|
59
|
+
# * and a {#length} ({BinStruct::Int32} type).
|
60
60
|
#
|
61
61
|
# == Create a IKE Plugin
|
62
62
|
# === Standalone
|
@@ -94,48 +94,32 @@ module PacketGen::Plugin
|
|
94
94
|
# @!attribute init_spi
|
95
95
|
# 64-bit initiator SPI
|
96
96
|
# @return [Integer]
|
97
|
-
|
97
|
+
define_attr :init_spi, BinStruct::Int64
|
98
98
|
# @!attribute resp_spi
|
99
99
|
# 64-bit responder SPI
|
100
100
|
# @return [Integer]
|
101
|
-
|
101
|
+
define_attr :resp_spi, BinStruct::Int64
|
102
102
|
# @!attribute next
|
103
103
|
# 8-bit next payload type
|
104
104
|
# @return [Integer]
|
105
|
-
|
105
|
+
define_attr :next, BinStruct::Int8
|
106
106
|
# @!attribute version
|
107
107
|
# 8-bit IKE version
|
108
108
|
# @return [Integer]
|
109
|
-
|
109
|
+
# @!attribute mjver
|
110
|
+
# 4-bit major version value ({#version}'s 4 most significant bits)
|
111
|
+
# @return [Integer]
|
112
|
+
# @!attribute mnver
|
113
|
+
# 4-bit minor version value ({#version}'s 4 least significant bits)
|
114
|
+
# @return [Integer]
|
115
|
+
define_bit_attr :version, default: 0x20, mjver: 4, mver: 4
|
110
116
|
# @!attribute [r] exchange_type
|
111
117
|
# 8-bit exchange type
|
112
118
|
# @return [Integer]
|
113
|
-
|
114
|
-
# @!attribute flags
|
119
|
+
define_attr :exchange_type, BinStruct::Int8Enum, enum: EXCHANGE_TYPES
|
120
|
+
# @!attribute flags. See {#flag_r}, {#flag_v} and {#flag_i}.
|
115
121
|
# 8-bit flags
|
116
122
|
# @return [Integer]
|
117
|
-
define_field :flags, PacketGen::Types::Int8
|
118
|
-
# @!attribute message_id
|
119
|
-
# 32-bit message ID
|
120
|
-
# @return [Integer]
|
121
|
-
define_field :message_id, PacketGen::Types::Int32
|
122
|
-
# @!attribute length
|
123
|
-
# 32-bit length of total message (Plugin + payloads)
|
124
|
-
# @return [Integer]
|
125
|
-
define_field :length, PacketGen::Types::Int32
|
126
|
-
|
127
|
-
# Defining a body permits using Packet#parse to parse IKE payloads.
|
128
|
-
# But this method is hidden as prefered way to access payloads is via #payloads
|
129
|
-
define_field :body, PacketGen::Types::String
|
130
|
-
|
131
|
-
# @!attribute mjver
|
132
|
-
# 4-bit major version value
|
133
|
-
# @return [Integer]
|
134
|
-
# @!attribute mnver
|
135
|
-
# 4-bit minor version value
|
136
|
-
# @return [Integer]
|
137
|
-
define_bit_fields_on :version, :mjver, 4, :mnver, 4
|
138
|
-
|
139
123
|
# @!attribute rsv1
|
140
124
|
# @return [Integer]
|
141
125
|
# @!attribute rsv2
|
@@ -149,7 +133,19 @@ module PacketGen::Plugin
|
|
149
133
|
# @!attribute flag_v
|
150
134
|
# version flag. Ignored by IKEv2 peers, and should be set to 0
|
151
135
|
# @return [Boolean]
|
152
|
-
|
136
|
+
define_bit_attr :flags, rsv1: 2, flag_r: 1, flag_v: 1, flag_i: 1, rsv2: 3
|
137
|
+
# @!attribute message_id
|
138
|
+
# 32-bit message ID
|
139
|
+
# @return [Integer]
|
140
|
+
define_attr :message_id, BinStruct::Int32
|
141
|
+
# @!attribute length
|
142
|
+
# 32-bit length of total message (Plugin + payloads)
|
143
|
+
# @return [Integer]
|
144
|
+
define_attr :length, BinStruct::Int32
|
145
|
+
|
146
|
+
# Defining a body permits using Packet#parse to parse IKE payloads.
|
147
|
+
# But this method is hidden as prefered way to access payloads is via #payloads
|
148
|
+
define_attr :body, BinStruct::String
|
153
149
|
|
154
150
|
# @param [Hash] options
|
155
151
|
# @see PacketGen::Header::Base#initialize
|
@@ -198,8 +194,7 @@ module PacketGen::Plugin
|
|
198
194
|
str_flags << (send("flag_#{flag}?") ? flag.upcase : '.')
|
199
195
|
end
|
200
196
|
str = PacketGen::Inspect.shift_level
|
201
|
-
str << PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''), attr,
|
202
|
-
str_flags]
|
197
|
+
str << (PacketGen::Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''), attr, str_flags])
|
203
198
|
end
|
204
199
|
end
|
205
200
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'packetgen/plugin/ipsec_version'
|
@@ -8,8 +10,7 @@ Gem::Specification.new do |spec|
|
|
8
10
|
spec.authors = ['Sylvain Daubert']
|
9
11
|
spec.email = ['sylvain.daubert@laposte.net']
|
10
12
|
|
11
|
-
spec.summary =
|
12
|
-
#spec.description = %q{TODO: Write a longer description or delete this line.}
|
13
|
+
spec.summary = 'IPsec plugin for packetgen.'
|
13
14
|
spec.homepage = 'https://github.com/sdaubert/packetgen-plugin-ipsec'
|
14
15
|
|
15
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
@@ -17,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
17
18
|
end
|
18
19
|
spec.require_paths = ['lib']
|
19
20
|
|
20
|
-
spec.required_ruby_version = '>=
|
21
|
+
spec.required_ruby_version = '>= 3.0.0'
|
21
22
|
|
22
|
-
spec.add_dependency 'packetgen', '~>
|
23
|
+
spec.add_dependency 'packetgen', '~>4.0'
|
23
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packetgen-plugin-ipsec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvain Daubert
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: packetgen
|
@@ -16,21 +16,15 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 3.1.7
|
19
|
+
version: '4.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
24
|
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
30
|
-
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: 3.1.7
|
33
|
-
description:
|
26
|
+
version: '4.0'
|
27
|
+
description:
|
34
28
|
email:
|
35
29
|
- sylvain.daubert@laposte.net
|
36
30
|
executables: []
|
@@ -40,7 +34,6 @@ files:
|
|
40
34
|
- ".github/workflows/specs.yml"
|
41
35
|
- ".gitignore"
|
42
36
|
- ".rubocop.yml"
|
43
|
-
- ".travis.yml"
|
44
37
|
- Gemfile
|
45
38
|
- LICENSE
|
46
39
|
- README.md
|
@@ -66,7 +59,7 @@ files:
|
|
66
59
|
homepage: https://github.com/sdaubert/packetgen-plugin-ipsec
|
67
60
|
licenses: []
|
68
61
|
metadata: {}
|
69
|
-
post_install_message:
|
62
|
+
post_install_message:
|
70
63
|
rdoc_options: []
|
71
64
|
require_paths:
|
72
65
|
- lib
|
@@ -74,16 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
67
|
requirements:
|
75
68
|
- - ">="
|
76
69
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
70
|
+
version: 3.0.0
|
78
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
72
|
requirements:
|
80
73
|
- - ">="
|
81
74
|
- !ruby/object:Gem::Version
|
82
75
|
version: '0'
|
83
76
|
requirements: []
|
84
|
-
|
85
|
-
|
86
|
-
signing_key:
|
77
|
+
rubygems_version: 3.3.15
|
78
|
+
signing_key:
|
87
79
|
specification_version: 4
|
88
80
|
summary: IPsec plugin for packetgen.
|
89
81
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.3
|
4
|
-
- 2.4
|
5
|
-
- 2.5
|
6
|
-
- 2.6
|
7
|
-
|
8
|
-
install:
|
9
|
-
- sudo apt-get update -qq
|
10
|
-
- sudo apt-get install libpcap-dev -qq
|
11
|
-
- gem install bundler
|
12
|
-
- bundle install --path vendor/bundle --jobs=3 --retry=3
|
13
|
-
script:
|
14
|
-
- bundle exec rake
|