asn1.h File Reference

ASN.1 encoding. More...

Go to the source code of this file.

Data Structures

struct  asn1_cursor
 A DER-encoded ASN.1 object cursor. More...

Defines

#define ASN1_INTEGER   0x02
#define ASN1_BIT_STRING   0x03
#define ASN1_OCTET_STRING   0x04
#define ASN1_NULL   0x05
#define ASN1_OID   0x06
#define ASN1_SEQUENCE   0x30
#define ASN1_IP_ADDRESS   0x40
#define ASN1_EXPLICIT_TAG   0xa0

Functions

 FILE_LICENCE (GPL2_OR_LATER)
int asn1_enter (struct asn1_cursor *cursor, unsigned int type)
 Enter ASN.1 object.
int asn1_skip (struct asn1_cursor *cursor, unsigned int type)
 Skip ASN.1 object.


Detailed Description

ASN.1 encoding.

Definition in file asn1.h.


Define Documentation

#define ASN1_INTEGER   0x02

Definition at line 12 of file asn1.h.

#define ASN1_BIT_STRING   0x03

Definition at line 13 of file asn1.h.

#define ASN1_OCTET_STRING   0x04

Definition at line 14 of file asn1.h.

#define ASN1_NULL   0x05

Definition at line 15 of file asn1.h.

#define ASN1_OID   0x06

Definition at line 16 of file asn1.h.

#define ASN1_SEQUENCE   0x30

Definition at line 17 of file asn1.h.

#define ASN1_IP_ADDRESS   0x40

Definition at line 18 of file asn1.h.

#define ASN1_EXPLICIT_TAG   0xa0

Definition at line 19 of file asn1.h.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

int asn1_enter ( struct asn1_cursor cursor,
unsigned int  type 
)

Enter ASN.1 object.

Parameters:
cursor ASN.1 object cursor
type Expected type
Return values:
rc Return status code
The object cursor will be updated to point to the body of the current ASN.1 object. If any error occurs, the object cursor will be invalidated.

Definition at line 122 of file asn1.c.

References asn1_start(), DBGC, and asn1_cursor::len.

Referenced by x509_public_key(), and x509_rsa_public_key().

00122                                                                  {
00123         int len;
00124 
00125         len = asn1_start ( cursor, type );
00126         if ( len < 0 )
00127                 return len;
00128 
00129         cursor->len = len;
00130         DBGC ( cursor, "ASN1 %p entered object type %02x (len %x)\n",
00131                cursor, type, len );
00132 
00133         return 0;
00134 }

int asn1_skip ( struct asn1_cursor cursor,
unsigned int  type 
)

Skip ASN.1 object.

Parameters:
cursor ASN.1 object cursor
type Expected type
Return values:
rc Return status code
The object cursor will be updated to point to the next ASN.1 object. If any error occurs, the object cursor will be invalidated.

Definition at line 147 of file asn1.c.

References asn1_start(), asn1_cursor::data, DBGC, ENOENT, asn1_cursor::len, and NULL.

Referenced by x509_public_key(), and x509_rsa_public_key().

00147                                                                 {
00148         int len;
00149 
00150         len = asn1_start ( cursor, type );
00151         if ( len < 0 )
00152                 return len;
00153 
00154         cursor->data += len;
00155         cursor->len -= len;
00156         DBGC ( cursor, "ASN1 %p skipped object type %02x (len %x)\n",
00157                cursor, type, len );
00158 
00159         if ( ! cursor->len ) {
00160                 DBGC ( cursor, "ASN1 %p reached end of object\n", cursor );
00161                 cursor->data = NULL;
00162                 return -ENOENT;
00163         }
00164 
00165         return 0;
00166 }


Generated on Tue Apr 6 20:01:48 2010 for gPXE by  doxygen 1.5.7.1