[ruby/openssl] Allow empty string to OpenSSL::Cipher#update
For some reasons, plaintext may be empty string. ref https://www.rfc-editor.org/rfc/rfc9001.html#section-5.8 https://github.com/ruby/openssl/commit/953592a29e
This commit is contained in:
parent
d92f4fe4d7
commit
d4dce27d89
@ -384,8 +384,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
|
|||||||
|
|
||||||
StringValue(data);
|
StringValue(data);
|
||||||
in = (unsigned char *)RSTRING_PTR(data);
|
in = (unsigned char *)RSTRING_PTR(data);
|
||||||
if ((in_len = RSTRING_LEN(data)) == 0)
|
in_len = RSTRING_LEN(data);
|
||||||
ossl_raise(rb_eArgError, "data must not be empty");
|
|
||||||
GetCipher(self, ctx);
|
GetCipher(self, ctx);
|
||||||
out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
|
out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
|
||||||
if (out_len <= 0) {
|
if (out_len <= 0) {
|
||||||
|
@ -108,12 +108,6 @@ class OpenSSL::TestCipher < OpenSSL::TestCase
|
|||||||
assert_not_equal s1, s2
|
assert_not_equal s1, s2
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_empty_data
|
|
||||||
cipher = OpenSSL::Cipher.new("DES-EDE3-CBC").encrypt
|
|
||||||
cipher.random_key
|
|
||||||
assert_raise(ArgumentError) { cipher.update("") }
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_initialize
|
def test_initialize
|
||||||
cipher = OpenSSL::Cipher.new("DES-EDE3-CBC")
|
cipher = OpenSSL::Cipher.new("DES-EDE3-CBC")
|
||||||
assert_raise(RuntimeError) { cipher.__send__(:initialize, "DES-EDE3-CBC") }
|
assert_raise(RuntimeError) { cipher.__send__(:initialize, "DES-EDE3-CBC") }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user