xaes_256_gcm 0.5 → 0.8
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/lib/xaes_256_gcm/version.rb +2 -2
- data/lib/xaes_256_gcm/xaes_256_gcm_cipher.rb +12 -6
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 73faefcbe3a499de749e304d7be28f445fc0ccc366da293398b4dda4a57b7fff
|
|
4
|
+
data.tar.gz: a76cb192c27a233b22656b9e5cb7ab07c935ac835c5855d4cfdcbe5c0f26b6eb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 53ed3ca206a66f4b3fc49272b6d56ac1b2c4c411aec8eb96969deacf08af49b3bdef21816b52d84f4b51a78bc1f12a61bf4805533444e15c8fcdbf8bfa1c08b4
|
|
7
|
+
data.tar.gz: 8a2cdc221b251eb8f0826c6402fe492d64ca44228b927d05607945cf5b65c33dee6a34a012bc96d9c9d8de2359a45cfe00041576ae203eddd0f23f57d98da6f0
|
data/lib/xaes_256_gcm/version.rb
CHANGED
|
@@ -17,7 +17,13 @@ module Xaes256Gcm
|
|
|
17
17
|
#
|
|
18
18
|
# When a plaintext is encrypted, the resulting ciphertext will be larger because of the authentication tag.
|
|
19
19
|
# This value indicates how much larger a ciphertext will be than a plaintext.
|
|
20
|
-
|
|
20
|
+
OVERHEAD_ENCRYPTION = 16.freeze
|
|
21
|
+
|
|
22
|
+
# The overhead sealed data.
|
|
23
|
+
#
|
|
24
|
+
# When a plaintext is sealed, the resulting ciphertext will be larger.
|
|
25
|
+
# This value indicates how much larger a ciphertext will be than a plaintext.
|
|
26
|
+
OVERHEAD = (OVERHEAD_ENCRYPTION + NONCE_SIZE).freeze
|
|
21
27
|
|
|
22
28
|
BLOCK_SIZE = 16.freeze
|
|
23
29
|
private_constant :BLOCK_SIZE
|
|
@@ -74,12 +80,12 @@ module Xaes256Gcm
|
|
|
74
80
|
def decrypt(ciphertext, nonce, additionalData = nil)
|
|
75
81
|
ct_bytes = ciphertext.bytesize
|
|
76
82
|
raise InvalidNonceError if nonce.bytesize != NONCE_SIZE
|
|
77
|
-
raise InvalidCiphertextError if ciphertext.bytesize <
|
|
83
|
+
raise InvalidCiphertextError if ciphertext.bytesize < OVERHEAD_ENCRYPTION
|
|
78
84
|
|
|
79
|
-
tagless_ciphertext = ciphertext.byteslice(0, ct_bytes -
|
|
80
|
-
tag = ciphertext.byteslice(ct_bytes -
|
|
85
|
+
tagless_ciphertext = ciphertext.byteslice(0, ct_bytes - OVERHEAD_ENCRYPTION)
|
|
86
|
+
tag = ciphertext.byteslice(ct_bytes - OVERHEAD_ENCRYPTION, OVERHEAD_ENCRYPTION)
|
|
81
87
|
|
|
82
|
-
raise InvalidCiphertextError if tag.bytesize !=
|
|
88
|
+
raise InvalidCiphertextError if tag.bytesize != OVERHEAD_ENCRYPTION
|
|
83
89
|
|
|
84
90
|
key = derive_key(nonce.byteslice(0, 12))
|
|
85
91
|
gcm = OpenSSL::Cipher::AES256.new(:GCM)
|
|
@@ -102,7 +108,7 @@ module Xaes256Gcm
|
|
|
102
108
|
end
|
|
103
109
|
|
|
104
110
|
def open(ciphertext, additionalData = nil)
|
|
105
|
-
raise InvalidCiphertextError if ciphertext.nil? || ciphertext.bytesize < OVERHEAD
|
|
111
|
+
raise InvalidCiphertextError if ciphertext.nil? || ciphertext.bytesize < OVERHEAD
|
|
106
112
|
nonce = ciphertext.byteslice(0, NONCE_SIZE)
|
|
107
113
|
ct = ciphertext.byteslice(NONCE_SIZE, ciphertext.bytesize - NONCE_SIZE)
|
|
108
114
|
return decrypt(ct, nonce, additionalData)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xaes_256_gcm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.8'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- vcsjones
|
|
@@ -48,7 +48,7 @@ files:
|
|
|
48
48
|
- "./lib/xaes_256_gcm/version.rb"
|
|
49
49
|
- "./lib/xaes_256_gcm/xaes_256_gcm_cipher.rb"
|
|
50
50
|
- 3RD_PARTY_LICENSE
|
|
51
|
-
homepage: https://github.com/vcsjones/
|
|
51
|
+
homepage: https://github.com/vcsjones/xaes-256-gcm-ruby
|
|
52
52
|
licenses:
|
|
53
53
|
- MIT
|
|
54
54
|
metadata: {}
|