packetgen-plugin-ipsec 1.0.2 → 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 +32 -0
- data/.rubocop.yml +28 -3
- data/Gemfile +18 -0
- data/README.md +12 -6
- data/Rakefile +10 -4
- data/lib/packetgen/plugin/crypto.rb +38 -4
- data/lib/packetgen/plugin/esp.rb +410 -378
- data/lib/packetgen/plugin/ike/auth.rb +153 -140
- data/lib/packetgen/plugin/ike/cert.rb +61 -62
- data/lib/packetgen/plugin/ike/certreq.rb +51 -52
- data/lib/packetgen/plugin/ike/id.rb +80 -81
- data/lib/packetgen/plugin/ike/ke.rb +64 -65
- data/lib/packetgen/plugin/ike/nonce.rb +29 -31
- data/lib/packetgen/plugin/ike/notify.rb +134 -139
- data/lib/packetgen/plugin/ike/payload.rb +75 -76
- data/lib/packetgen/plugin/ike/sa.rb +515 -452
- data/lib/packetgen/plugin/ike/sk.rb +221 -221
- data/lib/packetgen/plugin/ike/ts.rb +226 -223
- data/lib/packetgen/plugin/ike/vendor_id.rb +28 -30
- data/lib/packetgen/plugin/ike.rb +213 -217
- data/lib/packetgen/plugin/ipsec_version.rb +8 -1
- data/lib/packetgen-plugin-ipsec.rb +2 -0
- data/packetgen-plugin-ipsec.gemspec +6 -11
- metadata +11 -88
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63e6c93595c3d2f6361e87c0c5dd6cf60a792fadf6f15ecd52a8fe38be56bf29
|
4
|
+
data.tar.gz: 7759ddd4bdb74e1b510db940114c38e89ac6865d803c8966ebbc2b80c7379f97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dab304078f641492b8b6f431777ee1fc1a1a701d3351660ea276321cea9d6a3f00def177c6da41e30c76970f684a29a2e26558b90fa6e43527d41af7e9598235
|
7
|
+
data.tar.gz: 475aeb08d49dcbfd0c45c40181546c96c531f8d1772a253c64d3314337d65380b08d3c9a718e08c8c9aedc68396585e7e951c2e7a0013e2f503b3972367d38df
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Specs
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
strategy:
|
12
|
+
fail-fast: false
|
13
|
+
matrix:
|
14
|
+
os: [ubuntu-latest]
|
15
|
+
ruby: ['3.0', '3.1', '3.2', '3.3', '3.4']
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Install dependencies
|
20
|
+
run: sudo apt-get update -qq && sudo apt-get install libpcap-dev -qq
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
- name: Install Gems
|
26
|
+
run: |
|
27
|
+
bundle config set path 'vendor/bundle'
|
28
|
+
bundle config set --local without noci
|
29
|
+
bundle install
|
30
|
+
- name: Run tests
|
31
|
+
run: |
|
32
|
+
bundle exec rake
|
data/.rubocop.yml
CHANGED
@@ -1,14 +1,39 @@
|
|
1
|
-
|
1
|
+
plugins:
|
2
|
+
- rubocop-performance
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: "3.0"
|
5
|
+
NewCops: enable
|
6
|
+
Exclude:
|
7
|
+
- .git/**/*
|
8
|
+
- spec/**/*
|
9
|
+
- vendor/**/*
|
10
|
+
Layout/LineLength:
|
11
|
+
Enabled: false
|
2
12
|
Layout/SpaceAroundEqualsInParameterDefault:
|
3
13
|
EnforcedStyle: no_space
|
4
14
|
Lint/EmptyWhen:
|
5
15
|
Enabled: false
|
6
16
|
Lint/Void:
|
7
17
|
Enabled: false
|
8
|
-
Metrics:
|
18
|
+
Metrics/AbcSize:
|
19
|
+
Max: 20
|
20
|
+
Metrics/ClassLength:
|
21
|
+
Max: 200
|
22
|
+
Metrics/MethodLength:
|
23
|
+
Max: 20
|
24
|
+
Metrics/ParameterLists:
|
25
|
+
MaxOptionalParameters: 4
|
26
|
+
Naming/FileName:
|
27
|
+
Enabled: false
|
28
|
+
Style/AccessModifierDeclarations:
|
9
29
|
Enabled: false
|
10
30
|
Style/AsciiComments:
|
11
31
|
Enabled: false
|
32
|
+
Style/ClassAndModuleChildren:
|
33
|
+
Enabled: false
|
34
|
+
Style/Documentation:
|
35
|
+
# Too many false positives!
|
36
|
+
Enabled: false
|
12
37
|
Style/Encoding:
|
13
38
|
Enabled: false
|
14
39
|
Style/EvalWithLocation:
|
@@ -16,7 +41,7 @@ Style/EvalWithLocation:
|
|
16
41
|
Style/FormatString:
|
17
42
|
EnforcedStyle: percent
|
18
43
|
Style/FormatStringToken:
|
19
|
-
|
44
|
+
MaxUnannotatedPlaceholdersAllowed: 3
|
20
45
|
Style/PerlBackrefs:
|
21
46
|
Enabled: false
|
22
47
|
Style/RedundantSelf:
|
data/Gemfile
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
6
|
+
|
7
|
+
gem 'bundler', '>= 1.17', '< 3'
|
8
|
+
|
9
|
+
group :development do
|
10
|
+
gem 'rake', '~>13.0', require: false
|
11
|
+
gem 'rspec', '~>3.13'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :noci do
|
15
|
+
gem 'rubocop', '~> 1.12', require: false
|
16
|
+
gem 'rubocop-performance', '~> 1.13', require: false
|
17
|
+
gem 'ruby-lsp', require: false
|
18
|
+
gem 'ruby-lsp-rspec', require: false
|
19
|
+
gem 'simplecov', '~> 0.21', require: false
|
20
|
+
gem 'yard', '~> 0.9', require: false
|
21
|
+
end
|
data/README.md
CHANGED
@@ -3,13 +3,15 @@
|
|
3
3
|
|
4
4
|
# packetgen-plugin-ipsec
|
5
5
|
|
6
|
-
**Warning:** this repository is a work-in-progress. It will be available with packetgen3.
|
7
|
-
|
8
6
|
This is a plugin for [PacketGen gem](https://github.com/sdaubert/packetgen). It adds two protocols:
|
9
7
|
|
10
8
|
* `PacketGen::Plugin::ESP`: IP Encapsulating Security Payload ([RFC 4303](https://tools.ietf.org/html/rfc4303)),
|
11
9
|
* `PacketGen::Plugin::IKE`: Internet Key Exchange v2 ([RFC 7296](https://tools.ietf.org/html/rfc7296)).
|
12
10
|
|
11
|
+
Versions 1.0.x are compatible with PacketGen 3.x.
|
12
|
+
|
13
|
+
Versions 1.1.x are compatible with PacketGen 4.x.
|
14
|
+
|
13
15
|
## Installation
|
14
16
|
|
15
17
|
Add this line to your application's Gemfile:
|
@@ -20,11 +22,15 @@ gem 'packetgen-plugin-ipsec'
|
|
20
22
|
|
21
23
|
And then execute:
|
22
24
|
|
23
|
-
|
25
|
+
```bash
|
26
|
+
bundle
|
27
|
+
```
|
24
28
|
|
25
29
|
Or install it yourself as:
|
26
30
|
|
27
|
-
|
31
|
+
```bash
|
32
|
+
gem install packetgen-plugin-ipsec
|
33
|
+
```
|
28
34
|
|
29
35
|
## Usage
|
30
36
|
|
@@ -86,7 +92,7 @@ pkt.to_w
|
|
86
92
|
|
87
93
|
## See also
|
88
94
|
|
89
|
-
API documentation: http://www.rubydoc.info/gems/packetgen-plugin-ipsec
|
95
|
+
API documentation: <http://www.rubydoc.info/gems/packetgen-plugin-ipsec>
|
90
96
|
|
91
97
|
## License
|
92
98
|
|
@@ -94,4 +100,4 @@ MIT License (see [LICENSE](https://github.com/sdaubert/packetgen-plugin-ipsec/bl
|
|
94
100
|
|
95
101
|
## Contributing
|
96
102
|
|
97
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/sdaubert/packetgen-plugin-ipsec
|
103
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/sdaubert/packetgen-plugin-ipsec>.
|
data/Rakefile
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'bundler/gem_tasks'
|
3
4
|
require 'rspec/core/rake_task'
|
4
|
-
require 'yard'
|
5
5
|
|
6
6
|
task default: :spec
|
7
7
|
|
8
8
|
RSpec::Core::RakeTask.new
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
begin
|
11
|
+
require 'yard'
|
12
|
+
|
13
|
+
YARD::Rake::YardocTask.new do |t|
|
14
|
+
t.options = ['--no-private']
|
15
|
+
t.files = ['lib/**/*.rb', '-', 'LICENSE']
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
# no yard, so no yard task
|
13
19
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
# This file is part of IPsec packetgen plugin.
|
3
5
|
# See https://github.com/sdaubert/packetgen-plugin-ipsec for more informations
|
4
6
|
# Copyright (c) 2018 Sylvain Daubert <sylvain.daubert@laposte.net>
|
5
7
|
# This program is published under MIT license.
|
6
8
|
|
7
|
-
# frozen_string_literal: true
|
8
|
-
|
9
9
|
module PacketGen::Plugin
|
10
10
|
# Mixin for cryptographic classes
|
11
11
|
# @api private
|
@@ -22,6 +22,7 @@ module PacketGen::Plugin
|
|
22
22
|
@conf = conf
|
23
23
|
@intg = intg
|
24
24
|
return unless conf.authenticated?
|
25
|
+
|
25
26
|
# #auth_tag_len only supported from ruby 2.4.0
|
26
27
|
@conf.auth_tag_len = @trunc if @conf.respond_to? :auth_tag_len
|
27
28
|
end
|
@@ -31,6 +32,7 @@ module PacketGen::Plugin
|
|
31
32
|
def confidentiality_mode
|
32
33
|
mode = @conf.name.match(/-([^-]*)$/)[1]
|
33
34
|
raise Error, 'unknown cipher mode' if mode.nil?
|
35
|
+
|
34
36
|
mode.downcase
|
35
37
|
end
|
36
38
|
|
@@ -59,7 +61,7 @@ module PacketGen::Plugin
|
|
59
61
|
# @return [String] enciphered data
|
60
62
|
def encipher(data)
|
61
63
|
enciphered_data = @conf.update(data)
|
62
|
-
@intg
|
64
|
+
@intg&.update(enciphered_data)
|
63
65
|
enciphered_data
|
64
66
|
end
|
65
67
|
|
@@ -67,8 +69,40 @@ module PacketGen::Plugin
|
|
67
69
|
# @param [String] data
|
68
70
|
# @return [String] deciphered data
|
69
71
|
def decipher(data)
|
70
|
-
@intg
|
72
|
+
@intg&.update(data)
|
71
73
|
@conf.update(data)
|
72
74
|
end
|
75
|
+
|
76
|
+
# Compute and set IV for deciphering mode
|
77
|
+
# @param [BinStruct::String] salt
|
78
|
+
# @param [String] msg ciphered message
|
79
|
+
# @return [String] iv
|
80
|
+
def compute_iv_for_decrypting(salt, msg)
|
81
|
+
case confidentiality_mode
|
82
|
+
when 'gcm'
|
83
|
+
iv = msg.slice!(0, 8)
|
84
|
+
real_iv = salt + iv
|
85
|
+
when 'cbc'
|
86
|
+
@conf.padding = 0
|
87
|
+
real_iv = iv = msg.slice!(0, 16)
|
88
|
+
when 'ctr'
|
89
|
+
iv = msg.slice!(0, 8)
|
90
|
+
real_iv = salt + iv + [1].pack('N')
|
91
|
+
else
|
92
|
+
real_iv = iv = msg.slice!(0, 16)
|
93
|
+
end
|
94
|
+
@conf.iv = real_iv
|
95
|
+
iv
|
96
|
+
end
|
97
|
+
|
98
|
+
# Compute and set real IV for ciphering mode
|
99
|
+
# @param [String] iv IV to use
|
100
|
+
# @param [String] salt salt to use
|
101
|
+
# @return [void]
|
102
|
+
def compute_iv_for_encrypting(iv, salt) # rubocop:disable Naming/MethodParameterName
|
103
|
+
real_iv = salt.b + iv.b
|
104
|
+
real_iv += [1].pack('N') if confidentiality_mode == 'ctr'
|
105
|
+
@conf.iv = real_iv
|
106
|
+
end
|
73
107
|
end
|
74
108
|
end
|