GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libcrypto/gost/gost_asn1.c Lines: 0 20 0.0 %
Date: 2017-11-07 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/**********************************************************************
2
 *                          gost_keytrans.c                           *
3
 *             Copyright (c) 2005-2006 Cryptocom LTD                  *
4
 *         This file is distributed under the same license as OpenSSL *
5
 *                                                                    *
6
 *   ASN1 structure definition for GOST key transport                 *
7
 *          Requires OpenSSL 0.9.9 for compilation                    *
8
 **********************************************************************/
9
10
#include <openssl/opensslconf.h>
11
12
#ifndef OPENSSL_NO_GOST
13
#include <openssl/asn1t.h>
14
#include <openssl/x509.h>
15
#include <openssl/gost.h>
16
17
#include "gost_locl.h"
18
#include "gost_asn1.h"
19
20
static const ASN1_TEMPLATE GOST_KEY_TRANSPORT_seq_tt[] = {
21
	{
22
		.flags = 0,
23
		.tag = 0,
24
		.offset = offsetof(GOST_KEY_TRANSPORT, key_info),
25
		.field_name = "key_info",
26
		.item = &GOST_KEY_INFO_it,
27
	},
28
	{
29
		.flags = ASN1_TFLG_IMPLICIT,
30
		.tag = 0,
31
		.offset = offsetof(GOST_KEY_TRANSPORT, key_agreement_info),
32
		.field_name = "key_agreement_info",
33
		.item = &GOST_KEY_AGREEMENT_INFO_it,
34
	},
35
};
36
37
const ASN1_ITEM GOST_KEY_TRANSPORT_it = {
38
	.itype = ASN1_ITYPE_NDEF_SEQUENCE,
39
	.utype = V_ASN1_SEQUENCE,
40
	.templates = GOST_KEY_TRANSPORT_seq_tt,
41
	.tcount = sizeof(GOST_KEY_TRANSPORT_seq_tt) / sizeof(ASN1_TEMPLATE),
42
	.funcs = NULL,
43
	.size = sizeof(GOST_KEY_TRANSPORT),
44
	.sname = "GOST_KEY_TRANSPORT",
45
};
46
47
GOST_KEY_TRANSPORT *
48
d2i_GOST_KEY_TRANSPORT(GOST_KEY_TRANSPORT **a, const unsigned char **in, long len)
49
{
50
	return (GOST_KEY_TRANSPORT *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
51
	    &GOST_KEY_TRANSPORT_it);
52
}
53
54
int
55
i2d_GOST_KEY_TRANSPORT(GOST_KEY_TRANSPORT *a, unsigned char **out)
56
{
57
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_TRANSPORT_it);
58
}
59
60
GOST_KEY_TRANSPORT *
61
GOST_KEY_TRANSPORT_new(void)
62
{
63
	return (GOST_KEY_TRANSPORT *)ASN1_item_new(&GOST_KEY_TRANSPORT_it);
64
}
65
66
void
67
GOST_KEY_TRANSPORT_free(GOST_KEY_TRANSPORT *a)
68
{
69
	ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_TRANSPORT_it);
70
}
71
72
static const ASN1_TEMPLATE GOST_KEY_INFO_seq_tt[] = {
73
	{
74
		.flags = 0,
75
		.tag = 0,
76
		.offset = offsetof(GOST_KEY_INFO, encrypted_key),
77
		.field_name = "encrypted_key",
78
		.item = &ASN1_OCTET_STRING_it,
79
	},
80
	{
81
		.flags = 0,
82
		.tag = 0,
83
		.offset = offsetof(GOST_KEY_INFO, imit),
84
		.field_name = "imit",
85
		.item = &ASN1_OCTET_STRING_it,
86
	},
87
};
88
89
const ASN1_ITEM GOST_KEY_INFO_it = {
90
	.itype = ASN1_ITYPE_NDEF_SEQUENCE,
91
	.utype = V_ASN1_SEQUENCE,
92
	.templates = GOST_KEY_INFO_seq_tt,
93
	.tcount = sizeof(GOST_KEY_INFO_seq_tt) / sizeof(ASN1_TEMPLATE),
94
	.funcs = NULL,
95
	.size = sizeof(GOST_KEY_INFO),
96
	.sname = "GOST_KEY_INFO",
97
};
98
99
GOST_KEY_INFO *
100
d2i_GOST_KEY_INFO(GOST_KEY_INFO **a, const unsigned char **in, long len)
101
{
102
	return (GOST_KEY_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
103
	    &GOST_KEY_INFO_it);
104
}
105
106
int
107
i2d_GOST_KEY_INFO(GOST_KEY_INFO *a, unsigned char **out)
108
{
109
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_INFO_it);
110
}
111
112
GOST_KEY_INFO *
113
GOST_KEY_INFO_new(void)
114
{
115
	return (GOST_KEY_INFO *)ASN1_item_new(&GOST_KEY_INFO_it);
116
}
117
118
void
119
GOST_KEY_INFO_free(GOST_KEY_INFO *a)
120
{
121
	ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_INFO_it);
