x509.h File Reference

#include <math.h>

Go to the source code of this file.

Defines

#define SECTION_X509_CERTIFICATE   "X509 CERTIFICATE"
#define SECTION_CERTIFICATE   "CERTIFICATE"
#define SECTION_RSA_PRIVATE_KEY   "RSA PRIVATE KEY"

Functions

int GetPrivateKey (B_KEY_OBJ *key, char *filename)
int GetCertificate (unsigned char **pCertificate, int *length, char *filename)
char * PrivateKeyToPEM (B_KEY_OBJ privateKey)
unsigned char * GetBerFromPEM (char *filename, char *section, int *length)
void AddLengthCount (Ns_DString *ds, unsigned int length)
int GetLengthCount (unsigned char *der, unsigned int *length)
int SetOf (unsigned char *der, int length)
int DecodeSetOf (Ns_DString *ds, unsigned char *der, int length, int indent)
void RecodeAsSetOf (Ns_DString *dsSrc, Ns_DString *dsDest)
int DERDecode (Ns_DString *ds, unsigned char *der, int length, int indent)
int DEREncode (Ns_DString *ds, char *asn1)


Define Documentation

#define SECTION_CERTIFICATE   "CERTIFICATE"

#define SECTION_RSA_PRIVATE_KEY   "RSA PRIVATE KEY"

#define SECTION_X509_CERTIFICATE   "X509 CERTIFICATE"


Function Documentation

void AddLengthCount ( Ns_DString *  ds,
unsigned int  length 
)

----------------------------------------------------------------------

AddLengthCount --

Big Endian Length counts for DER (Distinguished Encoding Rules) objects.

Results:

Side effects:

----------------------------------------------------------------------

Short length.

Long length.

Note: ceil fails if length == 1

int DecodeSetOf ( Ns_DString *  ds,
unsigned char *  der,
int  length,
int  indent 
)

----------------------------------------------------------------------

DecodeSetOf --

Decodes a SET OF by looking into each SET element and decoding its content.

Results: NS_OK or NS_ERROR.

Side effects: None.

----------------------------------------------------------------------

Constructed SET.

int DERDecode ( Ns_DString *  ds,
unsigned char *  der,
int  length,
int  indent 
)

----------------------------------------------------------------------

DERDecode --

Decode a der object.

Results: NS_OK or NS_ERROR.

Side effects: This is a recursive function.

----------------------------------------------------------------------

Low-tag-number form.

High-tag-number form.

Universal class.

int DEREncode ( Ns_DString *  ds,
char *  asn1 
)

----------------------------------------------------------------------

DEREncode --

Encode a der object.

Note: asn1 must be a writable string.

Results: NS_OK or NS_ERROR.

Side effects: This is a recursive function.

----------------------------------------------------------------------

Application, context-specific or private class.

Universal class.

SET OF gets inlined as individual SETs.

Note: ceil fails if val1 == 1.

We only generate low tags.

unsigned char* GetBerFromPEM ( char *  filename,
char *  section,
int *  length 
)

----------------------------------------------------------------------

GetBerFromPEM --

Grabs a BER (Basic Encoding Rules) object from a PEM (Privacy Enchanced Mail) format file. Returns NULL on error.

Results: Pointer to the BER object.

Side effects: Memory is allocated to hold the object.

----------------------------------------------------------------------

A little wasteful since it will actually be .75i, but short term.

int GetCertificate ( unsigned char **  pCertificate,
int *  length,
char *  filename 
)

----------------------------------------------------------------------

GetCertificate --

Get a BER encoded X509 certificate from a PEM format file.

Results: NS_OK or NS_ERROR.

Side effects: See function "GetBerFromPEM."

----------------------------------------------------------------------

int GetLengthCount ( unsigned char *  der,
unsigned int *  length 
)

----------------------------------------------------------------------

GetLengthCount --

Results:

Side effects:

----------------------------------------------------------------------

Long-form.

Short-form.

int GetPrivateKey ( B_KEY_OBJ *  privateKey,
char *  filename 
)

----------------------------------------------------------------------

GetPrivateKey --

Get a BER-encoded PKCS rsa private key from a PEM format file.

Results: NS_OK or NS_ERROR.

Side effects: Memory is allocated to hold the object in privateKey.

----------------------------------------------------------------------

char* PrivateKeyToPEM ( B_KEY_OBJ  privateKey  ) 

----------------------------------------------------------------------

PrivateKeyToPEM --

Generate a PEM format BER encoded version of a private key.

Results:

Side effects:

----------------------------------------------------------------------

void RecodeAsSetOf ( Ns_DString *  dsSrc,
Ns_DString *  dsDest 
)

----------------------------------------------------------------------

RecodeAsSetOf --

Sorts the items in the der in dsSrc, then wraps them in SETs and returns them in dsDest (not for STRICT_DER_RULES).

Results:

Side effects:

----------------------------------------------------------------------

Low-tag-number form.

High-tag-number form.

constructed SET

int SetOf ( unsigned char *  der,
int  length 
)

----------------------------------------------------------------------

SetOf --

Determines where der is a SET OF by checking that every item is a SET.

Results: NS_TRUE or NS_FALSE.

Side effects: None.

----------------------------------------------------------------------

constructed SET


Generated on Tue Sep 4 19:58:57 2007 by  doxygen 1.5.1