block_cipher_kit 0.0.3 → 0.0.4

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: 20609183e16f9958a035b581945c5d891851a85df83cbd19741b3e94efe3a676
4
- data.tar.gz: bee694246cdd3eae36af264e7fb3b90dc3179c22203f82e38d028a3733ee99a5
3
+ metadata.gz: 67d685c590f9785a81a3396fed0a249e7b9abfecfc3c36e54fe5a2d86d26b4ae
4
+ data.tar.gz: 6e4b5ecf5de2bdd0cb827afd333a49f4dd184e9159f8976596cd65a58bb4fc1e
5
5
  SHA512:
6
- metadata.gz: ac9365aa614c6b9f88fdad333da7577f6b2e1080430df7bafdbb15aba14f031183269407423e6ba79ba6757d9851f141bc09af7c82ed692830f95a7ca9d3ea48
7
- data.tar.gz: 5620bce257285e2c18be847ce3557cc5876136562b4c5f619c6eda9c7d761de884dee493f218ae781879af17e7dd94ab7aa6fe7d1f58e884453ac1da1ab07673
6
+ metadata.gz: d7b6b67768dd3fc0051a47e56c33310b964a160269b5c20e5d05bf13d31d7bb2ee4e1977b9fdd1fccdfaf7c6ffaafddc8451ab57c016f1dd9043369284c3897e
7
+ data.tar.gz: ae8573278cb11449d1736a19e40316f1162deb012019bd03a9cf8bb57005f6e70595a42341180224ff6cc527ea2acde3d6ecde387bc405a2e637e0265d1d909d
@@ -8,6 +8,9 @@ class BlockCipherKit::CipherIO
8
8
  end
9
9
 
10
10
  def write(bytes)
11
+ # OpenSSL ciphers fail if you update() them with an empty buffer
12
+ return 0 if bytes.bytesize.zero?
13
+
11
14
  @io.write(@cipher.update(bytes))
12
15
  # We must return the amount of bytes of input
13
16
  # we have accepted, not the amount of bytes
@@ -1,3 +1,3 @@
1
1
  module BlockCipherKit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  # typed: strong
2
2
  module BlockCipherKit
3
- VERSION = T.let("0.0.3", T.untyped)
3
+ VERSION = T.let("0.0.4", T.untyped)
4
4
 
5
5
  # Allows an OpenSSL::Cipher to be written through as if it were an IO. This
6
6
  # allows the cipher to be passed to things like IO.copy_stream
@@ -5,6 +5,8 @@ require_relative "test_helper"
5
5
  class CipherIOTest < Minitest::Test
6
6
  class FakeCipher
7
7
  def update(str)
8
+ # Fail the same way as OpenSSL ciphers do on empty input
9
+ raise ArgumentError, " data must not be empty" if str.bytesize.zero?
8
10
  str + "c"
9
11
  end
10
12
  end
@@ -15,4 +17,14 @@ class CipherIOTest < Minitest::Test
15
17
  assert_equal 2, cipher_io.write("ab")
16
18
  assert_equal "abc", out.string
17
19
  end
20
+
21
+ def test_does_not_update_cipher_with_empty_strings
22
+ fake_cipher = FakeCipher.new
23
+ assert_raises(ArgumentError) { fake_cipher.update("") }
24
+
25
+ out = StringIO.new
26
+ cipher_io = BlockCipherKit::CipherIO.new(out, FakeCipher.new)
27
+ assert_equal 0, cipher_io.write("")
28
+ assert out.size.zero?
29
+ end
18
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: block_cipher_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julik Tarkhanov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2025-02-26 00:00:00.000000000 Z
12
+ date: 2025-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest