Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 7fb1b40
  • /
  • obj.doc
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:bad347c9366a4aa369ed207ed878db615b90ca26
directory badge Iframe embedding
swh:1:dir:7fb1b40fac800276b83cf2e67cdda4b7cd930197
obj.doc
The Object library.

As part of my Crypto library, I found I required a method of identifying various
objects.  These objects normally had 3 different values associated with
them, a short text name, a long (or lower case) text name, and an
ASN.1 Object Identifier (which is a sequence of numbers).
This library contains a static list of objects and functions to lookup
according to one type and to return the other types.

To use these routines, 'Object.h' needs to be included.

For each supported object, #define entries are defined as follows
#define SN_Algorithm			"Algorithm"
#define LN_algorithm			"algorithm"
#define NID_algorithm			38
#define OBJ_algorithm			1L,3L,14L,3L,2L

SN_  stands for short name.
LN_  stands for either long name or lowercase name.
NID_ stands for Numeric ID.  I each object has a unique NID and this
     should be used internally to identify objects.
OBJ_ stands for ASN.1 Object Identifier or ASN1_OBJECT as defined in the
     ASN1 routines.  These values are used in ASN1 encoding.

The following functions are to be used to return pointers into a static
definition of these types.  What this means is "don't try to free() any
pointers returned from these functions.

ASN1_OBJECT *OBJ_nid2obj(
int n);
	Return the ASN1_OBJECT that corresponds to a NID of n.
	
char *OBJ_nid2ln(
int n);
	Return the long/lower case name of the object represented by the
	NID of n.
	
char *OBJ_nid2sn(
int n);
	Return the short name for the object represented by the NID of n.

ASN1_OBJECT *OBJ_dup(
ASN1_OBJECT *o);
	Duplicate and return a new ASN1_OBJECT that is the same as the
	passed parameter.
	
int OBJ_obj2nid(
ASN1_OBJECT *o);
	Given ASN1_OBJECT o, return the NID that corresponds.
	
int OBJ_ln2nid(
char *s);
	Given the long/lower case name 's', return the NID of the object.
	
int OBJ_sn2nid(
char *s);
	Given the short name 's', return the NID of the object.
	
char *OBJ_bsearch(
char *key,
char *base,
int num,
int size,
int (*cmp)());
	Since I have come across a few platforms that do not have the
	bsearch() function, OBJ_bsearch is my version of that function.
	Feel free to use this function, but you may as well just use the
	normal system bsearch(3) if it is present.  This version also
	has tolerance of being passed NULL pointers.

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top