Documentation ¶
Overview ¶
Convenient ASN.1 Object Identifier type and methods.
ASN.1 Object Identifiers often encompass information that goes beyond their dotted representation. This tiny package merely facilitates the handling of ASN.1 NameAndNumberForm values and alternate names that may be associated with a given OID in the wild.
Index ¶
- type NameAndNumberForm
- type ObjectIdentifier
- func (o ObjectIdentifier) ASN1() (a asn1.ObjectIdentifier)
- func (o ObjectIdentifier) AltNames() []string
- func (o ObjectIdentifier) Equal(x any) bool
- func (oid *ObjectIdentifier) IsZero() bool
- func (o ObjectIdentifier) NameAndNumberForm() (nanf NameAndNumberForm)
- func (o *ObjectIdentifier) SetAltNames(name ...string)
- func (o ObjectIdentifier) String() (a string)
- func (o ObjectIdentifier) Valid() bool
- type ObjectIdentifierMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NameAndNumberForm ¶
type NameAndNumberForm struct {
// contains filtered or unexported fields
}
func NewNameAndNumberForm ¶
func NewNameAndNumberForm(x any) (nanf *NameAndNumberForm, err error)
func (NameAndNumberForm) Decimal ¶
func (nanf NameAndNumberForm) Decimal() int
func (NameAndNumberForm) Equal ¶
func (nanf NameAndNumberForm) Equal(n NameAndNumberForm) bool
func (NameAndNumberForm) Identifier ¶
func (nanf NameAndNumberForm) Identifier() string
func (NameAndNumberForm) IsZero ¶
func (nanf NameAndNumberForm) IsZero() bool
func (NameAndNumberForm) String ¶
func (nanf NameAndNumberForm) String() (val string)
type ObjectIdentifier ¶
type ObjectIdentifier struct {
// contains filtered or unexported fields
}
ObjectIdentifier facilitates the storage, and varied representation of, an ASN.1 object identifier in a manner that goes beyond mere dotNotation and may be more convenient than using the asn1.ObjectIdentifier instance.
func NewObjectIdentifier ¶
func NewObjectIdentifier(x any) (o *ObjectIdentifier, err error)
NewObjectIdentifier creates an instance of ObjectIdentifier and returns it alongside an error.
The correct raw input syntax is the ASN.1 NameAndNumberForm sequence syntax, i.e.:
{ iso(1) identified-organization(3) dod(6) }
Not all NameAndNumberForm values (arcs) require actual names; they can be numbers alone or in the so-called nameAndNumber syntax (name(Number)). For example:
{ iso(1) identified-organization(3) 6 }
... is perfectly valid but generally not recommended when clarity is desired.
func (ObjectIdentifier) ASN1 ¶
func (o ObjectIdentifier) ASN1() (a asn1.ObjectIdentifier)
ASN1 returns a populated instance of asn1.ObjectIdentifier using the contents of the receiver.
func (ObjectIdentifier) AltNames ¶
func (o ObjectIdentifier) AltNames() []string
AltNames returns slices of string values, each representing an alternate name by which the receiver OID may be known in the wild.
func (ObjectIdentifier) Equal ¶
func (o ObjectIdentifier) Equal(x any) bool
Equal returns a boolean indicative of whether the provided type instance effectively matches the receiver.
This method supports asn1.ObjectIdentifier, []int, string and []string type instances for comparison. In the case of string input, a dotNotation match is attempted first, followed by an ASN.1 NameAndNumberForm sequence match and lastly a case folded string match of any alternative names by which the OID may be known.
func (*ObjectIdentifier) IsZero ¶
func (oid *ObjectIdentifier) IsZero() bool
IsZero checks the receiver for nilness and returns a boolean indicative of the result.
func (ObjectIdentifier) NameAndNumberForm ¶
func (o ObjectIdentifier) NameAndNumberForm() (nanf NameAndNumberForm)
func (*ObjectIdentifier) SetAltNames ¶
func (o *ObjectIdentifier) SetAltNames(name ...string)
SetAltNames assigns alternative names by which the receiver may be known in the wild in addition to its "principal" name. Duplicates are filtered out.
One example of an alternate name in the wild is the OID `id-kp-serverAuth(1)` (1.3.6.1.5.5.7.3.1), which is also known simply as 'serverAuth'.
func (ObjectIdentifier) String ¶
func (o ObjectIdentifier) String() (a string)
String returns the ASN.1 NameAndNumberForm sequence stored within the receiver in full, e.g.:
{ iso(1) identified-organization(3) dod(6) }
func (ObjectIdentifier) Valid ¶
func (o ObjectIdentifier) Valid() bool
Valid returns a boolean value indicative of whether the receiver's length is greater than or equal to one (1) slice member.
type ObjectIdentifierMap ¶
type ObjectIdentifierMap map[string]*ObjectIdentifier
func (ObjectIdentifierMap) Exists ¶
func (o ObjectIdentifierMap) Exists(term any) (exists bool)
func (ObjectIdentifierMap) Get ¶
func (o ObjectIdentifierMap) Get(term any) (*ObjectIdentifier, bool)
func (ObjectIdentifierMap) New ¶
func (o ObjectIdentifierMap) New(key, nanf string) (err error)
func (ObjectIdentifierMap) Set ¶
func (o ObjectIdentifierMap) Set(key string, x *ObjectIdentifier)