Added SILC Server library.
[silc.git] / lib / silcasn1 / tests / test_silcasn1.c
1 #include "silc.h"
2
3 /*
4 silc_asn1_encode(asn1, node,
5                  SILC_ASN1_BOOLEAN(SilcBool),
6                  SILC_ASN1_END);
7 silc_asn1_encode(asn1, dest,
8                  SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
9                    SILC_ASN1_SEQUENCE_T(0, 9),
10                      SILC_ASN1_SEQUENCE,
11                        SILC_ASN1_ANY_T(0, 33, node),
12                        SILC_ASN1_BOOLEAN_T(0, 4, boolv),
13                        SILC_ASN1_BOOLEAN(SilcBool),
14                      SILC_ASN1_END,
15                    SILC_ASN1_END,
16                  SILC_ASN1_END);
17
18   FATAL ERROR: Adding primitive node with implicit tagging is not possible.
19   The node either must be constructed (SEQUENCE or SET), or the tagging
20   must be explicit (in which case end result is same).
21 */
22
23
24 /*
25 silc_asn1_encode(asn1, node,
26                  SILC_ASN1_BOOLEAN(SilcBool),
27                  SILC_ASN1_END);
28 silc_asn1_encode(asn1, dest,
29                  SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
30                    SILC_ASN1_SEQUENCE_T(0, 9),
31                      SILC_ASN1_SEQUENCE,
32                        SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, node),
33                        SILC_ASN1_BOOLEAN_T(0, 4, boolv),
34                        SILC_ASN1_BOOLEAN(SilcBool),
35                      SILC_ASN1_END,
36                    SILC_ASN1_END,
37                  SILC_ASN1_END);
38
39   CORRECT: the tagging is now explicit.  Also note that tagging primitive
40   node explicitly is analougous of having a constructed node and tagging
41   that implicitly: the end result is same.
42
43 */
44
45
46 int main(int argc, char **argv)
47 {
48   SilcBufferStruct node, node2;
49   SilcAsn1 asn1;
50   SilcBool success = FALSE;
51   SilcBool val = TRUE;
52   int i;
53   unsigned char *str;
54   SilcUInt32 str_len;
55
56   memset(&node, 0, sizeof(node));
57   memset(&node2, 0, sizeof(node2));
58
59   if (argc > 1 && !strcmp(argv[1], "-d")) {
60     silc_log_debug(TRUE);
61     silc_log_debug_hexdump(TRUE);
62     silc_log_set_debug_string("*asn1*,*ber*");
63   }
64
65   SILC_LOG_DEBUG(("Allocating ASN.1 context"));
66   asn1 = silc_asn1_alloc();
67   if (!asn1)
68     goto out;
69
70   SILC_LOG_DEBUG(("Encoding ASN.1 tree 1"));
71   val = 1;
72   success =
73     silc_asn1_encode(asn1, &node,
74                      SILC_ASN1_SEQUENCE,
75                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
76                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
77                                               SILC_ASN1_INDEFINITE, 0),
78                            SILC_ASN1_BOOLEAN_T(0, 4, val),
79                            SILC_ASN1_BOOLEAN(val),
80                          SILC_ASN1_END,
81                        SILC_ASN1_END,
82                      SILC_ASN1_END, SILC_ASN1_END);
83   if (!success) {
84     SILC_LOG_DEBUG(("Encoding failed"));
85     goto out;
86   }
87   SILC_LOG_DEBUG(("Encoding success"));
88   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
89   SILC_LOG_DEBUG(("Decoding ASN.1 tree 1"));
90   success =
91     silc_asn1_decode(asn1, &node,
92                      SILC_ASN1_SEQUENCE,
93                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
94                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
95                                               SILC_ASN1_INDEFINITE, 0),
96                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
97                            SILC_ASN1_BOOLEAN(&val),
98                          SILC_ASN1_END,
99                        SILC_ASN1_END,
100                      SILC_ASN1_END, SILC_ASN1_END);
101   if (!success) {
102     SILC_LOG_DEBUG(("Decoding failed"));
103     goto out;
104   }
105   SILC_LOG_DEBUG(("Decoding success"));
106   SILC_LOG_DEBUG(("Boolean val %d", val));
107
108 #if 1
109   memset(&node, 0, sizeof(node));
110   SILC_LOG_DEBUG(("Encoding ASN.1 tree 1"));
111   val = 0;
112   success =
113     silc_asn1_encode(asn1, &node,
114                      SILC_ASN1_SEQUENCE,
115                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
116                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
117                                               SILC_ASN1_INDEFINITE, 0),
118                            SILC_ASN1_BOOLEAN_T(0, 4, val),
119                            SILC_ASN1_BOOLEAN(val),
120                          SILC_ASN1_END,
121                        SILC_ASN1_END,
122                      SILC_ASN1_END, SILC_ASN1_END);
123   if (!success) {
124     SILC_LOG_DEBUG(("Encoding failed"));
125     goto out;
126   }
127   SILC_LOG_DEBUG(("Encoding success"));
128   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
129   SILC_LOG_DEBUG(("Decoding ASN.1 tree 1"));
130   success =
131     silc_asn1_decode(asn1, &node,
132                      SILC_ASN1_SEQUENCE,
133                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
134                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
135                                               SILC_ASN1_INDEFINITE, 0),
136                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
137                            SILC_ASN1_BOOLEAN(&val),
138                          SILC_ASN1_END,
139                        SILC_ASN1_END,
140                      SILC_ASN1_END, SILC_ASN1_END);
141   if (!success) {
142     SILC_LOG_DEBUG(("Decoding failed"));
143     goto out;
144   }
145   SILC_LOG_DEBUG(("Decoding success"));
146   SILC_LOG_DEBUG(("Boolean val %d", val));
147   printf("\n");
148
149
150   memset(&node, 0, sizeof(node));
151   SILC_LOG_DEBUG(("Encoding ASN.1 tree 2"));
152   val = 1;
153   success =
154     silc_asn1_encode(asn1, &node,
155                      SILC_ASN1_SEQUENCE,
156                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
157                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_INDEFINITE, 0),
158                            SILC_ASN1_BOOLEAN_T(0, 4, val),
159                            SILC_ASN1_BOOLEAN(val),
160                          SILC_ASN1_END,
161                        SILC_ASN1_END,
162                      SILC_ASN1_END, SILC_ASN1_END);
163   if (!success) {
164     SILC_LOG_DEBUG(("Encoding failed"));
165     goto out;
166   }
167   SILC_LOG_DEBUG(("Encoding success"));
168   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
169   SILC_LOG_DEBUG(("Decoding ASN.1 tree 2"));
170   success =
171     silc_asn1_decode(asn1, &node,
172                      SILC_ASN1_SEQUENCE,
173                        SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
174                          SILC_ASN1_SEQUENCE_T(SILC_ASN1_INDEFINITE, 0),
175                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
176                            SILC_ASN1_BOOLEAN(&val),
177                          SILC_ASN1_END,
178                        SILC_ASN1_END,
179                      SILC_ASN1_END, SILC_ASN1_END);
180   if (!success) {
181     SILC_LOG_DEBUG(("Decoding failed"));
182     goto out;
183   }
184   SILC_LOG_DEBUG(("Decoding success"));
185   SILC_LOG_DEBUG(("Boolean val %d", val));
186   printf("\n");
187
188
189   memset(&node, 0, sizeof(node));
190   SILC_LOG_DEBUG(("Encoding ASN.1 tree 3"));
191   val = 0;
192   success =
193     silc_asn1_encode(asn1, &node,
194                      SILC_ASN1_SEQUENCE,
195                        SILC_ASN1_SEQUENCE_T(0, 9),
196                          SILC_ASN1_SEQUENCE,
197                            SILC_ASN1_BOOLEAN_T(0, 4, val),
198                            SILC_ASN1_BOOLEAN(val),
199                          SILC_ASN1_END,
200                        SILC_ASN1_END,
201                      SILC_ASN1_END, SILC_ASN1_END);
202   if (!success) {
203     SILC_LOG_DEBUG(("Encoding failed"));
204     goto out;
205   }
206   SILC_LOG_DEBUG(("Encoding success"));
207   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
208   SILC_LOG_DEBUG(("Decoding ASN.1 tree 3"));
209   success =
210     silc_asn1_decode(asn1, &node,
211                      SILC_ASN1_SEQUENCE,
212                        SILC_ASN1_SEQUENCE_T(0, 9),
213                          SILC_ASN1_SEQUENCE,
214                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
215                            SILC_ASN1_BOOLEAN(&val),
216                          SILC_ASN1_END,
217                        SILC_ASN1_END,
218                      SILC_ASN1_END, SILC_ASN1_END);
219   if (!success) {
220     SILC_LOG_DEBUG(("Decoding failed"));
221     goto out;
222   }
223   SILC_LOG_DEBUG(("Decoding success"));
224   SILC_LOG_DEBUG(("Boolean val %d", val));
225   printf("\n");
226
227
228   memset(&node, 0, sizeof(node));
229   SILC_LOG_DEBUG(("Encoding ASN.1 tree 4"));
230   val = 1;
231   success =
232     silc_asn1_encode(asn1, &node,
233                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE |
234                                           SILC_ASN1_EXPLICIT, 101),
235                        SILC_ASN1_SEQUENCE_T(0, 9),
236                          SILC_ASN1_SEQUENCE,
237                            SILC_ASN1_BOOLEAN_T(0, 4, val),
238                            SILC_ASN1_BOOLEAN(val),
239                          SILC_ASN1_END,
240                        SILC_ASN1_END,
241                      SILC_ASN1_END, SILC_ASN1_END);
242   if (!success) {
243     SILC_LOG_DEBUG(("Encoding failed"));
244     goto out;
245   }
246   SILC_LOG_DEBUG(("Encoding success"));
247   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
248   SILC_LOG_DEBUG(("Decoding ASN.1 tree 4"));
249   success =
250     silc_asn1_decode(asn1, &node,
251                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE |
252                                           SILC_ASN1_EXPLICIT, 101),
253                        SILC_ASN1_SEQUENCE_T(0, 9),
254                          SILC_ASN1_SEQUENCE,
255                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
256                            SILC_ASN1_BOOLEAN(&val),
257                          SILC_ASN1_END,
258                        SILC_ASN1_END,
259                      SILC_ASN1_END, SILC_ASN1_END);
260   if (!success) {
261     SILC_LOG_DEBUG(("Decoding failed"));
262     goto out;
263   }
264   SILC_LOG_DEBUG(("Decoding success"));
265   SILC_LOG_DEBUG(("Boolean val %d", val));
266   printf("\n");
267
268
269   memset(&node, 0, sizeof(node));
270   SILC_LOG_DEBUG(("Encoding ASN.1 tree 5"));
271   success =
272     silc_asn1_encode(asn1, &node2,
273                      SILC_ASN1_BOOLEAN(val),
274                      SILC_ASN1_END);
275   SILC_LOG_DEBUG(("Encoding success"));
276   success =
277     silc_asn1_encode(asn1, &node,
278                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
279                        SILC_ASN1_SEQUENCE_T(0, 9),
280                          SILC_ASN1_SEQUENCE,
281                            SILC_ASN1_ANY(&node2),
282                            SILC_ASN1_BOOLEAN_T(0, 4, val),
283                            SILC_ASN1_BOOLEAN(val),
284                          SILC_ASN1_END,
285                        SILC_ASN1_END,
286                      SILC_ASN1_END, SILC_ASN1_END);
287   if (!success) {
288     SILC_LOG_DEBUG(("Encoding failed"));
289     goto out;
290   }
291   SILC_LOG_DEBUG(("Encoding success"));
292   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
293   memset(&node2, 0, sizeof(node2));
294   SILC_LOG_DEBUG(("Decoding ASN.1 tree 5"));
295   success =
296     silc_asn1_decode(asn1, &node,
297                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
298                        SILC_ASN1_SEQUENCE_T(0, 9),
299                          SILC_ASN1_SEQUENCE,
300                            SILC_ASN1_ANY(&node2),
301                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
302                            SILC_ASN1_BOOLEAN(&val),
303                          SILC_ASN1_END,
304                        SILC_ASN1_END,
305                      SILC_ASN1_END, SILC_ASN1_END);
306   if (!success) {
307     SILC_LOG_DEBUG(("Decoding failed"));
308     goto out;
309   }
310   SILC_LOG_DEBUG(("Decoding success"));
311   SILC_LOG_DEBUG(("Boolean val %d", val));
312   success =
313     silc_asn1_decode(asn1, &node2,
314                      SILC_ASN1_BOOLEAN(&val),
315                      SILC_ASN1_END);
316   if (!success) {
317     SILC_LOG_DEBUG(("Decoding failed"));
318     goto out;
319   }
320   SILC_LOG_DEBUG(("Decoding success"));
321   SILC_LOG_DEBUG(("Boolean val %d", val));
322   memset(&node2, 0, sizeof(node2));
323   printf("\n");
324
325
326   memset(&node, 0, sizeof(node));
327   SILC_LOG_DEBUG(("Encoding ASN.1 tree 6"));
328   success =
329     silc_asn1_encode(asn1, &node2,
330                      SILC_ASN1_BOOLEAN(val),
331                      SILC_ASN1_END);
332   SILC_LOG_DEBUG(("Encoding success"));
333   success =
334     silc_asn1_encode(asn1, &node,
335                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
336                        SILC_ASN1_SEQUENCE_T(0, 9),
337                          SILC_ASN1_SEQUENCE,
338                            SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, &node2),
339                            SILC_ASN1_BOOLEAN_T(0, 4, val),
340                            SILC_ASN1_BOOLEAN(val),
341                          SILC_ASN1_END,
342                        SILC_ASN1_END,
343                      SILC_ASN1_END, SILC_ASN1_END);
344   if (!success) {
345     SILC_LOG_DEBUG(("Encoding failed"));
346     goto out;
347   }
348   SILC_LOG_DEBUG(("Encoding success"));
349   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
350   memset(&node2, 0, sizeof(node2));
351   SILC_LOG_DEBUG(("Decoding ASN.1 tree 6"));
352   success =
353     silc_asn1_decode(asn1, &node,
354                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
355                        SILC_ASN1_SEQUENCE_T(0, 9),
356                          SILC_ASN1_SEQUENCE,
357                            SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, &node2),
358                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
359                            SILC_ASN1_BOOLEAN(&val),
360                          SILC_ASN1_END,
361                        SILC_ASN1_END,
362                      SILC_ASN1_END, SILC_ASN1_END);
363   if (!success) {
364     SILC_LOG_DEBUG(("Decoding failed"));
365     goto out;
366   }
367   SILC_LOG_DEBUG(("Decoding success"));
368   SILC_LOG_DEBUG(("Boolean val %d", val));
369   success =
370     silc_asn1_decode(asn1, &node2,
371                      SILC_ASN1_BOOLEAN(&val),
372                      SILC_ASN1_END);
373   if (!success) {
374     SILC_LOG_DEBUG(("Decoding failed"));
375     goto out;
376   }
377   SILC_LOG_DEBUG(("Decoding success"));
378   SILC_LOG_DEBUG(("Boolean val %d", val));
379   memset(&node2, 0, sizeof(node2));
380   printf("\n");
381
382
383   memset(&node, 0, sizeof(node));
384   SILC_LOG_DEBUG(("Encoding ASN.1 tree 7"));
385   val = 0;
386   success =
387     silc_asn1_encode(asn1, &node2,
388                      SILC_ASN1_SEQUENCE,
389                        SILC_ASN1_BOOLEAN(val),
390                        SILC_ASN1_BOOLEAN(val),
391                        SILC_ASN1_BOOLEAN(val),
392                        SILC_ASN1_BOOLEAN(val),
393                      SILC_ASN1_END, SILC_ASN1_END);
394   SILC_LOG_DEBUG(("Encoding success"));
395   val = 1;
396   success =
397     silc_asn1_encode(asn1, &node,
398                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
399                        SILC_ASN1_SEQUENCE_T(0, 9),
400                          SILC_ASN1_SEQUENCE,
401                            SILC_ASN1_ANY_T(0, 11, &node2),
402                            SILC_ASN1_BOOLEAN_T(0, 4, val),
403                            SILC_ASN1_BOOLEAN(val),
404                          SILC_ASN1_END,
405                        SILC_ASN1_END,
406                      SILC_ASN1_END, SILC_ASN1_END);
407   if (!success) {
408     SILC_LOG_DEBUG(("Encoding failed"));
409     goto out;
410   }
411   SILC_LOG_DEBUG(("Encoding success"));
412   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
413   memset(&node2, 0, sizeof(node2));
414   SILC_LOG_DEBUG(("Decoding ASN.1 tree 7"));
415   success =
416     silc_asn1_decode(asn1, &node,
417                      SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
418                        SILC_ASN1_SEQUENCE_T(0, 9),
419                          SILC_ASN1_SEQUENCE,
420                            SILC_ASN1_ANY_T(0, 11, &node2), /* NOTE: tag */
421                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
422                            SILC_ASN1_BOOLEAN(&val),
423                          SILC_ASN1_END,
424                        SILC_ASN1_END,
425                      SILC_ASN1_END, SILC_ASN1_END);
426   if (!success) {
427     SILC_LOG_DEBUG(("Decoding failed"));
428     goto out;
429   }
430   SILC_LOG_DEBUG(("Decoding success"));
431   SILC_LOG_DEBUG(("Boolean val %d", val));
432   success =
433     silc_asn1_decode(asn1, &node2,
434                      SILC_ASN1_SEQUENCE_T(0, 11), /* NOTE: using implicit
435                                                      tag! */
436                        SILC_ASN1_BOOLEAN(&val),
437                        SILC_ASN1_BOOLEAN(&val),
438                        SILC_ASN1_BOOLEAN(&val),
439                        SILC_ASN1_BOOLEAN(&val),
440                      SILC_ASN1_END, SILC_ASN1_END);
441   if (!success) {
442     SILC_LOG_DEBUG(("Decoding failed"));
443     goto out;
444   }
445   SILC_LOG_DEBUG(("Decoding success"));
446   SILC_LOG_DEBUG(("Boolean val %d", val));
447   memset(&node2, 0, sizeof(node2));
448   printf("\n");
449
450
451   memset(&node, 0, sizeof(node));
452   SILC_LOG_DEBUG(("Encoding ASN.1 tree 8"));
453   success =
454     silc_asn1_encode(asn1, &node,
455                      SILC_ASN1_SEQUENCE,
456                        SILC_ASN1_BOOLEAN_T(SILC_ASN1_IMPLICIT, 9999, val),
457                      SILC_ASN1_END, SILC_ASN1_END);
458   if (!success) {
459     SILC_LOG_DEBUG(("Encoding failed"));
460     goto out;
461   }
462   SILC_LOG_DEBUG(("Encoding success"));
463   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
464   SILC_LOG_DEBUG(("Decoding ASN.1 tree 8"));
465   success =
466     silc_asn1_decode(asn1, &node,
467                      SILC_ASN1_SEQUENCE,
468                        SILC_ASN1_BOOLEAN_T(0, 9999, &val),
469                      SILC_ASN1_END, SILC_ASN1_END);
470   if (!success) {
471     SILC_LOG_DEBUG(("Decoding failed"));
472     goto out;
473   }
474   SILC_LOG_DEBUG(("Decoding success"));
475   SILC_LOG_DEBUG(("Boolean val %d", val));
476   memset(&node, 0, sizeof(node));
477   printf("\n");
478
479   memset(&node, 0, sizeof(node));
480   SILC_LOG_DEBUG(("Encoding ASN.1 tree 9"));
481   success =
482     silc_asn1_encode(asn1, &node,
483                      SILC_ASN1_SEQUENCE,
484                        SILC_ASN1_SEQUENCE_T(0, 9),
485                          SILC_ASN1_SEQUENCE,
486                            SILC_ASN1_BOOLEAN_T(0, 4, val),
487                            SILC_ASN1_BOOLEAN(val),
488                          SILC_ASN1_END,
489                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 99, val),
490                          SILC_ASN1_BOOLEAN_T(0, 100, val),
491                        SILC_ASN1_END,
492                        SILC_ASN1_SEQUENCE,
493                          SILC_ASN1_NULL,
494                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 0, val),
495                          SILC_ASN1_OCTET_STRING("foobar", 6),
496                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_PRIVATE, 43, val),
497                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_APP |
498                                              SILC_ASN1_EXPLICIT, 1, val),
499                        SILC_ASN1_END,
500                      SILC_ASN1_END, SILC_ASN1_END);
501   if (!success) {
502     SILC_LOG_DEBUG(("Encoding failed"));
503     goto out;
504   }
505   SILC_LOG_DEBUG(("Encoding success"));
506   SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
507   SILC_LOG_DEBUG(("Decoding ASN.1 tree 9"));
508   success =
509     silc_asn1_decode(asn1, &node,
510                      SILC_ASN1_SEQUENCE,
511                        SILC_ASN1_SEQUENCE_T(0, 9),
512                          SILC_ASN1_SEQUENCE,
513                            SILC_ASN1_BOOLEAN_T(0, 4, &val),
514                            SILC_ASN1_BOOLEAN(&val),
515                          SILC_ASN1_END,
516                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 99, &val),
517                          SILC_ASN1_BOOLEAN_T(0, 100, &val),
518                        SILC_ASN1_END,
519                        SILC_ASN1_SEQUENCE,
520                          SILC_ASN1_NULL,
521                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 0, &val),
522                          SILC_ASN1_OCTET_STRING(&str, &str_len),
523                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_PRIVATE, 43, &val),
524                          SILC_ASN1_BOOLEAN_T(SILC_ASN1_APP |
525                                              SILC_ASN1_EXPLICIT, 1, &val),
526                        SILC_ASN1_END,
527                      SILC_ASN1_END, SILC_ASN1_END);
528   if (!success) {
529     SILC_LOG_DEBUG(("Decoding failed"));
530     goto out;
531   }
532   SILC_LOG_DEBUG(("Decoding success"));
533   SILC_LOG_DEBUG(("Boolean val %d", val));
534   SILC_LOG_DEBUG(("Ooctet-string %s, len %d", str, str_len));
535   printf("\n");
536
537 #endif
538   silc_asn1_free(asn1);
539
540  out:
541   exit(success);
542 }