24#ifndef WOLFSSL_ASN1_H_
25#define WOLFSSL_ASN1_H_
27#include <wolfssl/openssl/ssl.h>
29#define ASN1_STRING_new wolfSSL_ASN1_STRING_new
30#define ASN1_STRING_type_new wolfSSL_ASN1_STRING_type_new
31#define ASN1_STRING_type wolfSSL_ASN1_STRING_type
32#define ASN1_STRING_set wolfSSL_ASN1_STRING_set
33#define ASN1_STRING_free wolfSSL_ASN1_STRING_free
35#define V_ASN1_INTEGER 0x02
36#define V_ASN1_OCTET_STRING 0x04
37#define V_ASN1_NEG 0x100
38#define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG)
39#define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG)
42# define ASN1_STRFLGS_ESC_2253 1
43# define ASN1_STRFLGS_ESC_CTRL 2
44# define ASN1_STRFLGS_ESC_MSB 4
45# define ASN1_STRFLGS_ESC_QUOTE 8
46# define ASN1_STRFLGS_UTF8_CONVERT 0x10
47# define ASN1_STRFLGS_IGNORE_TYPE 0x20
48# define ASN1_STRFLGS_SHOW_TYPE 0x40
49# define ASN1_STRFLGS_DUMP_ALL 0x80
50# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100
51# define ASN1_STRFLGS_DUMP_DER 0x200
52# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \
53 ASN1_STRFLGS_ESC_CTRL | \
54 ASN1_STRFLGS_ESC_MSB | \
55 ASN1_STRFLGS_UTF8_CONVERT | \
56 ASN1_STRFLGS_DUMP_UNKNOWN | \
57 ASN1_STRFLGS_DUMP_DER)
59#define MBSTRING_UTF8 0x1000
60#define MBSTRING_ASC 0x1001
61#define MBSTRING_BMP 0x1002
62#define MBSTRING_UNIV 0x1004
64#define ASN1_UTCTIME_print wolfSSL_ASN1_UTCTIME_print
65#define ASN1_TIME_check wolfSSL_ASN1_TIME_check
66#define ASN1_TIME_diff wolfSSL_ASN1_TIME_diff
67#define ASN1_TIME_set wolfSSL_ASN1_TIME_set
69#define V_ASN1_OBJECT 6
70#define V_ASN1_UTCTIME 23
71#define V_ASN1_GENERALIZEDTIME 24
73#define ASN1_STRING_FLAG_BITS_LEFT 0x008
74#define ASN1_STRING_FLAG_NDEF 0x010
75#define ASN1_STRING_FLAG_CONT 0x020
76#define ASN1_STRING_FLAG_MSTRING 0x040
77#define ASN1_STRING_FLAG_EMBED 0x080
83WOLFSSL_API
void wolfSSL_ASN1_TYPE_set(
WOLFSSL_ASN1_TYPE *a,
int type,
void *value);
105 WOLFSSL_X509_ALGOR_ASN1 = 0,
106 WOLFSSL_ASN1_BIT_STRING_ASN1,
109#define ASN1_SEQUENCE(type) \
110 static const type __##type##_dummy_struct;\
111 static const WOLFSSL_ASN1_TEMPLATE type##_member_data[]
113#define ASN1_SIMPLE(type, member, member_type) \
114 { (char*)&__##type##_dummy_struct.member - (char*)&__##type##_dummy_struct, \
115 WOLFSSL_##member_type##_ASN1 }
117#define ASN1_SEQUENCE_END(type) \
119 const WOLFSSL_ASN1_ITEM type##_template_data = { \
121 type##_member_data, \
122 sizeof(type##_member_data) / sizeof(WOLFSSL_ASN1_TEMPLATE), \
127WOLFSSL_API
void wolfSSL_ASN1_item_free(
void *val,
const WOLFSSL_ASN1_ITEM *
template);
128WOLFSSL_API
int wolfSSL_ASN1_item_i2d(
const void *src,
byte **dest,
132#define IMPLEMENT_ASN1_FUNCTIONS(type) \
133 type *type##_new(void); \
134 type *type##_new(void){ \
135 return (type*)wolfSSL_ASN1_item_new(&type##_template_data); \
137 void type##_free(type *t); \
138 void type##_free(type *t){ \
139 wolfSSL_ASN1_item_free(t, &type##_template_data); \
141 int i2d_##type(type *src, byte **dest); \
142 int i2d_##type(type *src, byte **dest) \
144 return wolfSSL_ASN1_item_i2d(src, dest, &type##_template_data);\
149#define BN_to_ASN1_INTEGER wolfSSL_BN_to_ASN1_INTEGER
150#define ASN1_TYPE_set wolfSSL_ASN1_TYPE_set
Definition asn_public.h:213