122
}
123
124
static const ASN1_TEMPLATE GOST_KEY_AGREEMENT_INFO_seq_tt[] = {
125
	{
126
		.flags = 0,
127
		.tag = 0,
128
		.offset = offsetof(GOST_KEY_AGREEMENT_INFO, cipher),
129
		.field_name = "cipher",
130
		.item = &ASN1_OBJECT_it,
131
	},
132
	{
133
		.flags = ASN1_TFLG_IMPLICIT | ASN1_TFLG_OPTIONAL,
134
		.tag = 0,
135
		.offset = offsetof(GOST_KEY_AGREEMENT_INFO, ephem_key),
136
		.field_name = "ephem_key",
137
		.item = &X509_PUBKEY_it,
138
	},
139
	{
140
		.flags = 0,
141
		.tag = 0,
142
		.offset = offsetof(GOST_KEY_AGREEMENT_INFO, eph_iv),
143
		.field_name = "eph_iv",
144
		.item = &ASN1_OCTET_STRING_it,
145
	},
146
};
147
148
const ASN1_ITEM GOST_KEY_AGREEMENT_INFO_it = {
149
	.itype = ASN1_ITYPE_NDEF_SEQUENCE,
150
	.utype = V_ASN1_SEQUENCE,
151
	.templates = GOST_KEY_AGREEMENT_INFO_seq_tt,
152
	.tcount = sizeof(GOST_KEY_AGREEMENT_INFO_seq_tt) / sizeof(ASN1_TEMPLATE),
153
	.funcs = NULL,
154
	.size = sizeof(GOST_KEY_AGREEMENT_INFO),
155
	.sname = "GOST_KEY_AGREEMENT_INFO",
156
};
157
158
GOST_KEY_AGREEMENT_INFO *
159
d2i_GOST_KEY_AGREEMENT_INFO(GOST_KEY_AGREEMENT_INFO **a, const unsigned char **in, long len)
160
{
161
	return (GOST_KEY_AGREEMENT_INFO *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
162
	    &GOST_KEY_AGREEMENT_INFO_it);
163
}
164
165
int
166
i2d_GOST_KEY_AGREEMENT_INFO(GOST_KEY_AGREEMENT_INFO *a, unsigned char **out)
167
{
168
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_AGREEMENT_INFO_it);
169
}
170
171
GOST_KEY_AGREEMENT_INFO *
172
GOST_KEY_AGREEMENT_INFO_new(void)
173
{
174
	return (GOST_KEY_AGREEMENT_INFO *)ASN1_item_new(&GOST_KEY_AGREEMENT_INFO_it);
175
}
176
177
void
178
GOST_KEY_AGREEMENT_INFO_free(GOST_KEY_AGREEMENT_INFO *a)
179
{
180
	ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_AGREEMENT_INFO_it);
