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