aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_digest.c
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 02:37:35 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-13 02:37:35 +0000
commit4247bfd60a15438e6adbabff682e96a235e2d241 (patch)
tree5eb88e41eee17b55e0db66b44b78df3131a72abc /ext/openssl/ossl_digest.c
parenta27b63d3fc1c491eda62a8a48527df53301f45ce (diff)
downloadruby-4247bfd60a15438e6adbabff682e96a235e2d241.tar.gz
* ext/openssl/ossl_digest.c: allow Digests to be created by sn, ln or
oid. * test/openssl/test_digest.rb: add tests for this. [Ruby 1.9 - Feature #4412] [ruby-core:35319] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_digest.c')
-rw-r--r--ext/openssl/ossl_digest.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/openssl/ossl_digest.c b/ext/openssl/ossl_digest.c
index 346b6cfe14..ebfca120da 100644
--- a/ext/openssl/ossl_digest.c
+++ b/ext/openssl/ossl_digest.c
@@ -36,12 +36,15 @@ const EVP_MD *
GetDigestPtr(VALUE obj)
{
const EVP_MD *md;
+ ASN1_OBJECT *oid = NULL;
if (TYPE(obj) == T_STRING) {
const char *name = StringValueCStr(obj);
- md = EVP_get_digestbyname(name);
- if (!md)
+ oid = OBJ_txt2obj(name, 0);
+ md = EVP_get_digestbyobj(oid);
+ ASN1_OBJECT_free(oid);
+ if(!md)
ossl_raise(rb_eRuntimeError, "Unsupported digest algorithm (%s).", name);
} else {
EVP_MD_CTX *ctx;
@@ -260,8 +263,9 @@ ossl_digest_size(VALUE self)
* digest.block_length -> integer
*
* Returns the block length of the digest algorithm, i.e. the length in bytes
- * of an individual block. Most modern partition a message to be digested into
- * a sequence of fix-sized blocks that are processed consecutively.
+ * of an individual block. Most modern algorithms partition a message to be
+ * digested into a sequence of fix-sized blocks that are processed
+ * consecutively.
*
* === Example
* digest = OpenSSL::Digest::SHA1.new