Class: OpenSSL::ASN1::ObjectId (Ruby 2.3.4)

In Files

  • openssl/ossl_asn1.c

Class/Module Index [+]

Quicksearch

OpenSSL::ASN1::ObjectId

Represents the primitive object id for OpenSSL::ASN1

Public Class Methods

OpenSSL::ASN1::ObjectId.register(object_id, short_name, long_name)

This adds a new ObjectId to the internal tables. Where object_id is the numerical form, short_name is the short name, and long_name is the long name.

Returns true if successful. Raises an OpenSSL::ASN1::ASN1Error if it fails.

 
               static VALUE
ossl_asn1obj_s_register(VALUE self, VALUE oid, VALUE sn, VALUE ln)
{
    StringValue(oid);
    StringValue(sn);
    StringValue(ln);

    if(!OBJ_create(RSTRING_PTR(oid), RSTRING_PTR(sn), RSTRING_PTR(ln)))
        ossl_raise(eASN1Error, NULL);

    return Qtrue;
}
            

Public Instance Methods

ln()

The long name of the ObjectId, as defined in <openssl/objects.h>.

 
               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;
}
            
Also aliased as: long_name
long_name()
Alias for: ln
oid()

The object identifier as a String, e.g. "1.2.3.4.5"

 
               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);
}
            
short_name()
Alias for: sn
sn()

The short name of the ObjectId, as defined in <openssl/objects.h>.

 
               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;
}
            
Also aliased as: short_name