4 silc_asn1_encode(asn1, node,
5 SILC_ASN1_BOOLEAN(SilcBool),
7 silc_asn1_encode(asn1, dest,
8 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
9 SILC_ASN1_SEQUENCE_T(0, 9),
11 SILC_ASN1_ANY_T(0, 33, node),
12 SILC_ASN1_BOOLEAN_T(0, 4, boolv),
13 SILC_ASN1_BOOLEAN(SilcBool),
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).
25 silc_asn1_encode(asn1, node,
26 SILC_ASN1_BOOLEAN(SilcBool),
28 silc_asn1_encode(asn1, dest,
29 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
30 SILC_ASN1_SEQUENCE_T(0, 9),
32 SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, node),
33 SILC_ASN1_BOOLEAN_T(0, 4, boolv),
34 SILC_ASN1_BOOLEAN(SilcBool),
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.
46 int main(int argc, char **argv)
48 SilcBufferStruct node, node2;
50 SilcBool success = FALSE;
54 SilcUInt32 str_len, tmpint;
57 SilcMPInt mpint, mpint2;
59 memset(&node, 0, sizeof(node));
60 memset(&node2, 0, sizeof(node2));
62 if (argc > 1 && !strcmp(argv[1], "-d")) {
64 silc_log_debug_hexdump(TRUE);
65 silc_log_set_debug_string("*asn1*,*ber*");
68 silc_hash_register_default();
69 rng = silc_rng_alloc();
72 SILC_LOG_DEBUG(("Allocating ASN.1 context"));
73 asn1 = silc_asn1_alloc();
77 SILC_LOG_DEBUG(("Encoding ASN.1 tree 1"));
80 silc_asn1_encode(asn1, &node,
82 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
83 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
84 SILC_ASN1_INDEFINITE, 0),
85 SILC_ASN1_BOOLEAN_T(0, 4, val),
86 SILC_ASN1_BOOLEAN(val),
89 SILC_ASN1_END, SILC_ASN1_END);
91 SILC_LOG_DEBUG(("Encoding failed"));
94 SILC_LOG_DEBUG(("Encoding success"));
95 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
96 SILC_LOG_DEBUG(("Decoding ASN.1 tree 1"));
98 silc_asn1_decode(asn1, &node,
100 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
101 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
102 SILC_ASN1_INDEFINITE, 0),
103 SILC_ASN1_BOOLEAN_T(0, 4, &val),
104 SILC_ASN1_BOOLEAN(&val),
107 SILC_ASN1_END, SILC_ASN1_END);
109 SILC_LOG_DEBUG(("Decoding failed"));
112 SILC_LOG_DEBUG(("Decoding success"));
113 SILC_LOG_DEBUG(("Boolean val %d", val));
116 memset(&node, 0, sizeof(node));
117 SILC_LOG_DEBUG(("Encoding ASN.1 tree 1"));
120 silc_asn1_encode(asn1, &node,
122 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
123 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
124 SILC_ASN1_INDEFINITE, 0),
125 SILC_ASN1_BOOLEAN_T(0, 4, val),
126 SILC_ASN1_BOOLEAN(val),
129 SILC_ASN1_END, SILC_ASN1_END);
131 SILC_LOG_DEBUG(("Encoding failed"));
134 SILC_LOG_DEBUG(("Encoding success"));
135 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
136 SILC_LOG_DEBUG(("Decoding ASN.1 tree 1"));
138 silc_asn1_decode(asn1, &node,
140 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
141 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT |
142 SILC_ASN1_INDEFINITE, 0),
143 SILC_ASN1_BOOLEAN_T(0, 4, &val),
144 SILC_ASN1_BOOLEAN(&val),
147 SILC_ASN1_END, SILC_ASN1_END);
149 SILC_LOG_DEBUG(("Decoding failed"));
152 SILC_LOG_DEBUG(("Decoding success"));
153 SILC_LOG_DEBUG(("Boolean val %d", val));
157 memset(&node, 0, sizeof(node));
158 SILC_LOG_DEBUG(("Encoding ASN.1 tree 2"));
161 silc_asn1_encode(asn1, &node,
163 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
164 SILC_ASN1_SEQUENCE_T(SILC_ASN1_INDEFINITE, 0),
165 SILC_ASN1_BOOLEAN_T(0, 4, val),
166 SILC_ASN1_BOOLEAN(val),
169 SILC_ASN1_END, SILC_ASN1_END);
171 SILC_LOG_DEBUG(("Encoding failed"));
174 SILC_LOG_DEBUG(("Encoding success"));
175 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
176 SILC_LOG_DEBUG(("Decoding ASN.1 tree 2"));
178 silc_asn1_decode(asn1, &node,
180 SILC_ASN1_SEQUENCE_T(SILC_ASN1_EXPLICIT, 9),
181 SILC_ASN1_SEQUENCE_T(SILC_ASN1_INDEFINITE, 0),
182 SILC_ASN1_BOOLEAN_T(0, 4, &val),
183 SILC_ASN1_BOOLEAN(&val),
186 SILC_ASN1_END, SILC_ASN1_END);
188 SILC_LOG_DEBUG(("Decoding failed"));
191 SILC_LOG_DEBUG(("Decoding success"));
192 SILC_LOG_DEBUG(("Boolean val %d", val));
196 memset(&node, 0, sizeof(node));
197 SILC_LOG_DEBUG(("Encoding ASN.1 tree 3"));
200 silc_asn1_encode(asn1, &node,
202 SILC_ASN1_SEQUENCE_T(0, 9),
204 SILC_ASN1_BOOLEAN_T(0, 4, val),
205 SILC_ASN1_BOOLEAN(val),
208 SILC_ASN1_END, SILC_ASN1_END);
210 SILC_LOG_DEBUG(("Encoding failed"));
213 SILC_LOG_DEBUG(("Encoding success"));
214 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
215 SILC_LOG_DEBUG(("Decoding ASN.1 tree 3"));
217 silc_asn1_decode(asn1, &node,
219 SILC_ASN1_SEQUENCE_T(0, 9),
221 SILC_ASN1_BOOLEAN_T(0, 4, &val),
222 SILC_ASN1_BOOLEAN(&val),
225 SILC_ASN1_END, SILC_ASN1_END);
227 SILC_LOG_DEBUG(("Decoding failed"));
230 SILC_LOG_DEBUG(("Decoding success"));
231 SILC_LOG_DEBUG(("Boolean val %d", val));
235 memset(&node, 0, sizeof(node));
236 SILC_LOG_DEBUG(("Encoding ASN.1 tree 4"));
239 silc_asn1_encode(asn1, &node,
240 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE |
241 SILC_ASN1_EXPLICIT, 101),
242 SILC_ASN1_SEQUENCE_T(0, 9),
244 SILC_ASN1_BOOLEAN_T(0, 4, val),
245 SILC_ASN1_BOOLEAN(val),
248 SILC_ASN1_END, SILC_ASN1_END);
250 SILC_LOG_DEBUG(("Encoding failed"));
253 SILC_LOG_DEBUG(("Encoding success"));
254 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
255 SILC_LOG_DEBUG(("Decoding ASN.1 tree 4"));
257 silc_asn1_decode(asn1, &node,
258 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE |
259 SILC_ASN1_EXPLICIT, 101),
260 SILC_ASN1_SEQUENCE_T(0, 9),
262 SILC_ASN1_BOOLEAN_T(0, 4, &val),
263 SILC_ASN1_BOOLEAN(&val),
266 SILC_ASN1_END, SILC_ASN1_END);
268 SILC_LOG_DEBUG(("Decoding failed"));
271 SILC_LOG_DEBUG(("Decoding success"));
272 SILC_LOG_DEBUG(("Boolean val %d", val));
276 memset(&node, 0, sizeof(node));
277 SILC_LOG_DEBUG(("Encoding ASN.1 tree 5"));
279 silc_asn1_encode(asn1, &node2,
280 SILC_ASN1_BOOLEAN(val),
282 SILC_LOG_DEBUG(("Encoding success"));
284 silc_asn1_encode(asn1, &node,
285 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
286 SILC_ASN1_SEQUENCE_T(0, 9),
288 SILC_ASN1_ANY(&node2),
289 SILC_ASN1_BOOLEAN_T(0, 4, val),
290 SILC_ASN1_BOOLEAN(val),
293 SILC_ASN1_END, SILC_ASN1_END);
295 SILC_LOG_DEBUG(("Encoding failed"));
298 SILC_LOG_DEBUG(("Encoding success"));
299 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
300 memset(&node2, 0, sizeof(node2));
301 SILC_LOG_DEBUG(("Decoding ASN.1 tree 5"));
303 silc_asn1_decode(asn1, &node,
304 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
305 SILC_ASN1_SEQUENCE_T(0, 9),
307 SILC_ASN1_ANY(&node2),
308 SILC_ASN1_BOOLEAN_T(0, 4, &val),
309 SILC_ASN1_BOOLEAN(&val),
312 SILC_ASN1_END, SILC_ASN1_END);
314 SILC_LOG_DEBUG(("Decoding failed"));
317 SILC_LOG_DEBUG(("Decoding success"));
318 SILC_LOG_DEBUG(("Boolean val %d", val));
320 silc_asn1_decode(asn1, &node2,
321 SILC_ASN1_BOOLEAN(&val),
324 SILC_LOG_DEBUG(("Decoding failed"));
327 SILC_LOG_DEBUG(("Decoding success"));
328 SILC_LOG_DEBUG(("Boolean val %d", val));
329 memset(&node2, 0, sizeof(node2));
333 memset(&node, 0, sizeof(node));
334 SILC_LOG_DEBUG(("Encoding ASN.1 tree (ANY_PRIMITIVE)"));
335 memset(tmp, 0, sizeof(tmp));
337 silc_buffer_set(&node2, tmp, 1);
338 SILC_LOG_DEBUG(("Encoding success"));
340 silc_asn1_encode(asn1, &node,
342 SILC_ASN1_ANY_PRIMITIVE(SILC_ASN1_TAG_BOOLEAN,
344 SILC_ASN1_END, SILC_ASN1_END);
346 SILC_LOG_DEBUG(("Encoding failed"));
349 SILC_LOG_DEBUG(("Encoding success"));
350 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
351 memset(&node2, 0, sizeof(node2));
352 SILC_LOG_DEBUG(("Decoding ASN.1 tree (ANY_PRIMITIVE)"));
354 silc_asn1_decode(asn1, &node,
356 SILC_ASN1_ANY_PRIMITIVE(SILC_ASN1_TAG_BOOLEAN,
358 SILC_ASN1_END, SILC_ASN1_END);
360 SILC_LOG_DEBUG(("Decoding failed"));
363 SILC_LOG_DEBUG(("Boolean val %d", node2.data[0]));
364 if (node2.data[0] != 0xff) {
365 SILC_LOG_DEBUG(("Decoding failed"));
368 SILC_LOG_DEBUG(("Decoding success"));
369 memset(&node, 0, sizeof(node));
370 SILC_LOG_DEBUG(("Encoding ASN.1 tree (ANY_PRIMITIVE)"));
371 memset(tmp, 0, sizeof(tmp));
373 silc_buffer_set(&node2, tmp, 1);
374 SILC_LOG_DEBUG(("Encoding success"));
376 silc_asn1_encode(asn1, &node,
378 SILC_ASN1_ANY_PRIMITIVE(SILC_ASN1_TAG_BOOLEAN,
380 SILC_ASN1_END, SILC_ASN1_END);
382 SILC_LOG_DEBUG(("Encoding failed"));
385 SILC_LOG_DEBUG(("Encoding success"));
386 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
387 memset(&node2, 0, sizeof(node2));
388 SILC_LOG_DEBUG(("Decoding ASN.1 tree (ANY_PRIMITIVE)"));
390 silc_asn1_decode(asn1, &node,
392 SILC_ASN1_BOOLEAN(&val),
393 SILC_ASN1_END, SILC_ASN1_END);
395 SILC_LOG_DEBUG(("Decoding failed"));
398 SILC_LOG_DEBUG(("Decoding success"));
399 SILC_LOG_DEBUG(("Boolean val %d", val));
400 memset(&node, 0, sizeof(node));
401 SILC_LOG_DEBUG(("Encoding ASN.1 tree (ANY_PRIMITIVE)"));
402 memset(tmp, 0, sizeof(tmp));
404 silc_buffer_set(&node2, tmp, 1);
405 SILC_LOG_DEBUG(("Encoding success"));
407 silc_asn1_encode(asn1, &node,
409 SILC_ASN1_BOOLEAN(val),
410 SILC_ASN1_END, SILC_ASN1_END);
412 SILC_LOG_DEBUG(("Encoding failed"));
415 SILC_LOG_DEBUG(("Encoding success"));
416 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
417 memset(&node2, 0, sizeof(node2));
418 SILC_LOG_DEBUG(("Decoding ASN.1 tree (ANY_PRIMITIVE)"));
420 silc_asn1_decode(asn1, &node,
422 SILC_ASN1_ANY_PRIMITIVE(SILC_ASN1_TAG_BOOLEAN,
424 SILC_ASN1_END, SILC_ASN1_END);
426 SILC_LOG_DEBUG(("Decoding failed"));
429 SILC_LOG_DEBUG(("Boolean val %d", node2.data[0]));
430 if (node2.data[0] != 0xff) {
431 SILC_LOG_DEBUG(("Decoding failed"));
434 SILC_LOG_DEBUG(("Decoding success"));
435 memset(&node2, 0, sizeof(node2));
439 memset(&node, 0, sizeof(node));
440 SILC_LOG_DEBUG(("Encoding ASN.1 tree 6"));
442 silc_asn1_encode(asn1, &node2,
443 SILC_ASN1_BOOLEAN(val),
445 SILC_LOG_DEBUG(("Encoding success"));
447 silc_asn1_encode(asn1, &node,
448 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
449 SILC_ASN1_SEQUENCE_T(0, 9),
451 SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, &node2),
452 SILC_ASN1_BOOLEAN_T(0, 4, val),
453 SILC_ASN1_BOOLEAN(val),
456 SILC_ASN1_END, SILC_ASN1_END);
458 SILC_LOG_DEBUG(("Encoding failed"));
461 SILC_LOG_DEBUG(("Encoding success"));
462 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
463 memset(&node2, 0, sizeof(node2));
464 SILC_LOG_DEBUG(("Decoding ASN.1 tree 6"));
466 silc_asn1_decode(asn1, &node,
467 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
468 SILC_ASN1_SEQUENCE_T(0, 9),
470 SILC_ASN1_ANY_T(SILC_ASN1_EXPLICIT, 33, &node2),
471 SILC_ASN1_BOOLEAN_T(0, 4, &val),
472 SILC_ASN1_BOOLEAN(&val),
475 SILC_ASN1_END, SILC_ASN1_END);
477 SILC_LOG_DEBUG(("Decoding failed"));
480 SILC_LOG_DEBUG(("Decoding success"));
481 SILC_LOG_DEBUG(("Boolean val %d", val));
483 silc_asn1_decode(asn1, &node2,
484 SILC_ASN1_BOOLEAN(&val),
487 SILC_LOG_DEBUG(("Decoding failed"));
490 SILC_LOG_DEBUG(("Decoding success"));
491 SILC_LOG_DEBUG(("Boolean val %d", val));
492 memset(&node2, 0, sizeof(node2));
496 memset(&node, 0, sizeof(node));
497 SILC_LOG_DEBUG(("Encoding ASN.1 tree 7"));
500 silc_asn1_encode(asn1, &node2,
502 SILC_ASN1_BOOLEAN(val),
503 SILC_ASN1_BOOLEAN(val),
504 SILC_ASN1_BOOLEAN(val),
505 SILC_ASN1_BOOLEAN(val),
506 SILC_ASN1_END, SILC_ASN1_END);
507 SILC_LOG_DEBUG(("Encoding success"));
510 silc_asn1_encode(asn1, &node,
511 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
512 SILC_ASN1_SEQUENCE_T(0, 9),
514 SILC_ASN1_ANY_T(0, 11, &node2),
515 SILC_ASN1_BOOLEAN_T(0, 4, val),
516 SILC_ASN1_BOOLEAN(val),
519 SILC_ASN1_END, SILC_ASN1_END);
521 SILC_LOG_DEBUG(("Encoding failed"));
524 SILC_LOG_DEBUG(("Encoding success"));
525 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
526 memset(&node2, 0, sizeof(node2));
527 SILC_LOG_DEBUG(("Decoding ASN.1 tree 7"));
529 silc_asn1_decode(asn1, &node,
530 SILC_ASN1_SEQUENCE_T(SILC_ASN1_PRIVATE, 101),
531 SILC_ASN1_SEQUENCE_T(0, 9),
533 SILC_ASN1_ANY_T(0, 11, &node2), /* NOTE: tag */
534 SILC_ASN1_BOOLEAN_T(0, 4, &val),
535 SILC_ASN1_BOOLEAN(&val),
538 SILC_ASN1_END, SILC_ASN1_END);
540 SILC_LOG_DEBUG(("Decoding failed"));
543 SILC_LOG_DEBUG(("Decoding success"));
544 SILC_LOG_DEBUG(("Boolean val %d", val));
546 silc_asn1_decode(asn1, &node2,
547 SILC_ASN1_SEQUENCE_T(0, 11), /* NOTE: using implicit
549 SILC_ASN1_BOOLEAN(&val),
550 SILC_ASN1_BOOLEAN(&val),
551 SILC_ASN1_BOOLEAN(&val),
552 SILC_ASN1_BOOLEAN(&val),
553 SILC_ASN1_END, SILC_ASN1_END);
555 SILC_LOG_DEBUG(("Decoding failed"));
558 SILC_LOG_DEBUG(("Decoding success"));
559 SILC_LOG_DEBUG(("Boolean val %d", val));
560 memset(&node2, 0, sizeof(node2));
564 memset(&node, 0, sizeof(node));
565 SILC_LOG_DEBUG(("Encoding ASN.1 tree 8"));
567 silc_asn1_encode(asn1, &node,
569 SILC_ASN1_BOOLEAN_T(SILC_ASN1_IMPLICIT, 9999, val),
570 SILC_ASN1_END, SILC_ASN1_END);
572 SILC_LOG_DEBUG(("Encoding failed"));
575 SILC_LOG_DEBUG(("Encoding success"));
576 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
577 SILC_LOG_DEBUG(("Decoding ASN.1 tree 8"));
579 silc_asn1_decode(asn1, &node,
581 SILC_ASN1_BOOLEAN_T(0, 9999, &val),
582 SILC_ASN1_END, SILC_ASN1_END);
584 SILC_LOG_DEBUG(("Decoding failed"));
587 SILC_LOG_DEBUG(("Decoding success"));
588 SILC_LOG_DEBUG(("Boolean val %d", val));
589 memset(&node, 0, sizeof(node));
593 memset(&node, 0, sizeof(node));
594 SILC_LOG_DEBUG(("Encoding ASN.1 tree 9"));
596 silc_asn1_encode(asn1, &node,
598 SILC_ASN1_SEQUENCE_T(0, 9),
600 SILC_ASN1_BOOLEAN_T(0, 4, val),
601 SILC_ASN1_BOOLEAN(val),
603 SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 99, val),
604 SILC_ASN1_BOOLEAN_T(0, 100, val),
608 SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 0, val),
609 SILC_ASN1_OCTET_STRING("foobar", 6),
610 SILC_ASN1_BOOLEAN_T(SILC_ASN1_PRIVATE, 43, val),
611 SILC_ASN1_BOOLEAN_T(SILC_ASN1_APP |
612 SILC_ASN1_EXPLICIT, 1, val),
614 SILC_ASN1_END, SILC_ASN1_END);
616 SILC_LOG_DEBUG(("Encoding failed"));
619 SILC_LOG_DEBUG(("Encoding success"));
620 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
621 SILC_LOG_DEBUG(("Decoding ASN.1 tree 9"));
623 silc_asn1_decode(asn1, &node,
625 SILC_ASN1_SEQUENCE_T(0, 9),
627 SILC_ASN1_BOOLEAN_T(0, 4, &val),
628 SILC_ASN1_BOOLEAN(&val),
630 SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 99, &val),
631 SILC_ASN1_BOOLEAN_T(0, 100, &val),
635 SILC_ASN1_BOOLEAN_T(SILC_ASN1_EXPLICIT, 0, &val),
636 SILC_ASN1_OCTET_STRING(&str, &str_len),
637 SILC_ASN1_BOOLEAN_T(SILC_ASN1_PRIVATE, 43, &val),
638 SILC_ASN1_BOOLEAN_T(SILC_ASN1_APP |
639 SILC_ASN1_EXPLICIT, 1, &val),
641 SILC_ASN1_END, SILC_ASN1_END);
643 SILC_LOG_DEBUG(("Decoding failed"));
646 SILC_LOG_DEBUG(("Decoding success"));
647 SILC_LOG_DEBUG(("Boolean val %d", val));
648 SILC_LOG_DEBUG(("Ooctet-string %s, len %d", str, str_len));
652 memset(&node, 0, sizeof(node));
653 SILC_LOG_DEBUG(("Encoding ASN.1 tree 10 (INTEGER)"));
654 str = silc_rng_get_rn_data(rng, 256);
655 silc_mp_init(&mpint);
656 silc_mp_init(&mpint2);
657 silc_mp_bin2mp(str, 256, &mpint);
659 silc_asn1_encode(asn1, &node,
660 SILC_ASN1_INT(&mpint),
663 SILC_LOG_DEBUG(("Encoding failed"));
666 SILC_LOG_DEBUG(("Encoding success"));
667 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
668 SILC_LOG_DEBUG(("Decoding ASN.1 tree 10 (INTEGER)"));
670 silc_asn1_decode(asn1, &node,
671 SILC_ASN1_INT(&mpint2),
673 if (silc_mp_cmp(&mpint, &mpint2) != 0) {
674 SILC_LOG_DEBUG(("INTEGER MISMATCH"));
678 SILC_LOG_DEBUG(("Decoding failed"));
681 SILC_LOG_DEBUG(("Decoding success"));
685 memset(&node, 0, sizeof(node));
686 SILC_LOG_DEBUG(("Encoding ASN.1 tree 11 (OID)"));
688 silc_asn1_encode(asn1, &node,
689 SILC_ASN1_OPTS(SILC_ASN1_ACCUMUL),
690 SILC_ASN1_OID("1.2.840.113549"),
693 SILC_LOG_DEBUG(("Encoding failed"));
696 SILC_LOG_DEBUG(("Encoding success"));
697 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
698 SILC_LOG_DEBUG(("Decoding ASN.1 tree 11 (OID)"));
700 silc_asn1_decode(asn1, &node,
701 SILC_ASN1_OPTS(SILC_ASN1_ACCUMUL),
705 SILC_LOG_DEBUG(("Decoding failed"));
708 SILC_LOG_DEBUG(("Decoding success"));
709 SILC_LOG_DEBUG(("OID %s", str));
713 memset(&node, 0, sizeof(node));
714 SILC_LOG_DEBUG(("Encoding ASN.1 tree 12 (SHORT INTEGER)"));
717 SILC_LOG_DEBUG(("Short integer: %d", str_len));
718 SILC_LOG_DEBUG(("Short integer: %d", tmpint));
720 silc_asn1_encode(asn1, &node,
721 SILC_ASN1_SHORT_INT(str_len),
722 SILC_ASN1_SHORT_INT_T(SILC_ASN1_IMPLICIT, 100, tmpint),
725 SILC_LOG_DEBUG(("Encoding failed"));
728 SILC_LOG_DEBUG(("Encoding success"));
729 SILC_LOG_HEXDUMP(("ASN.1 tree"), node.data, silc_buffer_len(&node));
730 SILC_LOG_DEBUG(("Decoding ASN.1 tree 12 (SHORT INTEGER)"));
732 silc_asn1_decode(asn1, &node,
733 SILC_ASN1_SHORT_INT(&str_len),
734 SILC_ASN1_SHORT_INT_T(SILC_ASN1_IMPLICIT, 100, &tmpint),
737 SILC_LOG_DEBUG(("Decoding failed"));
740 SILC_LOG_DEBUG(("Short integer: %d", str_len));
741 SILC_LOG_DEBUG(("Short integer: %d", tmpint));
742 SILC_LOG_DEBUG(("Decoding success"));
746 silc_asn1_free(asn1);
750 SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
751 fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");