source: azure_iot_hub_riscv/trunk/wolfssl-4.4.0/wolfssl/openssl/asn1.h@ 453

Last change on this file since 453 was 453, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 5.9 KB
Line 
1/* asn1.h
2 *
3 * Copyright (C) 2006-2020 wolfSSL Inc.
4 *
5 * This file is part of wolfSSL.
6 *
7 * wolfSSL is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * wolfSSL is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20 */
21
22/* asn1.h for openssl */
23
24#ifndef WOLFSSL_ASN1_H_
25#define WOLFSSL_ASN1_H_
26
27#include <wolfssl/openssl/ssl.h>
28
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
34
35#define V_ASN1_INTEGER 0x02
36#define V_ASN1_OCTET_STRING 0x04 /* tag for ASN1_OCTET_STRING */
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)
40
41/* Type for ASN1_print_ex */
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)
58
59#define MBSTRING_UTF8 0x1000
60#define MBSTRING_ASC 0x1001
61#define MBSTRING_BMP 0x1002
62#define MBSTRING_UNIV 0x1004
63
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
68
69#define V_ASN1_OBJECT 6
70#define V_ASN1_UTCTIME 23
71#define V_ASN1_GENERALIZEDTIME 24
72
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
78
79
80WOLFSSL_API WOLFSSL_ASN1_INTEGER *wolfSSL_BN_to_ASN1_INTEGER(
81 const WOLFSSL_BIGNUM*, WOLFSSL_ASN1_INTEGER*);
82
83WOLFSSL_API void wolfSSL_ASN1_TYPE_set(WOLFSSL_ASN1_TYPE *a, int type, void *value);
84
85#ifdef OPENSSL_ALL
86/* IMPLEMENT_ASN1_FUNCTIONS is strictly for external use only. Internally
87 * we don't use this. Some projects use OpenSSL to implement ASN1 types and
88 * this section is only to provide those projects with ASN1 functionality. */
89typedef struct {
90 size_t offset; /* Offset of this field in structure */
91 byte type; /* The type of the member as defined in
92 * WOLFSSL_ASN1_TYPES */
93} WOLFSSL_ASN1_TEMPLATE;
94
95typedef struct {
96 byte type; /* One of the ASN_Tags types */
97 const WOLFSSL_ASN1_TEMPLATE *members; /* If SEQUENCE or CHOICE this
98 * contains the contents */
99 size_t mcount; /* Number of members if SEQUENCE
100 * or CHOICE */
101 size_t size; /* Structure size */
102} WOLFSSL_ASN1_ITEM;
103
104typedef enum {
105 WOLFSSL_X509_ALGOR_ASN1 = 0,
106 WOLFSSL_ASN1_BIT_STRING_ASN1,
107} WOLFSSL_ASN1_TYPES;
108
109#define ASN1_SEQUENCE(type) \
110 static const type __##type##_dummy_struct;\
111 static const WOLFSSL_ASN1_TEMPLATE type##_member_data[]
112
113#define ASN1_SIMPLE(type, member, member_type) \
114 { (char*)&__##type##_dummy_struct.member - (char*)&__##type##_dummy_struct, \
115 WOLFSSL_##member_type##_ASN1 }
116
117#define ASN1_SEQUENCE_END(type) \
118 ; \
119 const WOLFSSL_ASN1_ITEM type##_template_data = { \
120 ASN_SEQUENCE, \
121 type##_member_data, \
122 sizeof(type##_member_data) / sizeof(WOLFSSL_ASN1_TEMPLATE), \
123 sizeof(type) \
124 };
125
126WOLFSSL_API void *wolfSSL_ASN1_item_new(const WOLFSSL_ASN1_ITEM *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,
129 const WOLFSSL_ASN1_ITEM *template);
130
131/* Need function declaration otherwise compiler complains */
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); \
136 } \
137 void type##_free(type *t); \
138 void type##_free(type *t){ \
139 wolfSSL_ASN1_item_free(t, &type##_template_data); \
140 } \
141 int i2d_##type(type *src, byte **dest); \
142 int i2d_##type(type *src, byte **dest) \
143 { \
144 return wolfSSL_ASN1_item_i2d(src, dest, &type##_template_data);\
145 }
146
147#endif /* OPENSSL_ALL */
148
149#define BN_to_ASN1_INTEGER wolfSSL_BN_to_ASN1_INTEGER
150#define ASN1_TYPE_set wolfSSL_ASN1_TYPE_set
151
152#endif /* WOLFSSL_ASN1_H_ */
Note: See TracBrowser for help on using the repository browser.