Skip to content

Commit c1639f1

Browse files
authored
Merge pull request #568 from unasuke/empty_string_to_cipher_update
Allow empty string to OpenSSL::Cipher#update
2 parents 1b419b9 + 953592a commit c1639f1

File tree

2 files changed

+1
-8
lines changed

2 files changed

+1
-8
lines changed

ext/openssl/ossl_cipher.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ ossl_cipher_update(int argc, VALUE *argv, VALUE self)
384384

385385
StringValue(data);
386386
in = (unsigned char *)RSTRING_PTR(data);
387-
if ((in_len = RSTRING_LEN(data)) == 0)
388-
ossl_raise(rb_eArgError, "data must not be empty");
387+
in_len = RSTRING_LEN(data);
389388
GetCipher(self, ctx);
390389
out_len = in_len+EVP_CIPHER_CTX_block_size(ctx);
391390
if (out_len <= 0) {

test/openssl/test_cipher.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ def test_random_key_iv
108108
assert_not_equal s1, s2
109109
end
110110

111-
def test_empty_data
112-
cipher = OpenSSL::Cipher.new("DES-EDE3-CBC").encrypt
113-
cipher.random_key
114-
assert_raise(ArgumentError) { cipher.update("") }
115-
end
116-
117111
def test_initialize
118112
cipher = OpenSSL::Cipher.new("DES-EDE3-CBC")
119113
assert_raise(RuntimeError) { cipher.__send__(:initialize, "DES-EDE3-CBC") }

0 commit comments

Comments
 (0)