ASN1 allocation routines -- SSLeay 0.9.0b -- January 1999

NAME

ASN1_TYPE_new, ASN1_TYPE_free, ASN1_OBJECT_new, ASN1_OBJECT_free,
ASN1_STRING_new, ASN1_STRING_free, ASN1_HEADER_new, ASN1_HEADER_free,
ASN1_STRING_type_new -- ASN1 allocation routines

SYNOPSIS

#include "asn1.h"

ASN1_TYPE *ASN1_TYPE_new();

void ASN1_TYPE_free(a)
ASN1_TYPE *a;

ASN1_OBJECT *ASN1_OBJECT_new();

void ASN1_OBJECT_free(a)
ASN1_OBJECT *a;

ASN1_STRING *ASN1_STRING_new();

void ASN1_STRING_free(a)
ASN1_STRING *a;

ASN1_HEADER *ASN1_HEADER_new();

void ASN1_HEADER_free(a)
ASN1_HEADER *a;

ASN1_STRING *ASN1_STRING_type_new(type)
int type;

DESCRIPTION

The new functions all create a new structure of the type specified by the function and return a pointer to it; if memory cannot be allocated they return NULL.

The free functions all free the memory of the object pointed to by the argument, unless the argument is NULL, in which case they do nothing.

The one exception to this is ASN1_STRING_type_new, which takes a type as an argument, and creates an ASN1_STRING structure with the type element of the structure set to the type. This function is used by some of the other functions (see below).

Possible values for type are:

V_ASN1_BIT_STRING
V_ASN1_INTEGER
V_ASN1_OCTET_STRING
V_ASN1_PRINTABLESTRING
V_ASN1_T61STRING
V_ASN1_IA5STRING
V_ASN1_UTCTIME
V_ASN1_GENERALIZEDTIME
V_ASN1_GENERALSTRING
V_ASN1_UNIVERSALSTRING
V_ASN1_BMPSTRING

The following macros are provided as a convenience for the user. Their Their behavior is as described above.

#define ASN1_BIT_STRING_new() 
  (ASN1_BIT_STRING *)  ASN1_STRING_type_new(V_ASN1_BIT_STRING)
#define ASN1_BIT_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_INTEGER_new() 
  (ASN1_INTEGER *) ASN1_STRING_type_new(V_ASN1_INTEGER)
#define ASN1_INTEGER_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_OCTET_STRING_new() 
  (ASN1_OCTET_STRING *) ASN1_STRING_type_new(V_ASN1_OCTET_STRING)
#define ASN1_OCTET_STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

/* I am not sure if this one is quite right or not. I guess you
   have to choose some random type to start with :( */
#define ASN1_PRINTABLE_new() 
  ASN1_STRING_type_new(V_ASN1_T61STRING)
#define ASN1_PRINTABLE_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_PRINTABLESTRING_new() 
  (ASN1_PRINTABLESTRING_STRING *) ASN1_STRING_type_new(V_ASN1_PRINTABLESTRING)
#define ASN1_PRINTABLESTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_T61STRING_new() 
  (ASN1_T61STRING_STRING *) ASN1_STRING_type_new(V_ASN1_T61STRING)
#define ASN1_T61STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_IA5STRING_new() 
  (ASN1_IA5STRING *) ASN1_STRING_type_new(V_ASN1_IA5STRING)
#define ASN1_IA5STRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_UTCTIME_new() 
  (ASN1_UTCTIME *) ASN1_STRING_type_new(V_ASN1_UTCTIME)
#define ASN1_UTCTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_GENERALIZEDTIME_new()
  (ASN1_GENERALIZEDTIME *) ASN1_STRING_type_new(V_ASN1_GENERALIZEDTIME)
#define ASN1_GENERALIZEDTIME_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_GENERALSTRING_new()
  (ASN1_GENERALSTRING *) ASN1_STRING_type_new(V_ASN1_GENERALSTRING)
#define ASN1_GENERALSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)

#define ASN1_BMPSTRING_new()
  (ASN1_BMPSTRING *) ASN1_STRING_type_new(V_ASN1_BMPSTRING)
#define ASN1_BMPSTRING_free(a) ASN1_STRING_free((ASN1_STRING *)a)