diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-23 13:51:55 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-06-23 13:51:55 +0000 |
commit | bf2e60cda7ad9e08f03d1eed99f77cc9c6cc1496 (patch) | |
tree | 0c9592c3e01cbe0c96d44f8a611d9a678bb0d33e /ext/openssl | |
parent | 3e01a8d58e4095e77a7ecf6658fc7a825e8ed6c0 (diff) | |
download | ruby-bf2e60cda7ad9e08f03d1eed99f77cc9c6cc1496.tar.gz |
* ext/openssl/ossl_x509name.c: Add X509::Name#hash_old as a wrapper
for X509_NAME_hash_old in OpenSSL 1.0.0. See #4805
* test/openssl/test_x509name.rb (test_hash): Make test pass with
OpenSSL 1.0.0.
* NEWS: Add it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/extconf.rb | 1 | ||||
-rw-r--r-- | ext/openssl/ossl_x509name.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index 1bd5a0741c..d38af40b36 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -94,6 +94,7 @@ have_func("X509_CRL_add0_revoked") have_func("X509_CRL_set_issuer_name") have_func("X509_CRL_set_version") have_func("X509_CRL_sort") +have_func("X509_NAME_hash_old") have_func("X509_STORE_get_ex_data") have_func("X509_STORE_set_ex_data") have_func("OBJ_NAME_do_all_sorted") diff --git a/ext/openssl/ossl_x509name.c b/ext/openssl/ossl_x509name.c index b75ae398cc..13e18eecf1 100644 --- a/ext/openssl/ossl_x509name.c +++ b/ext/openssl/ossl_x509name.c @@ -317,6 +317,27 @@ ossl_x509name_hash(VALUE self) return ULONG2NUM(hash); } +#ifdef HAVE_X509_NAME_HASH_OLD +/* + * call-seq: + * name.hash_old => integer + * + * hash_old returns MD5 based hash used in OpenSSL 0.9.X. + */ +static VALUE +ossl_x509name_hash_old(VALUE self) +{ + X509_NAME *name; + unsigned long hash; + + GetX509Name(self, name); + + hash = X509_NAME_hash_old(name); + + return ULONG2NUM(hash); +} +#endif + /* * call-seq: * name.to_der => string @@ -364,6 +385,9 @@ Init_ossl_x509name() rb_define_alias(cX509Name, "<=>", "cmp"); rb_define_method(cX509Name, "eql?", ossl_x509name_eql, 1); rb_define_method(cX509Name, "hash", ossl_x509name_hash, 0); +#ifdef HAVE_X509_NAME_HASH_OLD + rb_define_method(cX509Name, "hash_old", ossl_x509name_hash_old, 0); +#endif rb_define_method(cX509Name, "to_der", ossl_x509name_to_der, 0); utf8str = INT2NUM(V_ASN1_UTF8STRING); |