]> git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/sm_x509ce.cpp
Security-28.tar.gz
[apple/security.git] / SecurityASN1 / c++ / sm_x509ce.cpp
1 // NOTE: this is a machine generated file--editing not recommended
2 //
3 // sm_x509ce.cpp - class member functions for ASN.1 module CertificateExtensions
4 //
5 // This file was generated by snacc on Wed Jun 27 16:40:55 2001
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
8
9
10 #include "asn-incl.h"
11 #include "sm_vdatypes.h"
12 #include "sm_x501ud.h"
13 #include "sm_x411ub.h"
14 #include "sm_x411mtsas.h"
15 #include "sm_x501if.h"
16 #include "sm_x520sa.h"
17 #include "sm_x509cmn.h"
18 #include "sm_x509af.h"
19 #include "sm_x509ce.h"
20 #include "pkcs1oids.h"
21 #include "pkcs9oids.h"
22 #include "sm_cms.h"
23 #include "sm_ess.h"
24 #include "pkcs7.h"
25 #include "pkcs8.h"
26 #include "appleoids.h"
27
28 //------------------------------------------------------------------------------
29 // value defs
30
31
32 //------------------------------------------------------------------------------
33 // class member definitions:
34
35 PolicyQualifierInfo::PolicyQualifierInfo()
36 {
37 qualifier = NULL;
38 }
39
40 PolicyQualifierInfo::PolicyQualifierInfo (const PolicyQualifierInfo &)
41 {
42 Asn1Error << "use of incompletely defined PolicyQualifierInfo::PolicyQualifierInfo (const PolicyQualifierInfo &)" << endl;
43 abort();
44 }
45
46 PolicyQualifierInfo::~PolicyQualifierInfo()
47 {
48 delete qualifier;
49 }
50
51 AsnType *PolicyQualifierInfo::Clone() const
52 {
53 return new PolicyQualifierInfo;
54 }
55
56 AsnType *PolicyQualifierInfo::Copy() const
57 {
58 return new PolicyQualifierInfo (*this);
59 }
60
61 #if SNACC_DEEP_COPY
62 PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &that)
63 #else // SNACC_DEEP_COPY
64 PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &)
65 #endif // SNACC_DEEP_COPY
66 {
67 #if SNACC_DEEP_COPY
68 if (this != &that)
69 {
70 policyQualifierId = that.policyQualifierId;
71 if (that.qualifier)
72 {
73 if (!qualifier)
74 qualifier = new AsnAny;
75 *qualifier = *that.qualifier;
76 }
77 else
78 {
79 delete qualifier;
80 qualifier = NULL;
81 }
82 }
83
84 return *this;
85 #else // SNACC_DEEP_COPY
86 Asn1Error << "use of incompletely defined PolicyQualifierInfo &PolicyQualifierInfo::operator = (const PolicyQualifierInfo &)" << endl;
87 abort();
88 // if your compiler complains here, check the -novolat option
89 #endif // SNACC_DEEP_COPY
90 }
91
92 AsnLen
93 PolicyQualifierInfo::BEncContent (BUF_TYPE b)
94 {
95 AsnLen totalLen = 0;
96 AsnLen l;
97
98 if (NOT_NULL (qualifier))
99 {
100 ENC_LOAD_ANYBUF(qualifier, b, l);
101 totalLen += l;
102 }
103
104 l = policyQualifierId.BEncContent (b);
105 l += BEncDefLen (b, l);
106
107 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
108 totalLen += l;
109
110 return totalLen;
111 } // PolicyQualifierInfo::BEncContent
112
113
114 void PolicyQualifierInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
115 {
116 AsnTag tag1;
117 AsnLen seqBytesDecoded = 0;
118 AsnLen elmtLen1;
119 tag1 = BDecTag (b, seqBytesDecoded, env);
120
121 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
122 {
123 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
124 policyQualifierId.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
125 if (seqBytesDecoded == elmtLen0)
126 {
127 bytesDecoded += seqBytesDecoded;
128 return;
129 }
130 else
131 {
132 tag1 = b.PeekByte();
133
134 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
135 {
136 BDecEoc (b, seqBytesDecoded, env);
137
138 bytesDecoded += seqBytesDecoded;
139 return;
140 }
141 }
142 }
143 else
144 {
145 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
146 longjmp (env, -100);
147 }
148
149 // ANY type
150 qualifier = new AsnAny;
151 DEC_LOAD_ANYBUF(qualifier, b, seqBytesDecoded, env);
152
153
154 bytesDecoded += seqBytesDecoded;
155 if (elmtLen0 == INDEFINITE_LEN)
156 {
157 BDecEoc (b, bytesDecoded, env);
158 return;
159 }
160 else if (seqBytesDecoded != elmtLen0)
161 {
162 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
163 longjmp (env, -101);
164 }
165 else
166 return;
167 } // PolicyQualifierInfo::BDecContent
168
169 AsnLen PolicyQualifierInfo::BEnc (BUF_TYPE b)
170 {
171 AsnLen l;
172 l = BEncContent (b);
173 l += BEncConsLen (b, l);
174 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
175 return l;
176 }
177
178 void PolicyQualifierInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
179 {
180 AsnTag tag;
181 AsnLen elmtLen1;
182
183 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
184 {
185 Asn1Error << "PolicyQualifierInfo::BDec: ERROR - wrong tag" << endl;
186 longjmp (env, -102);
187 }
188 elmtLen1 = BDecLen (b, bytesDecoded, env);
189 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
190 }
191
192 int PolicyQualifierInfo::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
193 {
194 bytesEncoded = BEnc (b);
195 return !b.WriteError();
196 }
197
198 int PolicyQualifierInfo::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
199 {
200 ENV_TYPE env;
201 int val;
202
203 bytesDecoded = 0;
204 if ((val = setjmp (env)) == 0)
205 {
206 BDec (b, bytesDecoded, env);
207 return !b.ReadError();
208 }
209 else
210 return false;
211 }
212
213 void PolicyQualifierInfo::Print (ostream &os) const
214 {
215 #ifndef NDEBUG
216 os << "{ -- SEQUENCE --" << endl;
217 indentG += stdIndentG;
218
219 {
220 Indent (os, indentG);
221 os << "policyQualifierId ";
222 os << policyQualifierId;
223 os << "," << endl;
224 }
225
226 if (NOT_NULL (qualifier))
227 {
228 os << ","<< endl;
229 Indent (os, indentG);
230 os << "qualifier ";
231 os << *qualifier;
232 }
233 else
234 {
235 Indent (os, indentG);
236 os << "qualifier ";
237 os << "-- void --";
238 os << endl;
239 }
240
241 os << endl;
242 indentG -= stdIndentG;
243 Indent (os, indentG);
244 os << "}";
245 #endif /* NDEBUG */
246 } // PolicyQualifierInfo::Print
247
248
249 AsnType *AttributesSyntax::Clone() const
250 {
251 return new AttributesSyntax;
252 }
253
254 AsnType *AttributesSyntax::Copy() const
255 {
256 return new AttributesSyntax (*this);
257 }
258
259 AsnLen AttributesSyntax::BEnc (BUF_TYPE b)
260 {
261 AsnLen l;
262 l = BEncContent (b);
263 l += BEncConsLen (b, l);
264 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
265 return l;
266 }
267
268 void AttributesSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
269 {
270 AsnTag tag;
271 AsnLen elmtLen1;
272
273 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
274 {
275 Asn1Error << "AttributesSyntax::BDec: ERROR - wrong tag" << endl;
276 longjmp (env, -103);
277 }
278 elmtLen1 = BDecLen (b, bytesDecoded, env);
279 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
280 }
281
282 AttributesSyntax::AttributesSyntax (const AttributesSyntax &)
283 {
284 Asn1Error << "use of incompletely defined AttributesSyntax::AttributesSyntax (const AttributesSyntax &)" << endl;
285 abort();
286 }
287
288 AttributesSyntax::~AttributesSyntax()
289 {
290 SetCurrToFirst();
291 for (; Curr() != NULL; RemoveCurrFromList())
292 ;
293 } // end of destructor
294
295 #if SNACC_DEEP_COPY
296 AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &that)
297 #else // SNACC_DEEP_COPY
298 AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &)
299 #endif // SNACC_DEEP_COPY
300 {
301 #if SNACC_DEEP_COPY
302 if (this != &that)
303 {
304 SetCurrToFirst();
305 for (; Curr(); RemoveCurrFromList())
306 ;
307
308 //that.SetCurrToFirst();
309 //for (; that.Curr(); that.GoNext())
310 // AppendCopy (*that.Curr());
311 for (const AsnListElmt *run=that.first; run; run=run->next)
312 AppendCopy (*run->elmt);
313 }
314
315 return *this;
316 #else // SNACC_DEEP_COPY
317 Asn1Error << "use of incompletely defined AttributesSyntax &AttributesSyntax::operator = (const AttributesSyntax &)" << endl;
318 abort();
319 // if your compiler complains here, check the -novolat option
320 #endif // SNACC_DEEP_COPY
321 }
322
323 void AttributesSyntax::Print (ostream &os) const
324 {
325 #ifndef NDEBUG
326 os << "{ -- SEQUENCE/SET OF -- " << endl;
327 indentG += stdIndentG;
328 //SetCurrToFirst();
329 //for (; Curr() != NULL; GoNext())
330 for (const AsnListElmt *run=first; run; run=run->next)
331 {
332 Indent (os, indentG);
333 //os << *Curr();
334 os << *run->elmt;
335 //if (Curr() != Last())
336 if (run != last)
337 os << ",";
338 os << endl;
339 }
340 indentG -= stdIndentG;
341 Indent (os, indentG);
342 os << "}\n";
343 #endif /* NDEBUG */
344
345
346 } // Print
347
348
349 void AttributesSyntax::SetCurrElmt (unsigned long int index)
350 {
351 unsigned long int i;
352 curr = first;
353 if (count)
354 for (i = 0; (i < (count-1)) && (i < index); i++)
355 curr = curr->next;
356 } // AttributesSyntax::SetCurrElmt
357
358
359 unsigned long int AttributesSyntax::GetCurrElmtIndex()
360 {
361 unsigned long int i;
362 AsnListElmt *tmp;
363 if (curr != NULL)
364 {
365 for (i = 0, tmp = first; tmp != NULL; i++)
366 {
367 if (tmp == curr)
368 return i;
369 else
370 tmp = tmp->next;
371 }
372 }
373 return count;
374 } // AttributesSyntax::GetCurrElmtIndex
375
376
377 // alloc new list elmt, put at end of list
378 // and return the component type
379 Attribute *AttributesSyntax::Append()
380 {
381 AsnListElmt *newElmt;
382 newElmt = new AsnListElmt;
383 newElmt->elmt = new Attribute;
384 newElmt->next = NULL;
385 if (last == NULL)
386 {
387 newElmt->prev = NULL;
388 first = last = newElmt;
389 }
390 else
391 {
392 newElmt->prev = last;
393 last->next = newElmt;
394 last = newElmt;
395 }
396 count++;
397 return (curr = newElmt)->elmt;
398 } // AttributesSyntax::Append
399
400
401 // alloc new list elmt, put at begining of list
402 // and return the component type
403 Attribute *AttributesSyntax::Prepend()
404 {
405 AsnListElmt *newElmt;
406 newElmt = new AsnListElmt;
407 newElmt->elmt = new Attribute;
408 newElmt->prev = NULL;
409 if (first == NULL)
410 {
411 newElmt->next = NULL;
412 first = last = newElmt;
413 }
414 else
415 {
416 newElmt->next = first;
417 first->prev = newElmt;
418 first = newElmt;
419 }
420 count++;
421 return (curr = newElmt)->elmt;
422 } // AttributesSyntax::Prepend
423
424
425 // alloc new list elmt, insert it before the
426 // current element and return the component type
427 // if the current element is null, the new element
428 // is placed at the beginning of the list.
429 Attribute *AttributesSyntax::InsertBefore()
430 {
431 AsnListElmt *newElmt;
432 newElmt = new AsnListElmt;
433 newElmt->elmt = new Attribute;
434 if (curr == NULL)
435 {
436 newElmt->next = first;
437 newElmt->prev = NULL;
438 first = newElmt;
439 if (last == NULL)
440 last = newElmt;
441 }
442 else
443 {
444 newElmt->next = curr;
445 newElmt->prev = curr->prev;
446 curr->prev = newElmt;
447 if (curr == first)
448 first = newElmt;
449 else
450 newElmt->prev->next = newElmt;
451 }
452 count++;
453 return (curr = newElmt)->elmt;
454 } // AttributesSyntax::InsertBefore
455
456
457 // alloc new list elmt, insert it after the
458 // current element and return the component type
459 // if the current element is null, the new element
460 // is placed at the end of the list.
461 Attribute *AttributesSyntax::InsertAfter()
462 {
463 AsnListElmt *newElmt;
464 newElmt = new AsnListElmt;
465 newElmt->elmt = new Attribute;
466 if (curr == NULL)
467 {
468 newElmt->prev = last;
469 newElmt->next = NULL;
470 last = newElmt;
471 if (first == NULL)
472 first = newElmt;
473 }
474 else
475 {
476 newElmt->prev = curr;
477 newElmt->next = curr->next;
478 curr->next = newElmt;
479 if (curr == last)
480 last = newElmt;
481 else
482 newElmt->next->prev = newElmt;
483 }
484 count++;
485 return (curr = newElmt)->elmt;
486 } // AttributesSyntax::InsertAfter
487
488
489 AttributesSyntax &AttributesSyntax::AppendCopy (Attribute &elmt)
490 {
491 AsnListElmt *newElmt;
492 newElmt = new AsnListElmt;
493 newElmt->elmt = new Attribute;
494 *newElmt->elmt = elmt;
495 newElmt->next = NULL;
496 if (last == NULL)
497 {
498 newElmt->prev = NULL;
499 first = last = newElmt;
500 }
501 else
502 {
503 newElmt->prev = last;
504 last->next = newElmt;
505 last = newElmt;
506 }
507 count++;
508 return *this;
509 } // AppendCopy
510
511
512 AttributesSyntax &AttributesSyntax::PrependCopy (Attribute &elmt)
513 {
514 AsnListElmt *newElmt;
515 newElmt = new AsnListElmt;
516 newElmt->elmt = new Attribute;
517 *newElmt->elmt = elmt;
518 newElmt->prev = NULL;
519 if (first == NULL)
520 {
521 newElmt->next = NULL;
522 first = last = newElmt;
523 }
524 else
525 {
526 newElmt->next = first;
527 first->prev = newElmt;
528 first = newElmt;
529 }
530 count++;
531 return *this;
532 } // AttributesSyntax::PrependCopy
533
534
535 // alloc new list elmt, insert it before the
536 // current element, copy the given elmt into the new elmt
537 // and return the component type.
538 // if the current element is null, the new element
539 // is placed at the beginning of the list.
540 AttributesSyntax &AttributesSyntax::InsertBeforeAndCopy (Attribute &elmt)
541 {
542 AsnListElmt *newElmt;
543
544 newElmt = new AsnListElmt;
545 newElmt->elmt = new Attribute;
546 *newElmt->elmt = elmt;
547
548 if (curr == NULL)
549 {
550 newElmt->next = first;
551 newElmt->prev = NULL;
552 first = newElmt;
553 if (last == NULL)
554 last = newElmt;
555 }
556 else
557 {
558 newElmt->next = curr;
559 newElmt->prev = curr->prev;
560 curr->prev = newElmt;
561 if (curr == first)
562 first = newElmt;
563 else
564 newElmt->prev->next = newElmt;
565 }
566 count++;
567 return *this;
568 } // AttributesSyntax::InsertBeforeAndCopy
569
570
571 // alloc new list elmt, insert it after the
572 // current element, copy given elmt in to new elmt
573 // and return the component type
574 // if the current element is null, the new element
575 // is placed at the end of the list.
576 AttributesSyntax &AttributesSyntax::InsertAfterAndCopy (Attribute &elmt)
577 {
578 AsnListElmt *newElmt;
579
580 newElmt = new AsnListElmt;
581 newElmt->elmt = new Attribute;
582 *newElmt->elmt = elmt;
583 if (curr == NULL)
584 {
585 newElmt->prev = last;
586 newElmt->next = NULL;
587 last = newElmt;
588 if (first == NULL)
589 first = newElmt;
590 }
591 else
592 {
593 newElmt->prev = curr;
594 newElmt->next = curr->next;
595 curr->next = newElmt;
596 if (curr == last)
597 last = newElmt;
598 else
599 newElmt->next->prev = newElmt;
600 }
601 count++;
602 return *this;
603 } // AttributesSyntax::InsertAfterAndCopy
604
605
606 // remove current element from list if current element is not NULL
607 // The new current element will be the next element.
608 // If the current element is the last element in the list
609 // the second but last element will become the new current element.
610 void AttributesSyntax::RemoveCurrFromList()
611 {
612 AsnListElmt *del_elmt;
613
614 if (curr != NULL)
615 {
616 del_elmt = curr;
617 count--;
618
619 if (count == 0)
620 first = last = curr = NULL;
621 else if (curr == first)
622 {
623 curr = first= first->next;
624 first->prev = NULL;
625 }
626 else if (curr == last)
627 {
628 curr = last = last->prev;
629 last->next = NULL;
630 }
631 else
632 {
633 curr->prev->next = curr->next;
634 curr->next->prev = curr->prev;
635 }
636
637 delete del_elmt->elmt;
638 delete del_elmt;
639 }
640 }
641
642
643 AsnLen AttributesSyntax::BEncContent (BUF_TYPE b)
644 {
645 AsnListElmt *currElmt;
646 AsnLen elmtLen;
647 AsnLen totalLen = 0;
648 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
649 {
650 BEncEocIfNec (b);
651 elmtLen = currElmt->elmt->BEncContent (b);
652 elmtLen += BEncConsLen (b, elmtLen);
653
654 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
655 totalLen += elmtLen;
656 }
657 return totalLen;
658 } // AttributesSyntax::BEncContent
659
660
661 void AttributesSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
662 AsnLen &bytesDecoded, ENV_TYPE env)
663 {
664 Attribute *listElmt;
665 AsnTag tag1;
666 AsnLen listBytesDecoded = 0;
667 AsnLen elmtLen1;
668
669 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
670 {
671 tag1 = BDecTag (b, listBytesDecoded, env);
672 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
673 {
674 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
675 break;
676 }
677 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
678 {
679 Asn1Error << "Unexpected Tag" << endl;
680 longjmp (env, -104);
681 }
682
683 elmtLen1 = BDecLen (b, listBytesDecoded, env);
684 listElmt = Append();
685 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
686 }
687
688 bytesDecoded += listBytesDecoded;
689 } // AttributesSyntax::BDecContent
690
691
692 DistributionPointName::DistributionPointName()
693 {
694 choiceId = fullNameCid;
695 #if TCL
696 fullName = new GeneralNames;
697 #else
698 fullName = NULL; // incomplete initialization of mandatory element!
699 #endif // TCL
700 }
701
702 DistributionPointName::DistributionPointName (const DistributionPointName &)
703 {
704 Asn1Error << "use of incompletely defined DistributionPointName::DistributionPointName (const DistributionPointName &)" << endl;
705 abort();
706 }
707
708 DistributionPointName::~DistributionPointName()
709 {
710 switch (choiceId)
711 {
712 case fullNameCid:
713 delete fullName;
714 break;
715 case nameRelativeToCRLIssuerCid:
716 delete nameRelativeToCRLIssuer;
717 break;
718 } // end of switch
719 } // end of destructor
720
721 AsnType *DistributionPointName::Clone() const
722 {
723 return new DistributionPointName;
724 }
725
726 AsnType *DistributionPointName::Copy() const
727 {
728 return new DistributionPointName (*this);
729 }
730
731 #if SNACC_DEEP_COPY
732 DistributionPointName &DistributionPointName::operator = (const DistributionPointName &that)
733 #else // SNACC_DEEP_COPY
734 DistributionPointName &DistributionPointName::operator = (const DistributionPointName &)
735 #endif // SNACC_DEEP_COPY
736 {
737 #if SNACC_DEEP_COPY
738 if (this != &that)
739 {
740 switch (choiceId)
741 {
742 case fullNameCid:
743 delete fullName;
744 break;
745 case nameRelativeToCRLIssuerCid:
746 delete nameRelativeToCRLIssuer;
747 break;
748 }
749 switch (choiceId = that.choiceId)
750 {
751 case fullNameCid:
752 fullName = new GeneralNames;
753 *fullName = *that.fullName;
754 break;
755 case nameRelativeToCRLIssuerCid:
756 nameRelativeToCRLIssuer = new RelativeDistinguishedName;
757 *nameRelativeToCRLIssuer = *that.nameRelativeToCRLIssuer;
758 break;
759 }
760 }
761
762 return *this;
763 #else // SNACC_DEEP_COPY
764 Asn1Error << "use of incompletely defined DistributionPointName &DistributionPointName::operator = (const DistributionPointName &)" << endl;
765 abort();
766 // if your compiler complains here, check the -novolat option
767 #endif // SNACC_DEEP_COPY
768 }
769
770 AsnLen
771 DistributionPointName::BEncContent (BUF_TYPE b)
772 {
773 AsnLen l;
774 switch (choiceId)
775 {
776 case fullNameCid:
777 BEncEocIfNec (b);
778 l = fullName->BEncContent (b);
779 l += BEncConsLen (b, l);
780
781 l += BEncTag1 (b, CNTX, CONS, 0);
782 break;
783
784 case nameRelativeToCRLIssuerCid:
785 BEncEocIfNec (b);
786 l = nameRelativeToCRLIssuer->BEncContent (b);
787 l += BEncConsLen (b, l);
788
789 l += BEncTag1 (b, CNTX, CONS, 1);
790 break;
791
792 } // end switch
793 return l;
794 } // DistributionPointName::BEncContent
795
796
797 void DistributionPointName::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
798 {
799 switch (tag)
800 {
801 case MAKE_TAG_ID (CNTX, CONS, 0):
802 choiceId = fullNameCid;
803 fullName = new GeneralNames;
804 fullName->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
805 break;
806
807 case MAKE_TAG_ID (CNTX, CONS, 1):
808 choiceId = nameRelativeToCRLIssuerCid;
809 nameRelativeToCRLIssuer = new RelativeDistinguishedName;
810 nameRelativeToCRLIssuer->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
811 break;
812
813 default:
814 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
815 longjmp (env, -105);
816 break;
817 } // end switch
818 } // DistributionPointName::BDecContent
819
820
821 AsnLen DistributionPointName::BEnc (BUF_TYPE b)
822 {
823 AsnLen l;
824 l = BEncContent (b);
825 return l;
826 }
827
828 void DistributionPointName::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
829 {
830 AsnLen elmtLen;
831 AsnTag tag;
832
833 /* CHOICEs are a special case - grab identifying tag */
834 /* this allows easier handling of nested CHOICEs */
835 tag = BDecTag (b, bytesDecoded, env);
836 elmtLen = BDecLen (b, bytesDecoded, env);
837 BDecContent (b, tag, elmtLen, bytesDecoded, env);
838 }
839
840 int DistributionPointName::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
841 {
842 bytesEncoded = BEnc (b);
843 return !b.WriteError();
844 }
845
846 int DistributionPointName::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
847 {
848 ENV_TYPE env;
849 int val;
850
851 bytesDecoded = 0;
852 if ((val = setjmp (env)) == 0)
853 {
854 BDec (b, bytesDecoded, env);
855 return !b.ReadError();
856 }
857 else
858 return false;
859 }
860
861 void DistributionPointName::Print (ostream &os) const
862 {
863 #ifndef NDEBUG
864 switch (choiceId)
865 {
866 case fullNameCid:
867 os << "fullName ";
868 if (fullName)
869 os << *fullName;
870 else
871 os << "-- void3 --\n";
872 break;
873
874 case nameRelativeToCRLIssuerCid:
875 os << "nameRelativeToCRLIssuer ";
876 if (nameRelativeToCRLIssuer)
877 os << *nameRelativeToCRLIssuer;
878 else
879 os << "-- void3 --\n";
880 break;
881
882 } // end of switch
883 #endif /* NDEBUG */
884 } // DistributionPointName::Print
885
886 PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq()
887 {
888 }
889
890 PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq (const PolicyMappingsSyntaxSeq &)
891 {
892 Asn1Error << "use of incompletely defined PolicyMappingsSyntaxSeq::PolicyMappingsSyntaxSeq (const PolicyMappingsSyntaxSeq &)" << endl;
893 abort();
894 }
895
896 PolicyMappingsSyntaxSeq::~PolicyMappingsSyntaxSeq()
897 {
898 }
899
900 AsnType *PolicyMappingsSyntaxSeq::Clone() const
901 {
902 return new PolicyMappingsSyntaxSeq;
903 }
904
905 AsnType *PolicyMappingsSyntaxSeq::Copy() const
906 {
907 return new PolicyMappingsSyntaxSeq (*this);
908 }
909
910 #if SNACC_DEEP_COPY
911 PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &that)
912 #else // SNACC_DEEP_COPY
913 PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &)
914 #endif // SNACC_DEEP_COPY
915 {
916 #if SNACC_DEEP_COPY
917 if (this != &that)
918 {
919 issuerDomainPolicy = that.issuerDomainPolicy;
920 subjectDomainPolicy = that.subjectDomainPolicy;
921 }
922
923 return *this;
924 #else // SNACC_DEEP_COPY
925 Asn1Error << "use of incompletely defined PolicyMappingsSyntaxSeq &PolicyMappingsSyntaxSeq::operator = (const PolicyMappingsSyntaxSeq &)" << endl;
926 abort();
927 // if your compiler complains here, check the -novolat option
928 #endif // SNACC_DEEP_COPY
929 }
930
931 AsnLen
932 PolicyMappingsSyntaxSeq::BEncContent (BUF_TYPE b)
933 {
934 AsnLen totalLen = 0;
935 AsnLen l;
936
937 l = subjectDomainPolicy.BEncContent (b);
938 l += BEncDefLen (b, l);
939
940 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
941 totalLen += l;
942
943 l = issuerDomainPolicy.BEncContent (b);
944 l += BEncDefLen (b, l);
945
946 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
947 totalLen += l;
948
949 return totalLen;
950 } // PolicyMappingsSyntaxSeq::BEncContent
951
952
953 void PolicyMappingsSyntaxSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
954 {
955 AsnTag tag1;
956 AsnLen seqBytesDecoded = 0;
957 AsnLen elmtLen1;
958 tag1 = BDecTag (b, seqBytesDecoded, env);
959
960 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
961 {
962 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
963 issuerDomainPolicy.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
964 tag1 = BDecTag (b, seqBytesDecoded, env);
965 }
966 else
967 {
968 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
969 longjmp (env, -106);
970 }
971
972 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
973 {
974 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
975 subjectDomainPolicy.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
976 }
977 else
978 {
979 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
980 longjmp (env, -107);
981 }
982
983 bytesDecoded += seqBytesDecoded;
984 if (elmtLen0 == INDEFINITE_LEN)
985 {
986 BDecEoc (b, bytesDecoded, env);
987 return;
988 }
989 else if (seqBytesDecoded != elmtLen0)
990 {
991 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
992 longjmp (env, -108);
993 }
994 else
995 return;
996 } // PolicyMappingsSyntaxSeq::BDecContent
997
998 AsnLen PolicyMappingsSyntaxSeq::BEnc (BUF_TYPE b)
999 {
1000 AsnLen l;
1001 l = BEncContent (b);
1002 l += BEncConsLen (b, l);
1003 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1004 return l;
1005 }
1006
1007 void PolicyMappingsSyntaxSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1008 {
1009 AsnTag tag;
1010 AsnLen elmtLen1;
1011
1012 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1013 {
1014 Asn1Error << "PolicyMappingsSyntaxSeq::BDec: ERROR - wrong tag" << endl;
1015 longjmp (env, -109);
1016 }
1017 elmtLen1 = BDecLen (b, bytesDecoded, env);
1018 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1019 }
1020
1021 int PolicyMappingsSyntaxSeq::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
1022 {
1023 bytesEncoded = BEnc (b);
1024 return !b.WriteError();
1025 }
1026
1027 int PolicyMappingsSyntaxSeq::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
1028 {
1029 ENV_TYPE env;
1030 int val;
1031
1032 bytesDecoded = 0;
1033 if ((val = setjmp (env)) == 0)
1034 {
1035 BDec (b, bytesDecoded, env);
1036 return !b.ReadError();
1037 }
1038 else
1039 return false;
1040 }
1041
1042 void PolicyMappingsSyntaxSeq::Print (ostream &os) const
1043 {
1044 #ifndef NDEBUG
1045 os << "{ -- SEQUENCE --" << endl;
1046 indentG += stdIndentG;
1047
1048 {
1049 Indent (os, indentG);
1050 os << "issuerDomainPolicy ";
1051 os << issuerDomainPolicy;
1052 os << "," << endl;
1053 }
1054
1055 {
1056 Indent (os, indentG);
1057 os << "subjectDomainPolicy ";
1058 os << subjectDomainPolicy;
1059 }
1060
1061 os << endl;
1062 indentG -= stdIndentG;
1063 Indent (os, indentG);
1064 os << "}";
1065 #endif /* NDEBUG */
1066 } // PolicyMappingsSyntaxSeq::Print
1067
1068
1069 AsnType *PolicyInformationSeqOf::Clone() const
1070 {
1071 return new PolicyInformationSeqOf;
1072 }
1073
1074 AsnType *PolicyInformationSeqOf::Copy() const
1075 {
1076 return new PolicyInformationSeqOf (*this);
1077 }
1078
1079 AsnLen PolicyInformationSeqOf::BEnc (BUF_TYPE b)
1080 {
1081 AsnLen l;
1082 l = BEncContent (b);
1083 l += BEncConsLen (b, l);
1084 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1085 return l;
1086 }
1087
1088 void PolicyInformationSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1089 {
1090 AsnTag tag;
1091 AsnLen elmtLen1;
1092
1093 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1094 {
1095 Asn1Error << "PolicyInformationSeqOf::BDec: ERROR - wrong tag" << endl;
1096 longjmp (env, -110);
1097 }
1098 elmtLen1 = BDecLen (b, bytesDecoded, env);
1099 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1100 }
1101
1102 PolicyInformationSeqOf::PolicyInformationSeqOf (const PolicyInformationSeqOf &)
1103 {
1104 Asn1Error << "use of incompletely defined PolicyInformationSeqOf::PolicyInformationSeqOf (const PolicyInformationSeqOf &)" << endl;
1105 abort();
1106 }
1107
1108 PolicyInformationSeqOf::~PolicyInformationSeqOf()
1109 {
1110 SetCurrToFirst();
1111 for (; Curr() != NULL; RemoveCurrFromList())
1112 ;
1113 } // end of destructor
1114
1115 #if SNACC_DEEP_COPY
1116 PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &that)
1117 #else // SNACC_DEEP_COPY
1118 PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &)
1119 #endif // SNACC_DEEP_COPY
1120 {
1121 #if SNACC_DEEP_COPY
1122 if (this != &that)
1123 {
1124 SetCurrToFirst();
1125 for (; Curr(); RemoveCurrFromList())
1126 ;
1127
1128 //that.SetCurrToFirst();
1129 //for (; that.Curr(); that.GoNext())
1130 // AppendCopy (*that.Curr());
1131 for (const AsnListElmt *run=that.first; run; run=run->next)
1132 AppendCopy (*run->elmt);
1133 }
1134
1135 return *this;
1136 #else // SNACC_DEEP_COPY
1137 Asn1Error << "use of incompletely defined PolicyInformationSeqOf &PolicyInformationSeqOf::operator = (const PolicyInformationSeqOf &)" << endl;
1138 abort();
1139 // if your compiler complains here, check the -novolat option
1140 #endif // SNACC_DEEP_COPY
1141 }
1142
1143 void PolicyInformationSeqOf::Print (ostream &os) const
1144 {
1145 #ifndef NDEBUG
1146 os << "{ -- SEQUENCE/SET OF -- " << endl;
1147 indentG += stdIndentG;
1148 //SetCurrToFirst();
1149 //for (; Curr() != NULL; GoNext())
1150 for (const AsnListElmt *run=first; run; run=run->next)
1151 {
1152 Indent (os, indentG);
1153 //os << *Curr();
1154 os << *run->elmt;
1155 //if (Curr() != Last())
1156 if (run != last)
1157 os << ",";
1158 os << endl;
1159 }
1160 indentG -= stdIndentG;
1161 Indent (os, indentG);
1162 os << "}\n";
1163 #endif /* NDEBUG */
1164
1165
1166 } // Print
1167
1168
1169 void PolicyInformationSeqOf::SetCurrElmt (unsigned long int index)
1170 {
1171 unsigned long int i;
1172 curr = first;
1173 if (count)
1174 for (i = 0; (i < (count-1)) && (i < index); i++)
1175 curr = curr->next;
1176 } // PolicyInformationSeqOf::SetCurrElmt
1177
1178
1179 unsigned long int PolicyInformationSeqOf::GetCurrElmtIndex()
1180 {
1181 unsigned long int i;
1182 AsnListElmt *tmp;
1183 if (curr != NULL)
1184 {
1185 for (i = 0, tmp = first; tmp != NULL; i++)
1186 {
1187 if (tmp == curr)
1188 return i;
1189 else
1190 tmp = tmp->next;
1191 }
1192 }
1193 return count;
1194 } // PolicyInformationSeqOf::GetCurrElmtIndex
1195
1196
1197 // alloc new list elmt, put at end of list
1198 // and return the component type
1199 PolicyQualifierInfo *PolicyInformationSeqOf::Append()
1200 {
1201 AsnListElmt *newElmt;
1202 newElmt = new AsnListElmt;
1203 newElmt->elmt = new PolicyQualifierInfo;
1204 newElmt->next = NULL;
1205 if (last == NULL)
1206 {
1207 newElmt->prev = NULL;
1208 first = last = newElmt;
1209 }
1210 else
1211 {
1212 newElmt->prev = last;
1213 last->next = newElmt;
1214 last = newElmt;
1215 }
1216 count++;
1217 return (curr = newElmt)->elmt;
1218 } // PolicyInformationSeqOf::Append
1219
1220
1221 // alloc new list elmt, put at begining of list
1222 // and return the component type
1223 PolicyQualifierInfo *PolicyInformationSeqOf::Prepend()
1224 {
1225 AsnListElmt *newElmt;
1226 newElmt = new AsnListElmt;
1227 newElmt->elmt = new PolicyQualifierInfo;
1228 newElmt->prev = NULL;
1229 if (first == NULL)
1230 {
1231 newElmt->next = NULL;
1232 first = last = newElmt;
1233 }
1234 else
1235 {
1236 newElmt->next = first;
1237 first->prev = newElmt;
1238 first = newElmt;
1239 }
1240 count++;
1241 return (curr = newElmt)->elmt;
1242 } // PolicyInformationSeqOf::Prepend
1243
1244
1245 // alloc new list elmt, insert it before the
1246 // current element and return the component type
1247 // if the current element is null, the new element
1248 // is placed at the beginning of the list.
1249 PolicyQualifierInfo *PolicyInformationSeqOf::InsertBefore()
1250 {
1251 AsnListElmt *newElmt;
1252 newElmt = new AsnListElmt;
1253 newElmt->elmt = new PolicyQualifierInfo;
1254 if (curr == NULL)
1255 {
1256 newElmt->next = first;
1257 newElmt->prev = NULL;
1258 first = newElmt;
1259 if (last == NULL)
1260 last = newElmt;
1261 }
1262 else
1263 {
1264 newElmt->next = curr;
1265 newElmt->prev = curr->prev;
1266 curr->prev = newElmt;
1267 if (curr == first)
1268 first = newElmt;
1269 else
1270 newElmt->prev->next = newElmt;
1271 }
1272 count++;
1273 return (curr = newElmt)->elmt;
1274 } // PolicyInformationSeqOf::InsertBefore
1275
1276
1277 // alloc new list elmt, insert it after the
1278 // current element and return the component type
1279 // if the current element is null, the new element
1280 // is placed at the end of the list.
1281 PolicyQualifierInfo *PolicyInformationSeqOf::InsertAfter()
1282 {
1283 AsnListElmt *newElmt;
1284 newElmt = new AsnListElmt;
1285 newElmt->elmt = new PolicyQualifierInfo;
1286 if (curr == NULL)
1287 {
1288 newElmt->prev = last;
1289 newElmt->next = NULL;
1290 last = newElmt;
1291 if (first == NULL)
1292 first = newElmt;
1293 }
1294 else
1295 {
1296 newElmt->prev = curr;
1297 newElmt->next = curr->next;
1298 curr->next = newElmt;
1299 if (curr == last)
1300 last = newElmt;
1301 else
1302 newElmt->next->prev = newElmt;
1303 }
1304 count++;
1305 return (curr = newElmt)->elmt;
1306 } // PolicyInformationSeqOf::InsertAfter
1307
1308
1309 PolicyInformationSeqOf &PolicyInformationSeqOf::AppendCopy (PolicyQualifierInfo &elmt)
1310 {
1311 AsnListElmt *newElmt;
1312 newElmt = new AsnListElmt;
1313 newElmt->elmt = new PolicyQualifierInfo;
1314 *newElmt->elmt = elmt;
1315 newElmt->next = NULL;
1316 if (last == NULL)
1317 {
1318 newElmt->prev = NULL;
1319 first = last = newElmt;
1320 }
1321 else
1322 {
1323 newElmt->prev = last;
1324 last->next = newElmt;
1325 last = newElmt;
1326 }
1327 count++;
1328 return *this;
1329 } // AppendCopy
1330
1331
1332 PolicyInformationSeqOf &PolicyInformationSeqOf::PrependCopy (PolicyQualifierInfo &elmt)
1333 {
1334 AsnListElmt *newElmt;
1335 newElmt = new AsnListElmt;
1336 newElmt->elmt = new PolicyQualifierInfo;
1337 *newElmt->elmt = elmt;
1338 newElmt->prev = NULL;
1339 if (first == NULL)
1340 {
1341 newElmt->next = NULL;
1342 first = last = newElmt;
1343 }
1344 else
1345 {
1346 newElmt->next = first;
1347 first->prev = newElmt;
1348 first = newElmt;
1349 }
1350 count++;
1351 return *this;
1352 } // PolicyInformationSeqOf::PrependCopy
1353
1354
1355 // alloc new list elmt, insert it before the
1356 // current element, copy the given elmt into the new elmt
1357 // and return the component type.
1358 // if the current element is null, the new element
1359 // is placed at the beginning of the list.
1360 PolicyInformationSeqOf &PolicyInformationSeqOf::InsertBeforeAndCopy (PolicyQualifierInfo &elmt)
1361 {
1362 AsnListElmt *newElmt;
1363
1364 newElmt = new AsnListElmt;
1365 newElmt->elmt = new PolicyQualifierInfo;
1366 *newElmt->elmt = elmt;
1367
1368 if (curr == NULL)
1369 {
1370 newElmt->next = first;
1371 newElmt->prev = NULL;
1372 first = newElmt;
1373 if (last == NULL)
1374 last = newElmt;
1375 }
1376 else
1377 {
1378 newElmt->next = curr;
1379 newElmt->prev = curr->prev;
1380 curr->prev = newElmt;
1381 if (curr == first)
1382 first = newElmt;
1383 else
1384 newElmt->prev->next = newElmt;
1385 }
1386 count++;
1387 return *this;
1388 } // PolicyInformationSeqOf::InsertBeforeAndCopy
1389
1390
1391 // alloc new list elmt, insert it after the
1392 // current element, copy given elmt in to new elmt
1393 // and return the component type
1394 // if the current element is null, the new element
1395 // is placed at the end of the list.
1396 PolicyInformationSeqOf &PolicyInformationSeqOf::InsertAfterAndCopy (PolicyQualifierInfo &elmt)
1397 {
1398 AsnListElmt *newElmt;
1399
1400 newElmt = new AsnListElmt;
1401 newElmt->elmt = new PolicyQualifierInfo;
1402 *newElmt->elmt = elmt;
1403 if (curr == NULL)
1404 {
1405 newElmt->prev = last;
1406 newElmt->next = NULL;
1407 last = newElmt;
1408 if (first == NULL)
1409 first = newElmt;
1410 }
1411 else
1412 {
1413 newElmt->prev = curr;
1414 newElmt->next = curr->next;
1415 curr->next = newElmt;
1416 if (curr == last)
1417 last = newElmt;
1418 else
1419 newElmt->next->prev = newElmt;
1420 }
1421 count++;
1422 return *this;
1423 } // PolicyInformationSeqOf::InsertAfterAndCopy
1424
1425
1426 // remove current element from list if current element is not NULL
1427 // The new current element will be the next element.
1428 // If the current element is the last element in the list
1429 // the second but last element will become the new current element.
1430 void PolicyInformationSeqOf::RemoveCurrFromList()
1431 {
1432 AsnListElmt *del_elmt;
1433
1434 if (curr != NULL)
1435 {
1436 del_elmt = curr;
1437 count--;
1438
1439 if (count == 0)
1440 first = last = curr = NULL;
1441 else if (curr == first)
1442 {
1443 curr = first= first->next;
1444 first->prev = NULL;
1445 }
1446 else if (curr == last)
1447 {
1448 curr = last = last->prev;
1449 last->next = NULL;
1450 }
1451 else
1452 {
1453 curr->prev->next = curr->next;
1454 curr->next->prev = curr->prev;
1455 }
1456
1457 delete del_elmt->elmt;
1458 delete del_elmt;
1459 }
1460 }
1461
1462
1463 AsnLen PolicyInformationSeqOf::BEncContent (BUF_TYPE b)
1464 {
1465 AsnListElmt *currElmt;
1466 AsnLen elmtLen;
1467 AsnLen totalLen = 0;
1468 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
1469 {
1470 BEncEocIfNec (b);
1471 elmtLen = currElmt->elmt->BEncContent (b);
1472 elmtLen += BEncConsLen (b, elmtLen);
1473
1474 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1475 totalLen += elmtLen;
1476 }
1477 return totalLen;
1478 } // PolicyInformationSeqOf::BEncContent
1479
1480
1481 void PolicyInformationSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
1482 AsnLen &bytesDecoded, ENV_TYPE env)
1483 {
1484 PolicyQualifierInfo *listElmt;
1485 AsnTag tag1;
1486 AsnLen listBytesDecoded = 0;
1487 AsnLen elmtLen1;
1488
1489 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
1490 {
1491 tag1 = BDecTag (b, listBytesDecoded, env);
1492 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
1493 {
1494 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
1495 break;
1496 }
1497 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1498 {
1499 Asn1Error << "Unexpected Tag" << endl;
1500 longjmp (env, -111);
1501 }
1502
1503 elmtLen1 = BDecLen (b, listBytesDecoded, env);
1504 listElmt = Append();
1505 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
1506 }
1507
1508 bytesDecoded += listBytesDecoded;
1509 } // PolicyInformationSeqOf::BDecContent
1510
1511
1512 PolicyInformation::PolicyInformation()
1513 {
1514 policyQualifiers = NULL;
1515 }
1516
1517 PolicyInformation::PolicyInformation (const PolicyInformation &)
1518 {
1519 Asn1Error << "use of incompletely defined PolicyInformation::PolicyInformation (const PolicyInformation &)" << endl;
1520 abort();
1521 }
1522
1523 PolicyInformation::~PolicyInformation()
1524 {
1525 delete policyQualifiers;
1526 }
1527
1528 AsnType *PolicyInformation::Clone() const
1529 {
1530 return new PolicyInformation;
1531 }
1532
1533 AsnType *PolicyInformation::Copy() const
1534 {
1535 return new PolicyInformation (*this);
1536 }
1537
1538 #if SNACC_DEEP_COPY
1539 PolicyInformation &PolicyInformation::operator = (const PolicyInformation &that)
1540 #else // SNACC_DEEP_COPY
1541 PolicyInformation &PolicyInformation::operator = (const PolicyInformation &)
1542 #endif // SNACC_DEEP_COPY
1543 {
1544 #if SNACC_DEEP_COPY
1545 if (this != &that)
1546 {
1547 policyIdentifier = that.policyIdentifier;
1548 if (that.policyQualifiers)
1549 {
1550 if (!policyQualifiers)
1551 policyQualifiers = new PolicyInformationSeqOf;
1552 *policyQualifiers = *that.policyQualifiers;
1553 }
1554 else
1555 {
1556 delete policyQualifiers;
1557 policyQualifiers = NULL;
1558 }
1559 }
1560
1561 return *this;
1562 #else // SNACC_DEEP_COPY
1563 Asn1Error << "use of incompletely defined PolicyInformation &PolicyInformation::operator = (const PolicyInformation &)" << endl;
1564 abort();
1565 // if your compiler complains here, check the -novolat option
1566 #endif // SNACC_DEEP_COPY
1567 }
1568
1569 AsnLen
1570 PolicyInformation::BEncContent (BUF_TYPE b)
1571 {
1572 AsnLen totalLen = 0;
1573 AsnLen l;
1574
1575 if (NOT_NULL (policyQualifiers))
1576 {
1577 BEncEocIfNec (b);
1578 l = policyQualifiers->BEncContent (b);
1579 l += BEncConsLen (b, l);
1580
1581 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1582 totalLen += l;
1583 }
1584
1585 l = policyIdentifier.BEncContent (b);
1586 l += BEncDefLen (b, l);
1587
1588 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
1589 totalLen += l;
1590
1591 return totalLen;
1592 } // PolicyInformation::BEncContent
1593
1594
1595 void PolicyInformation::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1596 {
1597 AsnTag tag1;
1598 AsnLen seqBytesDecoded = 0;
1599 AsnLen elmtLen1;
1600 tag1 = BDecTag (b, seqBytesDecoded, env);
1601
1602 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
1603 {
1604 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1605 policyIdentifier.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1606 if (seqBytesDecoded == elmtLen0)
1607 {
1608 bytesDecoded += seqBytesDecoded;
1609 return;
1610 }
1611 else
1612 {
1613 tag1 = BDecTag (b, seqBytesDecoded, env);
1614
1615 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1616 {
1617 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
1618 bytesDecoded += seqBytesDecoded;
1619 return;
1620 }
1621 }
1622 }
1623 else
1624 {
1625 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1626 longjmp (env, -112);
1627 }
1628
1629 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1630 {
1631 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1632 policyQualifiers = new PolicyInformationSeqOf;
1633 policyQualifiers->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1634 }
1635
1636 bytesDecoded += seqBytesDecoded;
1637 if (elmtLen0 == INDEFINITE_LEN)
1638 {
1639 BDecEoc (b, bytesDecoded, env);
1640 return;
1641 }
1642 else if (seqBytesDecoded != elmtLen0)
1643 {
1644 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1645 longjmp (env, -113);
1646 }
1647 else
1648 return;
1649 } // PolicyInformation::BDecContent
1650
1651 AsnLen PolicyInformation::BEnc (BUF_TYPE b)
1652 {
1653 AsnLen l;
1654 l = BEncContent (b);
1655 l += BEncConsLen (b, l);
1656 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1657 return l;
1658 }
1659
1660 void PolicyInformation::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1661 {
1662 AsnTag tag;
1663 AsnLen elmtLen1;
1664
1665 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1666 {
1667 Asn1Error << "PolicyInformation::BDec: ERROR - wrong tag" << endl;
1668 longjmp (env, -114);
1669 }
1670 elmtLen1 = BDecLen (b, bytesDecoded, env);
1671 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1672 }
1673
1674 int PolicyInformation::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
1675 {
1676 bytesEncoded = BEnc (b);
1677 return !b.WriteError();
1678 }
1679
1680 int PolicyInformation::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
1681 {
1682 ENV_TYPE env;
1683 int val;
1684
1685 bytesDecoded = 0;
1686 if ((val = setjmp (env)) == 0)
1687 {
1688 BDec (b, bytesDecoded, env);
1689 return !b.ReadError();
1690 }
1691 else
1692 return false;
1693 }
1694
1695 void PolicyInformation::Print (ostream &os) const
1696 {
1697 #ifndef NDEBUG
1698 os << "{ -- SEQUENCE --" << endl;
1699 indentG += stdIndentG;
1700
1701 {
1702 Indent (os, indentG);
1703 os << "policyIdentifier ";
1704 os << policyIdentifier;
1705 os << "," << endl;
1706 }
1707
1708 if (NOT_NULL (policyQualifiers))
1709 {
1710 os << ","<< endl;
1711 Indent (os, indentG);
1712 os << "policyQualifiers ";
1713 os << *policyQualifiers;
1714 }
1715 else
1716 {
1717 Indent (os, indentG);
1718 os << "policyQualifiers ";
1719 os << "-- void --";
1720 os << endl;
1721 }
1722
1723 os << endl;
1724 indentG -= stdIndentG;
1725 Indent (os, indentG);
1726 os << "}";
1727 #endif /* NDEBUG */
1728 } // PolicyInformation::Print
1729
1730
1731 GeneralSubtree::GeneralSubtree()
1732 {
1733 #if TCL
1734 base = new GeneralName;
1735 #else
1736 base = NULL; // incomplete initialization of mandatory element!
1737 #endif // TCL
1738 minimum = NULL;
1739 maximum = NULL;
1740 }
1741
1742 GeneralSubtree::GeneralSubtree (const GeneralSubtree &)
1743 {
1744 Asn1Error << "use of incompletely defined GeneralSubtree::GeneralSubtree (const GeneralSubtree &)" << endl;
1745 abort();
1746 }
1747
1748 GeneralSubtree::~GeneralSubtree()
1749 {
1750 delete base;
1751 delete minimum;
1752 delete maximum;
1753 }
1754
1755 AsnType *GeneralSubtree::Clone() const
1756 {
1757 return new GeneralSubtree;
1758 }
1759
1760 AsnType *GeneralSubtree::Copy() const
1761 {
1762 return new GeneralSubtree (*this);
1763 }
1764
1765 #if SNACC_DEEP_COPY
1766 GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &that)
1767 #else // SNACC_DEEP_COPY
1768 GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &)
1769 #endif // SNACC_DEEP_COPY
1770 {
1771 #if SNACC_DEEP_COPY
1772 if (this != &that)
1773 {
1774 if (that.base)
1775 {
1776 if (!base)
1777 base = new GeneralName;
1778 *base = *that.base;
1779 }
1780 else
1781 {
1782 delete base;
1783 base = NULL;
1784 }
1785 if (that.minimum)
1786 {
1787 if (!minimum)
1788 minimum = new BaseDistance;
1789 *minimum = *that.minimum;
1790 }
1791 else
1792 {
1793 delete minimum;
1794 minimum = NULL;
1795 }
1796 if (that.maximum)
1797 {
1798 if (!maximum)
1799 maximum = new BaseDistance;
1800 *maximum = *that.maximum;
1801 }
1802 else
1803 {
1804 delete maximum;
1805 maximum = NULL;
1806 }
1807 }
1808
1809 return *this;
1810 #else // SNACC_DEEP_COPY
1811 Asn1Error << "use of incompletely defined GeneralSubtree &GeneralSubtree::operator = (const GeneralSubtree &)" << endl;
1812 abort();
1813 // if your compiler complains here, check the -novolat option
1814 #endif // SNACC_DEEP_COPY
1815 }
1816
1817 AsnLen
1818 GeneralSubtree::BEncContent (BUF_TYPE b)
1819 {
1820 AsnLen totalLen = 0;
1821 AsnLen l;
1822
1823 if (NOT_NULL (maximum))
1824 {
1825 l = maximum->BEncContent (b);
1826 BEncDefLenTo127 (b, l);
1827 l++;
1828
1829 l += BEncTag1 (b, CNTX, PRIM, 1);
1830 totalLen += l;
1831 }
1832
1833 if (NOT_NULL (minimum))
1834 {
1835 l = minimum->BEncContent (b);
1836 BEncDefLenTo127 (b, l);
1837 l++;
1838
1839 l += BEncTag1 (b, CNTX, PRIM, 0);
1840 totalLen += l;
1841 }
1842
1843 l = base->BEncContent (b);
1844 totalLen += l;
1845
1846 return totalLen;
1847 } // GeneralSubtree::BEncContent
1848
1849
1850 void GeneralSubtree::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1851 {
1852 AsnTag tag1;
1853 AsnLen seqBytesDecoded = 0;
1854 AsnLen elmtLen1;
1855 tag1 = BDecTag (b, seqBytesDecoded, env);
1856
1857 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))
1858 || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))
1859 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1))
1860 || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 2))
1861 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2))
1862 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3))
1863 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 4))
1864 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 5))
1865 || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 6))
1866 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 6))
1867 || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 7))
1868 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 7))
1869 || (tag1 == MAKE_TAG_ID (CNTX, PRIM, 8)))
1870 {
1871 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1872 base = new GeneralName;
1873 base->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1874 if (seqBytesDecoded == elmtLen0)
1875 {
1876 bytesDecoded += seqBytesDecoded;
1877 return;
1878 }
1879 else
1880 {
1881 tag1 = BDecTag (b, seqBytesDecoded, env);
1882
1883 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1884 {
1885 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
1886 bytesDecoded += seqBytesDecoded;
1887 return;
1888 }
1889 }
1890 }
1891 else
1892 {
1893 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1894 longjmp (env, -115);
1895 }
1896
1897 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)))
1898 {
1899 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1900 minimum = new BaseDistance;
1901 minimum->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1902 if (seqBytesDecoded == elmtLen0)
1903 {
1904 bytesDecoded += seqBytesDecoded;
1905 return;
1906 }
1907 else
1908 {
1909 tag1 = BDecTag (b, seqBytesDecoded, env);
1910
1911 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1912 {
1913 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
1914 bytesDecoded += seqBytesDecoded;
1915 return;
1916 }
1917 }
1918 }
1919
1920 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)))
1921 {
1922 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1923 maximum = new BaseDistance;
1924 maximum->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1925 }
1926
1927 bytesDecoded += seqBytesDecoded;
1928 if (elmtLen0 == INDEFINITE_LEN)
1929 {
1930 BDecEoc (b, bytesDecoded, env);
1931 return;
1932 }
1933 else if (seqBytesDecoded != elmtLen0)
1934 {
1935 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1936 longjmp (env, -116);
1937 }
1938 else
1939 return;
1940 } // GeneralSubtree::BDecContent
1941
1942 AsnLen GeneralSubtree::BEnc (BUF_TYPE b)
1943 {
1944 AsnLen l;
1945 l = BEncContent (b);
1946 l += BEncConsLen (b, l);
1947 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1948 return l;
1949 }
1950
1951 void GeneralSubtree::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1952 {
1953 AsnTag tag;
1954 AsnLen elmtLen1;
1955
1956 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1957 {
1958 Asn1Error << "GeneralSubtree::BDec: ERROR - wrong tag" << endl;
1959 longjmp (env, -117);
1960 }
1961 elmtLen1 = BDecLen (b, bytesDecoded, env);
1962 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1963 }
1964
1965 int GeneralSubtree::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
1966 {
1967 bytesEncoded = BEnc (b);
1968 return !b.WriteError();
1969 }
1970
1971 int GeneralSubtree::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
1972 {
1973 ENV_TYPE env;
1974 int val;
1975
1976 bytesDecoded = 0;
1977 if ((val = setjmp (env)) == 0)
1978 {
1979 BDec (b, bytesDecoded, env);
1980 return !b.ReadError();
1981 }
1982 else
1983 return false;
1984 }
1985
1986 void GeneralSubtree::Print (ostream &os) const
1987 {
1988 #ifndef NDEBUG
1989 os << "{ -- SEQUENCE --" << endl;
1990 indentG += stdIndentG;
1991
1992 if (NOT_NULL (base))
1993 {
1994 Indent (os, indentG);
1995 os << "base ";
1996 os << *base;
1997 }
1998 else
1999 {
2000 Indent (os, indentG);
2001 os << "base ";
2002 os << "-- void --";
2003 os << "," << endl;
2004 }
2005
2006 if (NOT_NULL (minimum))
2007 {
2008 os << ","<< endl;
2009 Indent (os, indentG);
2010 os << "minimum ";
2011 os << *minimum;
2012 }
2013 else
2014 {
2015 Indent (os, indentG);
2016 os << "minimum ";
2017 os << "-- void --";
2018 os << "," << endl;
2019 }
2020
2021 if (NOT_NULL (maximum))
2022 {
2023 os << ","<< endl;
2024 Indent (os, indentG);
2025 os << "maximum ";
2026 os << *maximum;
2027 }
2028 else
2029 {
2030 Indent (os, indentG);
2031 os << "maximum ";
2032 os << "-- void --";
2033 os << endl;
2034 }
2035
2036 os << endl;
2037 indentG -= stdIndentG;
2038 Indent (os, indentG);
2039 os << "}";
2040 #endif /* NDEBUG */
2041 } // GeneralSubtree::Print
2042
2043
2044 DistributionPoint::DistributionPoint()
2045 {
2046 distributionPoint = NULL;
2047 reasons = NULL;
2048 cRLIssuer = NULL;
2049 }
2050
2051 DistributionPoint::DistributionPoint (const DistributionPoint &)
2052 {
2053 Asn1Error << "use of incompletely defined DistributionPoint::DistributionPoint (const DistributionPoint &)" << endl;
2054 abort();
2055 }
2056
2057 DistributionPoint::~DistributionPoint()
2058 {
2059 delete distributionPoint;
2060 delete reasons;
2061 delete cRLIssuer;
2062 }
2063
2064 AsnType *DistributionPoint::Clone() const
2065 {
2066 return new DistributionPoint;
2067 }
2068
2069 AsnType *DistributionPoint::Copy() const
2070 {
2071 return new DistributionPoint (*this);
2072 }
2073
2074 #if SNACC_DEEP_COPY
2075 DistributionPoint &DistributionPoint::operator = (const DistributionPoint &that)
2076 #else // SNACC_DEEP_COPY
2077 DistributionPoint &DistributionPoint::operator = (const DistributionPoint &)
2078 #endif // SNACC_DEEP_COPY
2079 {
2080 #if SNACC_DEEP_COPY
2081 if (this != &that)
2082 {
2083 if (that.distributionPoint)
2084 {
2085 if (!distributionPoint)
2086 distributionPoint = new DistributionPointName;
2087 *distributionPoint = *that.distributionPoint;
2088 }
2089 else
2090 {
2091 delete distributionPoint;
2092 distributionPoint = NULL;
2093 }
2094 if (that.reasons)
2095 {
2096 if (!reasons)
2097 reasons = new ReasonFlags;
2098 *reasons = *that.reasons;
2099 }
2100 else
2101 {
2102 delete reasons;
2103 reasons = NULL;
2104 }
2105 if (that.cRLIssuer)
2106 {
2107 if (!cRLIssuer)
2108 cRLIssuer = new GeneralNames;
2109 *cRLIssuer = *that.cRLIssuer;
2110 }
2111 else
2112 {
2113 delete cRLIssuer;
2114 cRLIssuer = NULL;
2115 }
2116 }
2117
2118 return *this;
2119 #else // SNACC_DEEP_COPY
2120 Asn1Error << "use of incompletely defined DistributionPoint &DistributionPoint::operator = (const DistributionPoint &)" << endl;
2121 abort();
2122 // if your compiler complains here, check the -novolat option
2123 #endif // SNACC_DEEP_COPY
2124 }
2125
2126 AsnLen
2127 DistributionPoint::BEncContent (BUF_TYPE b)
2128 {
2129 AsnLen totalLen = 0;
2130 AsnLen l;
2131
2132 if (NOT_NULL (cRLIssuer))
2133 {
2134 BEncEocIfNec (b);
2135 l = cRLIssuer->BEncContent (b);
2136 l += BEncConsLen (b, l);
2137
2138 l += BEncTag1 (b, CNTX, CONS, 2);
2139 totalLen += l;
2140 }
2141
2142 if (NOT_NULL (reasons))
2143 {
2144 l = reasons->BEncContent (b);
2145 l += BEncDefLen (b, l);
2146
2147 l += BEncTag1 (b, CNTX, PRIM, 1);
2148 totalLen += l;
2149 }
2150
2151 if (NOT_NULL (distributionPoint))
2152 {
2153 BEncEocIfNec (b);
2154 l = distributionPoint->BEncContent (b);
2155 l += BEncConsLen (b, l);
2156
2157 l += BEncTag1 (b, CNTX, CONS, 0);
2158 totalLen += l;
2159 }
2160
2161 return totalLen;
2162 } // DistributionPoint::BEncContent
2163
2164
2165 void DistributionPoint::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
2166 {
2167 AsnTag tag1;
2168 AsnLen seqBytesDecoded = 0;
2169 AsnLen elmtLen1;
2170 AsnLen elmtLen2;
2171 if (elmtLen0 == 0)
2172 return;
2173 else
2174 {
2175 tag1 = BDecTag (b, seqBytesDecoded, env);
2176
2177 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
2178 {
2179 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
2180 bytesDecoded += seqBytesDecoded;
2181 return;
2182 }
2183 }
2184
2185 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
2186 {
2187 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2188 tag1 = BDecTag (b, seqBytesDecoded, env);
2189 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
2190 distributionPoint = new DistributionPointName;
2191 distributionPoint->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
2192 if (elmtLen1 == INDEFINITE_LEN)
2193 BDecEoc (b, seqBytesDecoded, env);
2194
2195 if (seqBytesDecoded == elmtLen0)
2196 {
2197 bytesDecoded += seqBytesDecoded;
2198 return;
2199 }
2200 else
2201 {
2202 tag1 = BDecTag (b, seqBytesDecoded, env);
2203
2204 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
2205 {
2206 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
2207 bytesDecoded += seqBytesDecoded;
2208 return;
2209 }
2210 }
2211 }
2212
2213 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))
2214 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
2215 {
2216 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2217 reasons = new ReasonFlags;
2218 reasons->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
2219 if (seqBytesDecoded == elmtLen0)
2220 {
2221 bytesDecoded += seqBytesDecoded;
2222 return;
2223 }
2224 else
2225 {
2226 tag1 = BDecTag (b, seqBytesDecoded, env);
2227
2228 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
2229 {
2230 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
2231 bytesDecoded += seqBytesDecoded;
2232 return;
2233 }
2234 }
2235 }
2236
2237 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2)))
2238 {
2239 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2240 cRLIssuer = new GeneralNames;
2241 cRLIssuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
2242 }
2243
2244 bytesDecoded += seqBytesDecoded;
2245 if (elmtLen0 == INDEFINITE_LEN)
2246 {
2247 BDecEoc (b, bytesDecoded, env);
2248 return;
2249 }
2250 else if (seqBytesDecoded != elmtLen0)
2251 {
2252 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
2253 longjmp (env, -118);
2254 }
2255 else
2256 return;
2257 } // DistributionPoint::BDecContent
2258
2259 AsnLen DistributionPoint::BEnc (BUF_TYPE b)
2260 {
2261 AsnLen l;
2262 l = BEncContent (b);
2263 l += BEncConsLen (b, l);
2264 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2265 return l;
2266 }
2267
2268 void DistributionPoint::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2269 {
2270 AsnTag tag;
2271 AsnLen elmtLen1;
2272
2273 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2274 {
2275 Asn1Error << "DistributionPoint::BDec: ERROR - wrong tag" << endl;
2276 longjmp (env, -119);
2277 }
2278 elmtLen1 = BDecLen (b, bytesDecoded, env);
2279 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2280 }
2281
2282 int DistributionPoint::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
2283 {
2284 bytesEncoded = BEnc (b);
2285 return !b.WriteError();
2286 }
2287
2288 int DistributionPoint::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
2289 {
2290 ENV_TYPE env;
2291 int val;
2292
2293 bytesDecoded = 0;
2294 if ((val = setjmp (env)) == 0)
2295 {
2296 BDec (b, bytesDecoded, env);
2297 return !b.ReadError();
2298 }
2299 else
2300 return false;
2301 }
2302
2303 void DistributionPoint::Print (ostream &os) const
2304 {
2305 #ifndef NDEBUG
2306 int nonePrinted = true;
2307 os << "{ -- SEQUENCE --" << endl;
2308 indentG += stdIndentG;
2309
2310 if (NOT_NULL (distributionPoint))
2311 {
2312 nonePrinted = false;
2313 Indent (os, indentG);
2314 os << "distributionPoint ";
2315 os << *distributionPoint;
2316 }
2317 else
2318 {
2319 Indent (os, indentG);
2320 os << "distributionPoint ";
2321 os << "-- void --";
2322 os << "," << endl;
2323 }
2324
2325 if (NOT_NULL (reasons))
2326 {
2327 if (!nonePrinted)
2328 os << "," << endl;
2329 nonePrinted = false;
2330 Indent (os, indentG);
2331 os << "reasons ";
2332 os << *reasons;
2333 }
2334 else
2335 {
2336 Indent (os, indentG);
2337 os << "reasons ";
2338 os << "-- void --";
2339 os << "," << endl;
2340 }
2341
2342 if (NOT_NULL (cRLIssuer))
2343 {
2344 if (!nonePrinted)
2345 os << "," << endl;
2346 nonePrinted = false;
2347 Indent (os, indentG);
2348 os << "cRLIssuer ";
2349 os << *cRLIssuer;
2350 }
2351 else
2352 {
2353 Indent (os, indentG);
2354 os << "cRLIssuer ";
2355 os << "-- void --";
2356 os << endl;
2357 }
2358
2359 os << endl;
2360 indentG -= stdIndentG;
2361 Indent (os, indentG);
2362 os << "}";
2363 #endif /* NDEBUG */
2364 } // DistributionPoint::Print
2365
2366
2367 AsnType *CertificatePoliciesSyntax::Clone() const
2368 {
2369 return new CertificatePoliciesSyntax;
2370 }
2371
2372 AsnType *CertificatePoliciesSyntax::Copy() const
2373 {
2374 return new CertificatePoliciesSyntax (*this);
2375 }
2376
2377 AsnLen CertificatePoliciesSyntax::BEnc (BUF_TYPE b)
2378 {
2379 AsnLen l;
2380 l = BEncContent (b);
2381 l += BEncConsLen (b, l);
2382 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2383 return l;
2384 }
2385
2386 void CertificatePoliciesSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2387 {
2388 AsnTag tag;
2389 AsnLen elmtLen1;
2390
2391 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2392 {
2393 Asn1Error << "CertificatePoliciesSyntax::BDec: ERROR - wrong tag" << endl;
2394 longjmp (env, -120);
2395 }
2396 elmtLen1 = BDecLen (b, bytesDecoded, env);
2397 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2398 }
2399
2400 CertificatePoliciesSyntax::CertificatePoliciesSyntax (const CertificatePoliciesSyntax &)
2401 {
2402 Asn1Error << "use of incompletely defined CertificatePoliciesSyntax::CertificatePoliciesSyntax (const CertificatePoliciesSyntax &)" << endl;
2403 abort();
2404 }
2405
2406 CertificatePoliciesSyntax::~CertificatePoliciesSyntax()
2407 {
2408 SetCurrToFirst();
2409 for (; Curr() != NULL; RemoveCurrFromList())
2410 ;
2411 } // end of destructor
2412
2413 #if SNACC_DEEP_COPY
2414 CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &that)
2415 #else // SNACC_DEEP_COPY
2416 CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &)
2417 #endif // SNACC_DEEP_COPY
2418 {
2419 #if SNACC_DEEP_COPY
2420 if (this != &that)
2421 {
2422 SetCurrToFirst();
2423 for (; Curr(); RemoveCurrFromList())
2424 ;
2425
2426 //that.SetCurrToFirst();
2427 //for (; that.Curr(); that.GoNext())
2428 // AppendCopy (*that.Curr());
2429 for (const AsnListElmt *run=that.first; run; run=run->next)
2430 AppendCopy (*run->elmt);
2431 }
2432
2433 return *this;
2434 #else // SNACC_DEEP_COPY
2435 Asn1Error << "use of incompletely defined CertificatePoliciesSyntax &CertificatePoliciesSyntax::operator = (const CertificatePoliciesSyntax &)" << endl;
2436 abort();
2437 // if your compiler complains here, check the -novolat option
2438 #endif // SNACC_DEEP_COPY
2439 }
2440
2441 void CertificatePoliciesSyntax::Print (ostream &os) const
2442 {
2443 #ifndef NDEBUG
2444 os << "{ -- SEQUENCE/SET OF -- " << endl;
2445 indentG += stdIndentG;
2446 //SetCurrToFirst();
2447 //for (; Curr() != NULL; GoNext())
2448 for (const AsnListElmt *run=first; run; run=run->next)
2449 {
2450 Indent (os, indentG);
2451 //os << *Curr();
2452 os << *run->elmt;
2453 //if (Curr() != Last())
2454 if (run != last)
2455 os << ",";
2456 os << endl;
2457 }
2458 indentG -= stdIndentG;
2459 Indent (os, indentG);
2460 os << "}\n";
2461 #endif /* NDEBUG */
2462
2463
2464 } // Print
2465
2466
2467 void CertificatePoliciesSyntax::SetCurrElmt (unsigned long int index)
2468 {
2469 unsigned long int i;
2470 curr = first;
2471 if (count)
2472 for (i = 0; (i < (count-1)) && (i < index); i++)
2473 curr = curr->next;
2474 } // CertificatePoliciesSyntax::SetCurrElmt
2475
2476
2477 unsigned long int CertificatePoliciesSyntax::GetCurrElmtIndex()
2478 {
2479 unsigned long int i;
2480 AsnListElmt *tmp;
2481 if (curr != NULL)
2482 {
2483 for (i = 0, tmp = first; tmp != NULL; i++)
2484 {
2485 if (tmp == curr)
2486 return i;
2487 else
2488 tmp = tmp->next;
2489 }
2490 }
2491 return count;
2492 } // CertificatePoliciesSyntax::GetCurrElmtIndex
2493
2494
2495 // alloc new list elmt, put at end of list
2496 // and return the component type
2497 PolicyInformation *CertificatePoliciesSyntax::Append()
2498 {
2499 AsnListElmt *newElmt;
2500 newElmt = new AsnListElmt;
2501 newElmt->elmt = new PolicyInformation;
2502 newElmt->next = NULL;
2503 if (last == NULL)
2504 {
2505 newElmt->prev = NULL;
2506 first = last = newElmt;
2507 }
2508 else
2509 {
2510 newElmt->prev = last;
2511 last->next = newElmt;
2512 last = newElmt;
2513 }
2514 count++;
2515 return (curr = newElmt)->elmt;
2516 } // CertificatePoliciesSyntax::Append
2517
2518
2519 // alloc new list elmt, put at begining of list
2520 // and return the component type
2521 PolicyInformation *CertificatePoliciesSyntax::Prepend()
2522 {
2523 AsnListElmt *newElmt;
2524 newElmt = new AsnListElmt;
2525 newElmt->elmt = new PolicyInformation;
2526 newElmt->prev = NULL;
2527 if (first == NULL)
2528 {
2529 newElmt->next = NULL;
2530 first = last = newElmt;
2531 }
2532 else
2533 {
2534 newElmt->next = first;
2535 first->prev = newElmt;
2536 first = newElmt;
2537 }
2538 count++;
2539 return (curr = newElmt)->elmt;
2540 } // CertificatePoliciesSyntax::Prepend
2541
2542
2543 // alloc new list elmt, insert it before the
2544 // current element and return the component type
2545 // if the current element is null, the new element
2546 // is placed at the beginning of the list.
2547 PolicyInformation *CertificatePoliciesSyntax::InsertBefore()
2548 {
2549 AsnListElmt *newElmt;
2550 newElmt = new AsnListElmt;
2551 newElmt->elmt = new PolicyInformation;
2552 if (curr == NULL)
2553 {
2554 newElmt->next = first;
2555 newElmt->prev = NULL;
2556 first = newElmt;
2557 if (last == NULL)
2558 last = newElmt;
2559 }
2560 else
2561 {
2562 newElmt->next = curr;
2563 newElmt->prev = curr->prev;
2564 curr->prev = newElmt;
2565 if (curr == first)
2566 first = newElmt;
2567 else
2568 newElmt->prev->next = newElmt;
2569 }
2570 count++;
2571 return (curr = newElmt)->elmt;
2572 } // CertificatePoliciesSyntax::InsertBefore
2573
2574
2575 // alloc new list elmt, insert it after the
2576 // current element and return the component type
2577 // if the current element is null, the new element
2578 // is placed at the end of the list.
2579 PolicyInformation *CertificatePoliciesSyntax::InsertAfter()
2580 {
2581 AsnListElmt *newElmt;
2582 newElmt = new AsnListElmt;
2583 newElmt->elmt = new PolicyInformation;
2584 if (curr == NULL)
2585 {
2586 newElmt->prev = last;
2587 newElmt->next = NULL;
2588 last = newElmt;
2589 if (first == NULL)
2590 first = newElmt;
2591 }
2592 else
2593 {
2594 newElmt->prev = curr;
2595 newElmt->next = curr->next;
2596 curr->next = newElmt;
2597 if (curr == last)
2598 last = newElmt;
2599 else
2600 newElmt->next->prev = newElmt;
2601 }
2602 count++;
2603 return (curr = newElmt)->elmt;
2604 } // CertificatePoliciesSyntax::InsertAfter
2605
2606
2607 CertificatePoliciesSyntax &CertificatePoliciesSyntax::AppendCopy (PolicyInformation &elmt)
2608 {
2609 AsnListElmt *newElmt;
2610 newElmt = new AsnListElmt;
2611 newElmt->elmt = new PolicyInformation;
2612 *newElmt->elmt = elmt;
2613 newElmt->next = NULL;
2614 if (last == NULL)
2615 {
2616 newElmt->prev = NULL;
2617 first = last = newElmt;
2618 }
2619 else
2620 {
2621 newElmt->prev = last;
2622 last->next = newElmt;
2623 last = newElmt;
2624 }
2625 count++;
2626 return *this;
2627 } // AppendCopy
2628
2629
2630 CertificatePoliciesSyntax &CertificatePoliciesSyntax::PrependCopy (PolicyInformation &elmt)
2631 {
2632 AsnListElmt *newElmt;
2633 newElmt = new AsnListElmt;
2634 newElmt->elmt = new PolicyInformation;
2635 *newElmt->elmt = elmt;
2636 newElmt->prev = NULL;
2637 if (first == NULL)
2638 {
2639 newElmt->next = NULL;
2640 first = last = newElmt;
2641 }
2642 else
2643 {
2644 newElmt->next = first;
2645 first->prev = newElmt;
2646 first = newElmt;
2647 }
2648 count++;
2649 return *this;
2650 } // CertificatePoliciesSyntax::PrependCopy
2651
2652
2653 // alloc new list elmt, insert it before the
2654 // current element, copy the given elmt into the new elmt
2655 // and return the component type.
2656 // if the current element is null, the new element
2657 // is placed at the beginning of the list.
2658 CertificatePoliciesSyntax &CertificatePoliciesSyntax::InsertBeforeAndCopy (PolicyInformation &elmt)
2659 {
2660 AsnListElmt *newElmt;
2661
2662 newElmt = new AsnListElmt;
2663 newElmt->elmt = new PolicyInformation;
2664 *newElmt->elmt = elmt;
2665
2666 if (curr == NULL)
2667 {
2668 newElmt->next = first;
2669 newElmt->prev = NULL;
2670 first = newElmt;
2671 if (last == NULL)
2672 last = newElmt;
2673 }
2674 else
2675 {
2676 newElmt->next = curr;
2677 newElmt->prev = curr->prev;
2678 curr->prev = newElmt;
2679 if (curr == first)
2680 first = newElmt;
2681 else
2682 newElmt->prev->next = newElmt;
2683 }
2684 count++;
2685 return *this;
2686 } // CertificatePoliciesSyntax::InsertBeforeAndCopy
2687
2688
2689 // alloc new list elmt, insert it after the
2690 // current element, copy given elmt in to new elmt
2691 // and return the component type
2692 // if the current element is null, the new element
2693 // is placed at the end of the list.
2694 CertificatePoliciesSyntax &CertificatePoliciesSyntax::InsertAfterAndCopy (PolicyInformation &elmt)
2695 {
2696 AsnListElmt *newElmt;
2697
2698 newElmt = new AsnListElmt;
2699 newElmt->elmt = new PolicyInformation;
2700 *newElmt->elmt = elmt;
2701 if (curr == NULL)
2702 {
2703 newElmt->prev = last;
2704 newElmt->next = NULL;
2705 last = newElmt;
2706 if (first == NULL)
2707 first = newElmt;
2708 }
2709 else
2710 {
2711 newElmt->prev = curr;
2712 newElmt->next = curr->next;
2713 curr->next = newElmt;
2714 if (curr == last)
2715 last = newElmt;
2716 else
2717 newElmt->next->prev = newElmt;
2718 }
2719 count++;
2720 return *this;
2721 } // CertificatePoliciesSyntax::InsertAfterAndCopy
2722
2723
2724 // remove current element from list if current element is not NULL
2725 // The new current element will be the next element.
2726 // If the current element is the last element in the list
2727 // the second but last element will become the new current element.
2728 void CertificatePoliciesSyntax::RemoveCurrFromList()
2729 {
2730 AsnListElmt *del_elmt;
2731
2732 if (curr != NULL)
2733 {
2734 del_elmt = curr;
2735 count--;
2736
2737 if (count == 0)
2738 first = last = curr = NULL;
2739 else if (curr == first)
2740 {
2741 curr = first= first->next;
2742 first->prev = NULL;
2743 }
2744 else if (curr == last)
2745 {
2746 curr = last = last->prev;
2747 last->next = NULL;
2748 }
2749 else
2750 {
2751 curr->prev->next = curr->next;
2752 curr->next->prev = curr->prev;
2753 }
2754
2755 delete del_elmt->elmt;
2756 delete del_elmt;
2757 }
2758 }
2759
2760
2761 AsnLen CertificatePoliciesSyntax::BEncContent (BUF_TYPE b)
2762 {
2763 AsnListElmt *currElmt;
2764 AsnLen elmtLen;
2765 AsnLen totalLen = 0;
2766 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
2767 {
2768 BEncEocIfNec (b);
2769 elmtLen = currElmt->elmt->BEncContent (b);
2770 elmtLen += BEncConsLen (b, elmtLen);
2771
2772 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2773 totalLen += elmtLen;
2774 }
2775 return totalLen;
2776 } // CertificatePoliciesSyntax::BEncContent
2777
2778
2779 void CertificatePoliciesSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
2780 AsnLen &bytesDecoded, ENV_TYPE env)
2781 {
2782 PolicyInformation *listElmt;
2783 AsnTag tag1;
2784 AsnLen listBytesDecoded = 0;
2785 AsnLen elmtLen1;
2786
2787 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
2788 {
2789 tag1 = BDecTag (b, listBytesDecoded, env);
2790 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2791 {
2792 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
2793 break;
2794 }
2795 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
2796 {
2797 Asn1Error << "Unexpected Tag" << endl;
2798 longjmp (env, -121);
2799 }
2800
2801 elmtLen1 = BDecLen (b, listBytesDecoded, env);
2802 listElmt = Append();
2803 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
2804 }
2805
2806 bytesDecoded += listBytesDecoded;
2807 } // CertificatePoliciesSyntax::BDecContent
2808
2809
2810 AsnType *GeneralSubtrees::Clone() const
2811 {
2812 return new GeneralSubtrees;
2813 }
2814
2815 AsnType *GeneralSubtrees::Copy() const
2816 {
2817 return new GeneralSubtrees (*this);
2818 }
2819
2820 AsnLen GeneralSubtrees::BEnc (BUF_TYPE b)
2821 {
2822 AsnLen l;
2823 l = BEncContent (b);
2824 l += BEncConsLen (b, l);
2825 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2826 return l;
2827 }
2828
2829 void GeneralSubtrees::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2830 {
2831 AsnTag tag;
2832 AsnLen elmtLen1;
2833
2834 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2835 {
2836 Asn1Error << "GeneralSubtrees::BDec: ERROR - wrong tag" << endl;
2837 longjmp (env, -122);
2838 }
2839 elmtLen1 = BDecLen (b, bytesDecoded, env);
2840 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2841 }
2842
2843 GeneralSubtrees::GeneralSubtrees (const GeneralSubtrees &)
2844 {
2845 Asn1Error << "use of incompletely defined GeneralSubtrees::GeneralSubtrees (const GeneralSubtrees &)" << endl;
2846 abort();
2847 }
2848
2849 GeneralSubtrees::~GeneralSubtrees()
2850 {
2851 SetCurrToFirst();
2852 for (; Curr() != NULL; RemoveCurrFromList())
2853 ;
2854 } // end of destructor
2855
2856 #if SNACC_DEEP_COPY
2857 GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &that)
2858 #else // SNACC_DEEP_COPY
2859 GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &)
2860 #endif // SNACC_DEEP_COPY
2861 {
2862 #if SNACC_DEEP_COPY
2863 if (this != &that)
2864 {
2865 SetCurrToFirst();
2866 for (; Curr(); RemoveCurrFromList())
2867 ;
2868
2869 //that.SetCurrToFirst();
2870 //for (; that.Curr(); that.GoNext())
2871 // AppendCopy (*that.Curr());
2872 for (const AsnListElmt *run=that.first; run; run=run->next)
2873 AppendCopy (*run->elmt);
2874 }
2875
2876 return *this;
2877 #else // SNACC_DEEP_COPY
2878 Asn1Error << "use of incompletely defined GeneralSubtrees &GeneralSubtrees::operator = (const GeneralSubtrees &)" << endl;
2879 abort();
2880 // if your compiler complains here, check the -novolat option
2881 #endif // SNACC_DEEP_COPY
2882 }
2883
2884 void GeneralSubtrees::Print (ostream &os) const
2885 {
2886 #ifndef NDEBUG
2887 os << "{ -- SEQUENCE/SET OF -- " << endl;
2888 indentG += stdIndentG;
2889 //SetCurrToFirst();
2890 //for (; Curr() != NULL; GoNext())
2891 for (const AsnListElmt *run=first; run; run=run->next)
2892 {
2893 Indent (os, indentG);
2894 //os << *Curr();
2895 os << *run->elmt;
2896 //if (Curr() != Last())
2897 if (run != last)
2898 os << ",";
2899 os << endl;
2900 }
2901 indentG -= stdIndentG;
2902 Indent (os, indentG);
2903 os << "}\n";
2904 #endif /* NDEBUG */
2905
2906
2907 } // Print
2908
2909
2910 void GeneralSubtrees::SetCurrElmt (unsigned long int index)
2911 {
2912 unsigned long int i;
2913 curr = first;
2914 if (count)
2915 for (i = 0; (i < (count-1)) && (i < index); i++)
2916 curr = curr->next;
2917 } // GeneralSubtrees::SetCurrElmt
2918
2919
2920 unsigned long int GeneralSubtrees::GetCurrElmtIndex()
2921 {
2922 unsigned long int i;
2923 AsnListElmt *tmp;
2924 if (curr != NULL)
2925 {
2926 for (i = 0, tmp = first; tmp != NULL; i++)
2927 {
2928 if (tmp == curr)
2929 return i;
2930 else
2931 tmp = tmp->next;
2932 }
2933 }
2934 return count;
2935 } // GeneralSubtrees::GetCurrElmtIndex
2936
2937
2938 // alloc new list elmt, put at end of list
2939 // and return the component type
2940 GeneralSubtree *GeneralSubtrees::Append()
2941 {
2942 AsnListElmt *newElmt;
2943 newElmt = new AsnListElmt;
2944 newElmt->elmt = new GeneralSubtree;
2945 newElmt->next = NULL;
2946 if (last == NULL)
2947 {
2948 newElmt->prev = NULL;
2949 first = last = newElmt;
2950 }
2951 else
2952 {
2953 newElmt->prev = last;
2954 last->next = newElmt;
2955 last = newElmt;
2956 }
2957 count++;
2958 return (curr = newElmt)->elmt;
2959 } // GeneralSubtrees::Append
2960
2961
2962 // alloc new list elmt, put at begining of list
2963 // and return the component type
2964 GeneralSubtree *GeneralSubtrees::Prepend()
2965 {
2966 AsnListElmt *newElmt;
2967 newElmt = new AsnListElmt;
2968 newElmt->elmt = new GeneralSubtree;
2969 newElmt->prev = NULL;
2970 if (first == NULL)
2971 {
2972 newElmt->next = NULL;
2973 first = last = newElmt;
2974 }
2975 else
2976 {
2977 newElmt->next = first;
2978 first->prev = newElmt;
2979 first = newElmt;
2980 }
2981 count++;
2982 return (curr = newElmt)->elmt;
2983 } // GeneralSubtrees::Prepend
2984
2985
2986 // alloc new list elmt, insert it before the
2987 // current element and return the component type
2988 // if the current element is null, the new element
2989 // is placed at the beginning of the list.
2990 GeneralSubtree *GeneralSubtrees::InsertBefore()
2991 {
2992 AsnListElmt *newElmt;
2993 newElmt = new AsnListElmt;
2994 newElmt->elmt = new GeneralSubtree;
2995 if (curr == NULL)
2996 {
2997 newElmt->next = first;
2998 newElmt->prev = NULL;
2999 first = newElmt;
3000 if (last == NULL)
3001 last = newElmt;
3002 }
3003 else
3004 {
3005 newElmt->next = curr;
3006 newElmt->prev = curr->prev;
3007 curr->prev = newElmt;
3008 if (curr == first)
3009 first = newElmt;
3010 else
3011 newElmt->prev->next = newElmt;
3012 }
3013 count++;
3014 return (curr = newElmt)->elmt;
3015 } // GeneralSubtrees::InsertBefore
3016
3017
3018 // alloc new list elmt, insert it after the
3019 // current element and return the component type
3020 // if the current element is null, the new element
3021 // is placed at the end of the list.
3022 GeneralSubtree *GeneralSubtrees::InsertAfter()
3023 {
3024 AsnListElmt *newElmt;
3025 newElmt = new AsnListElmt;
3026 newElmt->elmt = new GeneralSubtree;
3027 if (curr == NULL)
3028 {
3029 newElmt->prev = last;
3030 newElmt->next = NULL;
3031 last = newElmt;
3032 if (first == NULL)
3033 first = newElmt;
3034 }
3035 else
3036 {
3037 newElmt->prev = curr;
3038 newElmt->next = curr->next;
3039 curr->next = newElmt;
3040 if (curr == last)
3041 last = newElmt;
3042 else
3043 newElmt->next->prev = newElmt;
3044 }
3045 count++;
3046 return (curr = newElmt)->elmt;
3047 } // GeneralSubtrees::InsertAfter
3048
3049
3050 GeneralSubtrees &GeneralSubtrees::AppendCopy (GeneralSubtree &elmt)
3051 {
3052 AsnListElmt *newElmt;
3053 newElmt = new AsnListElmt;
3054 newElmt->elmt = new GeneralSubtree;
3055 *newElmt->elmt = elmt;
3056 newElmt->next = NULL;
3057 if (last == NULL)
3058 {
3059 newElmt->prev = NULL;
3060 first = last = newElmt;
3061 }
3062 else
3063 {
3064 newElmt->prev = last;
3065 last->next = newElmt;
3066 last = newElmt;
3067 }
3068 count++;
3069 return *this;
3070 } // AppendCopy
3071
3072
3073 GeneralSubtrees &GeneralSubtrees::PrependCopy (GeneralSubtree &elmt)
3074 {
3075 AsnListElmt *newElmt;
3076 newElmt = new AsnListElmt;
3077 newElmt->elmt = new GeneralSubtree;
3078 *newElmt->elmt = elmt;
3079 newElmt->prev = NULL;
3080 if (first == NULL)
3081 {
3082 newElmt->next = NULL;
3083 first = last = newElmt;
3084 }
3085 else
3086 {
3087 newElmt->next = first;
3088 first->prev = newElmt;
3089 first = newElmt;
3090 }
3091 count++;
3092 return *this;
3093 } // GeneralSubtrees::PrependCopy
3094
3095
3096 // alloc new list elmt, insert it before the
3097 // current element, copy the given elmt into the new elmt
3098 // and return the component type.
3099 // if the current element is null, the new element
3100 // is placed at the beginning of the list.
3101 GeneralSubtrees &GeneralSubtrees::InsertBeforeAndCopy (GeneralSubtree &elmt)
3102 {
3103 AsnListElmt *newElmt;
3104
3105 newElmt = new AsnListElmt;
3106 newElmt->elmt = new GeneralSubtree;
3107 *newElmt->elmt = elmt;
3108
3109 if (curr == NULL)
3110 {
3111 newElmt->next = first;
3112 newElmt->prev = NULL;
3113 first = newElmt;
3114 if (last == NULL)
3115 last = newElmt;
3116 }
3117 else
3118 {
3119 newElmt->next = curr;
3120 newElmt->prev = curr->prev;
3121 curr->prev = newElmt;
3122 if (curr == first)
3123 first = newElmt;
3124 else
3125 newElmt->prev->next = newElmt;
3126 }
3127 count++;
3128 return *this;
3129 } // GeneralSubtrees::InsertBeforeAndCopy
3130
3131
3132 // alloc new list elmt, insert it after the
3133 // current element, copy given elmt in to new elmt
3134 // and return the component type
3135 // if the current element is null, the new element
3136 // is placed at the end of the list.
3137 GeneralSubtrees &GeneralSubtrees::InsertAfterAndCopy (GeneralSubtree &elmt)
3138 {
3139 AsnListElmt *newElmt;
3140
3141 newElmt = new AsnListElmt;
3142 newElmt->elmt = new GeneralSubtree;
3143 *newElmt->elmt = elmt;
3144 if (curr == NULL)
3145 {
3146 newElmt->prev = last;
3147 newElmt->next = NULL;
3148 last = newElmt;
3149 if (first == NULL)
3150 first = newElmt;
3151 }
3152 else
3153 {
3154 newElmt->prev = curr;
3155 newElmt->next = curr->next;
3156 curr->next = newElmt;
3157 if (curr == last)
3158 last = newElmt;
3159 else
3160 newElmt->next->prev = newElmt;
3161 }
3162 count++;
3163 return *this;
3164 } // GeneralSubtrees::InsertAfterAndCopy
3165
3166
3167 // remove current element from list if current element is not NULL
3168 // The new current element will be the next element.
3169 // If the current element is the last element in the list
3170 // the second but last element will become the new current element.
3171 void GeneralSubtrees::RemoveCurrFromList()
3172 {
3173 AsnListElmt *del_elmt;
3174
3175 if (curr != NULL)
3176 {
3177 del_elmt = curr;
3178 count--;
3179
3180 if (count == 0)
3181 first = last = curr = NULL;
3182 else if (curr == first)
3183 {
3184 curr = first= first->next;
3185 first->prev = NULL;
3186 }
3187 else if (curr == last)
3188 {
3189 curr = last = last->prev;
3190 last->next = NULL;
3191 }
3192 else
3193 {
3194 curr->prev->next = curr->next;
3195 curr->next->prev = curr->prev;
3196 }
3197
3198 delete del_elmt->elmt;
3199 delete del_elmt;
3200 }
3201 }
3202
3203
3204 AsnLen GeneralSubtrees::BEncContent (BUF_TYPE b)
3205 {
3206 AsnListElmt *currElmt;
3207 AsnLen elmtLen;
3208 AsnLen totalLen = 0;
3209 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
3210 {
3211 BEncEocIfNec (b);
3212 elmtLen = currElmt->elmt->BEncContent (b);
3213 elmtLen += BEncConsLen (b, elmtLen);
3214
3215 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3216 totalLen += elmtLen;
3217 }
3218 return totalLen;
3219 } // GeneralSubtrees::BEncContent
3220
3221
3222 void GeneralSubtrees::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
3223 AsnLen &bytesDecoded, ENV_TYPE env)
3224 {
3225 GeneralSubtree *listElmt;
3226 AsnTag tag1;
3227 AsnLen listBytesDecoded = 0;
3228 AsnLen elmtLen1;
3229
3230 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
3231 {
3232 tag1 = BDecTag (b, listBytesDecoded, env);
3233 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
3234 {
3235 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
3236 break;
3237 }
3238 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
3239 {
3240 Asn1Error << "Unexpected Tag" << endl;
3241 longjmp (env, -123);
3242 }
3243
3244 elmtLen1 = BDecLen (b, listBytesDecoded, env);
3245 listElmt = Append();
3246 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
3247 }
3248
3249 bytesDecoded += listBytesDecoded;
3250 } // GeneralSubtrees::BDecContent
3251
3252
3253 AuthorityKeyIdentifier::AuthorityKeyIdentifier()
3254 {
3255 keyIdentifier = NULL;
3256 authorityCertIssuer = NULL;
3257 authorityCertSerialNumber = NULL;
3258 }
3259
3260 AuthorityKeyIdentifier::AuthorityKeyIdentifier (const AuthorityKeyIdentifier &)
3261 {
3262 Asn1Error << "use of incompletely defined AuthorityKeyIdentifier::AuthorityKeyIdentifier (const AuthorityKeyIdentifier &)" << endl;
3263 abort();
3264 }
3265
3266 AuthorityKeyIdentifier::~AuthorityKeyIdentifier()
3267 {
3268 delete keyIdentifier;
3269 delete authorityCertIssuer;
3270 delete authorityCertSerialNumber;
3271 }
3272
3273 AsnType *AuthorityKeyIdentifier::Clone() const
3274 {
3275 return new AuthorityKeyIdentifier;
3276 }
3277
3278 AsnType *AuthorityKeyIdentifier::Copy() const
3279 {
3280 return new AuthorityKeyIdentifier (*this);
3281 }
3282
3283 #if SNACC_DEEP_COPY
3284 AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &that)
3285 #else // SNACC_DEEP_COPY
3286 AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &)
3287 #endif // SNACC_DEEP_COPY
3288 {
3289 #if SNACC_DEEP_COPY
3290 if (this != &that)
3291 {
3292 if (that.keyIdentifier)
3293 {
3294 if (!keyIdentifier)
3295 keyIdentifier = new KeyIdentifier;
3296 *keyIdentifier = *that.keyIdentifier;
3297 }
3298 else
3299 {
3300 delete keyIdentifier;
3301 keyIdentifier = NULL;
3302 }
3303 if (that.authorityCertIssuer)
3304 {
3305 if (!authorityCertIssuer)
3306 authorityCertIssuer = new GeneralNames;
3307 *authorityCertIssuer = *that.authorityCertIssuer;
3308 }
3309 else
3310 {
3311 delete authorityCertIssuer;
3312 authorityCertIssuer = NULL;
3313 }
3314 if (that.authorityCertSerialNumber)
3315 {
3316 if (!authorityCertSerialNumber)
3317 authorityCertSerialNumber = new CertificateSerialNumber;
3318 *authorityCertSerialNumber = *that.authorityCertSerialNumber;
3319 }
3320 else
3321 {
3322 delete authorityCertSerialNumber;
3323 authorityCertSerialNumber = NULL;
3324 }
3325 }
3326
3327 return *this;
3328 #else // SNACC_DEEP_COPY
3329 Asn1Error << "use of incompletely defined AuthorityKeyIdentifier &AuthorityKeyIdentifier::operator = (const AuthorityKeyIdentifier &)" << endl;
3330 abort();
3331 // if your compiler complains here, check the -novolat option
3332 #endif // SNACC_DEEP_COPY
3333 }
3334
3335 AsnLen
3336 AuthorityKeyIdentifier::BEncContent (BUF_TYPE b)
3337 {
3338 AsnLen totalLen = 0;
3339 AsnLen l;
3340
3341 if (NOT_NULL (authorityCertSerialNumber))
3342 {
3343 l = authorityCertSerialNumber->BEncContent (b);
3344 l += BEncDefLen (b, l);
3345
3346 l += BEncTag1 (b, CNTX, PRIM, 2);
3347 totalLen += l;
3348 }
3349
3350 if (NOT_NULL (authorityCertIssuer))
3351 {
3352 BEncEocIfNec (b);
3353 l = authorityCertIssuer->BEncContent (b);
3354 l += BEncConsLen (b, l);
3355
3356 l += BEncTag1 (b, CNTX, CONS, 1);
3357 totalLen += l;
3358 }
3359
3360 if (NOT_NULL (keyIdentifier))
3361 {
3362 l = keyIdentifier->BEncContent (b);
3363 l += BEncDefLen (b, l);
3364
3365 l += BEncTag1 (b, CNTX, PRIM, 0);
3366 totalLen += l;
3367 }
3368
3369 return totalLen;
3370 } // AuthorityKeyIdentifier::BEncContent
3371
3372
3373 void AuthorityKeyIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
3374 {
3375 AsnTag tag1;
3376 AsnLen seqBytesDecoded = 0;
3377 AsnLen elmtLen1;
3378 if (elmtLen0 == 0)
3379 return;
3380 else
3381 {
3382 tag1 = BDecTag (b, seqBytesDecoded, env);
3383
3384 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
3385 {
3386 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
3387 bytesDecoded += seqBytesDecoded;
3388 return;
3389 }
3390 }
3391
3392 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))
3393 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
3394 {
3395 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3396 keyIdentifier = new KeyIdentifier;
3397 keyIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3398 if (seqBytesDecoded == elmtLen0)
3399 {
3400 bytesDecoded += seqBytesDecoded;
3401 return;
3402 }
3403 else
3404 {
3405 tag1 = BDecTag (b, seqBytesDecoded, env);
3406
3407 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
3408 {
3409 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
3410 bytesDecoded += seqBytesDecoded;
3411 return;
3412 }
3413 }
3414 }
3415
3416 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
3417 {
3418 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3419 authorityCertIssuer = new GeneralNames;
3420 authorityCertIssuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3421 if (seqBytesDecoded == elmtLen0)
3422 {
3423 bytesDecoded += seqBytesDecoded;
3424 return;
3425 }
3426 else
3427 {
3428 tag1 = BDecTag (b, seqBytesDecoded, env);
3429
3430 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
3431 {
3432 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
3433 bytesDecoded += seqBytesDecoded;
3434 return;
3435 }
3436 }
3437 }
3438
3439 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2))
3440 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2)))
3441 {
3442 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3443 authorityCertSerialNumber = new CertificateSerialNumber;
3444 authorityCertSerialNumber->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3445 }
3446
3447 bytesDecoded += seqBytesDecoded;
3448 if (elmtLen0 == INDEFINITE_LEN)
3449 {
3450 BDecEoc (b, bytesDecoded, env);
3451 return;
3452 }
3453 else if (seqBytesDecoded != elmtLen0)
3454 {
3455 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
3456 longjmp (env, -124);
3457 }
3458 else
3459 return;
3460 } // AuthorityKeyIdentifier::BDecContent
3461
3462 AsnLen AuthorityKeyIdentifier::BEnc (BUF_TYPE b)
3463 {
3464 AsnLen l;
3465 l = BEncContent (b);
3466 l += BEncConsLen (b, l);
3467 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3468 return l;
3469 }
3470
3471 void AuthorityKeyIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3472 {
3473 AsnTag tag;
3474 AsnLen elmtLen1;
3475
3476 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3477 {
3478 Asn1Error << "AuthorityKeyIdentifier::BDec: ERROR - wrong tag" << endl;
3479 longjmp (env, -125);
3480 }
3481 elmtLen1 = BDecLen (b, bytesDecoded, env);
3482 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3483 }
3484
3485 int AuthorityKeyIdentifier::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
3486 {
3487 bytesEncoded = BEnc (b);
3488 return !b.WriteError();
3489 }
3490
3491 int AuthorityKeyIdentifier::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
3492 {
3493 ENV_TYPE env;
3494 int val;
3495
3496 bytesDecoded = 0;
3497 if ((val = setjmp (env)) == 0)
3498 {
3499 BDec (b, bytesDecoded, env);
3500 return !b.ReadError();
3501 }
3502 else
3503 return false;
3504 }
3505
3506 void AuthorityKeyIdentifier::Print (ostream &os) const
3507 {
3508 #ifndef NDEBUG
3509 int nonePrinted = true;
3510 os << "{ -- SEQUENCE --" << endl;
3511 indentG += stdIndentG;
3512
3513 if (NOT_NULL (keyIdentifier))
3514 {
3515 nonePrinted = false;
3516 Indent (os, indentG);
3517 os << "keyIdentifier ";
3518 os << *keyIdentifier;
3519 }
3520 else
3521 {
3522 Indent (os, indentG);
3523 os << "keyIdentifier ";
3524 os << "-- void --";
3525 os << "," << endl;
3526 }
3527
3528 if (NOT_NULL (authorityCertIssuer))
3529 {
3530 if (!nonePrinted)
3531 os << "," << endl;
3532 nonePrinted = false;
3533 Indent (os, indentG);
3534 os << "authorityCertIssuer ";
3535 os << *authorityCertIssuer;
3536 }
3537 else
3538 {
3539 Indent (os, indentG);
3540 os << "authorityCertIssuer ";
3541 os << "-- void --";
3542 os << "," << endl;
3543 }
3544
3545 if (NOT_NULL (authorityCertSerialNumber))
3546 {
3547 if (!nonePrinted)
3548 os << "," << endl;
3549 nonePrinted = false;
3550 Indent (os, indentG);
3551 os << "authorityCertSerialNumber ";
3552 os << *authorityCertSerialNumber;
3553 }
3554 else
3555 {
3556 Indent (os, indentG);
3557 os << "authorityCertSerialNumber ";
3558 os << "-- void --";
3559 os << endl;
3560 }
3561
3562 os << endl;
3563 indentG -= stdIndentG;
3564 Indent (os, indentG);
3565 os << "}";
3566 #endif /* NDEBUG */
3567 } // AuthorityKeyIdentifier::Print
3568
3569
3570 AsnType *ExtKeyUsageSyntax::Clone() const
3571 {
3572 return new ExtKeyUsageSyntax;
3573 }
3574
3575 AsnType *ExtKeyUsageSyntax::Copy() const
3576 {
3577 return new ExtKeyUsageSyntax (*this);
3578 }
3579
3580 AsnLen ExtKeyUsageSyntax::BEnc (BUF_TYPE b)
3581 {
3582 AsnLen l;
3583 l = BEncContent (b);
3584 l += BEncConsLen (b, l);
3585 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3586 return l;
3587 }
3588
3589 void ExtKeyUsageSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3590 {
3591 AsnTag tag;
3592 AsnLen elmtLen1;
3593
3594 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3595 {
3596 Asn1Error << "ExtKeyUsageSyntax::BDec: ERROR - wrong tag" << endl;
3597 longjmp (env, -126);
3598 }
3599 elmtLen1 = BDecLen (b, bytesDecoded, env);
3600 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3601 }
3602
3603 ExtKeyUsageSyntax::ExtKeyUsageSyntax (const ExtKeyUsageSyntax &)
3604 {
3605 Asn1Error << "use of incompletely defined ExtKeyUsageSyntax::ExtKeyUsageSyntax (const ExtKeyUsageSyntax &)" << endl;
3606 abort();
3607 }
3608
3609 ExtKeyUsageSyntax::~ExtKeyUsageSyntax()
3610 {
3611 SetCurrToFirst();
3612 for (; Curr() != NULL; RemoveCurrFromList())
3613 ;
3614 } // end of destructor
3615
3616 #if SNACC_DEEP_COPY
3617 ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &that)
3618 #else // SNACC_DEEP_COPY
3619 ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &)
3620 #endif // SNACC_DEEP_COPY
3621 {
3622 #if SNACC_DEEP_COPY
3623 if (this != &that)
3624 {
3625 SetCurrToFirst();
3626 for (; Curr(); RemoveCurrFromList())
3627 ;
3628
3629 //that.SetCurrToFirst();
3630 //for (; that.Curr(); that.GoNext())
3631 // AppendCopy (*that.Curr());
3632 for (const AsnListElmt *run=that.first; run; run=run->next)
3633 AppendCopy (*run->elmt);
3634 }
3635
3636 return *this;
3637 #else // SNACC_DEEP_COPY
3638 Asn1Error << "use of incompletely defined ExtKeyUsageSyntax &ExtKeyUsageSyntax::operator = (const ExtKeyUsageSyntax &)" << endl;
3639 abort();
3640 // if your compiler complains here, check the -novolat option
3641 #endif // SNACC_DEEP_COPY
3642 }
3643
3644 void ExtKeyUsageSyntax::Print (ostream &os) const
3645 {
3646 #ifndef NDEBUG
3647 os << "{ -- SEQUENCE/SET OF -- " << endl;
3648 indentG += stdIndentG;
3649 //SetCurrToFirst();
3650 //for (; Curr() != NULL; GoNext())
3651 for (const AsnListElmt *run=first; run; run=run->next)
3652 {
3653 Indent (os, indentG);
3654 //os << *Curr();
3655 os << *run->elmt;
3656 //if (Curr() != Last())
3657 if (run != last)
3658 os << ",";
3659 os << endl;
3660 }
3661 indentG -= stdIndentG;
3662 Indent (os, indentG);
3663 os << "}\n";
3664 #endif /* NDEBUG */
3665
3666
3667 } // Print
3668
3669
3670 void ExtKeyUsageSyntax::SetCurrElmt (unsigned long int index)
3671 {
3672 unsigned long int i;
3673 curr = first;
3674 if (count)
3675 for (i = 0; (i < (count-1)) && (i < index); i++)
3676 curr = curr->next;
3677 } // ExtKeyUsageSyntax::SetCurrElmt
3678
3679
3680 unsigned long int ExtKeyUsageSyntax::GetCurrElmtIndex()
3681 {
3682 unsigned long int i;
3683 AsnListElmt *tmp;
3684 if (curr != NULL)
3685 {
3686 for (i = 0, tmp = first; tmp != NULL; i++)
3687 {
3688 if (tmp == curr)
3689 return i;
3690 else
3691 tmp = tmp->next;
3692 }
3693 }
3694 return count;
3695 } // ExtKeyUsageSyntax::GetCurrElmtIndex
3696
3697
3698 // alloc new list elmt, put at end of list
3699 // and return the component type
3700 KeyPurposeId *ExtKeyUsageSyntax::Append()
3701 {
3702 AsnListElmt *newElmt;
3703 newElmt = new AsnListElmt;
3704 newElmt->elmt = new KeyPurposeId;
3705 newElmt->next = NULL;
3706 if (last == NULL)
3707 {
3708 newElmt->prev = NULL;
3709 first = last = newElmt;
3710 }
3711 else
3712 {
3713 newElmt->prev = last;
3714 last->next = newElmt;
3715 last = newElmt;
3716 }
3717 count++;
3718 return (curr = newElmt)->elmt;
3719 } // ExtKeyUsageSyntax::Append
3720
3721
3722 // alloc new list elmt, put at begining of list
3723 // and return the component type
3724 KeyPurposeId *ExtKeyUsageSyntax::Prepend()
3725 {
3726 AsnListElmt *newElmt;
3727 newElmt = new AsnListElmt;
3728 newElmt->elmt = new KeyPurposeId;
3729 newElmt->prev = NULL;
3730 if (first == NULL)
3731 {
3732 newElmt->next = NULL;
3733 first = last = newElmt;
3734 }
3735 else
3736 {
3737 newElmt->next = first;
3738 first->prev = newElmt;
3739 first = newElmt;
3740 }
3741 count++;
3742 return (curr = newElmt)->elmt;
3743 } // ExtKeyUsageSyntax::Prepend
3744
3745
3746 // alloc new list elmt, insert it before the
3747 // current element and return the component type
3748 // if the current element is null, the new element
3749 // is placed at the beginning of the list.
3750 KeyPurposeId *ExtKeyUsageSyntax::InsertBefore()
3751 {
3752 AsnListElmt *newElmt;
3753 newElmt = new AsnListElmt;
3754 newElmt->elmt = new KeyPurposeId;
3755 if (curr == NULL)
3756 {
3757 newElmt->next = first;
3758 newElmt->prev = NULL;
3759 first = newElmt;
3760 if (last == NULL)
3761 last = newElmt;
3762 }
3763 else
3764 {
3765 newElmt->next = curr;
3766 newElmt->prev = curr->prev;
3767 curr->prev = newElmt;
3768 if (curr == first)
3769 first = newElmt;
3770 else
3771 newElmt->prev->next = newElmt;
3772 }
3773 count++;
3774 return (curr = newElmt)->elmt;
3775 } // ExtKeyUsageSyntax::InsertBefore
3776
3777
3778 // alloc new list elmt, insert it after the
3779 // current element and return the component type
3780 // if the current element is null, the new element
3781 // is placed at the end of the list.
3782 KeyPurposeId *ExtKeyUsageSyntax::InsertAfter()
3783 {
3784 AsnListElmt *newElmt;
3785 newElmt = new AsnListElmt;
3786 newElmt->elmt = new KeyPurposeId;
3787 if (curr == NULL)
3788 {
3789 newElmt->prev = last;
3790 newElmt->next = NULL;
3791 last = newElmt;
3792 if (first == NULL)
3793 first = newElmt;
3794 }
3795 else
3796 {
3797 newElmt->prev = curr;
3798 newElmt->next = curr->next;
3799 curr->next = newElmt;
3800 if (curr == last)
3801 last = newElmt;
3802 else
3803 newElmt->next->prev = newElmt;
3804 }
3805 count++;
3806 return (curr = newElmt)->elmt;
3807 } // ExtKeyUsageSyntax::InsertAfter
3808
3809
3810 ExtKeyUsageSyntax &ExtKeyUsageSyntax::AppendCopy (KeyPurposeId &elmt)
3811 {
3812 AsnListElmt *newElmt;
3813 newElmt = new AsnListElmt;
3814 newElmt->elmt = new KeyPurposeId;
3815 *newElmt->elmt = elmt;
3816 newElmt->next = NULL;
3817 if (last == NULL)
3818 {
3819 newElmt->prev = NULL;
3820 first = last = newElmt;
3821 }
3822 else
3823 {
3824 newElmt->prev = last;
3825 last->next = newElmt;
3826 last = newElmt;
3827 }
3828 count++;
3829 return *this;
3830 } // AppendCopy
3831
3832
3833 ExtKeyUsageSyntax &ExtKeyUsageSyntax::PrependCopy (KeyPurposeId &elmt)
3834 {
3835 AsnListElmt *newElmt;
3836 newElmt = new AsnListElmt;
3837 newElmt->elmt = new KeyPurposeId;
3838 *newElmt->elmt = elmt;
3839 newElmt->prev = NULL;
3840 if (first == NULL)
3841 {
3842 newElmt->next = NULL;
3843 first = last = newElmt;
3844 }
3845 else
3846 {
3847 newElmt->next = first;
3848 first->prev = newElmt;
3849 first = newElmt;
3850 }
3851 count++;
3852 return *this;
3853 } // ExtKeyUsageSyntax::PrependCopy
3854
3855
3856 // alloc new list elmt, insert it before the
3857 // current element, copy the given elmt into the new elmt
3858 // and return the component type.
3859 // if the current element is null, the new element
3860 // is placed at the beginning of the list.
3861 ExtKeyUsageSyntax &ExtKeyUsageSyntax::InsertBeforeAndCopy (KeyPurposeId &elmt)
3862 {
3863 AsnListElmt *newElmt;
3864
3865 newElmt = new AsnListElmt;
3866 newElmt->elmt = new KeyPurposeId;
3867 *newElmt->elmt = elmt;
3868
3869 if (curr == NULL)
3870 {
3871 newElmt->next = first;
3872 newElmt->prev = NULL;
3873 first = newElmt;
3874 if (last == NULL)
3875 last = newElmt;
3876 }
3877 else
3878 {
3879 newElmt->next = curr;
3880 newElmt->prev = curr->prev;
3881 curr->prev = newElmt;
3882 if (curr == first)
3883 first = newElmt;
3884 else
3885 newElmt->prev->next = newElmt;
3886 }
3887 count++;
3888 return *this;
3889 } // ExtKeyUsageSyntax::InsertBeforeAndCopy
3890
3891
3892 // alloc new list elmt, insert it after the
3893 // current element, copy given elmt in to new elmt
3894 // and return the component type
3895 // if the current element is null, the new element
3896 // is placed at the end of the list.
3897 ExtKeyUsageSyntax &ExtKeyUsageSyntax::InsertAfterAndCopy (KeyPurposeId &elmt)
3898 {
3899 AsnListElmt *newElmt;
3900
3901 newElmt = new AsnListElmt;
3902 newElmt->elmt = new KeyPurposeId;
3903 *newElmt->elmt = elmt;
3904 if (curr == NULL)
3905 {
3906 newElmt->prev = last;
3907 newElmt->next = NULL;
3908 last = newElmt;
3909 if (first == NULL)
3910 first = newElmt;
3911 }
3912 else
3913 {
3914 newElmt->prev = curr;
3915 newElmt->next = curr->next;
3916 curr->next = newElmt;
3917 if (curr == last)
3918 last = newElmt;
3919 else
3920 newElmt->next->prev = newElmt;
3921 }
3922 count++;
3923 return *this;
3924 } // ExtKeyUsageSyntax::InsertAfterAndCopy
3925
3926
3927 // remove current element from list if current element is not NULL
3928 // The new current element will be the next element.
3929 // If the current element is the last element in the list
3930 // the second but last element will become the new current element.
3931 void ExtKeyUsageSyntax::RemoveCurrFromList()
3932 {
3933 AsnListElmt *del_elmt;
3934
3935 if (curr != NULL)
3936 {
3937 del_elmt = curr;
3938 count--;
3939
3940 if (count == 0)
3941 first = last = curr = NULL;
3942 else if (curr == first)
3943 {
3944 curr = first= first->next;
3945 first->prev = NULL;
3946 }
3947 else if (curr == last)
3948 {
3949 curr = last = last->prev;
3950 last->next = NULL;
3951 }
3952 else
3953 {
3954 curr->prev->next = curr->next;
3955 curr->next->prev = curr->prev;
3956 }
3957
3958 delete del_elmt->elmt;
3959 delete del_elmt;
3960 }
3961 }
3962
3963
3964 AsnLen ExtKeyUsageSyntax::BEncContent (BUF_TYPE b)
3965 {
3966 AsnListElmt *currElmt;
3967 AsnLen elmtLen;
3968 AsnLen totalLen = 0;
3969 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
3970 {
3971 elmtLen = currElmt->elmt->BEncContent (b);
3972 elmtLen += BEncDefLen (b, elmtLen);
3973
3974 elmtLen += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
3975 totalLen += elmtLen;
3976 }
3977 return totalLen;
3978 } // ExtKeyUsageSyntax::BEncContent
3979
3980
3981 void ExtKeyUsageSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
3982 AsnLen &bytesDecoded, ENV_TYPE env)
3983 {
3984 KeyPurposeId *listElmt;
3985 AsnTag tag1;
3986 AsnLen listBytesDecoded = 0;
3987 AsnLen elmtLen1;
3988
3989 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
3990 {
3991 tag1 = BDecTag (b, listBytesDecoded, env);
3992 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
3993 {
3994 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
3995 break;
3996 }
3997 if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
3998 {
3999 Asn1Error << "Unexpected Tag" << endl;
4000 longjmp (env, -127);
4001 }
4002
4003 elmtLen1 = BDecLen (b, listBytesDecoded, env);
4004 listElmt = Append();
4005 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
4006 }
4007
4008 bytesDecoded += listBytesDecoded;
4009 } // ExtKeyUsageSyntax::BDecContent
4010
4011
4012 PrivateKeyUsagePeriod::PrivateKeyUsagePeriod()
4013 {
4014 notBefore = NULL;
4015 notAfter = NULL;
4016 }
4017
4018 PrivateKeyUsagePeriod::PrivateKeyUsagePeriod (const PrivateKeyUsagePeriod &)
4019 {
4020 Asn1Error << "use of incompletely defined PrivateKeyUsagePeriod::PrivateKeyUsagePeriod (const PrivateKeyUsagePeriod &)" << endl;
4021 abort();
4022 }
4023
4024 PrivateKeyUsagePeriod::~PrivateKeyUsagePeriod()
4025 {
4026 delete notBefore;
4027 delete notAfter;
4028 }
4029
4030 AsnType *PrivateKeyUsagePeriod::Clone() const
4031 {
4032 return new PrivateKeyUsagePeriod;
4033 }
4034
4035 AsnType *PrivateKeyUsagePeriod::Copy() const
4036 {
4037 return new PrivateKeyUsagePeriod (*this);
4038 }
4039
4040 #if SNACC_DEEP_COPY
4041 PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &that)
4042 #else // SNACC_DEEP_COPY
4043 PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &)
4044 #endif // SNACC_DEEP_COPY
4045 {
4046 #if SNACC_DEEP_COPY
4047 if (this != &that)
4048 {
4049 if (that.notBefore)
4050 {
4051 if (!notBefore)
4052 notBefore = new GeneralizedTime;
4053 *notBefore = *that.notBefore;
4054 }
4055 else
4056 {
4057 delete notBefore;
4058 notBefore = NULL;
4059 }
4060 if (that.notAfter)
4061 {
4062 if (!notAfter)
4063 notAfter = new GeneralizedTime;
4064 *notAfter = *that.notAfter;
4065 }
4066 else
4067 {
4068 delete notAfter;
4069 notAfter = NULL;
4070 }
4071 }
4072
4073 return *this;
4074 #else // SNACC_DEEP_COPY
4075 Asn1Error << "use of incompletely defined PrivateKeyUsagePeriod &PrivateKeyUsagePeriod::operator = (const PrivateKeyUsagePeriod &)" << endl;
4076 abort();
4077 // if your compiler complains here, check the -novolat option
4078 #endif // SNACC_DEEP_COPY
4079 }
4080
4081 AsnLen
4082 PrivateKeyUsagePeriod::BEncContent (BUF_TYPE b)
4083 {
4084 AsnLen totalLen = 0;
4085 AsnLen l;
4086
4087 if (NOT_NULL (notAfter))
4088 {
4089 l = notAfter->BEncContent (b);
4090 l += BEncDefLen (b, l);
4091
4092 l += BEncTag1 (b, CNTX, PRIM, 1);
4093 totalLen += l;
4094 }
4095
4096 if (NOT_NULL (notBefore))
4097 {
4098 l = notBefore->BEncContent (b);
4099 l += BEncDefLen (b, l);
4100
4101 l += BEncTag1 (b, CNTX, PRIM, 0);
4102 totalLen += l;
4103 }
4104
4105 return totalLen;
4106 } // PrivateKeyUsagePeriod::BEncContent
4107
4108
4109 void PrivateKeyUsagePeriod::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
4110 {
4111 AsnTag tag1;
4112 AsnLen seqBytesDecoded = 0;
4113 AsnLen elmtLen1;
4114 if (elmtLen0 == 0)
4115 return;
4116 else
4117 {
4118 tag1 = BDecTag (b, seqBytesDecoded, env);
4119
4120 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4121 {
4122 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4123 bytesDecoded += seqBytesDecoded;
4124 return;
4125 }
4126 }
4127
4128 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))
4129 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
4130 {
4131 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4132 notBefore = new GeneralizedTime;
4133 notBefore->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4134 if (seqBytesDecoded == elmtLen0)
4135 {
4136 bytesDecoded += seqBytesDecoded;
4137 return;
4138 }
4139 else
4140 {
4141 tag1 = BDecTag (b, seqBytesDecoded, env);
4142
4143 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4144 {
4145 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4146 bytesDecoded += seqBytesDecoded;
4147 return;
4148 }
4149 }
4150 }
4151
4152 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))
4153 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
4154 {
4155 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4156 notAfter = new GeneralizedTime;
4157 notAfter->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4158 }
4159
4160 bytesDecoded += seqBytesDecoded;
4161 if (elmtLen0 == INDEFINITE_LEN)
4162 {
4163 BDecEoc (b, bytesDecoded, env);
4164 return;
4165 }
4166 else if (seqBytesDecoded != elmtLen0)
4167 {
4168 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
4169 longjmp (env, -128);
4170 }
4171 else
4172 return;
4173 } // PrivateKeyUsagePeriod::BDecContent
4174
4175 AsnLen PrivateKeyUsagePeriod::BEnc (BUF_TYPE b)
4176 {
4177 AsnLen l;
4178 l = BEncContent (b);
4179 l += BEncConsLen (b, l);
4180 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4181 return l;
4182 }
4183
4184 void PrivateKeyUsagePeriod::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
4185 {
4186 AsnTag tag;
4187 AsnLen elmtLen1;
4188
4189 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4190 {
4191 Asn1Error << "PrivateKeyUsagePeriod::BDec: ERROR - wrong tag" << endl;
4192 longjmp (env, -129);
4193 }
4194 elmtLen1 = BDecLen (b, bytesDecoded, env);
4195 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
4196 }
4197
4198 int PrivateKeyUsagePeriod::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
4199 {
4200 bytesEncoded = BEnc (b);
4201 return !b.WriteError();
4202 }
4203
4204 int PrivateKeyUsagePeriod::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
4205 {
4206 ENV_TYPE env;
4207 int val;
4208
4209 bytesDecoded = 0;
4210 if ((val = setjmp (env)) == 0)
4211 {
4212 BDec (b, bytesDecoded, env);
4213 return !b.ReadError();
4214 }
4215 else
4216 return false;
4217 }
4218
4219 void PrivateKeyUsagePeriod::Print (ostream &os) const
4220 {
4221 #ifndef NDEBUG
4222 int nonePrinted = true;
4223 os << "{ -- SEQUENCE --" << endl;
4224 indentG += stdIndentG;
4225
4226 if (NOT_NULL (notBefore))
4227 {
4228 nonePrinted = false;
4229 Indent (os, indentG);
4230 os << "notBefore ";
4231 os << *notBefore;
4232 }
4233 else
4234 {
4235 Indent (os, indentG);
4236 os << "notBefore ";
4237 os << "-- void --";
4238 os << "," << endl;
4239 }
4240
4241 if (NOT_NULL (notAfter))
4242 {
4243 if (!nonePrinted)
4244 os << "," << endl;
4245 nonePrinted = false;
4246 Indent (os, indentG);
4247 os << "notAfter ";
4248 os << *notAfter;
4249 }
4250 else
4251 {
4252 Indent (os, indentG);
4253 os << "notAfter ";
4254 os << "-- void --";
4255 os << endl;
4256 }
4257
4258 os << endl;
4259 indentG -= stdIndentG;
4260 Indent (os, indentG);
4261 os << "}";
4262 #endif /* NDEBUG */
4263 } // PrivateKeyUsagePeriod::Print
4264
4265
4266 AsnType *PolicyMappingsSyntax::Clone() const
4267 {
4268 return new PolicyMappingsSyntax;
4269 }
4270
4271 AsnType *PolicyMappingsSyntax::Copy() const
4272 {
4273 return new PolicyMappingsSyntax (*this);
4274 }
4275
4276 AsnLen PolicyMappingsSyntax::BEnc (BUF_TYPE b)
4277 {
4278 AsnLen l;
4279 l = BEncContent (b);
4280 l += BEncConsLen (b, l);
4281 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4282 return l;
4283 }
4284
4285 void PolicyMappingsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
4286 {
4287 AsnTag tag;
4288 AsnLen elmtLen1;
4289
4290 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4291 {
4292 Asn1Error << "PolicyMappingsSyntax::BDec: ERROR - wrong tag" << endl;
4293 longjmp (env, -130);
4294 }
4295 elmtLen1 = BDecLen (b, bytesDecoded, env);
4296 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
4297 }
4298
4299 PolicyMappingsSyntax::PolicyMappingsSyntax (const PolicyMappingsSyntax &)
4300 {
4301 Asn1Error << "use of incompletely defined PolicyMappingsSyntax::PolicyMappingsSyntax (const PolicyMappingsSyntax &)" << endl;
4302 abort();
4303 }
4304
4305 PolicyMappingsSyntax::~PolicyMappingsSyntax()
4306 {
4307 SetCurrToFirst();
4308 for (; Curr() != NULL; RemoveCurrFromList())
4309 ;
4310 } // end of destructor
4311
4312 #if SNACC_DEEP_COPY
4313 PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &that)
4314 #else // SNACC_DEEP_COPY
4315 PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &)
4316 #endif // SNACC_DEEP_COPY
4317 {
4318 #if SNACC_DEEP_COPY
4319 if (this != &that)
4320 {
4321 SetCurrToFirst();
4322 for (; Curr(); RemoveCurrFromList())
4323 ;
4324
4325 //that.SetCurrToFirst();
4326 //for (; that.Curr(); that.GoNext())
4327 // AppendCopy (*that.Curr());
4328 for (const AsnListElmt *run=that.first; run; run=run->next)
4329 AppendCopy (*run->elmt);
4330 }
4331
4332 return *this;
4333 #else // SNACC_DEEP_COPY
4334 Asn1Error << "use of incompletely defined PolicyMappingsSyntax &PolicyMappingsSyntax::operator = (const PolicyMappingsSyntax &)" << endl;
4335 abort();
4336 // if your compiler complains here, check the -novolat option
4337 #endif // SNACC_DEEP_COPY
4338 }
4339
4340 void PolicyMappingsSyntax::Print (ostream &os) const
4341 {
4342 #ifndef NDEBUG
4343 os << "{ -- SEQUENCE/SET OF -- " << endl;
4344 indentG += stdIndentG;
4345 //SetCurrToFirst();
4346 //for (; Curr() != NULL; GoNext())
4347 for (const AsnListElmt *run=first; run; run=run->next)
4348 {
4349 Indent (os, indentG);
4350 //os << *Curr();
4351 os << *run->elmt;
4352 //if (Curr() != Last())
4353 if (run != last)
4354 os << ",";
4355 os << endl;
4356 }
4357 indentG -= stdIndentG;
4358 Indent (os, indentG);
4359 os << "}\n";
4360 #endif /* NDEBUG */
4361
4362
4363 } // Print
4364
4365
4366 void PolicyMappingsSyntax::SetCurrElmt (unsigned long int index)
4367 {
4368 unsigned long int i;
4369 curr = first;
4370 if (count)
4371 for (i = 0; (i < (count-1)) && (i < index); i++)
4372 curr = curr->next;
4373 } // PolicyMappingsSyntax::SetCurrElmt
4374
4375
4376 unsigned long int PolicyMappingsSyntax::GetCurrElmtIndex()
4377 {
4378 unsigned long int i;
4379 AsnListElmt *tmp;
4380 if (curr != NULL)
4381 {
4382 for (i = 0, tmp = first; tmp != NULL; i++)
4383 {
4384 if (tmp == curr)
4385 return i;
4386 else
4387 tmp = tmp->next;
4388 }
4389 }
4390 return count;
4391 } // PolicyMappingsSyntax::GetCurrElmtIndex
4392
4393
4394 // alloc new list elmt, put at end of list
4395 // and return the component type
4396 PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::Append()
4397 {
4398 AsnListElmt *newElmt;
4399 newElmt = new AsnListElmt;
4400 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4401 newElmt->next = NULL;
4402 if (last == NULL)
4403 {
4404 newElmt->prev = NULL;
4405 first = last = newElmt;
4406 }
4407 else
4408 {
4409 newElmt->prev = last;
4410 last->next = newElmt;
4411 last = newElmt;
4412 }
4413 count++;
4414 return (curr = newElmt)->elmt;
4415 } // PolicyMappingsSyntax::Append
4416
4417
4418 // alloc new list elmt, put at begining of list
4419 // and return the component type
4420 PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::Prepend()
4421 {
4422 AsnListElmt *newElmt;
4423 newElmt = new AsnListElmt;
4424 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4425 newElmt->prev = NULL;
4426 if (first == NULL)
4427 {
4428 newElmt->next = NULL;
4429 first = last = newElmt;
4430 }
4431 else
4432 {
4433 newElmt->next = first;
4434 first->prev = newElmt;
4435 first = newElmt;
4436 }
4437 count++;
4438 return (curr = newElmt)->elmt;
4439 } // PolicyMappingsSyntax::Prepend
4440
4441
4442 // alloc new list elmt, insert it before the
4443 // current element and return the component type
4444 // if the current element is null, the new element
4445 // is placed at the beginning of the list.
4446 PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::InsertBefore()
4447 {
4448 AsnListElmt *newElmt;
4449 newElmt = new AsnListElmt;
4450 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4451 if (curr == NULL)
4452 {
4453 newElmt->next = first;
4454 newElmt->prev = NULL;
4455 first = newElmt;
4456 if (last == NULL)
4457 last = newElmt;
4458 }
4459 else
4460 {
4461 newElmt->next = curr;
4462 newElmt->prev = curr->prev;
4463 curr->prev = newElmt;
4464 if (curr == first)
4465 first = newElmt;
4466 else
4467 newElmt->prev->next = newElmt;
4468 }
4469 count++;
4470 return (curr = newElmt)->elmt;
4471 } // PolicyMappingsSyntax::InsertBefore
4472
4473
4474 // alloc new list elmt, insert it after the
4475 // current element and return the component type
4476 // if the current element is null, the new element
4477 // is placed at the end of the list.
4478 PolicyMappingsSyntaxSeq *PolicyMappingsSyntax::InsertAfter()
4479 {
4480 AsnListElmt *newElmt;
4481 newElmt = new AsnListElmt;
4482 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4483 if (curr == NULL)
4484 {
4485 newElmt->prev = last;
4486 newElmt->next = NULL;
4487 last = newElmt;
4488 if (first == NULL)
4489 first = newElmt;
4490 }
4491 else
4492 {
4493 newElmt->prev = curr;
4494 newElmt->next = curr->next;
4495 curr->next = newElmt;
4496 if (curr == last)
4497 last = newElmt;
4498 else
4499 newElmt->next->prev = newElmt;
4500 }
4501 count++;
4502 return (curr = newElmt)->elmt;
4503 } // PolicyMappingsSyntax::InsertAfter
4504
4505
4506 PolicyMappingsSyntax &PolicyMappingsSyntax::AppendCopy (PolicyMappingsSyntaxSeq &elmt)
4507 {
4508 AsnListElmt *newElmt;
4509 newElmt = new AsnListElmt;
4510 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4511 *newElmt->elmt = elmt;
4512 newElmt->next = NULL;
4513 if (last == NULL)
4514 {
4515 newElmt->prev = NULL;
4516 first = last = newElmt;
4517 }
4518 else
4519 {
4520 newElmt->prev = last;
4521 last->next = newElmt;
4522 last = newElmt;
4523 }
4524 count++;
4525 return *this;
4526 } // AppendCopy
4527
4528
4529 PolicyMappingsSyntax &PolicyMappingsSyntax::PrependCopy (PolicyMappingsSyntaxSeq &elmt)
4530 {
4531 AsnListElmt *newElmt;
4532 newElmt = new AsnListElmt;
4533 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4534 *newElmt->elmt = elmt;
4535 newElmt->prev = NULL;
4536 if (first == NULL)
4537 {
4538 newElmt->next = NULL;
4539 first = last = newElmt;
4540 }
4541 else
4542 {
4543 newElmt->next = first;
4544 first->prev = newElmt;
4545 first = newElmt;
4546 }
4547 count++;
4548 return *this;
4549 } // PolicyMappingsSyntax::PrependCopy
4550
4551
4552 // alloc new list elmt, insert it before the
4553 // current element, copy the given elmt into the new elmt
4554 // and return the component type.
4555 // if the current element is null, the new element
4556 // is placed at the beginning of the list.
4557 PolicyMappingsSyntax &PolicyMappingsSyntax::InsertBeforeAndCopy (PolicyMappingsSyntaxSeq &elmt)
4558 {
4559 AsnListElmt *newElmt;
4560
4561 newElmt = new AsnListElmt;
4562 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4563 *newElmt->elmt = elmt;
4564
4565 if (curr == NULL)
4566 {
4567 newElmt->next = first;
4568 newElmt->prev = NULL;
4569 first = newElmt;
4570 if (last == NULL)
4571 last = newElmt;
4572 }
4573 else
4574 {
4575 newElmt->next = curr;
4576 newElmt->prev = curr->prev;
4577 curr->prev = newElmt;
4578 if (curr == first)
4579 first = newElmt;
4580 else
4581 newElmt->prev->next = newElmt;
4582 }
4583 count++;
4584 return *this;
4585 } // PolicyMappingsSyntax::InsertBeforeAndCopy
4586
4587
4588 // alloc new list elmt, insert it after the
4589 // current element, copy given elmt in to new elmt
4590 // and return the component type
4591 // if the current element is null, the new element
4592 // is placed at the end of the list.
4593 PolicyMappingsSyntax &PolicyMappingsSyntax::InsertAfterAndCopy (PolicyMappingsSyntaxSeq &elmt)
4594 {
4595 AsnListElmt *newElmt;
4596
4597 newElmt = new AsnListElmt;
4598 newElmt->elmt = new PolicyMappingsSyntaxSeq;
4599 *newElmt->elmt = elmt;
4600 if (curr == NULL)
4601 {
4602 newElmt->prev = last;
4603 newElmt->next = NULL;
4604 last = newElmt;
4605 if (first == NULL)
4606 first = newElmt;
4607 }
4608 else
4609 {
4610 newElmt->prev = curr;
4611 newElmt->next = curr->next;
4612 curr->next = newElmt;
4613 if (curr == last)
4614 last = newElmt;
4615 else
4616 newElmt->next->prev = newElmt;
4617 }
4618 count++;
4619 return *this;
4620 } // PolicyMappingsSyntax::InsertAfterAndCopy
4621
4622
4623 // remove current element from list if current element is not NULL
4624 // The new current element will be the next element.
4625 // If the current element is the last element in the list
4626 // the second but last element will become the new current element.
4627 void PolicyMappingsSyntax::RemoveCurrFromList()
4628 {
4629 AsnListElmt *del_elmt;
4630
4631 if (curr != NULL)
4632 {
4633 del_elmt = curr;
4634 count--;
4635
4636 if (count == 0)
4637 first = last = curr = NULL;
4638 else if (curr == first)
4639 {
4640 curr = first= first->next;
4641 first->prev = NULL;
4642 }
4643 else if (curr == last)
4644 {
4645 curr = last = last->prev;
4646 last->next = NULL;
4647 }
4648 else
4649 {
4650 curr->prev->next = curr->next;
4651 curr->next->prev = curr->prev;
4652 }
4653
4654 delete del_elmt->elmt;
4655 delete del_elmt;
4656 }
4657 }
4658
4659
4660 AsnLen PolicyMappingsSyntax::BEncContent (BUF_TYPE b)
4661 {
4662 AsnListElmt *currElmt;
4663 AsnLen elmtLen;
4664 AsnLen totalLen = 0;
4665 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
4666 {
4667 BEncEocIfNec (b);
4668 elmtLen = currElmt->elmt->BEncContent (b);
4669 elmtLen += BEncConsLen (b, elmtLen);
4670
4671 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4672 totalLen += elmtLen;
4673 }
4674 return totalLen;
4675 } // PolicyMappingsSyntax::BEncContent
4676
4677
4678 void PolicyMappingsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
4679 AsnLen &bytesDecoded, ENV_TYPE env)
4680 {
4681 PolicyMappingsSyntaxSeq *listElmt;
4682 AsnTag tag1;
4683 AsnLen listBytesDecoded = 0;
4684 AsnLen elmtLen1;
4685
4686 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
4687 {
4688 tag1 = BDecTag (b, listBytesDecoded, env);
4689 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
4690 {
4691 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
4692 break;
4693 }
4694 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4695 {
4696 Asn1Error << "Unexpected Tag" << endl;
4697 longjmp (env, -131);
4698 }
4699
4700 elmtLen1 = BDecLen (b, listBytesDecoded, env);
4701 listElmt = Append();
4702 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
4703 }
4704
4705 bytesDecoded += listBytesDecoded;
4706 } // PolicyMappingsSyntax::BDecContent
4707
4708
4709 SupportedAlgorithm::SupportedAlgorithm()
4710 {
4711 #if TCL
4712 algorithmIdentifier = new AlgorithmIdentifier;
4713 #else
4714 algorithmIdentifier = NULL; // incomplete initialization of mandatory element!
4715 #endif // TCL
4716 intendedUsage = NULL;
4717 intendedCertificatePolicies = NULL;
4718 }
4719
4720 SupportedAlgorithm::SupportedAlgorithm (const SupportedAlgorithm &)
4721 {
4722 Asn1Error << "use of incompletely defined SupportedAlgorithm::SupportedAlgorithm (const SupportedAlgorithm &)" << endl;
4723 abort();
4724 }
4725
4726 SupportedAlgorithm::~SupportedAlgorithm()
4727 {
4728 delete algorithmIdentifier;
4729 delete intendedUsage;
4730 delete intendedCertificatePolicies;
4731 }
4732
4733 AsnType *SupportedAlgorithm::Clone() const
4734 {
4735 return new SupportedAlgorithm;
4736 }
4737
4738 AsnType *SupportedAlgorithm::Copy() const
4739 {
4740 return new SupportedAlgorithm (*this);
4741 }
4742
4743 #if SNACC_DEEP_COPY
4744 SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &that)
4745 #else // SNACC_DEEP_COPY
4746 SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &)
4747 #endif // SNACC_DEEP_COPY
4748 {
4749 #if SNACC_DEEP_COPY
4750 if (this != &that)
4751 {
4752 if (that.algorithmIdentifier)
4753 {
4754 if (!algorithmIdentifier)
4755 algorithmIdentifier = new AlgorithmIdentifier;
4756 *algorithmIdentifier = *that.algorithmIdentifier;
4757 }
4758 else
4759 {
4760 delete algorithmIdentifier;
4761 algorithmIdentifier = NULL;
4762 }
4763 if (that.intendedUsage)
4764 {
4765 if (!intendedUsage)
4766 intendedUsage = new KeyUsage;
4767 *intendedUsage = *that.intendedUsage;
4768 }
4769 else
4770 {
4771 delete intendedUsage;
4772 intendedUsage = NULL;
4773 }
4774 if (that.intendedCertificatePolicies)
4775 {
4776 if (!intendedCertificatePolicies)
4777 intendedCertificatePolicies = new CertificatePoliciesSyntax;
4778 *intendedCertificatePolicies = *that.intendedCertificatePolicies;
4779 }
4780 else
4781 {
4782 delete intendedCertificatePolicies;
4783 intendedCertificatePolicies = NULL;
4784 }
4785 }
4786
4787 return *this;
4788 #else // SNACC_DEEP_COPY
4789 Asn1Error << "use of incompletely defined SupportedAlgorithm &SupportedAlgorithm::operator = (const SupportedAlgorithm &)" << endl;
4790 abort();
4791 // if your compiler complains here, check the -novolat option
4792 #endif // SNACC_DEEP_COPY
4793 }
4794
4795 AsnLen
4796 SupportedAlgorithm::BEncContent (BUF_TYPE b)
4797 {
4798 AsnLen totalLen = 0;
4799 AsnLen l;
4800
4801 if (NOT_NULL (intendedCertificatePolicies))
4802 {
4803 BEncEocIfNec (b);
4804 l = intendedCertificatePolicies->BEncContent (b);
4805 l += BEncConsLen (b, l);
4806
4807 l += BEncTag1 (b, CNTX, CONS, 1);
4808 totalLen += l;
4809 }
4810
4811 if (NOT_NULL (intendedUsage))
4812 {
4813 l = intendedUsage->BEncContent (b);
4814 l += BEncDefLen (b, l);
4815
4816 l += BEncTag1 (b, CNTX, PRIM, 0);
4817 totalLen += l;
4818 }
4819
4820 BEncEocIfNec (b);
4821 l = algorithmIdentifier->BEncContent (b);
4822 l += BEncConsLen (b, l);
4823
4824 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4825 totalLen += l;
4826
4827 return totalLen;
4828 } // SupportedAlgorithm::BEncContent
4829
4830
4831 void SupportedAlgorithm::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
4832 {
4833 AsnTag tag1;
4834 AsnLen seqBytesDecoded = 0;
4835 AsnLen elmtLen1;
4836 tag1 = BDecTag (b, seqBytesDecoded, env);
4837
4838 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4839 {
4840 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4841 algorithmIdentifier = new AlgorithmIdentifier;
4842 algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4843 if (seqBytesDecoded == elmtLen0)
4844 {
4845 bytesDecoded += seqBytesDecoded;
4846 return;
4847 }
4848 else
4849 {
4850 tag1 = BDecTag (b, seqBytesDecoded, env);
4851
4852 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4853 {
4854 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4855 bytesDecoded += seqBytesDecoded;
4856 return;
4857 }
4858 }
4859 }
4860 else
4861 {
4862 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4863 longjmp (env, -132);
4864 }
4865
4866 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0))
4867 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
4868 {
4869 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4870 intendedUsage = new KeyUsage;
4871 intendedUsage->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4872 if (seqBytesDecoded == elmtLen0)
4873 {
4874 bytesDecoded += seqBytesDecoded;
4875 return;
4876 }
4877 else
4878 {
4879 tag1 = BDecTag (b, seqBytesDecoded, env);
4880
4881 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4882 {
4883 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4884 bytesDecoded += seqBytesDecoded;
4885 return;
4886 }
4887 }
4888 }
4889
4890 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
4891 {
4892 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4893 intendedCertificatePolicies = new CertificatePoliciesSyntax;
4894 intendedCertificatePolicies->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4895 }
4896
4897 bytesDecoded += seqBytesDecoded;
4898 if (elmtLen0 == INDEFINITE_LEN)
4899 {
4900 BDecEoc (b, bytesDecoded, env);
4901 return;
4902 }
4903 else if (seqBytesDecoded != elmtLen0)
4904 {
4905 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
4906 longjmp (env, -133);
4907 }
4908 else
4909 return;
4910 } // SupportedAlgorithm::BDecContent
4911
4912 AsnLen SupportedAlgorithm::BEnc (BUF_TYPE b)
4913 {
4914 AsnLen l;
4915 l = BEncContent (b);
4916 l += BEncConsLen (b, l);
4917 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4918 return l;
4919 }
4920
4921 void SupportedAlgorithm::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
4922 {
4923 AsnTag tag;
4924 AsnLen elmtLen1;
4925
4926 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4927 {
4928 Asn1Error << "SupportedAlgorithm::BDec: ERROR - wrong tag" << endl;
4929 longjmp (env, -134);
4930 }
4931 elmtLen1 = BDecLen (b, bytesDecoded, env);
4932 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
4933 }
4934
4935 int SupportedAlgorithm::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
4936 {
4937 bytesEncoded = BEnc (b);
4938 return !b.WriteError();
4939 }
4940
4941 int SupportedAlgorithm::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
4942 {
4943 ENV_TYPE env;
4944 int val;
4945
4946 bytesDecoded = 0;
4947 if ((val = setjmp (env)) == 0)
4948 {
4949 BDec (b, bytesDecoded, env);
4950 return !b.ReadError();
4951 }
4952 else
4953 return false;
4954 }
4955
4956 void SupportedAlgorithm::Print (ostream &os) const
4957 {
4958 #ifndef NDEBUG
4959 os << "{ -- SEQUENCE --" << endl;
4960 indentG += stdIndentG;
4961
4962 if (NOT_NULL (algorithmIdentifier))
4963 {
4964 Indent (os, indentG);
4965 os << "algorithmIdentifier ";
4966 os << *algorithmIdentifier;
4967 }
4968 else
4969 {
4970 Indent (os, indentG);
4971 os << "algorithmIdentifier ";
4972 os << "-- void --";
4973 os << "," << endl;
4974 }
4975
4976 if (NOT_NULL (intendedUsage))
4977 {
4978 os << ","<< endl;
4979 Indent (os, indentG);
4980 os << "intendedUsage ";
4981 os << *intendedUsage;
4982 }
4983 else
4984 {
4985 Indent (os, indentG);
4986 os << "intendedUsage ";
4987 os << "-- void --";
4988 os << "," << endl;
4989 }
4990
4991 if (NOT_NULL (intendedCertificatePolicies))
4992 {
4993 os << ","<< endl;
4994 Indent (os, indentG);
4995 os << "intendedCertificatePolicies ";
4996 os << *intendedCertificatePolicies;
4997 }
4998 else
4999 {
5000 Indent (os, indentG);
5001 os << "intendedCertificatePolicies ";
5002 os << "-- void --";
5003 os << endl;
5004 }
5005
5006 os << endl;
5007 indentG -= stdIndentG;
5008 Indent (os, indentG);
5009 os << "}";
5010 #endif /* NDEBUG */
5011 } // SupportedAlgorithm::Print
5012
5013
5014 BasicConstraintsSyntax::BasicConstraintsSyntax()
5015 {
5016 cA = NULL;
5017 pathLenConstraint = NULL;
5018 }
5019
5020 BasicConstraintsSyntax::BasicConstraintsSyntax (const BasicConstraintsSyntax &)
5021 {
5022 Asn1Error << "use of incompletely defined BasicConstraintsSyntax::BasicConstraintsSyntax (const BasicConstraintsSyntax &)" << endl;
5023 abort();
5024 }
5025
5026 BasicConstraintsSyntax::~BasicConstraintsSyntax()
5027 {
5028 delete cA;
5029 delete pathLenConstraint;
5030 }
5031
5032 AsnType *BasicConstraintsSyntax::Clone() const
5033 {
5034 return new BasicConstraintsSyntax;
5035 }
5036
5037 AsnType *BasicConstraintsSyntax::Copy() const
5038 {
5039 return new BasicConstraintsSyntax (*this);
5040 }
5041
5042 #if SNACC_DEEP_COPY
5043 BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &that)
5044 #else // SNACC_DEEP_COPY
5045 BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &)
5046 #endif // SNACC_DEEP_COPY
5047 {
5048 #if SNACC_DEEP_COPY
5049 if (this != &that)
5050 {
5051 if (that.cA)
5052 {
5053 if (!cA)
5054 cA = new AsnBool;
5055 *cA = *that.cA;
5056 }
5057 else
5058 {
5059 delete cA;
5060 cA = NULL;
5061 }
5062 if (that.pathLenConstraint)
5063 {
5064 if (!pathLenConstraint)
5065 pathLenConstraint = new AsnInt;
5066 *pathLenConstraint = *that.pathLenConstraint;
5067 }
5068 else
5069 {
5070 delete pathLenConstraint;
5071 pathLenConstraint = NULL;
5072 }
5073 }
5074
5075 return *this;
5076 #else // SNACC_DEEP_COPY
5077 Asn1Error << "use of incompletely defined BasicConstraintsSyntax &BasicConstraintsSyntax::operator = (const BasicConstraintsSyntax &)" << endl;
5078 abort();
5079 // if your compiler complains here, check the -novolat option
5080 #endif // SNACC_DEEP_COPY
5081 }
5082
5083 AsnLen
5084 BasicConstraintsSyntax::BEncContent (BUF_TYPE b)
5085 {
5086 AsnLen totalLen = 0;
5087 AsnLen l;
5088
5089 if (NOT_NULL (pathLenConstraint))
5090 {
5091 l = pathLenConstraint->BEncContent (b);
5092 BEncDefLenTo127 (b, l);
5093 l++;
5094
5095 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
5096 totalLen += l;
5097 }
5098
5099 if (NOT_NULL (cA))
5100 {
5101 l = cA->BEncContent (b);
5102 BEncDefLenTo127 (b, l);
5103 l++;
5104
5105 l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE);
5106 totalLen += l;
5107 }
5108
5109 return totalLen;
5110 } // BasicConstraintsSyntax::BEncContent
5111
5112
5113 void BasicConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
5114 {
5115 AsnTag tag1;
5116 AsnLen seqBytesDecoded = 0;
5117 AsnLen elmtLen1;
5118 if (elmtLen0 == 0)
5119 return;
5120 else
5121 {
5122 tag1 = BDecTag (b, seqBytesDecoded, env);
5123
5124 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5125 {
5126 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5127 bytesDecoded += seqBytesDecoded;
5128 return;
5129 }
5130 }
5131
5132 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))
5133 {
5134 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5135 cA = new AsnBool;
5136 cA->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5137 if (seqBytesDecoded == elmtLen0)
5138 {
5139 bytesDecoded += seqBytesDecoded;
5140 return;
5141 }
5142 else
5143 {
5144 tag1 = BDecTag (b, seqBytesDecoded, env);
5145
5146 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5147 {
5148 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5149 bytesDecoded += seqBytesDecoded;
5150 return;
5151 }
5152 }
5153 }
5154
5155 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))
5156 {
5157 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5158 pathLenConstraint = new AsnInt;
5159 pathLenConstraint->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5160 }
5161
5162 bytesDecoded += seqBytesDecoded;
5163 if (elmtLen0 == INDEFINITE_LEN)
5164 {
5165 BDecEoc (b, bytesDecoded, env);
5166 return;
5167 }
5168 else if (seqBytesDecoded != elmtLen0)
5169 {
5170 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
5171 longjmp (env, -135);
5172 }
5173 else
5174 return;
5175 } // BasicConstraintsSyntax::BDecContent
5176
5177 AsnLen BasicConstraintsSyntax::BEnc (BUF_TYPE b)
5178 {
5179 AsnLen l;
5180 l = BEncContent (b);
5181 l += BEncConsLen (b, l);
5182 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5183 return l;
5184 }
5185
5186 void BasicConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5187 {
5188 AsnTag tag;
5189 AsnLen elmtLen1;
5190
5191 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5192 {
5193 Asn1Error << "BasicConstraintsSyntax::BDec: ERROR - wrong tag" << endl;
5194 longjmp (env, -136);
5195 }
5196 elmtLen1 = BDecLen (b, bytesDecoded, env);
5197 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5198 }
5199
5200 int BasicConstraintsSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
5201 {
5202 bytesEncoded = BEnc (b);
5203 return !b.WriteError();
5204 }
5205
5206 int BasicConstraintsSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
5207 {
5208 ENV_TYPE env;
5209 int val;
5210
5211 bytesDecoded = 0;
5212 if ((val = setjmp (env)) == 0)
5213 {
5214 BDec (b, bytesDecoded, env);
5215 return !b.ReadError();
5216 }
5217 else
5218 return false;
5219 }
5220
5221 void BasicConstraintsSyntax::Print (ostream &os) const
5222 {
5223 #ifndef NDEBUG
5224 int nonePrinted = true;
5225 os << "{ -- SEQUENCE --" << endl;
5226 indentG += stdIndentG;
5227
5228 if (NOT_NULL (cA))
5229 {
5230 nonePrinted = false;
5231 Indent (os, indentG);
5232 os << "cA ";
5233 os << *cA;
5234 }
5235 else
5236 {
5237 Indent (os, indentG);
5238 os << "cA ";
5239 os << "-- void --";
5240 os << "," << endl;
5241 }
5242
5243 if (NOT_NULL (pathLenConstraint))
5244 {
5245 if (!nonePrinted)
5246 os << "," << endl;
5247 nonePrinted = false;
5248 Indent (os, indentG);
5249 os << "pathLenConstraint ";
5250 os << *pathLenConstraint;
5251 }
5252 else
5253 {
5254 Indent (os, indentG);
5255 os << "pathLenConstraint ";
5256 os << "-- void --";
5257 os << endl;
5258 }
5259
5260 os << endl;
5261 indentG -= stdIndentG;
5262 Indent (os, indentG);
5263 os << "}";
5264 #endif /* NDEBUG */
5265 } // BasicConstraintsSyntax::Print
5266
5267
5268 NameConstraintsSyntax::NameConstraintsSyntax()
5269 {
5270 permittedSubtrees = NULL;
5271 excludedSubtrees = NULL;
5272 }
5273
5274 NameConstraintsSyntax::NameConstraintsSyntax (const NameConstraintsSyntax &)
5275 {
5276 Asn1Error << "use of incompletely defined NameConstraintsSyntax::NameConstraintsSyntax (const NameConstraintsSyntax &)" << endl;
5277 abort();
5278 }
5279
5280 NameConstraintsSyntax::~NameConstraintsSyntax()
5281 {
5282 delete permittedSubtrees;
5283 delete excludedSubtrees;
5284 }
5285
5286 AsnType *NameConstraintsSyntax::Clone() const
5287 {
5288 return new NameConstraintsSyntax;
5289 }
5290
5291 AsnType *NameConstraintsSyntax::Copy() const
5292 {
5293 return new NameConstraintsSyntax (*this);
5294 }
5295
5296 #if SNACC_DEEP_COPY
5297 NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &that)
5298 #else // SNACC_DEEP_COPY
5299 NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &)
5300 #endif // SNACC_DEEP_COPY
5301 {
5302 #if SNACC_DEEP_COPY
5303 if (this != &that)
5304 {
5305 if (that.permittedSubtrees)
5306 {
5307 if (!permittedSubtrees)
5308 permittedSubtrees = new GeneralSubtrees;
5309 *permittedSubtrees = *that.permittedSubtrees;
5310 }
5311 else
5312 {
5313 delete permittedSubtrees;
5314 permittedSubtrees = NULL;
5315 }
5316 if (that.excludedSubtrees)
5317 {
5318 if (!excludedSubtrees)
5319 excludedSubtrees = new GeneralSubtrees;
5320 *excludedSubtrees = *that.excludedSubtrees;
5321 }
5322 else
5323 {
5324 delete excludedSubtrees;
5325 excludedSubtrees = NULL;
5326 }
5327 }
5328
5329 return *this;
5330 #else // SNACC_DEEP_COPY
5331 Asn1Error << "use of incompletely defined NameConstraintsSyntax &NameConstraintsSyntax::operator = (const NameConstraintsSyntax &)" << endl;
5332 abort();
5333 // if your compiler complains here, check the -novolat option
5334 #endif // SNACC_DEEP_COPY
5335 }
5336
5337 AsnLen
5338 NameConstraintsSyntax::BEncContent (BUF_TYPE b)
5339 {
5340 AsnLen totalLen = 0;
5341 AsnLen l;
5342
5343 if (NOT_NULL (excludedSubtrees))
5344 {
5345 BEncEocIfNec (b);
5346 l = excludedSubtrees->BEncContent (b);
5347 l += BEncConsLen (b, l);
5348
5349 l += BEncTag1 (b, CNTX, CONS, 1);
5350 totalLen += l;
5351 }
5352
5353 if (NOT_NULL (permittedSubtrees))
5354 {
5355 BEncEocIfNec (b);
5356 l = permittedSubtrees->BEncContent (b);
5357 l += BEncConsLen (b, l);
5358
5359 l += BEncTag1 (b, CNTX, CONS, 0);
5360 totalLen += l;
5361 }
5362
5363 return totalLen;
5364 } // NameConstraintsSyntax::BEncContent
5365
5366
5367 void NameConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
5368 {
5369 AsnTag tag1;
5370 AsnLen seqBytesDecoded = 0;
5371 AsnLen elmtLen1;
5372 if (elmtLen0 == 0)
5373 return;
5374 else
5375 {
5376 tag1 = BDecTag (b, seqBytesDecoded, env);
5377
5378 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5379 {
5380 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5381 bytesDecoded += seqBytesDecoded;
5382 return;
5383 }
5384 }
5385
5386 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
5387 {
5388 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5389 permittedSubtrees = new GeneralSubtrees;
5390 permittedSubtrees->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5391 if (seqBytesDecoded == elmtLen0)
5392 {
5393 bytesDecoded += seqBytesDecoded;
5394 return;
5395 }
5396 else
5397 {
5398 tag1 = BDecTag (b, seqBytesDecoded, env);
5399
5400 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5401 {
5402 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5403 bytesDecoded += seqBytesDecoded;
5404 return;
5405 }
5406 }
5407 }
5408
5409 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
5410 {
5411 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5412 excludedSubtrees = new GeneralSubtrees;
5413 excludedSubtrees->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5414 }
5415
5416 bytesDecoded += seqBytesDecoded;
5417 if (elmtLen0 == INDEFINITE_LEN)
5418 {
5419 BDecEoc (b, bytesDecoded, env);
5420 return;
5421 }
5422 else if (seqBytesDecoded != elmtLen0)
5423 {
5424 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
5425 longjmp (env, -137);
5426 }
5427 else
5428 return;
5429 } // NameConstraintsSyntax::BDecContent
5430
5431 AsnLen NameConstraintsSyntax::BEnc (BUF_TYPE b)
5432 {
5433 AsnLen l;
5434 l = BEncContent (b);
5435 l += BEncConsLen (b, l);
5436 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5437 return l;
5438 }
5439
5440 void NameConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5441 {
5442 AsnTag tag;
5443 AsnLen elmtLen1;
5444
5445 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5446 {
5447 Asn1Error << "NameConstraintsSyntax::BDec: ERROR - wrong tag" << endl;
5448 longjmp (env, -138);
5449 }
5450 elmtLen1 = BDecLen (b, bytesDecoded, env);
5451 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5452 }
5453
5454 int NameConstraintsSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
5455 {
5456 bytesEncoded = BEnc (b);
5457 return !b.WriteError();
5458 }
5459
5460 int NameConstraintsSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
5461 {
5462 ENV_TYPE env;
5463 int val;
5464
5465 bytesDecoded = 0;
5466 if ((val = setjmp (env)) == 0)
5467 {
5468 BDec (b, bytesDecoded, env);
5469 return !b.ReadError();
5470 }
5471 else
5472 return false;
5473 }
5474
5475 void NameConstraintsSyntax::Print (ostream &os) const
5476 {
5477 #ifndef NDEBUG
5478 int nonePrinted = true;
5479 os << "{ -- SEQUENCE --" << endl;
5480 indentG += stdIndentG;
5481
5482 if (NOT_NULL (permittedSubtrees))
5483 {
5484 nonePrinted = false;
5485 Indent (os, indentG);
5486 os << "permittedSubtrees ";
5487 os << *permittedSubtrees;
5488 }
5489 else
5490 {
5491 Indent (os, indentG);
5492 os << "permittedSubtrees ";
5493 os << "-- void --";
5494 os << "," << endl;
5495 }
5496
5497 if (NOT_NULL (excludedSubtrees))
5498 {
5499 if (!nonePrinted)
5500 os << "," << endl;
5501 nonePrinted = false;
5502 Indent (os, indentG);
5503 os << "excludedSubtrees ";
5504 os << *excludedSubtrees;
5505 }
5506 else
5507 {
5508 Indent (os, indentG);
5509 os << "excludedSubtrees ";
5510 os << "-- void --";
5511 os << endl;
5512 }
5513
5514 os << endl;
5515 indentG -= stdIndentG;
5516 Indent (os, indentG);
5517 os << "}";
5518 #endif /* NDEBUG */
5519 } // NameConstraintsSyntax::Print
5520
5521
5522 PolicyConstraintsSyntax::PolicyConstraintsSyntax()
5523 {
5524 requireExplicitPolicy = NULL;
5525 inhibitPolicyMapping = NULL;
5526 }
5527
5528 PolicyConstraintsSyntax::PolicyConstraintsSyntax (const PolicyConstraintsSyntax &)
5529 {
5530 Asn1Error << "use of incompletely defined PolicyConstraintsSyntax::PolicyConstraintsSyntax (const PolicyConstraintsSyntax &)" << endl;
5531 abort();
5532 }
5533
5534 PolicyConstraintsSyntax::~PolicyConstraintsSyntax()
5535 {
5536 delete requireExplicitPolicy;
5537 delete inhibitPolicyMapping;
5538 }
5539
5540 AsnType *PolicyConstraintsSyntax::Clone() const
5541 {
5542 return new PolicyConstraintsSyntax;
5543 }
5544
5545 AsnType *PolicyConstraintsSyntax::Copy() const
5546 {
5547 return new PolicyConstraintsSyntax (*this);
5548 }
5549
5550 #if SNACC_DEEP_COPY
5551 PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &that)
5552 #else // SNACC_DEEP_COPY
5553 PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &)
5554 #endif // SNACC_DEEP_COPY
5555 {
5556 #if SNACC_DEEP_COPY
5557 if (this != &that)
5558 {
5559 if (that.requireExplicitPolicy)
5560 {
5561 if (!requireExplicitPolicy)
5562 requireExplicitPolicy = new SkipCerts;
5563 *requireExplicitPolicy = *that.requireExplicitPolicy;
5564 }
5565 else
5566 {
5567 delete requireExplicitPolicy;
5568 requireExplicitPolicy = NULL;
5569 }
5570 if (that.inhibitPolicyMapping)
5571 {
5572 if (!inhibitPolicyMapping)
5573 inhibitPolicyMapping = new SkipCerts;
5574 *inhibitPolicyMapping = *that.inhibitPolicyMapping;
5575 }
5576 else
5577 {
5578 delete inhibitPolicyMapping;
5579 inhibitPolicyMapping = NULL;
5580 }
5581 }
5582
5583 return *this;
5584 #else // SNACC_DEEP_COPY
5585 Asn1Error << "use of incompletely defined PolicyConstraintsSyntax &PolicyConstraintsSyntax::operator = (const PolicyConstraintsSyntax &)" << endl;
5586 abort();
5587 // if your compiler complains here, check the -novolat option
5588 #endif // SNACC_DEEP_COPY
5589 }
5590
5591 AsnLen
5592 PolicyConstraintsSyntax::BEncContent (BUF_TYPE b)
5593 {
5594 AsnLen totalLen = 0;
5595 AsnLen l;
5596
5597 if (NOT_NULL (inhibitPolicyMapping))
5598 {
5599 l = inhibitPolicyMapping->BEncContent (b);
5600 BEncDefLenTo127 (b, l);
5601 l++;
5602
5603 l += BEncTag1 (b, CNTX, PRIM, 1);
5604 totalLen += l;
5605 }
5606
5607 if (NOT_NULL (requireExplicitPolicy))
5608 {
5609 l = requireExplicitPolicy->BEncContent (b);
5610 BEncDefLenTo127 (b, l);
5611 l++;
5612
5613 l += BEncTag1 (b, CNTX, PRIM, 0);
5614 totalLen += l;
5615 }
5616
5617 return totalLen;
5618 } // PolicyConstraintsSyntax::BEncContent
5619
5620
5621 void PolicyConstraintsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
5622 {
5623 AsnTag tag1;
5624 AsnLen seqBytesDecoded = 0;
5625 AsnLen elmtLen1;
5626 if (elmtLen0 == 0)
5627 return;
5628 else
5629 {
5630 tag1 = BDecTag (b, seqBytesDecoded, env);
5631
5632 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5633 {
5634 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5635 bytesDecoded += seqBytesDecoded;
5636 return;
5637 }
5638 }
5639
5640 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 0)))
5641 {
5642 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5643 requireExplicitPolicy = new SkipCerts;
5644 requireExplicitPolicy->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5645 if (seqBytesDecoded == elmtLen0)
5646 {
5647 bytesDecoded += seqBytesDecoded;
5648 return;
5649 }
5650 else
5651 {
5652 tag1 = BDecTag (b, seqBytesDecoded, env);
5653
5654 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5655 {
5656 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5657 bytesDecoded += seqBytesDecoded;
5658 return;
5659 }
5660 }
5661 }
5662
5663 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)))
5664 {
5665 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5666 inhibitPolicyMapping = new SkipCerts;
5667 inhibitPolicyMapping->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5668 }
5669
5670 bytesDecoded += seqBytesDecoded;
5671 if (elmtLen0 == INDEFINITE_LEN)
5672 {
5673 BDecEoc (b, bytesDecoded, env);
5674 return;
5675 }
5676 else if (seqBytesDecoded != elmtLen0)
5677 {
5678 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
5679 longjmp (env, -139);
5680 }
5681 else
5682 return;
5683 } // PolicyConstraintsSyntax::BDecContent
5684
5685 AsnLen PolicyConstraintsSyntax::BEnc (BUF_TYPE b)
5686 {
5687 AsnLen l;
5688 l = BEncContent (b);
5689 l += BEncConsLen (b, l);
5690 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5691 return l;
5692 }
5693
5694 void PolicyConstraintsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5695 {
5696 AsnTag tag;
5697 AsnLen elmtLen1;
5698
5699 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5700 {
5701 Asn1Error << "PolicyConstraintsSyntax::BDec: ERROR - wrong tag" << endl;
5702 longjmp (env, -140);
5703 }
5704 elmtLen1 = BDecLen (b, bytesDecoded, env);
5705 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5706 }
5707
5708 int PolicyConstraintsSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
5709 {
5710 bytesEncoded = BEnc (b);
5711 return !b.WriteError();
5712 }
5713
5714 int PolicyConstraintsSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
5715 {
5716 ENV_TYPE env;
5717 int val;
5718
5719 bytesDecoded = 0;
5720 if ((val = setjmp (env)) == 0)
5721 {
5722 BDec (b, bytesDecoded, env);
5723 return !b.ReadError();
5724 }
5725 else
5726 return false;
5727 }
5728
5729 void PolicyConstraintsSyntax::Print (ostream &os) const
5730 {
5731 #ifndef NDEBUG
5732 int nonePrinted = true;
5733 os << "{ -- SEQUENCE --" << endl;
5734 indentG += stdIndentG;
5735
5736 if (NOT_NULL (requireExplicitPolicy))
5737 {
5738 nonePrinted = false;
5739 Indent (os, indentG);
5740 os << "requireExplicitPolicy ";
5741 os << *requireExplicitPolicy;
5742 }
5743 else
5744 {
5745 Indent (os, indentG);
5746 os << "requireExplicitPolicy ";
5747 os << "-- void --";
5748 os << "," << endl;
5749 }
5750
5751 if (NOT_NULL (inhibitPolicyMapping))
5752 {
5753 if (!nonePrinted)
5754 os << "," << endl;
5755 nonePrinted = false;
5756 Indent (os, indentG);
5757 os << "inhibitPolicyMapping ";
5758 os << *inhibitPolicyMapping;
5759 }
5760 else
5761 {
5762 Indent (os, indentG);
5763 os << "inhibitPolicyMapping ";
5764 os << "-- void --";
5765 os << endl;
5766 }
5767
5768 os << endl;
5769 indentG -= stdIndentG;
5770 Indent (os, indentG);
5771 os << "}";
5772 #endif /* NDEBUG */
5773 } // PolicyConstraintsSyntax::Print
5774
5775
5776 AsnType *CertPolicySet::Clone() const
5777 {
5778 return new CertPolicySet;
5779 }
5780
5781 AsnType *CertPolicySet::Copy() const
5782 {
5783 return new CertPolicySet (*this);
5784 }
5785
5786 AsnLen CertPolicySet::BEnc (BUF_TYPE b)
5787 {
5788 AsnLen l;
5789 l = BEncContent (b);
5790 l += BEncConsLen (b, l);
5791 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5792 return l;
5793 }
5794
5795 void CertPolicySet::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5796 {
5797 AsnTag tag;
5798 AsnLen elmtLen1;
5799
5800 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5801 {
5802 Asn1Error << "CertPolicySet::BDec: ERROR - wrong tag" << endl;
5803 longjmp (env, -141);
5804 }
5805 elmtLen1 = BDecLen (b, bytesDecoded, env);
5806 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5807 }
5808
5809 CertPolicySet::CertPolicySet (const CertPolicySet &)
5810 {
5811 Asn1Error << "use of incompletely defined CertPolicySet::CertPolicySet (const CertPolicySet &)" << endl;
5812 abort();
5813 }
5814
5815 CertPolicySet::~CertPolicySet()
5816 {
5817 SetCurrToFirst();
5818 for (; Curr() != NULL; RemoveCurrFromList())
5819 ;
5820 } // end of destructor
5821
5822 #if SNACC_DEEP_COPY
5823 CertPolicySet &CertPolicySet::operator = (const CertPolicySet &that)
5824 #else // SNACC_DEEP_COPY
5825 CertPolicySet &CertPolicySet::operator = (const CertPolicySet &)
5826 #endif // SNACC_DEEP_COPY
5827 {
5828 #if SNACC_DEEP_COPY
5829 if (this != &that)
5830 {
5831 SetCurrToFirst();
5832 for (; Curr(); RemoveCurrFromList())
5833 ;
5834
5835 //that.SetCurrToFirst();
5836 //for (; that.Curr(); that.GoNext())
5837 // AppendCopy (*that.Curr());
5838 for (const AsnListElmt *run=that.first; run; run=run->next)
5839 AppendCopy (*run->elmt);
5840 }
5841
5842 return *this;
5843 #else // SNACC_DEEP_COPY
5844 Asn1Error << "use of incompletely defined CertPolicySet &CertPolicySet::operator = (const CertPolicySet &)" << endl;
5845 abort();
5846 // if your compiler complains here, check the -novolat option
5847 #endif // SNACC_DEEP_COPY
5848 }
5849
5850 void CertPolicySet::Print (ostream &os) const
5851 {
5852 #ifndef NDEBUG
5853 os << "{ -- SEQUENCE/SET OF -- " << endl;
5854 indentG += stdIndentG;
5855 //SetCurrToFirst();
5856 //for (; Curr() != NULL; GoNext())
5857 for (const AsnListElmt *run=first; run; run=run->next)
5858 {
5859 Indent (os, indentG);
5860 //os << *Curr();
5861 os << *run->elmt;
5862 //if (Curr() != Last())
5863 if (run != last)
5864 os << ",";
5865 os << endl;
5866 }
5867 indentG -= stdIndentG;
5868 Indent (os, indentG);
5869 os << "}\n";
5870 #endif /* NDEBUG */
5871
5872
5873 } // Print
5874
5875
5876 void CertPolicySet::SetCurrElmt (unsigned long int index)
5877 {
5878 unsigned long int i;
5879 curr = first;
5880 if (count)
5881 for (i = 0; (i < (count-1)) && (i < index); i++)
5882 curr = curr->next;
5883 } // CertPolicySet::SetCurrElmt
5884
5885
5886 unsigned long int CertPolicySet::GetCurrElmtIndex()
5887 {
5888 unsigned long int i;
5889 AsnListElmt *tmp;
5890 if (curr != NULL)
5891 {
5892 for (i = 0, tmp = first; tmp != NULL; i++)
5893 {
5894 if (tmp == curr)
5895 return i;
5896 else
5897 tmp = tmp->next;
5898 }
5899 }
5900 return count;
5901 } // CertPolicySet::GetCurrElmtIndex
5902
5903
5904 // alloc new list elmt, put at end of list
5905 // and return the component type
5906 CertPolicyId *CertPolicySet::Append()
5907 {
5908 AsnListElmt *newElmt;
5909 newElmt = new AsnListElmt;
5910 newElmt->elmt = new CertPolicyId;
5911 newElmt->next = NULL;
5912 if (last == NULL)
5913 {
5914 newElmt->prev = NULL;
5915 first = last = newElmt;
5916 }
5917 else
5918 {
5919 newElmt->prev = last;
5920 last->next = newElmt;
5921 last = newElmt;
5922 }
5923 count++;
5924 return (curr = newElmt)->elmt;
5925 } // CertPolicySet::Append
5926
5927
5928 // alloc new list elmt, put at begining of list
5929 // and return the component type
5930 CertPolicyId *CertPolicySet::Prepend()
5931 {
5932 AsnListElmt *newElmt;
5933 newElmt = new AsnListElmt;
5934 newElmt->elmt = new CertPolicyId;
5935 newElmt->prev = NULL;
5936 if (first == NULL)
5937 {
5938 newElmt->next = NULL;
5939 first = last = newElmt;
5940 }
5941 else
5942 {
5943 newElmt->next = first;
5944 first->prev = newElmt;
5945 first = newElmt;
5946 }
5947 count++;
5948 return (curr = newElmt)->elmt;
5949 } // CertPolicySet::Prepend
5950
5951
5952 // alloc new list elmt, insert it before the
5953 // current element and return the component type
5954 // if the current element is null, the new element
5955 // is placed at the beginning of the list.
5956 CertPolicyId *CertPolicySet::InsertBefore()
5957 {
5958 AsnListElmt *newElmt;
5959 newElmt = new AsnListElmt;
5960 newElmt->elmt = new CertPolicyId;
5961 if (curr == NULL)
5962 {
5963 newElmt->next = first;
5964 newElmt->prev = NULL;
5965 first = newElmt;
5966 if (last == NULL)
5967 last = newElmt;
5968 }
5969 else
5970 {
5971 newElmt->next = curr;
5972 newElmt->prev = curr->prev;
5973 curr->prev = newElmt;
5974 if (curr == first)
5975 first = newElmt;
5976 else
5977 newElmt->prev->next = newElmt;
5978 }
5979 count++;
5980 return (curr = newElmt)->elmt;
5981 } // CertPolicySet::InsertBefore
5982
5983
5984 // alloc new list elmt, insert it after the
5985 // current element and return the component type
5986 // if the current element is null, the new element
5987 // is placed at the end of the list.
5988 CertPolicyId *CertPolicySet::InsertAfter()
5989 {
5990 AsnListElmt *newElmt;
5991 newElmt = new AsnListElmt;
5992 newElmt->elmt = new CertPolicyId;
5993 if (curr == NULL)
5994 {
5995 newElmt->prev = last;
5996 newElmt->next = NULL;
5997 last = newElmt;
5998 if (first == NULL)
5999 first = newElmt;
6000 }
6001 else
6002 {
6003 newElmt->prev = curr;
6004 newElmt->next = curr->next;
6005 curr->next = newElmt;
6006 if (curr == last)
6007 last = newElmt;
6008 else
6009 newElmt->next->prev = newElmt;
6010 }
6011 count++;
6012 return (curr = newElmt)->elmt;
6013 } // CertPolicySet::InsertAfter
6014
6015
6016 CertPolicySet &CertPolicySet::AppendCopy (CertPolicyId &elmt)
6017 {
6018 AsnListElmt *newElmt;
6019 newElmt = new AsnListElmt;
6020 newElmt->elmt = new CertPolicyId;
6021 *newElmt->elmt = elmt;
6022 newElmt->next = NULL;
6023 if (last == NULL)
6024 {
6025 newElmt->prev = NULL;
6026 first = last = newElmt;
6027 }
6028 else
6029 {
6030 newElmt->prev = last;
6031 last->next = newElmt;
6032 last = newElmt;
6033 }
6034 count++;
6035 return *this;
6036 } // AppendCopy
6037
6038
6039 CertPolicySet &CertPolicySet::PrependCopy (CertPolicyId &elmt)
6040 {
6041 AsnListElmt *newElmt;
6042 newElmt = new AsnListElmt;
6043 newElmt->elmt = new CertPolicyId;
6044 *newElmt->elmt = elmt;
6045 newElmt->prev = NULL;
6046 if (first == NULL)
6047 {
6048 newElmt->next = NULL;
6049 first = last = newElmt;
6050 }
6051 else
6052 {
6053 newElmt->next = first;
6054 first->prev = newElmt;
6055 first = newElmt;
6056 }
6057 count++;
6058 return *this;
6059 } // CertPolicySet::PrependCopy
6060
6061
6062 // alloc new list elmt, insert it before the
6063 // current element, copy the given elmt into the new elmt
6064 // and return the component type.
6065 // if the current element is null, the new element
6066 // is placed at the beginning of the list.
6067 CertPolicySet &CertPolicySet::InsertBeforeAndCopy (CertPolicyId &elmt)
6068 {
6069 AsnListElmt *newElmt;
6070
6071 newElmt = new AsnListElmt;
6072 newElmt->elmt = new CertPolicyId;
6073 *newElmt->elmt = elmt;
6074
6075 if (curr == NULL)
6076 {
6077 newElmt->next = first;
6078 newElmt->prev = NULL;
6079 first = newElmt;
6080 if (last == NULL)
6081 last = newElmt;
6082 }
6083 else
6084 {
6085 newElmt->next = curr;
6086 newElmt->prev = curr->prev;
6087 curr->prev = newElmt;
6088 if (curr == first)
6089 first = newElmt;
6090 else
6091 newElmt->prev->next = newElmt;
6092 }
6093 count++;
6094 return *this;
6095 } // CertPolicySet::InsertBeforeAndCopy
6096
6097
6098 // alloc new list elmt, insert it after the
6099 // current element, copy given elmt in to new elmt
6100 // and return the component type
6101 // if the current element is null, the new element
6102 // is placed at the end of the list.
6103 CertPolicySet &CertPolicySet::InsertAfterAndCopy (CertPolicyId &elmt)
6104 {
6105 AsnListElmt *newElmt;
6106
6107 newElmt = new AsnListElmt;
6108 newElmt->elmt = new CertPolicyId;
6109 *newElmt->elmt = elmt;
6110 if (curr == NULL)
6111 {
6112 newElmt->prev = last;
6113 newElmt->next = NULL;
6114 last = newElmt;
6115 if (first == NULL)
6116 first = newElmt;
6117 }
6118 else
6119 {
6120 newElmt->prev = curr;
6121 newElmt->next = curr->next;
6122 curr->next = newElmt;
6123 if (curr == last)
6124 last = newElmt;
6125 else
6126 newElmt->next->prev = newElmt;
6127 }
6128 count++;
6129 return *this;
6130 } // CertPolicySet::InsertAfterAndCopy
6131
6132
6133 // remove current element from list if current element is not NULL
6134 // The new current element will be the next element.
6135 // If the current element is the last element in the list
6136 // the second but last element will become the new current element.
6137 void CertPolicySet::RemoveCurrFromList()
6138 {
6139 AsnListElmt *del_elmt;
6140
6141 if (curr != NULL)
6142 {
6143 del_elmt = curr;
6144 count--;
6145
6146 if (count == 0)
6147 first = last = curr = NULL;
6148 else if (curr == first)
6149 {
6150 curr = first= first->next;
6151 first->prev = NULL;
6152 }
6153 else if (curr == last)
6154 {
6155 curr = last = last->prev;
6156 last->next = NULL;
6157 }
6158 else
6159 {
6160 curr->prev->next = curr->next;
6161 curr->next->prev = curr->prev;
6162 }
6163
6164 delete del_elmt->elmt;
6165 delete del_elmt;
6166 }
6167 }
6168
6169
6170 AsnLen CertPolicySet::BEncContent (BUF_TYPE b)
6171 {
6172 AsnListElmt *currElmt;
6173 AsnLen elmtLen;
6174 AsnLen totalLen = 0;
6175 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
6176 {
6177 elmtLen = currElmt->elmt->BEncContent (b);
6178 elmtLen += BEncDefLen (b, elmtLen);
6179
6180 elmtLen += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
6181 totalLen += elmtLen;
6182 }
6183 return totalLen;
6184 } // CertPolicySet::BEncContent
6185
6186
6187 void CertPolicySet::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
6188 AsnLen &bytesDecoded, ENV_TYPE env)
6189 {
6190 CertPolicyId *listElmt;
6191 AsnTag tag1;
6192 AsnLen listBytesDecoded = 0;
6193 AsnLen elmtLen1;
6194
6195 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
6196 {
6197 tag1 = BDecTag (b, listBytesDecoded, env);
6198 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
6199 {
6200 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
6201 break;
6202 }
6203 if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
6204 {
6205 Asn1Error << "Unexpected Tag" << endl;
6206 longjmp (env, -142);
6207 }
6208
6209 elmtLen1 = BDecLen (b, listBytesDecoded, env);
6210 listElmt = Append();
6211 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
6212 }
6213
6214 bytesDecoded += listBytesDecoded;
6215 } // CertPolicySet::BDecContent
6216
6217
6218 AsnType *CRLDistPointsSyntax::Clone() const
6219 {
6220 return new CRLDistPointsSyntax;
6221 }
6222
6223 AsnType *CRLDistPointsSyntax::Copy() const
6224 {
6225 return new CRLDistPointsSyntax (*this);
6226 }
6227
6228 AsnLen CRLDistPointsSyntax::BEnc (BUF_TYPE b)
6229 {
6230 AsnLen l;
6231 l = BEncContent (b);
6232 l += BEncConsLen (b, l);
6233 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6234 return l;
6235 }
6236
6237 void CRLDistPointsSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6238 {
6239 AsnTag tag;
6240 AsnLen elmtLen1;
6241
6242 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6243 {
6244 Asn1Error << "CRLDistPointsSyntax::BDec: ERROR - wrong tag" << endl;
6245 longjmp (env, -143);
6246 }
6247 elmtLen1 = BDecLen (b, bytesDecoded, env);
6248 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6249 }
6250
6251 CRLDistPointsSyntax::CRLDistPointsSyntax (const CRLDistPointsSyntax &)
6252 {
6253 Asn1Error << "use of incompletely defined CRLDistPointsSyntax::CRLDistPointsSyntax (const CRLDistPointsSyntax &)" << endl;
6254 abort();
6255 }
6256
6257 CRLDistPointsSyntax::~CRLDistPointsSyntax()
6258 {
6259 SetCurrToFirst();
6260 for (; Curr() != NULL; RemoveCurrFromList())
6261 ;
6262 } // end of destructor
6263
6264 #if SNACC_DEEP_COPY
6265 CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &that)
6266 #else // SNACC_DEEP_COPY
6267 CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &)
6268 #endif // SNACC_DEEP_COPY
6269 {
6270 #if SNACC_DEEP_COPY
6271 if (this != &that)
6272 {
6273 SetCurrToFirst();
6274 for (; Curr(); RemoveCurrFromList())
6275 ;
6276
6277 //that.SetCurrToFirst();
6278 //for (; that.Curr(); that.GoNext())
6279 // AppendCopy (*that.Curr());
6280 for (const AsnListElmt *run=that.first; run; run=run->next)
6281 AppendCopy (*run->elmt);
6282 }
6283
6284 return *this;
6285 #else // SNACC_DEEP_COPY
6286 Asn1Error << "use of incompletely defined CRLDistPointsSyntax &CRLDistPointsSyntax::operator = (const CRLDistPointsSyntax &)" << endl;
6287 abort();
6288 // if your compiler complains here, check the -novolat option
6289 #endif // SNACC_DEEP_COPY
6290 }
6291
6292 void CRLDistPointsSyntax::Print (ostream &os) const
6293 {
6294 #ifndef NDEBUG
6295 os << "{ -- SEQUENCE/SET OF -- " << endl;
6296 indentG += stdIndentG;
6297 //SetCurrToFirst();
6298 //for (; Curr() != NULL; GoNext())
6299 for (const AsnListElmt *run=first; run; run=run->next)
6300 {
6301 Indent (os, indentG);
6302 //os << *Curr();
6303 os << *run->elmt;
6304 //if (Curr() != Last())
6305 if (run != last)
6306 os << ",";
6307 os << endl;
6308 }
6309 indentG -= stdIndentG;
6310 Indent (os, indentG);
6311 os << "}\n";
6312 #endif /* NDEBUG */
6313
6314
6315 } // Print
6316
6317
6318 void CRLDistPointsSyntax::SetCurrElmt (unsigned long int index)
6319 {
6320 unsigned long int i;
6321 curr = first;
6322 if (count)
6323 for (i = 0; (i < (count-1)) && (i < index); i++)
6324 curr = curr->next;
6325 } // CRLDistPointsSyntax::SetCurrElmt
6326
6327
6328 unsigned long int CRLDistPointsSyntax::GetCurrElmtIndex()
6329 {
6330 unsigned long int i;
6331 AsnListElmt *tmp;
6332 if (curr != NULL)
6333 {
6334 for (i = 0, tmp = first; tmp != NULL; i++)
6335 {
6336 if (tmp == curr)
6337 return i;
6338 else
6339 tmp = tmp->next;
6340 }
6341 }
6342 return count;
6343 } // CRLDistPointsSyntax::GetCurrElmtIndex
6344
6345
6346 // alloc new list elmt, put at end of list
6347 // and return the component type
6348 DistributionPoint *CRLDistPointsSyntax::Append()
6349 {
6350 AsnListElmt *newElmt;
6351 newElmt = new AsnListElmt;
6352 newElmt->elmt = new DistributionPoint;
6353 newElmt->next = NULL;
6354 if (last == NULL)
6355 {
6356 newElmt->prev = NULL;
6357 first = last = newElmt;
6358 }
6359 else
6360 {
6361 newElmt->prev = last;
6362 last->next = newElmt;
6363 last = newElmt;
6364 }
6365 count++;
6366 return (curr = newElmt)->elmt;
6367 } // CRLDistPointsSyntax::Append
6368
6369
6370 // alloc new list elmt, put at begining of list
6371 // and return the component type
6372 DistributionPoint *CRLDistPointsSyntax::Prepend()
6373 {
6374 AsnListElmt *newElmt;
6375 newElmt = new AsnListElmt;
6376 newElmt->elmt = new DistributionPoint;
6377 newElmt->prev = NULL;
6378 if (first == NULL)
6379 {
6380 newElmt->next = NULL;
6381 first = last = newElmt;
6382 }
6383 else
6384 {
6385 newElmt->next = first;
6386 first->prev = newElmt;
6387 first = newElmt;
6388 }
6389 count++;
6390 return (curr = newElmt)->elmt;
6391 } // CRLDistPointsSyntax::Prepend
6392
6393
6394 // alloc new list elmt, insert it before the
6395 // current element and return the component type
6396 // if the current element is null, the new element
6397 // is placed at the beginning of the list.
6398 DistributionPoint *CRLDistPointsSyntax::InsertBefore()
6399 {
6400 AsnListElmt *newElmt;
6401 newElmt = new AsnListElmt;
6402 newElmt->elmt = new DistributionPoint;
6403 if (curr == NULL)
6404 {
6405 newElmt->next = first;
6406 newElmt->prev = NULL;
6407 first = newElmt;
6408 if (last == NULL)
6409 last = newElmt;
6410 }
6411 else
6412 {
6413 newElmt->next = curr;
6414 newElmt->prev = curr->prev;
6415 curr->prev = newElmt;
6416 if (curr == first)
6417 first = newElmt;
6418 else
6419 newElmt->prev->next = newElmt;
6420 }
6421 count++;
6422 return (curr = newElmt)->elmt;
6423 } // CRLDistPointsSyntax::InsertBefore
6424
6425
6426 // alloc new list elmt, insert it after the
6427 // current element and return the component type
6428 // if the current element is null, the new element
6429 // is placed at the end of the list.
6430 DistributionPoint *CRLDistPointsSyntax::InsertAfter()
6431 {
6432 AsnListElmt *newElmt;
6433 newElmt = new AsnListElmt;
6434 newElmt->elmt = new DistributionPoint;
6435 if (curr == NULL)
6436 {
6437 newElmt->prev = last;
6438 newElmt->next = NULL;
6439 last = newElmt;
6440 if (first == NULL)
6441 first = newElmt;
6442 }
6443 else
6444 {
6445 newElmt->prev = curr;
6446 newElmt->next = curr->next;
6447 curr->next = newElmt;
6448 if (curr == last)
6449 last = newElmt;
6450 else
6451 newElmt->next->prev = newElmt;
6452 }
6453 count++;
6454 return (curr = newElmt)->elmt;
6455 } // CRLDistPointsSyntax::InsertAfter
6456
6457
6458 CRLDistPointsSyntax &CRLDistPointsSyntax::AppendCopy (DistributionPoint &elmt)
6459 {
6460 AsnListElmt *newElmt;
6461 newElmt = new AsnListElmt;
6462 newElmt->elmt = new DistributionPoint;
6463 *newElmt->elmt = elmt;
6464 newElmt->next = NULL;
6465 if (last == NULL)
6466 {
6467 newElmt->prev = NULL;
6468 first = last = newElmt;
6469 }
6470 else
6471 {
6472 newElmt->prev = last;
6473 last->next = newElmt;
6474 last = newElmt;
6475 }
6476 count++;
6477 return *this;
6478 } // AppendCopy
6479
6480
6481 CRLDistPointsSyntax &CRLDistPointsSyntax::PrependCopy (DistributionPoint &elmt)
6482 {
6483 AsnListElmt *newElmt;
6484 newElmt = new AsnListElmt;
6485 newElmt->elmt = new DistributionPoint;
6486 *newElmt->elmt = elmt;
6487 newElmt->prev = NULL;
6488 if (first == NULL)
6489 {
6490 newElmt->next = NULL;
6491 first = last = newElmt;
6492 }
6493 else
6494 {
6495 newElmt->next = first;
6496 first->prev = newElmt;
6497 first = newElmt;
6498 }
6499 count++;
6500 return *this;
6501 } // CRLDistPointsSyntax::PrependCopy
6502
6503
6504 // alloc new list elmt, insert it before the
6505 // current element, copy the given elmt into the new elmt
6506 // and return the component type.
6507 // if the current element is null, the new element
6508 // is placed at the beginning of the list.
6509 CRLDistPointsSyntax &CRLDistPointsSyntax::InsertBeforeAndCopy (DistributionPoint &elmt)
6510 {
6511 AsnListElmt *newElmt;
6512
6513 newElmt = new AsnListElmt;
6514 newElmt->elmt = new DistributionPoint;
6515 *newElmt->elmt = elmt;
6516
6517 if (curr == NULL)
6518 {
6519 newElmt->next = first;
6520 newElmt->prev = NULL;
6521 first = newElmt;
6522 if (last == NULL)
6523 last = newElmt;
6524 }
6525 else
6526 {
6527 newElmt->next = curr;
6528 newElmt->prev = curr->prev;
6529 curr->prev = newElmt;
6530 if (curr == first)
6531 first = newElmt;
6532 else
6533 newElmt->prev->next = newElmt;
6534 }
6535 count++;
6536 return *this;
6537 } // CRLDistPointsSyntax::InsertBeforeAndCopy
6538
6539
6540 // alloc new list elmt, insert it after the
6541 // current element, copy given elmt in to new elmt
6542 // and return the component type
6543 // if the current element is null, the new element
6544 // is placed at the end of the list.
6545 CRLDistPointsSyntax &CRLDistPointsSyntax::InsertAfterAndCopy (DistributionPoint &elmt)
6546 {
6547 AsnListElmt *newElmt;
6548
6549 newElmt = new AsnListElmt;
6550 newElmt->elmt = new DistributionPoint;
6551 *newElmt->elmt = elmt;
6552 if (curr == NULL)
6553 {
6554 newElmt->prev = last;
6555 newElmt->next = NULL;
6556 last = newElmt;
6557 if (first == NULL)
6558 first = newElmt;
6559 }
6560 else
6561 {
6562 newElmt->prev = curr;
6563 newElmt->next = curr->next;
6564 curr->next = newElmt;
6565 if (curr == last)
6566 last = newElmt;
6567 else
6568 newElmt->next->prev = newElmt;
6569 }
6570 count++;
6571 return *this;
6572 } // CRLDistPointsSyntax::InsertAfterAndCopy
6573
6574
6575 // remove current element from list if current element is not NULL
6576 // The new current element will be the next element.
6577 // If the current element is the last element in the list
6578 // the second but last element will become the new current element.
6579 void CRLDistPointsSyntax::RemoveCurrFromList()
6580 {
6581 AsnListElmt *del_elmt;
6582
6583 if (curr != NULL)
6584 {
6585 del_elmt = curr;
6586 count--;
6587
6588 if (count == 0)
6589 first = last = curr = NULL;
6590 else if (curr == first)
6591 {
6592 curr = first= first->next;
6593 first->prev = NULL;
6594 }
6595 else if (curr == last)
6596 {
6597 curr = last = last->prev;
6598 last->next = NULL;
6599 }
6600 else
6601 {
6602 curr->prev->next = curr->next;
6603 curr->next->prev = curr->prev;
6604 }
6605
6606 delete del_elmt->elmt;
6607 delete del_elmt;
6608 }
6609 }
6610
6611
6612 AsnLen CRLDistPointsSyntax::BEncContent (BUF_TYPE b)
6613 {
6614 AsnListElmt *currElmt;
6615 AsnLen elmtLen;
6616 AsnLen totalLen = 0;
6617 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
6618 {
6619 BEncEocIfNec (b);
6620 elmtLen = currElmt->elmt->BEncContent (b);
6621 elmtLen += BEncConsLen (b, elmtLen);
6622
6623 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6624 totalLen += elmtLen;
6625 }
6626 return totalLen;
6627 } // CRLDistPointsSyntax::BEncContent
6628
6629
6630 void CRLDistPointsSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
6631 AsnLen &bytesDecoded, ENV_TYPE env)
6632 {
6633 DistributionPoint *listElmt;
6634 AsnTag tag1;
6635 AsnLen listBytesDecoded = 0;
6636 AsnLen elmtLen1;
6637
6638 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
6639 {
6640 tag1 = BDecTag (b, listBytesDecoded, env);
6641 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
6642 {
6643 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
6644 break;
6645 }
6646 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6647 {
6648 Asn1Error << "Unexpected Tag" << endl;
6649 longjmp (env, -144);
6650 }
6651
6652 elmtLen1 = BDecLen (b, listBytesDecoded, env);
6653 listElmt = Append();
6654 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
6655 }
6656
6657 bytesDecoded += listBytesDecoded;
6658 } // CRLDistPointsSyntax::BDecContent
6659
6660
6661 IssuingDistPointSyntax::IssuingDistPointSyntax()
6662 {
6663 distributionPoint = NULL;
6664 onlyContainsUserCerts = NULL;
6665 onlyContainsCACerts = NULL;
6666 onlySomeReasons = NULL;
6667 indirectCRL = NULL;
6668 }
6669
6670 IssuingDistPointSyntax::IssuingDistPointSyntax (const IssuingDistPointSyntax &)
6671 {
6672 Asn1Error << "use of incompletely defined IssuingDistPointSyntax::IssuingDistPointSyntax (const IssuingDistPointSyntax &)" << endl;
6673 abort();
6674 }
6675
6676 IssuingDistPointSyntax::~IssuingDistPointSyntax()
6677 {
6678 delete distributionPoint;
6679 delete onlyContainsUserCerts;
6680 delete onlyContainsCACerts;
6681 delete onlySomeReasons;
6682 delete indirectCRL;
6683 }
6684
6685 AsnType *IssuingDistPointSyntax::Clone() const
6686 {
6687 return new IssuingDistPointSyntax;
6688 }
6689
6690 AsnType *IssuingDistPointSyntax::Copy() const
6691 {
6692 return new IssuingDistPointSyntax (*this);
6693 }
6694
6695 #if SNACC_DEEP_COPY
6696 IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &that)
6697 #else // SNACC_DEEP_COPY
6698 IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &)
6699 #endif // SNACC_DEEP_COPY
6700 {
6701 #if SNACC_DEEP_COPY
6702 if (this != &that)
6703 {
6704 if (that.distributionPoint)
6705 {
6706 if (!distributionPoint)
6707 distributionPoint = new DistributionPointName;
6708 *distributionPoint = *that.distributionPoint;
6709 }
6710 else
6711 {
6712 delete distributionPoint;
6713 distributionPoint = NULL;
6714 }
6715 if (that.onlyContainsUserCerts)
6716 {
6717 if (!onlyContainsUserCerts)
6718 onlyContainsUserCerts = new AsnBool;
6719 *onlyContainsUserCerts = *that.onlyContainsUserCerts;
6720 }
6721 else
6722 {
6723 delete onlyContainsUserCerts;
6724 onlyContainsUserCerts = NULL;
6725 }
6726 if (that.onlyContainsCACerts)
6727 {
6728 if (!onlyContainsCACerts)
6729 onlyContainsCACerts = new AsnBool;
6730 *onlyContainsCACerts = *that.onlyContainsCACerts;
6731 }
6732 else
6733 {
6734 delete onlyContainsCACerts;
6735 onlyContainsCACerts = NULL;
6736 }
6737 if (that.onlySomeReasons)
6738 {
6739 if (!onlySomeReasons)
6740 onlySomeReasons = new ReasonFlags;
6741 *onlySomeReasons = *that.onlySomeReasons;
6742 }
6743 else
6744 {
6745 delete onlySomeReasons;
6746 onlySomeReasons = NULL;
6747 }
6748 if (that.indirectCRL)
6749 {
6750 if (!indirectCRL)
6751 indirectCRL = new AsnBool;
6752 *indirectCRL = *that.indirectCRL;
6753 }
6754 else
6755 {
6756 delete indirectCRL;
6757 indirectCRL = NULL;
6758 }
6759 }
6760
6761 return *this;
6762 #else // SNACC_DEEP_COPY
6763 Asn1Error << "use of incompletely defined IssuingDistPointSyntax &IssuingDistPointSyntax::operator = (const IssuingDistPointSyntax &)" << endl;
6764 abort();
6765 // if your compiler complains here, check the -novolat option
6766 #endif // SNACC_DEEP_COPY
6767 }
6768
6769 AsnLen
6770 IssuingDistPointSyntax::BEncContent (BUF_TYPE b)
6771 {
6772 AsnLen totalLen = 0;
6773 AsnLen l;
6774
6775 if (NOT_NULL (indirectCRL))
6776 {
6777 l = indirectCRL->BEncContent (b);
6778 BEncDefLenTo127 (b, l);
6779 l++;
6780
6781 l += BEncTag1 (b, CNTX, PRIM, 4);
6782 totalLen += l;
6783 }
6784
6785 if (NOT_NULL (onlySomeReasons))
6786 {
6787 l = onlySomeReasons->BEncContent (b);
6788 l += BEncDefLen (b, l);
6789
6790 l += BEncTag1 (b, CNTX, PRIM, 3);
6791 totalLen += l;
6792 }
6793
6794 if (NOT_NULL (onlyContainsCACerts))
6795 {
6796 l = onlyContainsCACerts->BEncContent (b);
6797 BEncDefLenTo127 (b, l);
6798 l++;
6799
6800 l += BEncTag1 (b, CNTX, PRIM, 2);
6801 totalLen += l;
6802 }
6803
6804 if (NOT_NULL (onlyContainsUserCerts))
6805 {
6806 l = onlyContainsUserCerts->BEncContent (b);
6807 BEncDefLenTo127 (b, l);
6808 l++;
6809
6810 l += BEncTag1 (b, CNTX, PRIM, 1);
6811 totalLen += l;
6812 }
6813
6814 if (NOT_NULL (distributionPoint))
6815 {
6816 BEncEocIfNec (b);
6817 l = distributionPoint->BEncContent (b);
6818 l += BEncConsLen (b, l);
6819
6820 l += BEncTag1 (b, CNTX, CONS, 0);
6821 totalLen += l;
6822 }
6823
6824 return totalLen;
6825 } // IssuingDistPointSyntax::BEncContent
6826
6827
6828 void IssuingDistPointSyntax::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
6829 {
6830 AsnTag tag1;
6831 AsnLen seqBytesDecoded = 0;
6832 AsnLen elmtLen1;
6833 AsnLen elmtLen2;
6834 if (elmtLen0 == 0)
6835 return;
6836 else
6837 {
6838 tag1 = BDecTag (b, seqBytesDecoded, env);
6839
6840 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6841 {
6842 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6843 bytesDecoded += seqBytesDecoded;
6844 return;
6845 }
6846 }
6847
6848 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
6849 {
6850 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6851 tag1 = BDecTag (b, seqBytesDecoded, env);
6852 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
6853 distributionPoint = new DistributionPointName;
6854 distributionPoint->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
6855 if (elmtLen1 == INDEFINITE_LEN)
6856 BDecEoc (b, seqBytesDecoded, env);
6857
6858 if (seqBytesDecoded == elmtLen0)
6859 {
6860 bytesDecoded += seqBytesDecoded;
6861 return;
6862 }
6863 else
6864 {
6865 tag1 = BDecTag (b, seqBytesDecoded, env);
6866
6867 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6868 {
6869 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6870 bytesDecoded += seqBytesDecoded;
6871 return;
6872 }
6873 }
6874 }
6875
6876 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1)))
6877 {
6878 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6879 onlyContainsUserCerts = new AsnBool;
6880 onlyContainsUserCerts->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6881 if (seqBytesDecoded == elmtLen0)
6882 {
6883 bytesDecoded += seqBytesDecoded;
6884 return;
6885 }
6886 else
6887 {
6888 tag1 = BDecTag (b, seqBytesDecoded, env);
6889
6890 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6891 {
6892 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6893 bytesDecoded += seqBytesDecoded;
6894 return;
6895 }
6896 }
6897 }
6898
6899 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2)))
6900 {
6901 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6902 onlyContainsCACerts = new AsnBool;
6903 onlyContainsCACerts->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6904 if (seqBytesDecoded == elmtLen0)
6905 {
6906 bytesDecoded += seqBytesDecoded;
6907 return;
6908 }
6909 else
6910 {
6911 tag1 = BDecTag (b, seqBytesDecoded, env);
6912
6913 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6914 {
6915 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6916 bytesDecoded += seqBytesDecoded;
6917 return;
6918 }
6919 }
6920 }
6921
6922 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 3))
6923 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 3)))
6924 {
6925 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6926 onlySomeReasons = new ReasonFlags;
6927 onlySomeReasons->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6928 if (seqBytesDecoded == elmtLen0)
6929 {
6930 bytesDecoded += seqBytesDecoded;
6931 return;
6932 }
6933 else
6934 {
6935 tag1 = BDecTag (b, seqBytesDecoded, env);
6936
6937 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6938 {
6939 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6940 bytesDecoded += seqBytesDecoded;
6941 return;
6942 }
6943 }
6944 }
6945
6946 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 4)))
6947 {
6948 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6949 indirectCRL = new AsnBool;
6950 indirectCRL->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6951 }
6952
6953 bytesDecoded += seqBytesDecoded;
6954 if (elmtLen0 == INDEFINITE_LEN)
6955 {
6956 BDecEoc (b, bytesDecoded, env);
6957 return;
6958 }
6959 else if (seqBytesDecoded != elmtLen0)
6960 {
6961 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
6962 longjmp (env, -145);
6963 }
6964 else
6965 return;
6966 } // IssuingDistPointSyntax::BDecContent
6967
6968 AsnLen IssuingDistPointSyntax::BEnc (BUF_TYPE b)
6969 {
6970 AsnLen l;
6971 l = BEncContent (b);
6972 l += BEncConsLen (b, l);
6973 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6974 return l;
6975 }
6976
6977 void IssuingDistPointSyntax::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6978 {
6979 AsnTag tag;
6980 AsnLen elmtLen1;
6981
6982 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6983 {
6984 Asn1Error << "IssuingDistPointSyntax::BDec: ERROR - wrong tag" << endl;
6985 longjmp (env, -146);
6986 }
6987 elmtLen1 = BDecLen (b, bytesDecoded, env);
6988 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6989 }
6990
6991 int IssuingDistPointSyntax::BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded)
6992 {
6993 bytesEncoded = BEnc (b);
6994 return !b.WriteError();
6995 }
6996
6997 int IssuingDistPointSyntax::BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded)
6998 {
6999 ENV_TYPE env;
7000 int val;
7001
7002 bytesDecoded = 0;
7003 if ((val = setjmp (env)) == 0)
7004 {
7005 BDec (b, bytesDecoded, env);
7006 return !b.ReadError();
7007 }
7008 else
7009 return false;
7010 }
7011
7012 void IssuingDistPointSyntax::Print (ostream &os) const
7013 {
7014 #ifndef NDEBUG
7015 int nonePrinted = true;
7016 os << "{ -- SEQUENCE --" << endl;
7017 indentG += stdIndentG;
7018
7019 if (NOT_NULL (distributionPoint))
7020 {
7021 nonePrinted = false;
7022 Indent (os, indentG);
7023 os << "distributionPoint ";
7024 os << *distributionPoint;
7025 }
7026 else
7027 {
7028 Indent (os, indentG);
7029 os << "distributionPoint ";
7030 os << "-- void --";
7031 os << "," << endl;
7032 }
7033
7034 if (NOT_NULL (onlyContainsUserCerts))
7035 {
7036 if (!nonePrinted)
7037 os << "," << endl;
7038 nonePrinted = false;
7039 Indent (os, indentG);
7040 os << "onlyContainsUserCerts ";
7041 os << *onlyContainsUserCerts;
7042 }
7043 else
7044 {
7045 Indent (os, indentG);
7046 os << "onlyContainsUserCerts ";
7047 os << "-- void --";
7048 os << "," << endl;
7049 }
7050
7051 if (NOT_NULL (onlyContainsCACerts))
7052 {
7053 if (!nonePrinted)
7054 os << "," << endl;
7055 nonePrinted = false;
7056 Indent (os, indentG);
7057 os << "onlyContainsCACerts ";
7058 os << *onlyContainsCACerts;
7059 }
7060 else
7061 {
7062 Indent (os, indentG);
7063 os << "onlyContainsCACerts ";
7064 os << "-- void --";
7065 os << "," << endl;
7066 }
7067
7068 if (NOT_NULL (onlySomeReasons))
7069 {
7070 if (!nonePrinted)
7071 os << "," << endl;
7072 nonePrinted = false;
7073 Indent (os, indentG);
7074 os << "onlySomeReasons ";
7075 os << *onlySomeReasons;
7076 }
7077 else
7078 {
7079 Indent (os, indentG);
7080 os << "onlySomeReasons ";
7081 os << "-- void --";
7082 os << "," << endl;
7083 }
7084
7085 if (NOT_NULL (indirectCRL))
7086 {
7087 if (!nonePrinted)
7088 os << "," << endl;
7089 nonePrinted = false;
7090 Indent (os, indentG);
7091 os << "indirectCRL ";
7092 os << *indirectCRL;
7093 }
7094 else
7095 {
7096 Indent (os, indentG);
7097 os << "indirectCRL ";
7098 os << "-- void --";
7099 os << endl;
7100 }
7101
7102 os << endl;
7103 indentG -= stdIndentG;
7104 Indent (os, indentG);
7105 os << "}";
7106 #endif /* NDEBUG */
7107 } // IssuingDistPointSyntax::Print
7108
7109