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 +4 -4
- data/lib/block_cipher_kit/cipher_io.rb +3 -0
- data/lib/block_cipher_kit/version.rb +1 -1
- data/rbi/block_cipher_kit.rbi +1 -1
- data/test/cipher_io_test.rb +12 -0
- 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: 67d685c590f9785a81a3396fed0a249e7b9abfecfc3c36e54fe5a2d86d26b4ae
|
4
|
+
data.tar.gz: 6e4b5ecf5de2bdd0cb827afd333a49f4dd184e9159f8976596cd65a58bb4fc1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/rbi/block_cipher_kit.rbi
CHANGED
data/test/cipher_io_test.rb
CHANGED
@@ -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.
|
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-
|
12
|
+
date: 2025-03-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|