symmetric-encryption 4.0.0.beta3 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1b5ae57f5d8cdffd7543b690a8dc1c56e3d3d2
|
4
|
+
data.tar.gz: 8243a0f27600f82f27b098199292938b36c64f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51199eae1a22f24db637e403b774ac501c9e5f10635cabde7fb65e42517dace89c6badbe7de2649c6fc9ea8fec4f0f7f9544892b288000c31aa3a73ef0908b12
|
7
|
+
data.tar.gz: 8a912faebf87253678af05880029114dfe433edff0168207d200d9aefbffff9c3c1807d290904c1d1e22c9417ca0200849b77122bec26efc011dd82837753800
|
@@ -73,15 +73,16 @@ module SymmetricEncryption
|
|
73
73
|
|
74
74
|
config = cfg[:ciphers].first
|
75
75
|
|
76
|
+
# Only generate new keys for keystore's that have a key encrypting key
|
77
|
+
next unless config[:key_encrypting_key]
|
78
|
+
|
76
79
|
version = config.delete(:version) || 1
|
77
80
|
version -= 1
|
78
|
-
config.delete(:always_add_header)
|
79
|
-
config.delete(:encoding)
|
80
81
|
|
81
|
-
|
82
|
+
always_add_header = config.delete(:always_add_header)
|
83
|
+
encoding = config.delete(:encoding)
|
82
84
|
|
83
|
-
|
84
|
-
next unless config[:key_encrypting_key]
|
85
|
+
Key.migrate_config!(config)
|
85
86
|
|
86
87
|
# The current data encrypting key without any of the key encrypting keys.
|
87
88
|
key = Key.from_config(config)
|
@@ -96,7 +97,8 @@ module SymmetricEncryption
|
|
96
97
|
Keystore::Memory.new_key_config(cipher_name: cipher_name, app_name: app_name, version: version, environment: environment, dek: key)
|
97
98
|
end
|
98
99
|
|
99
|
-
new_key_config
|
100
|
+
new_key_config[:always_add_header] = always_add_header
|
101
|
+
new_key_config[:encoding] = encoding
|
100
102
|
|
101
103
|
# Replace existing config entry
|
102
104
|
cfg[:ciphers].shift
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# * The search looks for the header and then replaces the encrypted value.
|
7
7
|
#
|
8
8
|
# Example:
|
9
|
-
# re_encrypt = SymmetricEncryption::Utils::
|
9
|
+
# re_encrypt = SymmetricEncryption::Utils::ReEncryptFiles.new(version: 4)
|
10
10
|
# re_encrypt.process_directory('../../**/*.yml')
|
11
11
|
#
|
12
12
|
# Notes:
|
@@ -72,13 +72,10 @@ module SymmetricEncryption
|
|
72
72
|
line
|
73
73
|
end
|
74
74
|
end
|
75
|
-
if hits
|
75
|
+
if hits > 0
|
76
76
|
File.open(file_name, 'wb') { |file| file.write(output_lines) }
|
77
77
|
end
|
78
78
|
hits
|
79
|
-
rescue
|
80
|
-
puts "Failed re-encrypting the file contents of: #{file_name}"
|
81
|
-
raise
|
82
79
|
end
|
83
80
|
|
84
81
|
# Re Encrypt an entire file
|
@@ -112,8 +109,12 @@ module SymmetricEncryption
|
|
112
109
|
re_encrypt_file(file_name)
|
113
110
|
end
|
114
111
|
else
|
115
|
-
|
116
|
-
|
112
|
+
begin
|
113
|
+
count = re_encrypt_contents(file_name)
|
114
|
+
puts "Re-encrypted #{count} encrypted value(s) in: #{file_name}" if count > 0
|
115
|
+
rescue StandardError => exc
|
116
|
+
puts "Failed re-encrypting the file contents of: #{file_name}. #{exc.class.name}: #{exc.message}"
|
117
|
+
end
|
117
118
|
end
|
118
119
|
end
|
119
120
|
end
|
@@ -121,7 +122,7 @@ module SymmetricEncryption
|
|
121
122
|
private
|
122
123
|
|
123
124
|
def regexp
|
124
|
-
@regexp ||= /#{SymmetricEncryption.cipher.encoded_magic_header}([A-Za-z0-9+\/]
|
125
|
+
@regexp ||= /#{SymmetricEncryption.cipher.encoded_magic_header}([A-Za-z0-9+\/]+[=\\n]*)/
|
125
126
|
end
|
126
127
|
|
127
128
|
# Returns [Integer] encrypted file key version.
|
data/test/key_test.rb
CHANGED
@@ -2,6 +2,15 @@ require_relative 'test_helper'
|
|
2
2
|
|
3
3
|
class KeyTest < Minitest::Test
|
4
4
|
describe SymmetricEncryption::Key do
|
5
|
+
before do
|
6
|
+
Dir.mkdir('tmp') unless Dir.exist?('tmp')
|
7
|
+
end
|
8
|
+
|
9
|
+
after do
|
10
|
+
# Cleanup generated encryption key files.
|
11
|
+
`rm tmp/dek_tester* 2> /dev/null`
|
12
|
+
end
|
13
|
+
|
5
14
|
let :random_key do
|
6
15
|
SymmetricEncryption::Key.new
|
7
16
|
end
|
@@ -112,7 +121,7 @@ class KeyTest < Minitest::Test
|
|
112
121
|
end
|
113
122
|
|
114
123
|
let :dek_file_name do
|
115
|
-
'tmp/
|
124
|
+
'tmp/dek_tester_dek.encrypted_key'
|
116
125
|
end
|
117
126
|
|
118
127
|
describe 'key' do
|
data/test/test_db.sqlite3
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symmetric-encryption
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coercible
|
@@ -101,9 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '2.1'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- - "
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
|
-
version:
|
106
|
+
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
109
|
rubygems_version: 2.6.11
|