porky_lib 0.6.1 → 0.6.2

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
  SHA256:
3
- metadata.gz: 53ca6a913c5a5f9c9a71bb22032a31caecba2a460aff2e03fae6ac7fcfa93f54
4
- data.tar.gz: '0978ad17a78ee37962a36d563ea08061f9e8d8ee84ec838c9e31295a27883764'
3
+ metadata.gz: 073de134fa0c5a3b836f975475ecd1373488cc7a1549f1d5d363a3f1363c6488
4
+ data.tar.gz: 0e03c14d1d9251f9ce5caa4b47d172c9c09991040aebc7a36e28513edddeccac
5
5
  SHA512:
6
- metadata.gz: f05acefd1344c4ca9003fe0388084709dd6bcb8bc21899c00cdc37dae0575a02dd16dec2e5d05de7f8ab7096fc8dc7676a8f759ff6a84f0bc328ad2567fd46e0
7
- data.tar.gz: 9399aa25b56b4bfbbbfcb4904eab7a5609c67d6304c6803b3b14b101b03cceb4ddc4e56870e3106fcca2b691eda7163ab196396e63125fc1b7de176b974572c2
6
+ metadata.gz: 774a7f3448d8dacc59dbd8302b9edbe70a5e6b28ee6d7bb95edd9e7b3e3a1b050a125ed7c31027358849adb3a9bf7fdf592ba19f78e1bb6a76eb9bbe978dfdc1
7
+ data.tar.gz: f7f67d35b7ad9624addee071af67b94c9def18aff469f62636ee92b781342cd98caedd44ac4ad3a7216fb5b95d2adaee6dbd6a7bfa5242f7d47e41cd76ad043c
data/.hound.yml CHANGED
@@ -11,7 +11,7 @@ haml:
11
11
  enabled: false
12
12
 
13
13
  reek:
14
- enabled: true
14
+ enabled: false
15
15
 
16
16
  erblint:
17
17
  enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- porky_lib (0.6.1)
4
+ porky_lib (0.6.2)
5
5
  aws-sdk-kms
6
6
  aws-sdk-s3
7
7
  msgpack
@@ -13,8 +13,8 @@ GEM
13
13
  specs:
14
14
  ast (2.4.0)
15
15
  aws-eventstream (1.0.3)
16
- aws-partitions (1.193.0)
17
- aws-sdk-core (3.61.1)
16
+ aws-partitions (1.207.0)
17
+ aws-sdk-core (3.65.1)
18
18
  aws-eventstream (~> 1.0, >= 1.0.2)
19
19
  aws-partitions (~> 1.0)
20
20
  aws-sigv4 (~> 1.1)
@@ -22,7 +22,7 @@ GEM
22
22
  aws-sdk-kms (1.24.0)
23
23
  aws-sdk-core (~> 3, >= 3.61.1)
24
24
  aws-sigv4 (~> 1.1)
25
- aws-sdk-s3 (1.46.0)
25
+ aws-sdk-s3 (1.47.0)
26
26
  aws-sdk-core (~> 3, >= 3.61.1)
27
27
  aws-sdk-kms (~> 1)
28
28
  aws-sigv4 (~> 1.1)
@@ -191,6 +191,53 @@ class PorkyLib::Symmetric
191
191
  "\0" * length
192
192
  end
193
193
 
194
+ def encrypt_with_key_with_benchmark(plaintext, plaintext_key)
195
+ encryption_statistics = {}
196
+
197
+ nonce, ciphertext = benchmark_block(encryption_statistics, :encrypt) do
198
+ # Initialize the box
199
+ secret_box = RbNaCl::SecretBox.new(plaintext_key)
200
+
201
+ # First, make a nonce: A single-use value never repeated under the same key
202
+ # The nonce isn't secret, and can be sent with the ciphertext.
203
+ # The cipher instance has a nonce_bytes method for determining how many bytes should be in a nonce
204
+ nonce = RbNaCl::Random.random_bytes(secret_box.nonce_bytes)
205
+
206
+ # Encrypt a message with SecretBox
207
+ ciphertext = secret_box.encrypt(nonce, plaintext)
208
+
209
+ [nonce, ciphertext]
210
+ end
211
+
212
+ result = OpenStruct.new
213
+
214
+ result.ciphertext = ciphertext
215
+ result.nonce = nonce
216
+ result.statistics = encryption_statistics
217
+
218
+ result
219
+ end
220
+
221
+ def decrypt_with_key_with_benchmark(ciphertext, plaintext_key, nonce)
222
+ encryption_statistics = {}
223
+
224
+ plaintext = benchmark_block(encryption_statistics, :decrypt) do
225
+ secret_box = RbNaCl::SecretBox.new(plaintext_key)
226
+
227
+ # Decrypt the message
228
+ plaintext = secret_box.decrypt(nonce, ciphertext)
229
+
230
+ plaintext
231
+ end
232
+
233
+ result = OpenStruct.new
234
+
235
+ result.plaintext = plaintext
236
+ result.statistics = encryption_statistics
237
+
238
+ result
239
+ end
240
+
194
241
  private
195
242
 
196
243
  def benchmark_block(statistics, stat_label)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PorkyLib
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: porky_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Fletcher
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-22 00:00:00.000000000 Z
11
+ date: 2019-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-kms