181
}
182
183
184
static const ASN1_TEMPLATE GOST_KEY_PARAMS_seq_tt[] = {
185
	{
186
		.flags = 0,
187
		.tag = 0,
188
		.offset = offsetof(GOST_KEY_PARAMS, key_params),
189
		.field_name = "key_params",
190
		.item = &ASN1_OBJECT_it,
191
	},
192
	{
193
		.flags = 0,
194
		.tag = 0,
195
		.offset = offsetof(GOST_KEY_PARAMS, hash_params),
196
		.field_name = "hash_params",
197
		.item = &ASN1_OBJECT_it,
198
	},
199
	{
200
		.flags = ASN1_TFLG_OPTIONAL,
201
		.tag = 0,
202
		.offset = offsetof(GOST_KEY_PARAMS, cipher_params),
203
		.field_name = "cipher_params",
204
		.item = &ASN1_OBJECT_it,
205
	},
206
};
207
208
const ASN1_ITEM GOST_KEY_PARAMS_it = {
209
	.itype = ASN1_ITYPE_NDEF_SEQUENCE,
210
	.utype = V_ASN1_SEQUENCE,
211
	.templates = GOST_KEY_PARAMS_seq_tt,
212
	.tcount = sizeof(GOST_KEY_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE),
213
	.funcs = NULL,
214
	.size = sizeof(GOST_KEY_PARAMS),
215
	.sname = "GOST_KEY_PARAMS",
216
};
217
218
GOST_KEY_PARAMS *
219
d2i_GOST_KEY_PARAMS(GOST_KEY_PARAMS **a, const unsigned char **in, long len)
220
{
221
	return (GOST_KEY_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
222
	    &GOST_KEY_PARAMS_it);
223
}
224
225
int
226
i2d_GOST_KEY_PARAMS(GOST_KEY_PARAMS *a, unsigned char **out)
227
{
228
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_KEY_PARAMS_it);
229
}
230
231
GOST_KEY_PARAMS *
232
GOST_KEY_PARAMS_new(void)
233
{
234
	return (GOST_KEY_PARAMS *)ASN1_item_new(&GOST_KEY_PARAMS_it);
235
}
236
237
void
238
GOST_KEY_PARAMS_free(GOST_KEY_PARAMS *a)
239
{
240
	ASN1_item_free((ASN1_VALUE *)a, &GOST_KEY_PARAMS_it);
241
}
242
243
static const ASN1_TEMPLATE GOST_CIPHER_PARAMS_seq_tt[] = {
244
	{
245
		.flags = 0,
246
		.tag = 0,
247
		.offset = offsetof(GOST_CIPHER_PARAMS, iv),
248
		.field_name = "iv",
249
		.item = &ASN1_OCTET_STRING_it,
250
	},
251
	{
252
		.flags = 0,
253
		.tag = 0,
254
		.offset = offsetof(GOST_CIPHER_PARAMS, enc_param_set),
255
		.field_name = "enc_param_set",
256
		.item = &ASN1_OBJECT_it,
257
	},
258
};
259
260
const ASN1_ITEM GOST_CIPHER_PARAMS_it = {
261
	.itype = ASN1_ITYPE_NDEF_SEQUENCE,
262
	.utype = V_ASN1_SEQUENCE,
263
	.templates = GOST_CIPHER_PARAMS_seq_tt,
264
	.tcount = sizeof(GOST_CIPHER_PARAMS_seq_tt) / sizeof(ASN1_TEMPLATE),
265
	.funcs = NULL,
266
	.size = sizeof(GOST_CIPHER_PARAMS),
267
	.sname = "GOST_CIPHER_PARAMS",
268
};
269
270
GOST_CIPHER_PARAMS *
271
d2i_GOST_CIPHER_PARAMS(GOST_CIPHER_PARAMS **a, const unsigned char **in, long len)
272
{
273
	return (GOST_CIPHER_PARAMS *)ASN1_item_d2i((ASN1_VALUE **)a, in, len,
274
	    &GOST_CIPHER_PARAMS_it);
275
}
276
277
int
278
i2d_GOST_CIPHER_PARAMS(GOST_CIPHER_PARAMS *a, unsigned char **out)
279
{
280
	return ASN1_item_i2d((ASN1_VALUE *)a, out, &GOST_CIPHER_PARAMS_it);
281
}
282
283
GOST_CIPHER_PARAMS *
284
GOST_CIPHER_PARAMS_new(void)
285
{
286
	return (GOST_CIPHER_PARAMS *)ASN1_item_new(&GOST_CIPHER_PARAMS_it);
287
}
288
289
void
290
GOST_CIPHER_PARAMS_free(GOST_CIPHER_PARAMS *a)
291
{
292
	ASN1_item_free((ASN1_VALUE *)a, &GOST_CIPHER_PARAMS_it);
293
}
294
295
#endif