revert between 56095 -> 55830 in arch
[AROS.git] / workbench / devs / diskimage / include / amigaos / openssl / asn1_mac.h
blobfc5f4b881f0a2b2bb9a96b2a116bcff26211df9e
1 /* crypto/asn1/asn1_mac.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved.
5 * This package is an SSL implementation written
6 * by Eric Young (eay@cryptsoft.com).
7 * The implementation was written so as to conform with Netscapes SSL.
8 *
9 * This library is free for commercial and non-commercial use as long as
10 * the following conditions are aheared to. The following conditions
11 * apply to all code found in this distribution, be it the RC4, RSA,
12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
13 * included with this distribution is covered by the same copyright terms
14 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
16 * Copyright remains Eric Young's, and as such any Copyright notices in
17 * the code are not to be removed.
18 * If this package is used in a product, Eric Young should be given attribution
19 * as the author of the parts of the library used.
20 * This can be in the form of a textual message at program startup or
21 * in documentation (online or textual) provided with the package.
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 * 1. Redistributions of source code must retain the copyright
27 * notice, this list of conditions and the following disclaimer.
28 * 2. Redistributions in binary form must reproduce the above copyright
29 * notice, this list of conditions and the following disclaimer in the
30 * documentation and/or other materials provided with the distribution.
31 * 3. All advertising materials mentioning features or use of this software
32 * must display the following acknowledgement:
33 * "This product includes cryptographic software written by
34 * Eric Young (eay@cryptsoft.com)"
35 * The word 'cryptographic' can be left out if the rouines from the library
36 * being used are not cryptographic related :-).
37 * 4. If you include any Windows specific code (or a derivative thereof) from
38 * the apps directory (application code) you must include an acknowledgement:
39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 * SUCH DAMAGE.
53 * The licence and distribution terms for any publically available version or
54 * derivative of this code cannot be changed. i.e. this code cannot simply be
55 * copied and put under another distribution licence
56 * [including the GNU Public Licence.]
59 #ifndef PROTO_AMISSL_H
60 #include <proto/amissl.h>
61 #endif /* PROTO_AMISSL_H */
63 #ifndef HEADER_ASN1_MAC_H
64 #define HEADER_ASN1_MAC_H
66 #include <openssl/asn1.h>
68 #ifdef __cplusplus
69 extern "C" {
70 #endif
72 #ifndef ASN1_MAC_ERR_LIB
73 #define ASN1_MAC_ERR_LIB ERR_LIB_ASN1
74 #endif
76 #define ASN1_MAC_H_err(f,r,line) \
77 ERR_PUT_error(ASN1_MAC_ERR_LIB,(f),(r),__FILE__,(line))
79 #define M_ASN1_D2I_vars(a,type,func) \
80 ASN1_CTX c; \
81 type ret=NULL; \
83 c.pp=(unsigned char **)pp; \
84 c.q= *(unsigned char **)pp; \
85 c.error=ERR_R_NESTED_ASN1_ERROR; \
86 if ((a == NULL) || ((*a) == NULL)) \
87 { if ((ret=(type)func()) == NULL) \
88 { c.line=__LINE__; goto err; } } \
89 else ret=(*a);
91 #define M_ASN1_D2I_Init() \
92 c.p= *(unsigned char **)pp; \
93 c.max=(length == 0)?0:(c.p+length);
95 #define M_ASN1_D2I_Finish_2(a) \
96 if (!asn1_Finish(&c)) \
97 { c.line=__LINE__; goto err; } \
98 *(unsigned char **)pp=c.p; \
99 if (a != NULL) (*a)=ret; \
100 return(ret);
102 #define M_ASN1_D2I_Finish(a,func,e) \
103 M_ASN1_D2I_Finish_2(a); \
104 err:\
105 ASN1_MAC_H_err((e),c.error,c.line); \
106 asn1_add_error(*(unsigned char **)pp,(int)(c.q- *pp)); \
107 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
108 return(NULL)
110 #define M_ASN1_D2I_start_sequence() \
111 if (!asn1_GetSequence(&c,&length)) \
112 { c.line=__LINE__; goto err; }
113 /* Begin reading ASN1 without a surrounding sequence */
114 #define M_ASN1_D2I_begin() \
115 c.slen = length;
117 /* End reading ASN1 with no check on length */
118 #define M_ASN1_D2I_Finish_nolen(a, func, e) \
119 *pp=c.p; \
120 if (a != NULL) (*a)=ret; \
121 return(ret); \
122 err:\
123 ASN1_MAC_H_err((e),c.error,c.line); \
124 asn1_add_error(*pp,(int)(c.q- *pp)); \
125 if ((ret != NULL) && ((a == NULL) || (*a != ret))) func(ret); \
126 return(NULL)
128 #define M_ASN1_D2I_end_sequence() \
129 (((c.inf&1) == 0)?(c.slen <= 0): \
130 (c.eos=ASN1_check_infinite_end(&c.p,c.slen)))
132 /* Don't use this with d2i_ASN1_BOOLEAN() */
133 #define M_ASN1_D2I_get(b,func) \
134 c.q=c.p; \
135 if (func(&(b),&c.p,c.slen) == NULL) \
136 {c.line=__LINE__; goto err; } \
137 c.slen-=(c.p-c.q);
139 /* use this instead () */
140 #define M_ASN1_D2I_get_int(b,func) \
141 c.q=c.p; \
142 if (func(&(b),&c.p,c.slen) < 0) \
143 {c.line=__LINE__; goto err; } \
144 c.slen-=(c.p-c.q);
146 #define M_ASN1_D2I_get_opt(b,func,type) \
147 if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) \
148 == (V_ASN1_UNIVERSAL|(type)))) \
150 M_ASN1_D2I_get(b,func); \
153 #define M_ASN1_D2I_get_imp(b,func, type) \
154 M_ASN1_next=(_tmp& V_ASN1_CONSTRUCTED)|type; \
155 c.q=c.p; \
156 if (func(&(b),&c.p,c.slen) == NULL) \
157 {c.line=__LINE__; M_ASN1_next_prev = _tmp; goto err; } \
158 c.slen-=(c.p-c.q);\
159 M_ASN1_next_prev=_tmp;
161 #define M_ASN1_D2I_get_IMP_opt(b,func,tag,type) \
162 if ((c.slen != 0) && ((M_ASN1_next & (~V_ASN1_CONSTRUCTED)) == \
163 (V_ASN1_CONTEXT_SPECIFIC|(tag)))) \
165 unsigned char _tmp = M_ASN1_next; \
166 M_ASN1_D2I_get_imp(b,func, type);\
169 #define M_ASN1_D2I_get_set(r,func,free_func) \
170 M_ASN1_D2I_get_imp_set(r,func,free_func, \
171 V_ASN1_SET,V_ASN1_UNIVERSAL);
173 #define M_ASN1_D2I_get_set_type(type,r,func,free_func) \
174 M_ASN1_D2I_get_imp_set_type(type,r,func,free_func, \
175 V_ASN1_SET,V_ASN1_UNIVERSAL);
177 #define M_ASN1_D2I_get_set_opt(r,func,free_func) \
178 if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
179 V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
180 { M_ASN1_D2I_get_set(r,func,free_func); }
182 #define M_ASN1_D2I_get_set_opt_type(type,r,func,free_func) \
183 if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
184 V_ASN1_CONSTRUCTED|V_ASN1_SET)))\
185 { M_ASN1_D2I_get_set_type(type,r,func,free_func); }
187 #define M_ASN1_I2D_len_SET_opt(a,f) \
188 if ((a != NULL) && (sk_num(a) != 0)) \
189 M_ASN1_I2D_len_SET(a,f);
191 #define M_ASN1_I2D_put_SET_opt(a,f) \
192 if ((a != NULL) && (sk_num(a) != 0)) \
193 M_ASN1_I2D_put_SET(a,f);
195 #define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
196 if ((a != NULL) && (sk_num(a) != 0)) \
197 M_ASN1_I2D_put_SEQUENCE(a,f);
199 #define M_ASN1_I2D_put_SEQUENCE_opt_type(type,a,f) \
200 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
201 M_ASN1_I2D_put_SEQUENCE_type(type,a,f);
203 #define M_ASN1_D2I_get_IMP_set_opt(b,func,free_func,tag) \
204 if ((c.slen != 0) && \
205 (M_ASN1_next == \
206 (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
208 M_ASN1_D2I_get_imp_set(b,func,free_func,\
209 tag,V_ASN1_CONTEXT_SPECIFIC); \
212 #define M_ASN1_D2I_get_IMP_set_opt_type(type,b,func,free_func,tag) \
213 if ((c.slen != 0) && \
214 (M_ASN1_next == \
215 (V_ASN1_CONTEXT_SPECIFIC|V_ASN1_CONSTRUCTED|(tag))))\
217 M_ASN1_D2I_get_imp_set_type(type,b,func,free_func,\
218 tag,V_ASN1_CONTEXT_SPECIFIC); \
221 #define M_ASN1_D2I_get_seq(r,func,free_func) \
222 M_ASN1_D2I_get_imp_set(r,func,free_func,\
223 V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL);
225 #define M_ASN1_D2I_get_seq_type(type,r,func,free_func) \
226 M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
227 V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
229 #define M_ASN1_D2I_get_seq_opt(r,func,free_func) \
230 if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
231 V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
232 { M_ASN1_D2I_get_seq(r,func,free_func); }
234 #define M_ASN1_D2I_get_seq_opt_type(type,r,func,free_func) \
235 if ((c.slen != 0) && (M_ASN1_next == (V_ASN1_UNIVERSAL| \
236 V_ASN1_CONSTRUCTED|V_ASN1_SEQUENCE)))\
237 { M_ASN1_D2I_get_seq_type(type,r,func,free_func); }
239 #define M_ASN1_D2I_get_IMP_set(r,func,free_func,x) \
240 M_ASN1_D2I_get_imp_set(r,func,free_func,\
241 x,V_ASN1_CONTEXT_SPECIFIC);
243 #define M_ASN1_D2I_get_IMP_set_type(type,r,func,free_func,x) \
244 M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,\
245 x,V_ASN1_CONTEXT_SPECIFIC);
247 #define M_ASN1_D2I_get_imp_set(r,func,free_func,a,b) \
248 c.q=c.p; \
249 if (d2i_ASN1_SET(&(r),&c.p,c.slen,(char *(*)())func,\
250 (void (*)())free_func,a,b) == NULL) \
251 { c.line=__LINE__; goto err; } \
252 c.slen-=(c.p-c.q);
254 #define M_ASN1_D2I_get_imp_set_type(type,r,func,free_func,a,b) \
255 c.q=c.p; \
256 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,c.slen,func,\
257 free_func,a,b) == NULL) \
258 { c.line=__LINE__; goto err; } \
259 c.slen-=(c.p-c.q);
261 #define M_ASN1_D2I_get_set_strings(r,func,a,b) \
262 c.q=c.p; \
263 if (d2i_ASN1_STRING_SET(&(r),&c.p,c.slen,a,b) == NULL) \
264 { c.line=__LINE__; goto err; } \
265 c.slen-=(c.p-c.q);
267 #define M_ASN1_D2I_get_EXP_opt(r,func,tag) \
268 if ((c.slen != 0L) && (M_ASN1_next == \
269 (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
271 int Tinf,Ttag,Tclass; \
272 long Tlen; \
274 c.q=c.p; \
275 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
276 if (Tinf & 0x80) \
277 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
278 c.line=__LINE__; goto err; } \
279 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
280 Tlen = c.slen - (c.p - c.q) - 2; \
281 if (func(&(r),&c.p,Tlen) == NULL) \
282 { c.line=__LINE__; goto err; } \
283 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
284 Tlen = c.slen - (c.p - c.q); \
285 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
286 { c.error=ERR_R_MISSING_ASN1_EOS; \
287 c.line=__LINE__; goto err; } \
289 c.slen-=(c.p-c.q); \
292 #define M_ASN1_D2I_get_EXP_set_opt(r,func,free_func,tag,b) \
293 if ((c.slen != 0) && (M_ASN1_next == \
294 (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
296 int Tinf,Ttag,Tclass; \
297 long Tlen; \
299 c.q=c.p; \
300 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
301 if (Tinf & 0x80) \
302 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
303 c.line=__LINE__; goto err; } \
304 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
305 Tlen = c.slen - (c.p - c.q) - 2; \
306 if (d2i_ASN1_SET(&(r),&c.p,Tlen,(char *(*)())func, \
307 (void (*)())free_func, \
308 b,V_ASN1_UNIVERSAL) == NULL) \
309 { c.line=__LINE__; goto err; } \
310 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
311 Tlen = c.slen - (c.p - c.q); \
312 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
313 { c.error=ERR_R_MISSING_ASN1_EOS; \
314 c.line=__LINE__; goto err; } \
316 c.slen-=(c.p-c.q); \
319 #define M_ASN1_D2I_get_EXP_set_opt_type(type,r,func,free_func,tag,b) \
320 if ((c.slen != 0) && (M_ASN1_next == \
321 (V_ASN1_CONSTRUCTED|V_ASN1_CONTEXT_SPECIFIC|tag))) \
323 int Tinf,Ttag,Tclass; \
324 long Tlen; \
326 c.q=c.p; \
327 Tinf=ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen); \
328 if (Tinf & 0x80) \
329 { c.error=ERR_R_BAD_ASN1_OBJECT_HEADER; \
330 c.line=__LINE__; goto err; } \
331 if (Tinf == (V_ASN1_CONSTRUCTED+1)) \
332 Tlen = c.slen - (c.p - c.q) - 2; \
333 if (d2i_ASN1_SET_OF_##type(&(r),&c.p,Tlen,func, \
334 free_func,b,V_ASN1_UNIVERSAL) == NULL) \
335 { c.line=__LINE__; goto err; } \
336 if (Tinf == (V_ASN1_CONSTRUCTED+1)) { \
337 Tlen = c.slen - (c.p - c.q); \
338 if(!ASN1_check_infinite_end(&c.p, Tlen)) \
339 { c.error=ERR_R_MISSING_ASN1_EOS; \
340 c.line=__LINE__; goto err; } \
342 c.slen-=(c.p-c.q); \
345 /* New macros */
346 #define M_ASN1_New_Malloc(ret,type) \
347 if ((ret=(type *)OPENSSL_malloc(sizeof(type))) == NULL) \
348 { c.line=__LINE__; goto err2; }
350 #define M_ASN1_New(arg,func) \
351 if (((arg)=func()) == NULL) return(NULL)
353 #define M_ASN1_New_Error(a) \
354 /* err: ASN1_MAC_H_err((a),ERR_R_NESTED_ASN1_ERROR,c.line); \
355 return(NULL);*/ \
356 err2: ASN1_MAC_H_err((a),ERR_R_MALLOC_FAILURE,c.line); \
357 return(NULL)
360 #define M_ASN1_next (*c.p)
361 #define M_ASN1_next_prev (*c.q)
363 /*************************************************/
365 #define M_ASN1_I2D_vars(a) int r=0,ret=0; \
366 unsigned char *p; \
367 if (a == NULL) return(0)
369 /* Length Macros */
370 #define M_ASN1_I2D_len(a,f) ret+=f(a,NULL)
371 #define M_ASN1_I2D_len_IMP_opt(a,f) if (a != NULL) M_ASN1_I2D_len(a,f)
373 #define M_ASN1_I2D_len_SET(a,f) \
374 ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
376 #define M_ASN1_I2D_len_SET_type(type,a,f) \
377 ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SET, \
378 V_ASN1_UNIVERSAL,IS_SET);
380 #define M_ASN1_I2D_len_SEQUENCE(a,f) \
381 ret+=i2d_ASN1_SET(a,NULL,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
382 IS_SEQUENCE);
384 #define M_ASN1_I2D_len_SEQUENCE_type(type,a,f) \
385 ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,V_ASN1_SEQUENCE, \
386 V_ASN1_UNIVERSAL,IS_SEQUENCE)
388 #define M_ASN1_I2D_len_SEQUENCE_opt(a,f) \
389 if ((a != NULL) && (sk_num(a) != 0)) \
390 M_ASN1_I2D_len_SEQUENCE(a,f);
392 #define M_ASN1_I2D_len_SEQUENCE_opt_type(type,a,f) \
393 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
394 M_ASN1_I2D_len_SEQUENCE_type(type,a,f);
396 #define M_ASN1_I2D_len_IMP_SET(a,f,x) \
397 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET);
399 #define M_ASN1_I2D_len_IMP_SET_type(type,a,f,x) \
400 ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
401 V_ASN1_CONTEXT_SPECIFIC,IS_SET);
403 #define M_ASN1_I2D_len_IMP_SET_opt(a,f,x) \
404 if ((a != NULL) && (sk_num(a) != 0)) \
405 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
406 IS_SET);
408 #define M_ASN1_I2D_len_IMP_SET_opt_type(type,a,f,x) \
409 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
410 ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
411 V_ASN1_CONTEXT_SPECIFIC,IS_SET);
413 #define M_ASN1_I2D_len_IMP_SEQUENCE(a,f,x) \
414 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
415 IS_SEQUENCE);
417 #define M_ASN1_I2D_len_IMP_SEQUENCE_opt(a,f,x) \
418 if ((a != NULL) && (sk_num(a) != 0)) \
419 ret+=i2d_ASN1_SET(a,NULL,f,x,V_ASN1_CONTEXT_SPECIFIC, \
420 IS_SEQUENCE);
422 #define M_ASN1_I2D_len_IMP_SEQUENCE_opt_type(type,a,f,x) \
423 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
424 ret+=i2d_ASN1_SET_OF_##type(a,NULL,f,x, \
425 V_ASN1_CONTEXT_SPECIFIC, \
426 IS_SEQUENCE);
428 #define M_ASN1_I2D_len_EXP_opt(a,f,mtag,v) \
429 if (a != NULL)\
431 v=f(a,NULL); \
432 ret+=ASN1_object_size(1,v,mtag); \
435 #define M_ASN1_I2D_len_EXP_SET_opt(a,f,mtag,tag,v) \
436 if ((a != NULL) && (sk_num(a) != 0))\
438 v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
439 ret+=ASN1_object_size(1,v,mtag); \
442 #define M_ASN1_I2D_len_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
443 if ((a != NULL) && (sk_num(a) != 0))\
445 v=i2d_ASN1_SET(a,NULL,f,tag,V_ASN1_UNIVERSAL, \
446 IS_SEQUENCE); \
447 ret+=ASN1_object_size(1,v,mtag); \
450 #define M_ASN1_I2D_len_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
451 if ((a != NULL) && (sk_##type##_num(a) != 0))\
453 v=i2d_ASN1_SET_OF_##type(a,NULL,f,tag, \
454 V_ASN1_UNIVERSAL, \
455 IS_SEQUENCE); \
456 ret+=ASN1_object_size(1,v,mtag); \
459 /* Put Macros */
460 #define M_ASN1_I2D_put(a,f) f(a,&p)
462 #define M_ASN1_I2D_put_IMP_opt(a,f,t) \
463 if (a != NULL) \
465 unsigned char *q=p; \
466 f(a,&p); \
467 *q=(V_ASN1_CONTEXT_SPECIFIC|t|(*q&V_ASN1_CONSTRUCTED));\
470 #define M_ASN1_I2D_put_SET(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SET,\
471 V_ASN1_UNIVERSAL,IS_SET)
472 #define M_ASN1_I2D_put_SET_type(type,a,f) \
473 i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET)
474 #define M_ASN1_I2D_put_IMP_SET(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
475 V_ASN1_CONTEXT_SPECIFIC,IS_SET)
476 #define M_ASN1_I2D_put_IMP_SET_type(type,a,f,x) \
477 i2d_ASN1_SET_OF_##type(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC,IS_SET)
478 #define M_ASN1_I2D_put_IMP_SEQUENCE(a,f,x) i2d_ASN1_SET(a,&p,f,x,\
479 V_ASN1_CONTEXT_SPECIFIC,IS_SEQUENCE)
481 #define M_ASN1_I2D_put_SEQUENCE(a,f) i2d_ASN1_SET(a,&p,f,V_ASN1_SEQUENCE,\
482 V_ASN1_UNIVERSAL,IS_SEQUENCE)
484 #define M_ASN1_I2D_put_SEQUENCE_type(type,a,f) \
485 i2d_ASN1_SET_OF_##type(a,&p,f,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL, \
486 IS_SEQUENCE)
488 #define M_ASN1_I2D_put_SEQUENCE_opt(a,f) \
489 if ((a != NULL) && (sk_num(a) != 0)) \
490 M_ASN1_I2D_put_SEQUENCE(a,f);
492 #define M_ASN1_I2D_put_IMP_SET_opt(a,f,x) \
493 if ((a != NULL) && (sk_num(a) != 0)) \
494 { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
495 IS_SET); }
497 #define M_ASN1_I2D_put_IMP_SET_opt_type(type,a,f,x) \
498 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
499 { i2d_ASN1_SET_OF_##type(a,&p,f,x, \
500 V_ASN1_CONTEXT_SPECIFIC, \
501 IS_SET); }
503 #define M_ASN1_I2D_put_IMP_SEQUENCE_opt(a,f,x) \
504 if ((a != NULL) && (sk_num(a) != 0)) \
505 { i2d_ASN1_SET(a,&p,f,x,V_ASN1_CONTEXT_SPECIFIC, \
506 IS_SEQUENCE); }
508 #define M_ASN1_I2D_put_IMP_SEQUENCE_opt_type(type,a,f,x) \
509 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
510 { i2d_ASN1_SET_OF_##type(a,&p,f,x, \
511 V_ASN1_CONTEXT_SPECIFIC, \
512 IS_SEQUENCE); }
514 #define M_ASN1_I2D_put_EXP_opt(a,f,tag,v) \
515 if (a != NULL) \
517 ASN1_put_object(&p,1,v,tag,V_ASN1_CONTEXT_SPECIFIC); \
518 f(a,&p); \
521 #define M_ASN1_I2D_put_EXP_SET_opt(a,f,mtag,tag,v) \
522 if ((a != NULL) && (sk_num(a) != 0)) \
524 ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
525 i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SET); \
528 #define M_ASN1_I2D_put_EXP_SEQUENCE_opt(a,f,mtag,tag,v) \
529 if ((a != NULL) && (sk_num(a) != 0)) \
531 ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
532 i2d_ASN1_SET(a,&p,f,tag,V_ASN1_UNIVERSAL,IS_SEQUENCE); \
535 #define M_ASN1_I2D_put_EXP_SEQUENCE_opt_type(type,a,f,mtag,tag,v) \
536 if ((a != NULL) && (sk_##type##_num(a) != 0)) \
538 ASN1_put_object(&p,1,v,mtag,V_ASN1_CONTEXT_SPECIFIC); \
539 i2d_ASN1_SET_OF_##type(a,&p,f,tag,V_ASN1_UNIVERSAL, \
540 IS_SEQUENCE); \
543 #define M_ASN1_I2D_seq_total() \
544 r=ASN1_object_size(1,ret,V_ASN1_SEQUENCE); \
545 if (pp == NULL) return(r); \
546 p= *pp; \
547 ASN1_put_object(&p,1,ret,V_ASN1_SEQUENCE,V_ASN1_UNIVERSAL)
549 #define M_ASN1_I2D_INF_seq_start(tag,ctx) \
550 *(p++)=(V_ASN1_CONSTRUCTED|(tag)|(ctx)); \
551 *(p++)=0x80
553 #define M_ASN1_I2D_INF_seq_end() *(p++)=0x00; *(p++)=0x00
555 #define M_ASN1_I2D_finish() *pp=p; \
556 return(r);
558 int asn1_GetSequence(ASN1_CTX *c, long *length);
559 void asn1_add_error(unsigned char *address,int offset);
560 #ifdef __cplusplus
562 #endif
564 #endif