Class: OpenSSL::ASN1::ObjectId

Inherits:
Primitive show all
Defined in:
ossl_asn1.c,
ossl_asn1.c

Overview

Represents the primitive object id for OpenSSL::ASN1

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Primitive

#initialize, #to_der

Methods inherited from ASN1Data

#initialize, #to_der

Constructor Details

This class inherits a constructor from OpenSSL::ASN1::Primitive

Class Method Details

.register(object_id, short_name, long_name) ⇒ Object

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 ASN1Error otherwise.



1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
# File 'ossl_asn1.c', line 1372

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;
}

Instance Method Details

#lnObject Also known as: long_name

#long_name is an alias to #ln



1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
# File 'ossl_asn1.c', line 1414

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;
}

#oidObject

The object identifier as a String.



1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
# File 'ossl_asn1.c', line 1431

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);
}

#snObject Also known as: short_name

#short_name is an alias to #sn



1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
# File 'ossl_asn1.c', line 1393

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;
}