Skip to content

Commit dcb2a4f

Browse files
committed
digest: remove optional parameter from OpenSSL::Digest#finish
OpenSSL::Digest#finish overrides Digest::Instance#finish and is called from the Digest::Class framework in the digest library. This method is not supposed to take any arguments, as suggested by the RDoc comment for Digest::Instance#finish. It is a private method and not exposed to users. Let's remove it. This optional parameter exists since r15602 in Ruby trunk, the commit which converted OpenSSL::Digest to a subclass of Digest::Class.
1 parent 3f9a87a commit dcb2a4f

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

ext/openssl/ossl_digest.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,13 @@ ossl_digest_update(VALUE self, VALUE data)
245245
*
246246
*/
247247
static VALUE
248-
ossl_digest_finish(int argc, VALUE *argv, VALUE self)
248+
ossl_digest_finish(VALUE self)
249249
{
250250
EVP_MD_CTX *ctx;
251251
VALUE str;
252-
int out_len;
253252

254253
GetDigest(self, ctx);
255-
rb_scan_args(argc, argv, "01", &str);
256-
out_len = EVP_MD_CTX_size(ctx);
257-
258-
if (NIL_P(str)) {
259-
str = rb_str_new(NULL, out_len);
260-
} else {
261-
StringValue(str);
262-
rb_str_modify(str);
263-
rb_str_resize(str, out_len);
264-
}
265-
254+
str = rb_str_new(NULL, EVP_MD_CTX_size(ctx));
266255
if (!EVP_DigestFinal_ex(ctx, (unsigned char *)RSTRING_PTR(str), NULL))
267256
ossl_raise(eDigestError, "EVP_DigestFinal_ex");
268257

@@ -447,7 +436,7 @@ Init_ossl_digest(void)
447436
rb_define_method(cDigest, "reset", ossl_digest_reset, 0);
448437
rb_define_method(cDigest, "update", ossl_digest_update, 1);
449438
rb_define_alias(cDigest, "<<", "update");
450-
rb_define_private_method(cDigest, "finish", ossl_digest_finish, -1);
439+
rb_define_private_method(cDigest, "finish", ossl_digest_finish, 0);
451440
rb_define_method(cDigest, "digest_length", ossl_digest_size, 0);
452441
rb_define_method(cDigest, "block_length", ossl_digest_block_length, 0);
453442

0 commit comments

Comments
 (0)