1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/openssl/ossl_asn1.c (ossl_asn1_get_asn1type): use appropriate

free function for ASN1_OBJECT.

* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_sn): add new function for
  ASN1::ObjectId#sn; it returns short name text representation of OID.

* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_ln): add new function for
  ASN1::ObjectId#ln; it returns long name text representation of OID.

* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_oid): add new function for
  ASN1::ObjectId#oid; it returns numerical representation of OID.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2003-10-06 16:55:00 +00:00
parent 11d2edffe6
commit 0dd4fde745
2 changed files with 61 additions and 1 deletions

View file

@ -1,3 +1,17 @@
Tue Oct 7 01:42:34 2003 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/ossl_asn1.c (ossl_asn1_get_asn1type): use appropriate
free function for ASN1_OBJECT.
* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_sn): add new function for
ASN1::ObjectId#sn; it returns short name text representation of OID.
* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_ln): add new function for
ASN1::ObjectId#ln; it returns long name text representation of OID.
* ext/openssl/ossl_asn1.c (ossl_asn1obj_get_oid): add new function for
ASN1::ObjectId#oid; it returns numerical representation of OID.
Mon Oct 6 22:59:46 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>
* lib/csv.rb (IOReader, BasicWriter): call binmode when a given IO

View file

@ -530,7 +530,7 @@ ossl_asn1_get_asn1type(VALUE obj)
break;
case V_ASN1_OBJECT:
ptr = obj_to_asn1obj(value);
free_func = ASN1_INTEGER_free;
free_func = ASN1_OBJECT_free;
break;
case V_ASN1_UTCTIME:
ptr = obj_to_asn1utime(value);
@ -981,6 +981,47 @@ ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
return Qtrue;
}
static VALUE
ossl_asn1obj_get_sn(VALUE self)
{
VALUE val, ret = Qnil;
int nid;
val = ossl_asn1_get_value(self);
if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
ret = rb_str_new2(OBJ_nid2sn(nid));
return ret;
}
static VALUE
ossl_asn1obj_get_ln(VALUE self)
{
VALUE val, ret = Qnil;
int nid;
val = ossl_asn1_get_value(self);
if ((nid = OBJ_txt2nid(StringValuePtr(val))) != NID_undef)
ret = rb_str_new2(OBJ_nid2ln(nid));
return ret;
}
static VALUE
ossl_asn1obj_get_oid(VALUE self)
{
VALUE val;
ASN1_OBJECT *a1obj;
char buf[128];
val = ossl_asn1_get_value(self);
a1obj = obj_to_asn1obj(val);
OBJ_obj2txt(buf, sizeof(buf), a1obj, 1);
ASN1_OBJECT_free(a1obj);
return rb_str_new2(buf);
}
#define OSSL_ASN1_IMPL_FACTORY_METHOD(klass) \
static VALUE ossl_asn1_##klass(int argc, VALUE *argv, VALUE self)\
{ return rb_funcall3(cASN1##klass, rb_intern("new"), argc, argv); }
@ -1084,5 +1125,10 @@ do{\
OSSL_ASN1_DEFINE_CLASS(Set, Constructive);
rb_define_singleton_method(cASN1ObjectId, "register", ossl_asn1obj_s_register, 3);
rb_define_method(cASN1ObjectId, "sn", ossl_asn1obj_get_sn, 0);
rb_define_method(cASN1ObjectId, "ln", ossl_asn1obj_get_ln, 0);
rb_define_method(cASN1ObjectId, "oid", ossl_asn1obj_get_oid, 0);
rb_define_alias(cASN1ObjectId, "short_name", "sn");
rb_define_alias(cASN1ObjectId, "long_name", "ln");
rb_attr(cASN1BitString, rb_intern("unused_bits"), 1, 1, Qtrue);
}