oid: OBJECT IDENTIFIER Functions

View source: R/oid.R

oidR Documentation

OBJECT IDENTIFIER Functions

Description

Object Identifiers (OIDs) are entities defined by international standards (ITU-T, ISO, IEC) used to identify objects. In the PKI context they are used for example to identify encyrption algorithms. Each root (first integer - see below) denotes the standards body governing the allocations.

OIDs consist of a hierarchy of integers with each component having a meaning in the hierarchy. For example, the OID of the DER encoding is defined in the ITU-T X.680 standard as joint-iso-itu-t(2) asn1(1) ber-derived(2) distinguished-encoding(1) where the text before each integer describes its meaning in that context and the integer is the encoding of that meaning. So the OID itself would be in character form "2.1.2.1" (also called the dot notation introduced by IETF) and in R integer form c(2, 1, 2, 1). Internally, OIDs are represented in their ASN.1 encoding as raw vectors which is the way they are typically used in files or communication payload.

The following functions are used to operate on OIDs.

oid creates an OID.

Coercion methods as.integer and as.character convert the OID into its numeric and textural form respectively. as.oid is a generic for convering objects into OIDs and is implemented for at least the above cases.

is.oid returns TRUE if the object is an OID.

Usage

oid(x)

as.oid(x, ...) 
## Default S3 method:
as.oid(x, ...)
is.oid(x) 

## S3 method for class 'oid'
Ops(e1, e2) 
## S3 method for class 'oid'
print(x, ...) 

## S3 method for class 'oid'
as.character(x, ...) 
## S3 method for class 'oid'
as.integer(x, ...) 

Arguments

x

object to covert/create/check

e1

left-hand side argument for binary operators

e2

right-hand side arguemnt for binary operators

...

further arguments (currently unused)

Details

The only allowed oparators on OIDs are == and != which return TRUE or FALSE.

The oid(x) constructor (and also the as.oid default method) support following types: scalar string (expected to be in dot-notation), integer vector, numeric vector (it is coerced to integer vector implicitly), raw vector (must be ASN.1 encoding of the OID).

The S3 class of OID objects is "oid". It consists of a raw vector repesenting the ASN.1 encoded OID (without the type specifier). An additional attribute "type" is set to 6L for compatiblity with ASN1.encode.

Author(s)

Simon Urbanek

See Also

ASN1.encode

Examples

## RSA algorithm OID:
## iso(1) member-body(2) us(840) rsadsi(113549)
## pkcs(1) pkcs-1(1) rsaEncryption(1)
o <- oid("1.2.840.113549.1.1.1")
as.raw(o)
as.integer(o)
as.character(o)
as.oid(as.integer(o)) == o
is.oid(o)
(a <- ASN1.encode(o))
as.oid(ASN1.decode(a)) == o

s-u/PKI documentation built on Feb. 12, 2024, 10:43 p.m.