PolarSSL v1.1.5
asn1.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_ASN1_H
28 #define POLARSSL_ASN1_H
29 
30 #include "config.h"
31 
32 #if defined(POLARSSL_BIGNUM_C)
33 #include "bignum.h"
34 #endif
35 
36 #include <string.h>
37 
50 #define POLARSSL_ERR_ASN1_OUT_OF_DATA -0x0014
51 #define POLARSSL_ERR_ASN1_UNEXPECTED_TAG -0x0016
52 #define POLARSSL_ERR_ASN1_INVALID_LENGTH -0x0018
53 #define POLARSSL_ERR_ASN1_LENGTH_MISMATCH -0x001A
54 #define POLARSSL_ERR_ASN1_INVALID_DATA -0x001C
55 #define POLARSSL_ERR_ASN1_MALLOC_FAILED -0x001E
56 /* \} name */
57 
69 #define ASN1_BOOLEAN 0x01
70 #define ASN1_INTEGER 0x02
71 #define ASN1_BIT_STRING 0x03
72 #define ASN1_OCTET_STRING 0x04
73 #define ASN1_NULL 0x05
74 #define ASN1_OID 0x06
75 #define ASN1_UTF8_STRING 0x0C
76 #define ASN1_SEQUENCE 0x10
77 #define ASN1_SET 0x11
78 #define ASN1_PRINTABLE_STRING 0x13
79 #define ASN1_T61_STRING 0x14
80 #define ASN1_IA5_STRING 0x16
81 #define ASN1_UTC_TIME 0x17
82 #define ASN1_GENERALIZED_TIME 0x18
83 #define ASN1_UNIVERSAL_STRING 0x1C
84 #define ASN1_BMP_STRING 0x1E
85 #define ASN1_PRIMITIVE 0x00
86 #define ASN1_CONSTRUCTED 0x20
87 #define ASN1_CONTEXT_SPECIFIC 0x80
88 /* \} name */
89 /* \} addtogroup asn1_module */
90 
92 #define OID_SIZE(x) (sizeof(x) - 1)
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
106 typedef struct _asn1_buf
107 {
108  int tag;
109  size_t len;
110  unsigned char *p;
111 }
112 asn1_buf;
113 
117 typedef struct _asn1_bitstring
118 {
119  size_t len;
120  unsigned char unused_bits;
121  unsigned char *p;
122 }
124 
128 typedef struct _asn1_sequence
129 {
132 }
134 
147 int asn1_get_len( unsigned char **p,
148  const unsigned char *end,
149  size_t *len );
150 
163 int asn1_get_tag( unsigned char **p,
164  const unsigned char *end,
165  size_t *len, int tag );
166 
177 int asn1_get_bool( unsigned char **p,
178  const unsigned char *end,
179  int *val );
180 
191 int asn1_get_int( unsigned char **p,
192  const unsigned char *end,
193  int *val );
194 
205 int asn1_get_bitstring( unsigned char **p, const unsigned char *end,
206  asn1_bitstring *bs);
207 
219 int asn1_get_sequence_of( unsigned char **p,
220  const unsigned char *end,
221  asn1_sequence *cur,
222  int tag);
223 
224 #if defined(POLARSSL_BIGNUM_C)
225 
235 int asn1_get_mpi( unsigned char **p,
236  const unsigned char *end,
237  mpi *X );
238 #endif
239 
240 #ifdef __cplusplus
241 }
242 #endif
243 
244 #endif /* asn1.h */