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) click to toggle source

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)
{
    StringValueCStr(oid);
    StringValueCStr(sn);
    StringValueCStr(ln);

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

    return Qtrue;
}
            

Public Instance Methods

oid == other_oid => true or false click to toggle source

Returns true if other_oid is the same as oid

 
               static VALUE
ossl_asn1obj_eq(VALUE self, VALUE other)
{
    VALUE valSelf, valOther;
    int nidSelf, nidOther;

    valSelf = ossl_asn1_get_value(self);
    valOther = ossl_asn1_get_value(other);

    if ((nidSelf = OBJ_txt2nid(StringValueCStr(valSelf))) == NID_undef)
        ossl_raise(eASN1Error, "OBJ_txt2nid");

    if ((nidOther = OBJ_txt2nid(StringValueCStr(valOther))) == NID_undef)
        ossl_raise(eASN1Error, "OBJ_txt2nid");

    return nidSelf == nidOther ? Qtrue : Qfalse;
}
            
ln → string click to toggle source
long_name → string

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(StringValueCStr(val))) != NID_undef)
        ret = rb_str_new2(OBJ_nid2ln(nid));

    return ret;
}
            
Also aliased as: long_name
long_name() click to toggle source
Alias for: ln
oid → string click to toggle source

Returns a String representing the Object Identifier in the dot notation, e.g. “1.2.3.4.5”

 
               static VALUE
ossl_asn1obj_get_oid(VALUE self)
{
    VALUE str;
    ASN1_OBJECT *a1obj;
    int state;

    a1obj = obj_to_asn1obj(ossl_asn1_get_value(self));
    str = rb_protect(asn1obj_get_oid_i, (VALUE)a1obj, &state);
    ASN1_OBJECT_free(a1obj);
    if (state)
        rb_jump_tag(state);
    return str;
}
            
short_name() click to toggle source
Alias for: sn
sn → string click to toggle source
short_name → string

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(StringValueCStr(val))) != NID_undef)
        ret = rb_str_new2(OBJ_nid2sn(nid));

    return ret;
}
            
Also aliased as: short_name
There is an updated format of the API docs for this version here.