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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 13e3224657df10f718e02c0f0ee33cf83033b86f1f2103ea2bc4a9218abfa1fe
4
- data.tar.gz: ce838137cb9189d4c3d65194a40b166cfe435f467aeabefc6125d5274218129b
3
+ metadata.gz: 73faefcbe3a499de749e304d7be28f445fc0ccc366da293398b4dda4a57b7fff
4
+ data.tar.gz: a76cb192c27a233b22656b9e5cb7ab07c935ac835c5855d4cfdcbe5c0f26b6eb
5
5
  SHA512:
6
- metadata.gz: 5363f62cf23ce7010acc4874fcbb9ef84b1d494a85701b4c9eb757e01b2b7f8ad3071d5f82516649578eaf58beb3269f2099a3c1bb1ce7dc5b53a5830a3e9a0c
7
- data.tar.gz: d78ac4e268ddca93cb176966384c5ff64029474abed324391fe861ee227847329efa3df612a4830e65fa7ae12ee0262124a3249b3d15a444913cd9f6d44d115a
6
+ metadata.gz: 53ed3ca206a66f4b3fc49272b6d56ac1b2c4c411aec8eb96969deacf08af49b3bdef21816b52d84f4b51a78bc1f12a61bf4805533444e15c8fcdbf8bfa1c08b4
7
+ data.tar.gz: 8a2cdc221b251eb8f0826c6402fe492d64ca44228b927d05607945cf5b65c33dee6a34a012bc96d9c9d8de2359a45cfe00041576ae203eddd0f23f57d98da6f0
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Xaes256Gcm
4
4
  # The current version of the gem.
5
- VERSION = "0.5"
6
- end
5
+ VERSION = "0.8"
6
+ end
@@ -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
- OVERHEAD = 16.freeze
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 < OVERHEAD
83
+ raise InvalidCiphertextError if ciphertext.bytesize < OVERHEAD_ENCRYPTION
78
84
 
79
- tagless_ciphertext = ciphertext.byteslice(0, ct_bytes - OVERHEAD)
80
- tag = ciphertext.byteslice(ct_bytes - OVERHEAD, OVERHEAD)
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 != OVERHEAD
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 + NONCE_SIZE
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.5'
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/xaes_256_gcm
51
+ homepage: https://github.com/vcsjones/xaes-256-gcm-ruby
52
52
  licenses:
53
53
  - MIT
54
54
  metadata: {}