summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/asn1.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/asn1/asn1.h')
-rw-r--r--src/lib/libcrypto/asn1/asn1.h164
1 files changed, 124 insertions, 40 deletions
diff --git a/src/lib/libcrypto/asn1/asn1.h b/src/lib/libcrypto/asn1/asn1.h
index 99bd64a11e..6f956b1963 100644
--- a/src/lib/libcrypto/asn1/asn1.h
+++ b/src/lib/libcrypto/asn1/asn1.h
@@ -59,17 +59,18 @@
59#ifndef HEADER_ASN1_H 59#ifndef HEADER_ASN1_H
60#define HEADER_ASN1_H 60#define HEADER_ASN1_H
61 61
62#ifdef __cplusplus
63extern "C" {
64#endif
65
66#include <time.h> 62#include <time.h>
63#ifndef NO_BIO
64#include <openssl/bio.h>
65#endif
67#include <openssl/bn.h> 66#include <openssl/bn.h>
68#include <openssl/stack.h> 67#include <openssl/stack.h>
69#include <openssl/safestack.h> 68#include <openssl/safestack.h>
70 69
71#ifdef VMS 70#include <openssl/symhacks.h>
72#include <openssl/vms_idhacks.h> 71
72#ifdef __cplusplus
73extern "C" {
73#endif 74#endif
74 75
75#define V_ASN1_UNIVERSAL 0x00 76#define V_ASN1_UNIVERSAL 0x00
@@ -82,12 +83,15 @@ extern "C" {
82#define V_ASN1_PRIMATIVE_TAG 0x1f 83#define V_ASN1_PRIMATIVE_TAG 0x1f
83 84
84#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */ 85#define V_ASN1_APP_CHOOSE -2 /* let the recipient choose */
86#define V_ASN1_OTHER -3 /* used in ASN1_TYPE */
87
88#define V_ASN1_NEG 0x100 /* negative flag */
85 89
86#define V_ASN1_UNDEF -1 90#define V_ASN1_UNDEF -1
87#define V_ASN1_EOC 0 91#define V_ASN1_EOC 0
88#define V_ASN1_BOOLEAN 1 /**/ 92#define V_ASN1_BOOLEAN 1 /**/
89#define V_ASN1_INTEGER 2 93#define V_ASN1_INTEGER 2
90#define V_ASN1_NEG_INTEGER (2+0x100) 94#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
91#define V_ASN1_BIT_STRING 3 95#define V_ASN1_BIT_STRING 3
92#define V_ASN1_OCTET_STRING 4 96#define V_ASN1_OCTET_STRING 4
93#define V_ASN1_NULL 5 97#define V_ASN1_NULL 5
@@ -96,7 +100,7 @@ extern "C" {
96#define V_ASN1_EXTERNAL 8 100#define V_ASN1_EXTERNAL 8
97#define V_ASN1_REAL 9 101#define V_ASN1_REAL 9
98#define V_ASN1_ENUMERATED 10 102#define V_ASN1_ENUMERATED 10
99#define V_ASN1_NEG_ENUMERATED (10+0x100) 103#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
100#define V_ASN1_UTF8STRING 12 104#define V_ASN1_UTF8STRING 12
101#define V_ASN1_SEQUENCE 16 105#define V_ASN1_SEQUENCE 16
102#define V_ASN1_SET 17 106#define V_ASN1_SET 17
@@ -140,32 +144,10 @@ extern "C" {
140#define MBSTRING_UNIV (MBSTRING_FLAG|3) 144#define MBSTRING_UNIV (MBSTRING_FLAG|3)
141#define MBSTRING_UTF8 (MBSTRING_FLAG|4) 145#define MBSTRING_UTF8 (MBSTRING_FLAG|4)
142 146
143#define DECLARE_ASN1_SET_OF(type) \ 147struct X509_algor_st;
144int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \ 148
145 int (*func)(type *,unsigned char **), int ex_tag, \ 149#define DECLARE_ASN1_SET_OF(type) /* filled in by mkstack.pl */
146 int ex_class, int is_set); \ 150#define IMPLEMENT_ASN1_SET_OF(type) /* nothing, no longer needed */
147STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
148 long length, \
149 type *(*func)(type **, \
150 unsigned char **,long), \
151 void (*free_func)(type *), \
152 int ex_tag,int ex_class);
153
154#define IMPLEMENT_ASN1_SET_OF(type) \
155int i2d_ASN1_SET_OF_##type(STACK_OF(type) *a,unsigned char **pp, \
156 int (*func)(type *,unsigned char **), int ex_tag, \
157 int ex_class, int is_set) \
158 { return i2d_ASN1_SET((STACK *)a,pp,func,ex_tag,ex_class,is_set); } \
159STACK_OF(type) *d2i_ASN1_SET_OF_##type(STACK_OF(type) **a,unsigned char **pp, \
160 long length, \
161 type *(*func)(type **, \
162 unsigned char **,long), \
163 void (*free_func)(type *), \
164 int ex_tag,int ex_class) \
165 { return (STACK_OF(type) *)d2i_ASN1_SET((STACK **)a,pp,length, \
166 (char *(*)())func, \
167 (void (*)())free_func, \
168 ex_tag,ex_class); }
169 151
170typedef struct asn1_ctx_st 152typedef struct asn1_ctx_st
171 { 153 {
@@ -254,6 +236,7 @@ DECLARE_STACK_OF(ASN1_STRING_TABLE)
254#define ASN1_BMPSTRING ASN1_STRING 236#define ASN1_BMPSTRING ASN1_STRING
255#define ASN1_VISIBLESTRING ASN1_STRING 237#define ASN1_VISIBLESTRING ASN1_STRING
256#define ASN1_UTF8STRING ASN1_STRING 238#define ASN1_UTF8STRING ASN1_STRING
239#define ASN1_BOOLEAN int
257#else 240#else
258typedef struct asn1_string_st ASN1_INTEGER; 241typedef struct asn1_string_st ASN1_INTEGER;
259typedef struct asn1_string_st ASN1_ENUMERATED; 242typedef struct asn1_string_st ASN1_ENUMERATED;
@@ -270,15 +253,99 @@ typedef struct asn1_string_st ASN1_TIME;
270typedef struct asn1_string_st ASN1_GENERALIZEDTIME; 253typedef struct asn1_string_st ASN1_GENERALIZEDTIME;
271typedef struct asn1_string_st ASN1_VISIBLESTRING; 254typedef struct asn1_string_st ASN1_VISIBLESTRING;
272typedef struct asn1_string_st ASN1_UTF8STRING; 255typedef struct asn1_string_st ASN1_UTF8STRING;
256typedef int ASN1_BOOLEAN;
273#endif 257#endif
274 258
275typedef int ASN1_NULL; 259typedef int ASN1_NULL;
276 260
261/* Parameters used by ASN1_STRING_print_ex() */
262
263/* These determine which characters to escape:
264 * RFC2253 special characters, control characters and
265 * MSB set characters
266 */
267
268#define ASN1_STRFLGS_ESC_2253 1
269#define ASN1_STRFLGS_ESC_CTRL 2
270#define ASN1_STRFLGS_ESC_MSB 4
271
272
273/* This flag determines how we do escaping: normally
274 * RC2253 backslash only, set this to use backslash and
275 * quote.
276 */
277
278#define ASN1_STRFLGS_ESC_QUOTE 8
279
280
281/* These three flags are internal use only. */
282
283/* Character is a valid PrintableString character */
284#define CHARTYPE_PRINTABLESTRING 0x10
285/* Character needs escaping if it is the first character */
286#define CHARTYPE_FIRST_ESC_2253 0x20
287/* Character needs escaping if it is the last character */
288#define CHARTYPE_LAST_ESC_2253 0x40
289
290/* NB the internal flags are safely reused below by flags
291 * handled at the top level.
292 */
293
294/* If this is set we convert all character strings
295 * to UTF8 first
296 */
297
298#define ASN1_STRFLGS_UTF8_CONVERT 0x10
299
300/* If this is set we don't attempt to interpret content:
301 * just assume all strings are 1 byte per character. This
302 * will produce some pretty odd looking output!
303 */
304
305#define ASN1_STRFLGS_IGNORE_TYPE 0x20
306
307/* If this is set we include the string type in the output */
308#define ASN1_STRFLGS_SHOW_TYPE 0x40
309
310/* This determines which strings to display and which to
311 * 'dump' (hex dump of content octets or DER encoding). We can
312 * only dump non character strings or everything. If we
313 * don't dump 'unknown' they are interpreted as character
314 * strings with 1 octet per character and are subject to
315 * the usual escaping options.
316 */
317
318#define ASN1_STRFLGS_DUMP_ALL 0x80
319#define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
320
321/* These determine what 'dumping' does, we can dump the
322 * content octets or the DER encoding: both use the
323 * RFC2253 #XXXXX notation.
324 */
325
326#define ASN1_STRFLGS_DUMP_DER 0x200
327
328/* All the string flags consistent with RFC2253,
329 * escaping control characters isn't essential in
330 * RFC2253 but it is advisable anyway.
331 */
332
333#define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
334 ASN1_STRFLGS_ESC_CTRL | \
335 ASN1_STRFLGS_ESC_MSB | \
336 ASN1_STRFLGS_UTF8_CONVERT | \
337 ASN1_STRFLGS_DUMP_UNKNOWN | \
338 ASN1_STRFLGS_DUMP_DER)
339
340DECLARE_STACK_OF(ASN1_INTEGER)
341DECLARE_ASN1_SET_OF(ASN1_INTEGER)
342
277typedef struct asn1_type_st 343typedef struct asn1_type_st
278 { 344 {
279 int type; 345 int type;
280 union { 346 union {
281 char *ptr; 347 char *ptr;
348 ASN1_BOOLEAN boolean;
282 ASN1_STRING * asn1_string; 349 ASN1_STRING * asn1_string;
283 ASN1_OBJECT * object; 350 ASN1_OBJECT * object;
284 ASN1_INTEGER * integer; 351 ASN1_INTEGER * integer;
@@ -520,6 +587,8 @@ void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value);
520ASN1_OBJECT * ASN1_OBJECT_new(void ); 587ASN1_OBJECT * ASN1_OBJECT_new(void );
521void ASN1_OBJECT_free(ASN1_OBJECT *a); 588void ASN1_OBJECT_free(ASN1_OBJECT *a);
522int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp); 589int i2d_ASN1_OBJECT(ASN1_OBJECT *a,unsigned char **pp);
590ASN1_OBJECT * c2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
591 long length);
523ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp, 592ASN1_OBJECT * d2i_ASN1_OBJECT(ASN1_OBJECT **a,unsigned char **pp,
524 long length); 593 long length);
525 594
@@ -542,14 +611,17 @@ unsigned char * ASN1_STRING_data(ASN1_STRING *x);
542ASN1_BIT_STRING * ASN1_BIT_STRING_new(void); 611ASN1_BIT_STRING * ASN1_BIT_STRING_new(void);
543void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a); 612void ASN1_BIT_STRING_free(ASN1_BIT_STRING *a);
544int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp); 613int i2d_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
614int i2c_ASN1_BIT_STRING(ASN1_BIT_STRING *a,unsigned char **pp);
545ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp, 615ASN1_BIT_STRING *d2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
546 long length); 616 long length);
617ASN1_BIT_STRING *c2i_ASN1_BIT_STRING(ASN1_BIT_STRING **a,unsigned char **pp,
618 long length);
547int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, 619int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d,
548 int length ); 620 int length );
549int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); 621int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value);
550int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n); 622int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *a, int n);
551 623
552#ifdef HEADER_BIO_H 624#ifndef NO_BIO
553int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, 625int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs,
554 BIT_STRING_BITNAME *tbl, int indent); 626 BIT_STRING_BITNAME *tbl, int indent);
555#endif 627#endif
@@ -563,8 +635,11 @@ int d2i_ASN1_BOOLEAN(int *a,unsigned char **pp,long length);
563ASN1_INTEGER * ASN1_INTEGER_new(void); 635ASN1_INTEGER * ASN1_INTEGER_new(void);
564void ASN1_INTEGER_free(ASN1_INTEGER *a); 636void ASN1_INTEGER_free(ASN1_INTEGER *a);
565int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp); 637int i2d_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
638int i2c_ASN1_INTEGER(ASN1_INTEGER *a,unsigned char **pp);
566ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp, 639ASN1_INTEGER *d2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
567 long length); 640 long length);
641ASN1_INTEGER *c2i_ASN1_INTEGER(ASN1_INTEGER **a,unsigned char **pp,
642 long length);
568ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp, 643ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a,unsigned char **pp,
569 long length); 644 long length);
570ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x); 645ASN1_INTEGER * ASN1_INTEGER_dup(ASN1_INTEGER *x);
@@ -579,6 +654,10 @@ ASN1_ENUMERATED *d2i_ASN1_ENUMERATED(ASN1_ENUMERATED **a,unsigned char **pp,
579int ASN1_UTCTIME_check(ASN1_UTCTIME *a); 654int ASN1_UTCTIME_check(ASN1_UTCTIME *a);
580ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t); 655ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s,time_t t);
581int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str); 656int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, char *str);
657int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t);
658#if 0
659time_t ASN1_UTCTIME_get(const ASN1_UTCTIME *s);
660#endif
582 661
583int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a); 662int ASN1_GENERALIZEDTIME_check(ASN1_GENERALIZEDTIME *a);
584ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t); 663ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s,time_t t);
@@ -673,10 +752,10 @@ ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s,time_t t);
673int i2d_ASN1_SET(STACK *a, unsigned char **pp, 752int i2d_ASN1_SET(STACK *a, unsigned char **pp,
674 int (*func)(), int ex_tag, int ex_class, int is_set); 753 int (*func)(), int ex_tag, int ex_class, int is_set);
675STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length, 754STACK * d2i_ASN1_SET(STACK **a, unsigned char **pp, long length,
676 char *(*func)(), void (*free_func)(), 755 char *(*func)(), void (*free_func)(void *),
677 int ex_tag, int ex_class); 756 int ex_tag, int ex_class);
678 757
679#ifdef HEADER_BIO_H 758#ifndef NO_BIO
680int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a); 759int i2a_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *a);
681int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size); 760int a2i_ASN1_INTEGER(BIO *bp,ASN1_INTEGER *bs,char *buf,int size);
682int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a); 761int i2a_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *a);
@@ -729,16 +808,21 @@ char *ASN1_dup(int (*i2d)(),char *(*d2i)(),char *x);
729#ifndef NO_FP_API 808#ifndef NO_FP_API
730char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x); 809char *ASN1_d2i_fp(char *(*xnew)(),char *(*d2i)(),FILE *fp,unsigned char **x);
731int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x); 810int ASN1_i2d_fp(int (*i2d)(),FILE *out,unsigned char *x);
811int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
732#endif 812#endif
733 813
734#ifdef HEADER_BIO_H 814int ASN1_STRING_to_UTF8(unsigned char **out, ASN1_STRING *in);
815
816#ifndef NO_BIO
735char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x); 817char *ASN1_d2i_bio(char *(*xnew)(),char *(*d2i)(),BIO *bp,unsigned char **x);
736int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x); 818int ASN1_i2d_bio(int (*i2d)(),BIO *out,unsigned char *x);
737int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a); 819int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
738int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a); 820int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
739int ASN1_TIME_print(BIO *fp,ASN1_TIME *a); 821int ASN1_TIME_print(BIO *fp,ASN1_TIME *a);
740int ASN1_STRING_print(BIO *bp,ASN1_STRING *v); 822int ASN1_STRING_print(BIO *bp,ASN1_STRING *v);
823int ASN1_STRING_print_ex(BIO *out, ASN1_STRING *str, unsigned long flags);
741int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent); 824int ASN1_parse(BIO *bp,unsigned char *pp,long len,int indent);
825int ASN1_parse_dump(BIO *bp,unsigned char *pp,long len,int indent,int dump);
742#endif 826#endif
743const char *ASN1_tag2str(int tag); 827const char *ASN1_tag2str(int tag);
744 828
@@ -768,9 +852,9 @@ int ASN1_TYPE_get_int_octetstring(ASN1_TYPE *a,long *num,
768 unsigned char *data, int max_len); 852 unsigned char *data, int max_len);
769 853
770STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(), 854STACK *ASN1_seq_unpack(unsigned char *buf, int len, char *(*d2i)(),
771 void (*free_func)() ); 855 void (*free_func)(void *) );
772unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf, 856unsigned char *ASN1_seq_pack(STACK *safes, int (*i2d)(), unsigned char **buf,
773 int *len ); 857 int *len );
774void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)()); 858void *ASN1_unpack_string(ASN1_STRING *oct, char *(*d2i)());
775ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct); 859ASN1_STRING *ASN1_pack_string(void *obj, int (*i2d)(), ASN1_OCTET_STRING **oct);
776 860