1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5from __future__ import absolute_import, division, print_function
6
7INCLUDES = """
8#include <openssl/asn1.h>
9"""
10
11TYPES = """
12typedef int... time_t;
13
14typedef ... ASN1_INTEGER;
15
16struct asn1_string_st {
17    int length;
18    int type;
19    unsigned char *data;
20    long flags;
21};
22
23typedef struct asn1_string_st ASN1_OCTET_STRING;
24typedef struct asn1_string_st ASN1_IA5STRING;
25typedef struct asn1_string_st ASN1_BIT_STRING;
26typedef struct asn1_string_st ASN1_TIME;
27typedef ... ASN1_OBJECT;
28typedef struct asn1_string_st ASN1_STRING;
29typedef struct asn1_string_st ASN1_UTF8STRING;
30typedef ... ASN1_TYPE;
31typedef ... ASN1_GENERALIZEDTIME;
32typedef ... ASN1_ENUMERATED;
33typedef ... ASN1_NULL;
34
35static const int V_ASN1_GENERALIZEDTIME;
36
37static const int MBSTRING_UTF8;
38"""
39
40FUNCTIONS = """
41void ASN1_OBJECT_free(ASN1_OBJECT *);
42
43/*  ASN1 STRING */
44unsigned char *ASN1_STRING_data(ASN1_STRING *);
45int ASN1_STRING_set(ASN1_STRING *, const void *, int);
46
47/*  ASN1 OCTET STRING */
48ASN1_OCTET_STRING *ASN1_OCTET_STRING_new(void);
49void ASN1_OCTET_STRING_free(ASN1_OCTET_STRING *);
50int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *, const unsigned char *, int);
51
52/* ASN1 IA5STRING */
53ASN1_IA5STRING *ASN1_IA5STRING_new(void);
54
55/*  ASN1 INTEGER */
56void ASN1_INTEGER_free(ASN1_INTEGER *);
57int ASN1_INTEGER_set(ASN1_INTEGER *, long);
58
59/*  ASN1 TIME */
60ASN1_TIME *ASN1_TIME_new(void);
61void ASN1_TIME_free(ASN1_TIME *);
62ASN1_TIME *ASN1_TIME_set(ASN1_TIME *, time_t);
63int ASN1_TIME_set_string(ASN1_TIME *, const char *);
64
65/*  ASN1 GENERALIZEDTIME */
66ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *, time_t);
67void ASN1_GENERALIZEDTIME_free(ASN1_GENERALIZEDTIME *);
68
69/*  ASN1 ENUMERATED */
70ASN1_ENUMERATED *ASN1_ENUMERATED_new(void);
71void ASN1_ENUMERATED_free(ASN1_ENUMERATED *);
72int ASN1_ENUMERATED_set(ASN1_ENUMERATED *, long);
73
74int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *, int, int);
75/* These became const ASN1_* in 1.1.0 */
76int ASN1_STRING_type(ASN1_STRING *);
77int ASN1_STRING_to_UTF8(unsigned char **, ASN1_STRING *);
78long ASN1_ENUMERATED_get(ASN1_ENUMERATED *);
79int i2a_ASN1_INTEGER(BIO *, ASN1_INTEGER *);
80
81/* This became const ASN1_TIME in 1.1.0f */
82ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *,
83                                                   ASN1_GENERALIZEDTIME **);
84
85ASN1_UTF8STRING *ASN1_UTF8STRING_new(void);
86void ASN1_UTF8STRING_free(ASN1_UTF8STRING *);
87
88ASN1_BIT_STRING *ASN1_BIT_STRING_new(void);
89void ASN1_BIT_STRING_free(ASN1_BIT_STRING *);
90/* This is not a macro, but is const on some versions of OpenSSL */
91int ASN1_BIT_STRING_get_bit(ASN1_BIT_STRING *, int);
92
93int ASN1_STRING_length(ASN1_STRING *);
94int ASN1_STRING_set_default_mask_asc(char *);
95
96BIGNUM *ASN1_INTEGER_to_BN(ASN1_INTEGER *, BIGNUM *);
97ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *, ASN1_INTEGER *);
98
99int i2d_ASN1_TYPE(ASN1_TYPE *, unsigned char **);
100ASN1_TYPE *d2i_ASN1_TYPE(ASN1_TYPE **, const unsigned char **, long);
101
102ASN1_NULL *ASN1_NULL_new(void);
103"""
104
105CUSTOMIZATIONS = """
106"""
107