]> git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/sm_x509af.cpp
0b7bc800448ce7c7d4633c4b8ca7a4d8c2864a45
[apple/security.git] / SecurityASN1 / c++ / sm_x509af.cpp
1 // NOTE: this is a machine generated file--editing not recommended
2 //
3 // sm_x509af.cpp - class member functions for ASN.1 module AuthenticationFramework
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 AsnType *AttributeCertificateAssertionSetOf::Clone() const
37 {
38 return new AttributeCertificateAssertionSetOf;
39 }
40
41 AsnType *AttributeCertificateAssertionSetOf::Copy() const
42 {
43 return new AttributeCertificateAssertionSetOf (*this);
44 }
45
46 AsnLen AttributeCertificateAssertionSetOf::BEnc (BUF_TYPE b)
47 {
48 AsnLen l;
49 l = BEncContent (b);
50 l += BEncConsLen (b, l);
51 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
52 return l;
53 }
54
55 void AttributeCertificateAssertionSetOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
56 {
57 AsnTag tag;
58 AsnLen elmtLen1;
59
60 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
61 {
62 Asn1Error << "AttributeCertificateAssertionSetOf::BDec: ERROR - wrong tag" << endl;
63 SnaccExcep::throwMe(-100);
64 }
65 elmtLen1 = BDecLen (b, bytesDecoded, env);
66 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
67 }
68
69 AttributeCertificateAssertionSetOf::AttributeCertificateAssertionSetOf (const AttributeCertificateAssertionSetOf &)
70 {
71 Asn1Error << "use of incompletely defined AttributeCertificateAssertionSetOf::AttributeCertificateAssertionSetOf (const AttributeCertificateAssertionSetOf &)" << endl;
72 abort();
73 }
74
75 AttributeCertificateAssertionSetOf::~AttributeCertificateAssertionSetOf()
76 {
77 SetCurrToFirst();
78 for (; Curr() != NULL; RemoveCurrFromList())
79 ;
80 } // end of destructor
81
82 #if SNACC_DEEP_COPY
83 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &that)
84 #else // SNACC_DEEP_COPY
85 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &)
86 #endif // SNACC_DEEP_COPY
87 {
88 #if SNACC_DEEP_COPY
89 if (this != &that)
90 {
91 SetCurrToFirst();
92 for (; Curr(); RemoveCurrFromList())
93 ;
94
95 //that.SetCurrToFirst();
96 //for (; that.Curr(); that.GoNext())
97 // AppendCopy (*that.Curr());
98 for (const AsnListElmt *run=that.first; run; run=run->next)
99 AppendCopy (*run->elmt);
100 }
101
102 return *this;
103 #else // SNACC_DEEP_COPY
104 Asn1Error << "use of incompletely defined AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::operator = (const AttributeCertificateAssertionSetOf &)" << endl;
105 abort();
106 // if your compiler complains here, check the -novolat option
107 #endif // SNACC_DEEP_COPY
108 }
109
110 void AttributeCertificateAssertionSetOf::Print (ostream &os) const
111 {
112 #ifndef NDEBUG
113 os << "{ -- SEQUENCE/SET OF -- " << endl;
114 indentG += stdIndentG;
115 //SetCurrToFirst();
116 //for (; Curr() != NULL; GoNext())
117 for (const AsnListElmt *run=first; run; run=run->next)
118 {
119 Indent (os, indentG);
120 //os << *Curr();
121 os << *run->elmt;
122 //if (Curr() != Last())
123 if (run != last)
124 os << ",";
125 os << endl;
126 }
127 indentG -= stdIndentG;
128 Indent (os, indentG);
129 os << "}\n";
130 #endif /* NDEBUG */
131
132
133 } // Print
134
135
136 void AttributeCertificateAssertionSetOf::SetCurrElmt (unsigned long int index)
137 {
138 unsigned long int i;
139 curr = first;
140 if (count)
141 for (i = 0; (i < (count-1)) && (i < index); i++)
142 curr = curr->next;
143 } // AttributeCertificateAssertionSetOf::SetCurrElmt
144
145
146 unsigned long int AttributeCertificateAssertionSetOf::GetCurrElmtIndex()
147 {
148 unsigned long int i;
149 AsnListElmt *tmp;
150 if (curr != NULL)
151 {
152 for (i = 0, tmp = first; tmp != NULL; i++)
153 {
154 if (tmp == curr)
155 return i;
156 else
157 tmp = tmp->next;
158 }
159 }
160 return count;
161 } // AttributeCertificateAssertionSetOf::GetCurrElmtIndex
162
163
164 // alloc new list elmt, put at end of list
165 // and return the component type
166 AttributeType *AttributeCertificateAssertionSetOf::Append()
167 {
168 AsnListElmt *newElmt;
169 newElmt = new AsnListElmt;
170 newElmt->elmt = new AttributeType;
171 newElmt->next = NULL;
172 if (last == NULL)
173 {
174 newElmt->prev = NULL;
175 first = last = newElmt;
176 }
177 else
178 {
179 newElmt->prev = last;
180 last->next = newElmt;
181 last = newElmt;
182 }
183 count++;
184 return (curr = newElmt)->elmt;
185 } // AttributeCertificateAssertionSetOf::Append
186
187
188 // alloc new list elmt, put at begining of list
189 // and return the component type
190 AttributeType *AttributeCertificateAssertionSetOf::Prepend()
191 {
192 AsnListElmt *newElmt;
193 newElmt = new AsnListElmt;
194 newElmt->elmt = new AttributeType;
195 newElmt->prev = NULL;
196 if (first == NULL)
197 {
198 newElmt->next = NULL;
199 first = last = newElmt;
200 }
201 else
202 {
203 newElmt->next = first;
204 first->prev = newElmt;
205 first = newElmt;
206 }
207 count++;
208 return (curr = newElmt)->elmt;
209 } // AttributeCertificateAssertionSetOf::Prepend
210
211
212 // alloc new list elmt, insert it before the
213 // current element and return the component type
214 // if the current element is null, the new element
215 // is placed at the beginning of the list.
216 AttributeType *AttributeCertificateAssertionSetOf::InsertBefore()
217 {
218 AsnListElmt *newElmt;
219 newElmt = new AsnListElmt;
220 newElmt->elmt = new AttributeType;
221 if (curr == NULL)
222 {
223 newElmt->next = first;
224 newElmt->prev = NULL;
225 first = newElmt;
226 if (last == NULL)
227 last = newElmt;
228 }
229 else
230 {
231 newElmt->next = curr;
232 newElmt->prev = curr->prev;
233 curr->prev = newElmt;
234 if (curr == first)
235 first = newElmt;
236 else
237 newElmt->prev->next = newElmt;
238 }
239 count++;
240 return (curr = newElmt)->elmt;
241 } // AttributeCertificateAssertionSetOf::InsertBefore
242
243
244 // alloc new list elmt, insert it after the
245 // current element and return the component type
246 // if the current element is null, the new element
247 // is placed at the end of the list.
248 AttributeType *AttributeCertificateAssertionSetOf::InsertAfter()
249 {
250 AsnListElmt *newElmt;
251 newElmt = new AsnListElmt;
252 newElmt->elmt = new AttributeType;
253 if (curr == NULL)
254 {
255 newElmt->prev = last;
256 newElmt->next = NULL;
257 last = newElmt;
258 if (first == NULL)
259 first = newElmt;
260 }
261 else
262 {
263 newElmt->prev = curr;
264 newElmt->next = curr->next;
265 curr->next = newElmt;
266 if (curr == last)
267 last = newElmt;
268 else
269 newElmt->next->prev = newElmt;
270 }
271 count++;
272 return (curr = newElmt)->elmt;
273 } // AttributeCertificateAssertionSetOf::InsertAfter
274
275
276 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::AppendCopy (AttributeType &elmt)
277 {
278 AsnListElmt *newElmt;
279 newElmt = new AsnListElmt;
280 newElmt->elmt = new AttributeType;
281 *newElmt->elmt = elmt;
282 newElmt->next = NULL;
283 if (last == NULL)
284 {
285 newElmt->prev = NULL;
286 first = last = newElmt;
287 }
288 else
289 {
290 newElmt->prev = last;
291 last->next = newElmt;
292 last = newElmt;
293 }
294 count++;
295 return *this;
296 } // AppendCopy
297
298
299 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::PrependCopy (AttributeType &elmt)
300 {
301 AsnListElmt *newElmt;
302 newElmt = new AsnListElmt;
303 newElmt->elmt = new AttributeType;
304 *newElmt->elmt = elmt;
305 newElmt->prev = NULL;
306 if (first == NULL)
307 {
308 newElmt->next = NULL;
309 first = last = newElmt;
310 }
311 else
312 {
313 newElmt->next = first;
314 first->prev = newElmt;
315 first = newElmt;
316 }
317 count++;
318 return *this;
319 } // AttributeCertificateAssertionSetOf::PrependCopy
320
321
322 // alloc new list elmt, insert it before the
323 // current element, copy the given elmt into the new elmt
324 // and return the component type.
325 // if the current element is null, the new element
326 // is placed at the beginning of the list.
327 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::InsertBeforeAndCopy (AttributeType &elmt)
328 {
329 AsnListElmt *newElmt;
330
331 newElmt = new AsnListElmt;
332 newElmt->elmt = new AttributeType;
333 *newElmt->elmt = elmt;
334
335 if (curr == NULL)
336 {
337 newElmt->next = first;
338 newElmt->prev = NULL;
339 first = newElmt;
340 if (last == NULL)
341 last = newElmt;
342 }
343 else
344 {
345 newElmt->next = curr;
346 newElmt->prev = curr->prev;
347 curr->prev = newElmt;
348 if (curr == first)
349 first = newElmt;
350 else
351 newElmt->prev->next = newElmt;
352 }
353 count++;
354 return *this;
355 } // AttributeCertificateAssertionSetOf::InsertBeforeAndCopy
356
357
358 // alloc new list elmt, insert it after the
359 // current element, copy given elmt in to new elmt
360 // and return the component type
361 // if the current element is null, the new element
362 // is placed at the end of the list.
363 AttributeCertificateAssertionSetOf &AttributeCertificateAssertionSetOf::InsertAfterAndCopy (AttributeType &elmt)
364 {
365 AsnListElmt *newElmt;
366
367 newElmt = new AsnListElmt;
368 newElmt->elmt = new AttributeType;
369 *newElmt->elmt = elmt;
370 if (curr == NULL)
371 {
372 newElmt->prev = last;
373 newElmt->next = NULL;
374 last = newElmt;
375 if (first == NULL)
376 first = newElmt;
377 }
378 else
379 {
380 newElmt->prev = curr;
381 newElmt->next = curr->next;
382 curr->next = newElmt;
383 if (curr == last)
384 last = newElmt;
385 else
386 newElmt->next->prev = newElmt;
387 }
388 count++;
389 return *this;
390 } // AttributeCertificateAssertionSetOf::InsertAfterAndCopy
391
392
393 // remove current element from list if current element is not NULL
394 // The new current element will be the next element.
395 // If the current element is the last element in the list
396 // the second but last element will become the new current element.
397 void AttributeCertificateAssertionSetOf::RemoveCurrFromList()
398 {
399 AsnListElmt *del_elmt;
400
401 if (curr != NULL)
402 {
403 del_elmt = curr;
404 count--;
405
406 if (count == 0)
407 first = last = curr = NULL;
408 else if (curr == first)
409 {
410 curr = first= first->next;
411 first->prev = NULL;
412 }
413 else if (curr == last)
414 {
415 curr = last = last->prev;
416 last->next = NULL;
417 }
418 else
419 {
420 curr->prev->next = curr->next;
421 curr->next->prev = curr->prev;
422 }
423
424 delete del_elmt->elmt;
425 delete del_elmt;
426 }
427 }
428
429
430 AsnLen AttributeCertificateAssertionSetOf::BEncContent (BUF_TYPE b)
431 {
432 AsnListElmt *currElmt;
433 AsnLen elmtLen;
434 AsnLen totalLen = 0;
435 {
436 int iii,icount;
437 CSM_Buffer **tmpEnc=NULL;
438 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
439 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
440 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
441 {
442 ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen);
443 elmtLen += BEncDefLen (outputBuf, elmtLen);
444
445 elmtLen += BEncTag1 (outputBuf, UNIV, PRIM, OID_TAG_CODE);
446 ENCODE_BUF2(tmpEnc[iii]);
447 }
448 vdasnacc_sortSetOf(tmpEnc, icount);
449 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
450 SM_WriteToAsnBuf(tmpEnc[iii], b);
451 for (iii=0; iii < icount; iii++) delete tmpEnc[iii];
452 free(tmpEnc);
453 }
454 totalLen += elmtLen;
455 return totalLen;
456 } // AttributeCertificateAssertionSetOf::BEncContent
457
458
459 void AttributeCertificateAssertionSetOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
460 AsnLen &bytesDecoded, ENV_TYPE env)
461 {
462 AttributeType *listElmt;
463 AsnTag tag1;
464 AsnLen listBytesDecoded = 0;
465 AsnLen elmtLen1;
466
467 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
468 {
469 tag1 = BDecTag (b, listBytesDecoded, env);
470 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
471 {
472 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
473 break;
474 }
475 if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
476 {
477 Asn1Error << "Unexpected Tag" << endl;
478 SnaccExcep::throwMe(-101);
479 }
480
481 elmtLen1 = BDecLen (b, listBytesDecoded, env);
482 listElmt = Append();
483 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
484 }
485
486 bytesDecoded += listBytesDecoded;
487 } // AttributeCertificateAssertionSetOf::BDecContent
488
489
490 AsnType *AttributeCertificateInfoSeqOf::Clone() const
491 {
492 return new AttributeCertificateInfoSeqOf;
493 }
494
495 AsnType *AttributeCertificateInfoSeqOf::Copy() const
496 {
497 return new AttributeCertificateInfoSeqOf (*this);
498 }
499
500 AsnLen AttributeCertificateInfoSeqOf::BEnc (BUF_TYPE b)
501 {
502 AsnLen l;
503 l = BEncContent (b);
504 l += BEncConsLen (b, l);
505 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
506 return l;
507 }
508
509 void AttributeCertificateInfoSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
510 {
511 AsnTag tag;
512 AsnLen elmtLen1;
513
514 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
515 {
516 Asn1Error << "AttributeCertificateInfoSeqOf::BDec: ERROR - wrong tag" << endl;
517 SnaccExcep::throwMe(-102);
518 }
519 elmtLen1 = BDecLen (b, bytesDecoded, env);
520 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
521 }
522
523 AttributeCertificateInfoSeqOf::AttributeCertificateInfoSeqOf (const AttributeCertificateInfoSeqOf &)
524 {
525 Asn1Error << "use of incompletely defined AttributeCertificateInfoSeqOf::AttributeCertificateInfoSeqOf (const AttributeCertificateInfoSeqOf &)" << endl;
526 abort();
527 }
528
529 AttributeCertificateInfoSeqOf::~AttributeCertificateInfoSeqOf()
530 {
531 SetCurrToFirst();
532 for (; Curr() != NULL; RemoveCurrFromList())
533 ;
534 } // end of destructor
535
536 #if SNACC_DEEP_COPY
537 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &that)
538 #else // SNACC_DEEP_COPY
539 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &)
540 #endif // SNACC_DEEP_COPY
541 {
542 #if SNACC_DEEP_COPY
543 if (this != &that)
544 {
545 SetCurrToFirst();
546 for (; Curr(); RemoveCurrFromList())
547 ;
548
549 //that.SetCurrToFirst();
550 //for (; that.Curr(); that.GoNext())
551 // AppendCopy (*that.Curr());
552 for (const AsnListElmt *run=that.first; run; run=run->next)
553 AppendCopy (*run->elmt);
554 }
555
556 return *this;
557 #else // SNACC_DEEP_COPY
558 Asn1Error << "use of incompletely defined AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::operator = (const AttributeCertificateInfoSeqOf &)" << endl;
559 abort();
560 // if your compiler complains here, check the -novolat option
561 #endif // SNACC_DEEP_COPY
562 }
563
564 void AttributeCertificateInfoSeqOf::Print (ostream &os) const
565 {
566 #ifndef NDEBUG
567 os << "{ -- SEQUENCE/SET OF -- " << endl;
568 indentG += stdIndentG;
569 //SetCurrToFirst();
570 //for (; Curr() != NULL; GoNext())
571 for (const AsnListElmt *run=first; run; run=run->next)
572 {
573 Indent (os, indentG);
574 //os << *Curr();
575 os << *run->elmt;
576 //if (Curr() != Last())
577 if (run != last)
578 os << ",";
579 os << endl;
580 }
581 indentG -= stdIndentG;
582 Indent (os, indentG);
583 os << "}\n";
584 #endif /* NDEBUG */
585
586
587 } // Print
588
589
590 void AttributeCertificateInfoSeqOf::SetCurrElmt (unsigned long int index)
591 {
592 unsigned long int i;
593 curr = first;
594 if (count)
595 for (i = 0; (i < (count-1)) && (i < index); i++)
596 curr = curr->next;
597 } // AttributeCertificateInfoSeqOf::SetCurrElmt
598
599
600 unsigned long int AttributeCertificateInfoSeqOf::GetCurrElmtIndex()
601 {
602 unsigned long int i;
603 AsnListElmt *tmp;
604 if (curr != NULL)
605 {
606 for (i = 0, tmp = first; tmp != NULL; i++)
607 {
608 if (tmp == curr)
609 return i;
610 else
611 tmp = tmp->next;
612 }
613 }
614 return count;
615 } // AttributeCertificateInfoSeqOf::GetCurrElmtIndex
616
617
618 // alloc new list elmt, put at end of list
619 // and return the component type
620 Attribute *AttributeCertificateInfoSeqOf::Append()
621 {
622 AsnListElmt *newElmt;
623 newElmt = new AsnListElmt;
624 newElmt->elmt = new Attribute;
625 newElmt->next = NULL;
626 if (last == NULL)
627 {
628 newElmt->prev = NULL;
629 first = last = newElmt;
630 }
631 else
632 {
633 newElmt->prev = last;
634 last->next = newElmt;
635 last = newElmt;
636 }
637 count++;
638 return (curr = newElmt)->elmt;
639 } // AttributeCertificateInfoSeqOf::Append
640
641
642 // alloc new list elmt, put at begining of list
643 // and return the component type
644 Attribute *AttributeCertificateInfoSeqOf::Prepend()
645 {
646 AsnListElmt *newElmt;
647 newElmt = new AsnListElmt;
648 newElmt->elmt = new Attribute;
649 newElmt->prev = NULL;
650 if (first == NULL)
651 {
652 newElmt->next = NULL;
653 first = last = newElmt;
654 }
655 else
656 {
657 newElmt->next = first;
658 first->prev = newElmt;
659 first = newElmt;
660 }
661 count++;
662 return (curr = newElmt)->elmt;
663 } // AttributeCertificateInfoSeqOf::Prepend
664
665
666 // alloc new list elmt, insert it before the
667 // current element and return the component type
668 // if the current element is null, the new element
669 // is placed at the beginning of the list.
670 Attribute *AttributeCertificateInfoSeqOf::InsertBefore()
671 {
672 AsnListElmt *newElmt;
673 newElmt = new AsnListElmt;
674 newElmt->elmt = new Attribute;
675 if (curr == NULL)
676 {
677 newElmt->next = first;
678 newElmt->prev = NULL;
679 first = newElmt;
680 if (last == NULL)
681 last = newElmt;
682 }
683 else
684 {
685 newElmt->next = curr;
686 newElmt->prev = curr->prev;
687 curr->prev = newElmt;
688 if (curr == first)
689 first = newElmt;
690 else
691 newElmt->prev->next = newElmt;
692 }
693 count++;
694 return (curr = newElmt)->elmt;
695 } // AttributeCertificateInfoSeqOf::InsertBefore
696
697
698 // alloc new list elmt, insert it after the
699 // current element and return the component type
700 // if the current element is null, the new element
701 // is placed at the end of the list.
702 Attribute *AttributeCertificateInfoSeqOf::InsertAfter()
703 {
704 AsnListElmt *newElmt;
705 newElmt = new AsnListElmt;
706 newElmt->elmt = new Attribute;
707 if (curr == NULL)
708 {
709 newElmt->prev = last;
710 newElmt->next = NULL;
711 last = newElmt;
712 if (first == NULL)
713 first = newElmt;
714 }
715 else
716 {
717 newElmt->prev = curr;
718 newElmt->next = curr->next;
719 curr->next = newElmt;
720 if (curr == last)
721 last = newElmt;
722 else
723 newElmt->next->prev = newElmt;
724 }
725 count++;
726 return (curr = newElmt)->elmt;
727 } // AttributeCertificateInfoSeqOf::InsertAfter
728
729
730 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::AppendCopy (Attribute &elmt)
731 {
732 AsnListElmt *newElmt;
733 newElmt = new AsnListElmt;
734 newElmt->elmt = new Attribute;
735 *newElmt->elmt = elmt;
736 newElmt->next = NULL;
737 if (last == NULL)
738 {
739 newElmt->prev = NULL;
740 first = last = newElmt;
741 }
742 else
743 {
744 newElmt->prev = last;
745 last->next = newElmt;
746 last = newElmt;
747 }
748 count++;
749 return *this;
750 } // AppendCopy
751
752
753 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::PrependCopy (Attribute &elmt)
754 {
755 AsnListElmt *newElmt;
756 newElmt = new AsnListElmt;
757 newElmt->elmt = new Attribute;
758 *newElmt->elmt = elmt;
759 newElmt->prev = NULL;
760 if (first == NULL)
761 {
762 newElmt->next = NULL;
763 first = last = newElmt;
764 }
765 else
766 {
767 newElmt->next = first;
768 first->prev = newElmt;
769 first = newElmt;
770 }
771 count++;
772 return *this;
773 } // AttributeCertificateInfoSeqOf::PrependCopy
774
775
776 // alloc new list elmt, insert it before the
777 // current element, copy the given elmt into the new elmt
778 // and return the component type.
779 // if the current element is null, the new element
780 // is placed at the beginning of the list.
781 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::InsertBeforeAndCopy (Attribute &elmt)
782 {
783 AsnListElmt *newElmt;
784
785 newElmt = new AsnListElmt;
786 newElmt->elmt = new Attribute;
787 *newElmt->elmt = elmt;
788
789 if (curr == NULL)
790 {
791 newElmt->next = first;
792 newElmt->prev = NULL;
793 first = newElmt;
794 if (last == NULL)
795 last = newElmt;
796 }
797 else
798 {
799 newElmt->next = curr;
800 newElmt->prev = curr->prev;
801 curr->prev = newElmt;
802 if (curr == first)
803 first = newElmt;
804 else
805 newElmt->prev->next = newElmt;
806 }
807 count++;
808 return *this;
809 } // AttributeCertificateInfoSeqOf::InsertBeforeAndCopy
810
811
812 // alloc new list elmt, insert it after the
813 // current element, copy given elmt in to new elmt
814 // and return the component type
815 // if the current element is null, the new element
816 // is placed at the end of the list.
817 AttributeCertificateInfoSeqOf &AttributeCertificateInfoSeqOf::InsertAfterAndCopy (Attribute &elmt)
818 {
819 AsnListElmt *newElmt;
820
821 newElmt = new AsnListElmt;
822 newElmt->elmt = new Attribute;
823 *newElmt->elmt = elmt;
824 if (curr == NULL)
825 {
826 newElmt->prev = last;
827 newElmt->next = NULL;
828 last = newElmt;
829 if (first == NULL)
830 first = newElmt;
831 }
832 else
833 {
834 newElmt->prev = curr;
835 newElmt->next = curr->next;
836 curr->next = newElmt;
837 if (curr == last)
838 last = newElmt;
839 else
840 newElmt->next->prev = newElmt;
841 }
842 count++;
843 return *this;
844 } // AttributeCertificateInfoSeqOf::InsertAfterAndCopy
845
846
847 // remove current element from list if current element is not NULL
848 // The new current element will be the next element.
849 // If the current element is the last element in the list
850 // the second but last element will become the new current element.
851 void AttributeCertificateInfoSeqOf::RemoveCurrFromList()
852 {
853 AsnListElmt *del_elmt;
854
855 if (curr != NULL)
856 {
857 del_elmt = curr;
858 count--;
859
860 if (count == 0)
861 first = last = curr = NULL;
862 else if (curr == first)
863 {
864 curr = first= first->next;
865 first->prev = NULL;
866 }
867 else if (curr == last)
868 {
869 curr = last = last->prev;
870 last->next = NULL;
871 }
872 else
873 {
874 curr->prev->next = curr->next;
875 curr->next->prev = curr->prev;
876 }
877
878 delete del_elmt->elmt;
879 delete del_elmt;
880 }
881 }
882
883
884 AsnLen AttributeCertificateInfoSeqOf::BEncContent (BUF_TYPE b)
885 {
886 AsnListElmt *currElmt;
887 AsnLen elmtLen;
888 AsnLen totalLen = 0;
889 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
890 {
891 BEncEocIfNec (b);
892 elmtLen = currElmt->elmt->BEncContent (b);
893 elmtLen += BEncConsLen (b, elmtLen);
894
895 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
896 totalLen += elmtLen;
897 }
898 return totalLen;
899 } // AttributeCertificateInfoSeqOf::BEncContent
900
901
902 void AttributeCertificateInfoSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
903 AsnLen &bytesDecoded, ENV_TYPE env)
904 {
905 Attribute *listElmt;
906 AsnTag tag1;
907 AsnLen listBytesDecoded = 0;
908 AsnLen elmtLen1;
909
910 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
911 {
912 tag1 = BDecTag (b, listBytesDecoded, env);
913 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
914 {
915 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
916 break;
917 }
918 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
919 {
920 Asn1Error << "Unexpected Tag" << endl;
921 SnaccExcep::throwMe(-103);
922 }
923
924 elmtLen1 = BDecLen (b, listBytesDecoded, env);
925 listElmt = Append();
926 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
927 }
928
929 bytesDecoded += listBytesDecoded;
930 } // AttributeCertificateInfoSeqOf::BDecContent
931
932
933 AlgorithmIdentifier::AlgorithmIdentifier()
934 {
935 parameters = NULL;
936 }
937
938 AlgorithmIdentifier::AlgorithmIdentifier (const AlgorithmIdentifier &)
939 {
940 Asn1Error << "use of incompletely defined AlgorithmIdentifier::AlgorithmIdentifier (const AlgorithmIdentifier &)" << endl;
941 abort();
942 }
943
944 AlgorithmIdentifier::~AlgorithmIdentifier()
945 {
946 delete parameters;
947 }
948
949 AsnType *AlgorithmIdentifier::Clone() const
950 {
951 return new AlgorithmIdentifier;
952 }
953
954 AsnType *AlgorithmIdentifier::Copy() const
955 {
956 return new AlgorithmIdentifier (*this);
957 }
958
959 #if SNACC_DEEP_COPY
960 AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &that)
961 #else // SNACC_DEEP_COPY
962 AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &)
963 #endif // SNACC_DEEP_COPY
964 {
965 #if SNACC_DEEP_COPY
966 if (this != &that)
967 {
968 algorithm = that.algorithm;
969 if (that.parameters)
970 {
971 if (!parameters)
972 parameters = new AsnAny;
973 *parameters = *that.parameters;
974 }
975 else
976 {
977 delete parameters;
978 parameters = NULL;
979 }
980 }
981
982 return *this;
983 #else // SNACC_DEEP_COPY
984 Asn1Error << "use of incompletely defined AlgorithmIdentifier &AlgorithmIdentifier::operator = (const AlgorithmIdentifier &)" << endl;
985 abort();
986 // if your compiler complains here, check the -novolat option
987 #endif // SNACC_DEEP_COPY
988 }
989
990 AsnLen
991 AlgorithmIdentifier::BEncContent (BUF_TYPE b)
992 {
993 AsnLen totalLen = 0;
994 AsnLen l;
995
996 if (NOT_NULL (parameters))
997 {
998 ENC_LOAD_ANYBUF(parameters, b, l);
999 totalLen += l;
1000 }
1001
1002 l = algorithm.BEncContent (b);
1003 l += BEncDefLen (b, l);
1004
1005 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
1006 totalLen += l;
1007
1008 return totalLen;
1009 } // AlgorithmIdentifier::BEncContent
1010
1011
1012 void AlgorithmIdentifier::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1013 {
1014 AsnTag tag1;
1015 AsnLen seqBytesDecoded = 0;
1016 AsnLen elmtLen1;
1017 tag1 = BDecTag (b, seqBytesDecoded, env);
1018
1019 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
1020 {
1021 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1022 algorithm.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1023 if (seqBytesDecoded == elmtLen0)
1024 {
1025 bytesDecoded += seqBytesDecoded;
1026 return;
1027 }
1028 else
1029 {
1030 tag1 = b.PeekByte();
1031
1032 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
1033 {
1034 BDecEoc (b, seqBytesDecoded, env);
1035
1036 bytesDecoded += seqBytesDecoded;
1037 return;
1038 }
1039 }
1040 }
1041 else
1042 {
1043 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1044 SnaccExcep::throwMe(-104);
1045 }
1046
1047 // ANY type
1048 parameters = new AsnAny;
1049 DEC_LOAD_ANYBUF(parameters, b, seqBytesDecoded, env);
1050
1051
1052 bytesDecoded += seqBytesDecoded;
1053 if (elmtLen0 == INDEFINITE_LEN)
1054 {
1055 BDecEoc (b, bytesDecoded, env);
1056 return;
1057 }
1058 else if (seqBytesDecoded != elmtLen0)
1059 {
1060 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1061 SnaccExcep::throwMe(-105);
1062 }
1063 else
1064 return;
1065 } // AlgorithmIdentifier::BDecContent
1066
1067 AsnLen AlgorithmIdentifier::BEnc (BUF_TYPE b)
1068 {
1069 AsnLen l;
1070 l = BEncContent (b);
1071 l += BEncConsLen (b, l);
1072 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1073 return l;
1074 }
1075
1076 void AlgorithmIdentifier::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1077 {
1078 AsnTag tag;
1079 AsnLen elmtLen1;
1080
1081 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1082 {
1083 Asn1Error << "AlgorithmIdentifier::BDec: ERROR - wrong tag" << endl;
1084 SnaccExcep::throwMe(-106);
1085 }
1086 elmtLen1 = BDecLen (b, bytesDecoded, env);
1087 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1088 }
1089
1090 void AlgorithmIdentifier::Print (ostream &os) const
1091 {
1092 #ifndef NDEBUG
1093 os << "{ -- SEQUENCE --" << endl;
1094 indentG += stdIndentG;
1095
1096 {
1097 Indent (os, indentG);
1098 os << "algorithm ";
1099 os << algorithm;
1100 os << "," << endl;
1101 }
1102
1103 if (NOT_NULL (parameters))
1104 {
1105 os << ","<< endl;
1106 Indent (os, indentG);
1107 os << "parameters ";
1108 os << *parameters;
1109 }
1110 else
1111 {
1112 Indent (os, indentG);
1113 os << "parameters ";
1114 os << "-- void --";
1115 os << endl;
1116 }
1117
1118 os << endl;
1119 indentG -= stdIndentG;
1120 Indent (os, indentG);
1121 os << "}";
1122 #endif /* NDEBUG */
1123 } // AlgorithmIdentifier::Print
1124
1125
1126 Time::Time()
1127 {
1128 choiceId = utcTimeCid;
1129 #if TCL
1130 utcTime = new UTCTime;
1131 #else
1132 utcTime = NULL; // incomplete initialization of mandatory element!
1133 #endif // TCL
1134 }
1135
1136 Time::Time (const Time &)
1137 {
1138 Asn1Error << "use of incompletely defined Time::Time (const Time &)" << endl;
1139 abort();
1140 }
1141
1142 Time::~Time()
1143 {
1144 switch (choiceId)
1145 {
1146 case utcTimeCid:
1147 delete utcTime;
1148 break;
1149 case generalizedTimeCid:
1150 delete generalizedTime;
1151 break;
1152 } // end of switch
1153 } // end of destructor
1154
1155 AsnType *Time::Clone() const
1156 {
1157 return new Time;
1158 }
1159
1160 AsnType *Time::Copy() const
1161 {
1162 return new Time (*this);
1163 }
1164
1165 #if SNACC_DEEP_COPY
1166 Time &Time::operator = (const Time &that)
1167 #else // SNACC_DEEP_COPY
1168 Time &Time::operator = (const Time &)
1169 #endif // SNACC_DEEP_COPY
1170 {
1171 #if SNACC_DEEP_COPY
1172 if (this != &that)
1173 {
1174 switch (choiceId)
1175 {
1176 case utcTimeCid:
1177 delete utcTime;
1178 break;
1179 case generalizedTimeCid:
1180 delete generalizedTime;
1181 break;
1182 }
1183 switch (choiceId = that.choiceId)
1184 {
1185 case utcTimeCid:
1186 utcTime = new UTCTime;
1187 *utcTime = *that.utcTime;
1188 break;
1189 case generalizedTimeCid:
1190 generalizedTime = new GeneralizedTime;
1191 *generalizedTime = *that.generalizedTime;
1192 break;
1193 }
1194 }
1195
1196 return *this;
1197 #else // SNACC_DEEP_COPY
1198 Asn1Error << "use of incompletely defined Time &Time::operator = (const Time &)" << endl;
1199 abort();
1200 // if your compiler complains here, check the -novolat option
1201 #endif // SNACC_DEEP_COPY
1202 }
1203
1204 AsnLen
1205 Time::BEncContent (BUF_TYPE b)
1206 {
1207 AsnLen l;
1208 switch (choiceId)
1209 {
1210 case utcTimeCid:
1211 l = utcTime->BEncContent (b);
1212 l += BEncDefLen (b, l);
1213
1214 l += BEncTag1 (b, UNIV, PRIM, UTCTIME_TAG_CODE);
1215 break;
1216
1217 case generalizedTimeCid:
1218 l = generalizedTime->BEncContent (b);
1219 l += BEncDefLen (b, l);
1220
1221 l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE);
1222 break;
1223
1224 } // end switch
1225 return l;
1226 } // Time::BEncContent
1227
1228
1229 void Time::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1230 {
1231 switch (tag)
1232 {
1233 case MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE):
1234 case MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE):
1235 choiceId = utcTimeCid;
1236 utcTime = new UTCTime;
1237 utcTime->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
1238 break;
1239
1240 case MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE):
1241 case MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE):
1242 choiceId = generalizedTimeCid;
1243 generalizedTime = new GeneralizedTime;
1244 generalizedTime->BDecContent (b, tag, elmtLen0, bytesDecoded, env);
1245 break;
1246
1247 default:
1248 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
1249 SnaccExcep::throwMe(-107);
1250 break;
1251 } // end switch
1252 } // Time::BDecContent
1253
1254
1255 AsnLen Time::BEnc (BUF_TYPE b)
1256 {
1257 AsnLen l;
1258 l = BEncContent (b);
1259 return l;
1260 }
1261
1262 void Time::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1263 {
1264 AsnLen elmtLen;
1265 AsnTag tag;
1266
1267 /* CHOICEs are a special case - grab identifying tag */
1268 /* this allows easier handling of nested CHOICEs */
1269 tag = BDecTag (b, bytesDecoded, env);
1270 elmtLen = BDecLen (b, bytesDecoded, env);
1271 BDecContent (b, tag, elmtLen, bytesDecoded, env);
1272 }
1273
1274 void Time::Print (ostream &os) const
1275 {
1276 #ifndef NDEBUG
1277 switch (choiceId)
1278 {
1279 case utcTimeCid:
1280 os << "utcTime ";
1281 if (utcTime)
1282 os << *utcTime;
1283 else
1284 os << "-- void3 --\n";
1285 break;
1286
1287 case generalizedTimeCid:
1288 os << "generalizedTime ";
1289 if (generalizedTime)
1290 os << *generalizedTime;
1291 else
1292 os << "-- void3 --\n";
1293 break;
1294
1295 } // end of switch
1296 #endif /* NDEBUG */
1297 } // Time::Print
1298
1299 Extension::Extension()
1300 {
1301 critical = NULL;
1302 }
1303
1304 Extension::Extension (const Extension &)
1305 {
1306 Asn1Error << "use of incompletely defined Extension::Extension (const Extension &)" << endl;
1307 abort();
1308 }
1309
1310 Extension::~Extension()
1311 {
1312 delete critical;
1313 }
1314
1315 AsnType *Extension::Clone() const
1316 {
1317 return new Extension;
1318 }
1319
1320 AsnType *Extension::Copy() const
1321 {
1322 return new Extension (*this);
1323 }
1324
1325 #if SNACC_DEEP_COPY
1326 Extension &Extension::operator = (const Extension &that)
1327 #else // SNACC_DEEP_COPY
1328 Extension &Extension::operator = (const Extension &)
1329 #endif // SNACC_DEEP_COPY
1330 {
1331 #if SNACC_DEEP_COPY
1332 if (this != &that)
1333 {
1334 extnId = that.extnId;
1335 if (that.critical)
1336 {
1337 if (!critical)
1338 critical = new AsnBool;
1339 *critical = *that.critical;
1340 }
1341 else
1342 {
1343 delete critical;
1344 critical = NULL;
1345 }
1346 extnValue = that.extnValue;
1347 }
1348
1349 return *this;
1350 #else // SNACC_DEEP_COPY
1351 Asn1Error << "use of incompletely defined Extension &Extension::operator = (const Extension &)" << endl;
1352 abort();
1353 // if your compiler complains here, check the -novolat option
1354 #endif // SNACC_DEEP_COPY
1355 }
1356
1357 AsnLen
1358 Extension::BEncContent (BUF_TYPE b)
1359 {
1360 AsnLen totalLen = 0;
1361 AsnLen l;
1362
1363 l = extnValue.BEncContent (b);
1364 l += BEncDefLen (b, l);
1365
1366 l += BEncTag1 (b, UNIV, PRIM, OCTETSTRING_TAG_CODE);
1367 totalLen += l;
1368
1369 if (NOT_NULL (critical))
1370 {
1371 l = critical->BEncContent (b);
1372 BEncDefLenTo127 (b, l);
1373 l++;
1374
1375 l += BEncTag1 (b, UNIV, PRIM, BOOLEAN_TAG_CODE);
1376 totalLen += l;
1377 }
1378
1379 l = extnId.BEncContent (b);
1380 l += BEncDefLen (b, l);
1381
1382 l += BEncTag1 (b, UNIV, PRIM, OID_TAG_CODE);
1383 totalLen += l;
1384
1385 return totalLen;
1386 } // Extension::BEncContent
1387
1388
1389 void Extension::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1390 {
1391 AsnTag tag1;
1392 AsnLen seqBytesDecoded = 0;
1393 AsnLen elmtLen1;
1394 tag1 = BDecTag (b, seqBytesDecoded, env);
1395
1396 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OID_TAG_CODE)))
1397 {
1398 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1399 extnId.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1400 tag1 = BDecTag (b, seqBytesDecoded, env);
1401 }
1402 else
1403 {
1404 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1405 SnaccExcep::throwMe(-108);
1406 }
1407
1408 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BOOLEAN_TAG_CODE)))
1409 {
1410 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1411 critical = new AsnBool;
1412 critical->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1413 tag1 = BDecTag (b, seqBytesDecoded, env);
1414 }
1415
1416 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, OCTETSTRING_TAG_CODE))
1417 || (tag1 == MAKE_TAG_ID (UNIV, CONS, OCTETSTRING_TAG_CODE)))
1418 {
1419 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1420 extnValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1421 }
1422 else
1423 {
1424 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1425 SnaccExcep::throwMe(-109);
1426 }
1427
1428 bytesDecoded += seqBytesDecoded;
1429 if (elmtLen0 == INDEFINITE_LEN)
1430 {
1431 BDecEoc (b, bytesDecoded, env);
1432 return;
1433 }
1434 else if (seqBytesDecoded != elmtLen0)
1435 {
1436 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1437 SnaccExcep::throwMe(-110);
1438 }
1439 else
1440 return;
1441 } // Extension::BDecContent
1442
1443 AsnLen Extension::BEnc (BUF_TYPE b)
1444 {
1445 AsnLen l;
1446 l = BEncContent (b);
1447 l += BEncConsLen (b, l);
1448 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1449 return l;
1450 }
1451
1452 void Extension::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1453 {
1454 AsnTag tag;
1455 AsnLen elmtLen1;
1456
1457 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1458 {
1459 Asn1Error << "Extension::BDec: ERROR - wrong tag" << endl;
1460 SnaccExcep::throwMe(-111);
1461 }
1462 elmtLen1 = BDecLen (b, bytesDecoded, env);
1463 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1464 }
1465
1466 void Extension::Print (ostream &os) const
1467 {
1468 #ifndef NDEBUG
1469 os << "{ -- SEQUENCE --" << endl;
1470 indentG += stdIndentG;
1471
1472 {
1473 Indent (os, indentG);
1474 os << "extnId ";
1475 os << extnId;
1476 os << "," << endl;
1477 }
1478
1479 if (NOT_NULL (critical))
1480 {
1481 Indent (os, indentG);
1482 os << "critical ";
1483 os << *critical;
1484 }
1485 else
1486 {
1487 Indent (os, indentG);
1488 os << "critical ";
1489 os << "-- void --";
1490 os << "," << endl;
1491 }
1492
1493 {
1494 Indent (os, indentG);
1495 os << "extnValue ";
1496 os << extnValue;
1497 }
1498
1499 os << endl;
1500 indentG -= stdIndentG;
1501 Indent (os, indentG);
1502 os << "}";
1503 #endif /* NDEBUG */
1504 } // Extension::Print
1505
1506
1507 AttCertValidityPeriod::AttCertValidityPeriod()
1508 {
1509 }
1510
1511 AttCertValidityPeriod::AttCertValidityPeriod (const AttCertValidityPeriod &)
1512 {
1513 Asn1Error << "use of incompletely defined AttCertValidityPeriod::AttCertValidityPeriod (const AttCertValidityPeriod &)" << endl;
1514 abort();
1515 }
1516
1517 AttCertValidityPeriod::~AttCertValidityPeriod()
1518 {
1519 }
1520
1521 AsnType *AttCertValidityPeriod::Clone() const
1522 {
1523 return new AttCertValidityPeriod;
1524 }
1525
1526 AsnType *AttCertValidityPeriod::Copy() const
1527 {
1528 return new AttCertValidityPeriod (*this);
1529 }
1530
1531 #if SNACC_DEEP_COPY
1532 AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &that)
1533 #else // SNACC_DEEP_COPY
1534 AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &)
1535 #endif // SNACC_DEEP_COPY
1536 {
1537 #if SNACC_DEEP_COPY
1538 if (this != &that)
1539 {
1540 notBeforeTime = that.notBeforeTime;
1541 notAfterTime = that.notAfterTime;
1542 }
1543
1544 return *this;
1545 #else // SNACC_DEEP_COPY
1546 Asn1Error << "use of incompletely defined AttCertValidityPeriod &AttCertValidityPeriod::operator = (const AttCertValidityPeriod &)" << endl;
1547 abort();
1548 // if your compiler complains here, check the -novolat option
1549 #endif // SNACC_DEEP_COPY
1550 }
1551
1552 AsnLen
1553 AttCertValidityPeriod::BEncContent (BUF_TYPE b)
1554 {
1555 AsnLen totalLen = 0;
1556 AsnLen l;
1557
1558 l = notAfterTime.BEncContent (b);
1559 l += BEncDefLen (b, l);
1560
1561 l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE);
1562 totalLen += l;
1563
1564 l = notBeforeTime.BEncContent (b);
1565 l += BEncDefLen (b, l);
1566
1567 l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE);
1568 totalLen += l;
1569
1570 return totalLen;
1571 } // AttCertValidityPeriod::BEncContent
1572
1573
1574 void AttCertValidityPeriod::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1575 {
1576 AsnTag tag1;
1577 AsnLen seqBytesDecoded = 0;
1578 AsnLen elmtLen1;
1579 tag1 = BDecTag (b, seqBytesDecoded, env);
1580
1581 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
1582 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
1583 {
1584 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1585 notBeforeTime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1586 tag1 = BDecTag (b, seqBytesDecoded, env);
1587 }
1588 else
1589 {
1590 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1591 SnaccExcep::throwMe(-112);
1592 }
1593
1594 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
1595 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
1596 {
1597 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1598 notAfterTime.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1599 }
1600 else
1601 {
1602 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1603 SnaccExcep::throwMe(-113);
1604 }
1605
1606 bytesDecoded += seqBytesDecoded;
1607 if (elmtLen0 == INDEFINITE_LEN)
1608 {
1609 BDecEoc (b, bytesDecoded, env);
1610 return;
1611 }
1612 else if (seqBytesDecoded != elmtLen0)
1613 {
1614 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1615 SnaccExcep::throwMe(-114);
1616 }
1617 else
1618 return;
1619 } // AttCertValidityPeriod::BDecContent
1620
1621 AsnLen AttCertValidityPeriod::BEnc (BUF_TYPE b)
1622 {
1623 AsnLen l;
1624 l = BEncContent (b);
1625 l += BEncConsLen (b, l);
1626 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1627 return l;
1628 }
1629
1630 void AttCertValidityPeriod::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1631 {
1632 AsnTag tag;
1633 AsnLen elmtLen1;
1634
1635 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1636 {
1637 Asn1Error << "AttCertValidityPeriod::BDec: ERROR - wrong tag" << endl;
1638 SnaccExcep::throwMe(-115);
1639 }
1640 elmtLen1 = BDecLen (b, bytesDecoded, env);
1641 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1642 }
1643
1644 void AttCertValidityPeriod::Print (ostream &os) const
1645 {
1646 #ifndef NDEBUG
1647 os << "{ -- SEQUENCE --" << endl;
1648 indentG += stdIndentG;
1649
1650 {
1651 Indent (os, indentG);
1652 os << "notBeforeTime ";
1653 os << notBeforeTime;
1654 os << "," << endl;
1655 }
1656
1657 {
1658 Indent (os, indentG);
1659 os << "notAfterTime ";
1660 os << notAfterTime;
1661 }
1662
1663 os << endl;
1664 indentG -= stdIndentG;
1665 Indent (os, indentG);
1666 os << "}";
1667 #endif /* NDEBUG */
1668 } // AttCertValidityPeriod::Print
1669
1670
1671 Validity::Validity()
1672 {
1673 #if TCL
1674 notBefore = new Time;
1675 #else
1676 notBefore = NULL; // incomplete initialization of mandatory element!
1677 #endif // TCL
1678 #if TCL
1679 notAfter = new Time;
1680 #else
1681 notAfter = NULL; // incomplete initialization of mandatory element!
1682 #endif // TCL
1683 }
1684
1685 Validity::Validity (const Validity &)
1686 {
1687 Asn1Error << "use of incompletely defined Validity::Validity (const Validity &)" << endl;
1688 abort();
1689 }
1690
1691 Validity::~Validity()
1692 {
1693 delete notBefore;
1694 delete notAfter;
1695 }
1696
1697 AsnType *Validity::Clone() const
1698 {
1699 return new Validity;
1700 }
1701
1702 AsnType *Validity::Copy() const
1703 {
1704 return new Validity (*this);
1705 }
1706
1707 #if SNACC_DEEP_COPY
1708 Validity &Validity::operator = (const Validity &that)
1709 #else // SNACC_DEEP_COPY
1710 Validity &Validity::operator = (const Validity &)
1711 #endif // SNACC_DEEP_COPY
1712 {
1713 #if SNACC_DEEP_COPY
1714 if (this != &that)
1715 {
1716 if (that.notBefore)
1717 {
1718 if (!notBefore)
1719 notBefore = new Time;
1720 *notBefore = *that.notBefore;
1721 }
1722 else
1723 {
1724 delete notBefore;
1725 notBefore = NULL;
1726 }
1727 if (that.notAfter)
1728 {
1729 if (!notAfter)
1730 notAfter = new Time;
1731 *notAfter = *that.notAfter;
1732 }
1733 else
1734 {
1735 delete notAfter;
1736 notAfter = NULL;
1737 }
1738 }
1739
1740 return *this;
1741 #else // SNACC_DEEP_COPY
1742 Asn1Error << "use of incompletely defined Validity &Validity::operator = (const Validity &)" << endl;
1743 abort();
1744 // if your compiler complains here, check the -novolat option
1745 #endif // SNACC_DEEP_COPY
1746 }
1747
1748 AsnLen
1749 Validity::BEncContent (BUF_TYPE b)
1750 {
1751 AsnLen totalLen = 0;
1752 AsnLen l;
1753
1754 l = notAfter->BEncContent (b);
1755 totalLen += l;
1756
1757 l = notBefore->BEncContent (b);
1758 totalLen += l;
1759
1760 return totalLen;
1761 } // Validity::BEncContent
1762
1763
1764 void Validity::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1765 {
1766 AsnTag tag1;
1767 AsnLen seqBytesDecoded = 0;
1768 AsnLen elmtLen1;
1769 tag1 = BDecTag (b, seqBytesDecoded, env);
1770
1771 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))
1772 || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))
1773 || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
1774 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
1775 {
1776 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1777 notBefore = new Time;
1778 notBefore->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1779 tag1 = BDecTag (b, seqBytesDecoded, env);
1780 }
1781 else
1782 {
1783 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1784 SnaccExcep::throwMe(-116);
1785 }
1786
1787 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))
1788 || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))
1789 || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
1790 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
1791 {
1792 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1793 notAfter = new Time;
1794 notAfter->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1795 }
1796 else
1797 {
1798 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1799 SnaccExcep::throwMe(-117);
1800 }
1801
1802 bytesDecoded += seqBytesDecoded;
1803 if (elmtLen0 == INDEFINITE_LEN)
1804 {
1805 BDecEoc (b, bytesDecoded, env);
1806 return;
1807 }
1808 else if (seqBytesDecoded != elmtLen0)
1809 {
1810 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
1811 SnaccExcep::throwMe(-118);
1812 }
1813 else
1814 return;
1815 } // Validity::BDecContent
1816
1817 AsnLen Validity::BEnc (BUF_TYPE b)
1818 {
1819 AsnLen l;
1820 l = BEncContent (b);
1821 l += BEncConsLen (b, l);
1822 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1823 return l;
1824 }
1825
1826 void Validity::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
1827 {
1828 AsnTag tag;
1829 AsnLen elmtLen1;
1830
1831 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
1832 {
1833 Asn1Error << "Validity::BDec: ERROR - wrong tag" << endl;
1834 SnaccExcep::throwMe(-119);
1835 }
1836 elmtLen1 = BDecLen (b, bytesDecoded, env);
1837 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
1838 }
1839
1840 void Validity::Print (ostream &os) const
1841 {
1842 #ifndef NDEBUG
1843 os << "{ -- SEQUENCE --" << endl;
1844 indentG += stdIndentG;
1845
1846 if (NOT_NULL (notBefore))
1847 {
1848 Indent (os, indentG);
1849 os << "notBefore ";
1850 os << *notBefore;
1851 }
1852 else
1853 {
1854 Indent (os, indentG);
1855 os << "notBefore ";
1856 os << "-- void --";
1857 os << "," << endl;
1858 }
1859
1860 if (NOT_NULL (notAfter))
1861 {
1862 Indent (os, indentG);
1863 os << "notAfter ";
1864 os << *notAfter;
1865 }
1866 else
1867 {
1868 Indent (os, indentG);
1869 os << "notAfter ";
1870 os << "-- void --";
1871 os << endl;
1872 }
1873
1874 os << endl;
1875 indentG -= stdIndentG;
1876 Indent (os, indentG);
1877 os << "}";
1878 #endif /* NDEBUG */
1879 } // Validity::Print
1880
1881
1882 SubjectPublicKeyInfo::SubjectPublicKeyInfo()
1883 {
1884 #if TCL
1885 algorithm = new AlgorithmIdentifier;
1886 #else
1887 algorithm = NULL; // incomplete initialization of mandatory element!
1888 #endif // TCL
1889 }
1890
1891 SubjectPublicKeyInfo::SubjectPublicKeyInfo (const SubjectPublicKeyInfo &)
1892 {
1893 Asn1Error << "use of incompletely defined SubjectPublicKeyInfo::SubjectPublicKeyInfo (const SubjectPublicKeyInfo &)" << endl;
1894 abort();
1895 }
1896
1897 SubjectPublicKeyInfo::~SubjectPublicKeyInfo()
1898 {
1899 delete algorithm;
1900 }
1901
1902 AsnType *SubjectPublicKeyInfo::Clone() const
1903 {
1904 return new SubjectPublicKeyInfo;
1905 }
1906
1907 AsnType *SubjectPublicKeyInfo::Copy() const
1908 {
1909 return new SubjectPublicKeyInfo (*this);
1910 }
1911
1912 #if SNACC_DEEP_COPY
1913 SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &that)
1914 #else // SNACC_DEEP_COPY
1915 SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &)
1916 #endif // SNACC_DEEP_COPY
1917 {
1918 #if SNACC_DEEP_COPY
1919 if (this != &that)
1920 {
1921 if (that.algorithm)
1922 {
1923 if (!algorithm)
1924 algorithm = new AlgorithmIdentifier;
1925 *algorithm = *that.algorithm;
1926 }
1927 else
1928 {
1929 delete algorithm;
1930 algorithm = NULL;
1931 }
1932 subjectPublicKey = that.subjectPublicKey;
1933 }
1934
1935 return *this;
1936 #else // SNACC_DEEP_COPY
1937 Asn1Error << "use of incompletely defined SubjectPublicKeyInfo &SubjectPublicKeyInfo::operator = (const SubjectPublicKeyInfo &)" << endl;
1938 abort();
1939 // if your compiler complains here, check the -novolat option
1940 #endif // SNACC_DEEP_COPY
1941 }
1942
1943 AsnLen
1944 SubjectPublicKeyInfo::BEncContent (BUF_TYPE b)
1945 {
1946 AsnLen totalLen = 0;
1947 AsnLen l;
1948
1949 l = subjectPublicKey.BEncContent (b);
1950 l += BEncDefLen (b, l);
1951
1952 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
1953 totalLen += l;
1954
1955 BEncEocIfNec (b);
1956 l = algorithm->BEncContent (b);
1957 l += BEncConsLen (b, l);
1958
1959 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
1960 totalLen += l;
1961
1962 return totalLen;
1963 } // SubjectPublicKeyInfo::BEncContent
1964
1965
1966 void SubjectPublicKeyInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
1967 {
1968 AsnTag tag1;
1969 AsnLen seqBytesDecoded = 0;
1970 AsnLen elmtLen1;
1971 tag1 = BDecTag (b, seqBytesDecoded, env);
1972
1973 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
1974 {
1975 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1976 algorithm = new AlgorithmIdentifier;
1977 algorithm->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1978 tag1 = BDecTag (b, seqBytesDecoded, env);
1979 }
1980 else
1981 {
1982 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1983 SnaccExcep::throwMe(-120);
1984 }
1985
1986 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
1987 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
1988 {
1989 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
1990 subjectPublicKey.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
1991 }
1992 else
1993 {
1994 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
1995 SnaccExcep::throwMe(-121);
1996 }
1997
1998 bytesDecoded += seqBytesDecoded;
1999 if (elmtLen0 == INDEFINITE_LEN)
2000 {
2001 BDecEoc (b, bytesDecoded, env);
2002 return;
2003 }
2004 else if (seqBytesDecoded != elmtLen0)
2005 {
2006 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
2007 SnaccExcep::throwMe(-122);
2008 }
2009 else
2010 return;
2011 } // SubjectPublicKeyInfo::BDecContent
2012
2013 AsnLen SubjectPublicKeyInfo::BEnc (BUF_TYPE b)
2014 {
2015 AsnLen l;
2016 l = BEncContent (b);
2017 l += BEncConsLen (b, l);
2018 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2019 return l;
2020 }
2021
2022 void SubjectPublicKeyInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2023 {
2024 AsnTag tag;
2025 AsnLen elmtLen1;
2026
2027 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2028 {
2029 Asn1Error << "SubjectPublicKeyInfo::BDec: ERROR - wrong tag" << endl;
2030 SnaccExcep::throwMe(-123);
2031 }
2032 elmtLen1 = BDecLen (b, bytesDecoded, env);
2033 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2034 }
2035
2036 void SubjectPublicKeyInfo::Print (ostream &os) const
2037 {
2038 #ifndef NDEBUG
2039 os << "{ -- SEQUENCE --" << endl;
2040 indentG += stdIndentG;
2041
2042 if (NOT_NULL (algorithm))
2043 {
2044 Indent (os, indentG);
2045 os << "algorithm ";
2046 os << *algorithm;
2047 }
2048 else
2049 {
2050 Indent (os, indentG);
2051 os << "algorithm ";
2052 os << "-- void --";
2053 os << "," << endl;
2054 }
2055
2056 {
2057 Indent (os, indentG);
2058 os << "subjectPublicKey ";
2059 os << subjectPublicKey;
2060 }
2061
2062 os << endl;
2063 indentG -= stdIndentG;
2064 Indent (os, indentG);
2065 os << "}";
2066 #endif /* NDEBUG */
2067 } // SubjectPublicKeyInfo::Print
2068
2069
2070 AsnType *Extensions::Clone() const
2071 {
2072 return new Extensions;
2073 }
2074
2075 AsnType *Extensions::Copy() const
2076 {
2077 return new Extensions (*this);
2078 }
2079
2080 AsnLen Extensions::BEnc (BUF_TYPE b)
2081 {
2082 AsnLen l;
2083 l = BEncContent (b);
2084 l += BEncConsLen (b, l);
2085 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2086 return l;
2087 }
2088
2089 void Extensions::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2090 {
2091 AsnTag tag;
2092 AsnLen elmtLen1;
2093
2094 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2095 {
2096 Asn1Error << "Extensions::BDec: ERROR - wrong tag" << endl;
2097 SnaccExcep::throwMe(-124);
2098 }
2099 elmtLen1 = BDecLen (b, bytesDecoded, env);
2100 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2101 }
2102
2103 Extensions::Extensions (const Extensions &)
2104 {
2105 Asn1Error << "use of incompletely defined Extensions::Extensions (const Extensions &)" << endl;
2106 abort();
2107 }
2108
2109 Extensions::~Extensions()
2110 {
2111 SetCurrToFirst();
2112 for (; Curr() != NULL; RemoveCurrFromList())
2113 ;
2114 } // end of destructor
2115
2116 #if SNACC_DEEP_COPY
2117 Extensions &Extensions::operator = (const Extensions &that)
2118 #else // SNACC_DEEP_COPY
2119 Extensions &Extensions::operator = (const Extensions &)
2120 #endif // SNACC_DEEP_COPY
2121 {
2122 #if SNACC_DEEP_COPY
2123 if (this != &that)
2124 {
2125 SetCurrToFirst();
2126 for (; Curr(); RemoveCurrFromList())
2127 ;
2128
2129 //that.SetCurrToFirst();
2130 //for (; that.Curr(); that.GoNext())
2131 // AppendCopy (*that.Curr());
2132 for (const AsnListElmt *run=that.first; run; run=run->next)
2133 AppendCopy (*run->elmt);
2134 }
2135
2136 return *this;
2137 #else // SNACC_DEEP_COPY
2138 Asn1Error << "use of incompletely defined Extensions &Extensions::operator = (const Extensions &)" << endl;
2139 abort();
2140 // if your compiler complains here, check the -novolat option
2141 #endif // SNACC_DEEP_COPY
2142 }
2143
2144 void Extensions::Print (ostream &os) const
2145 {
2146 #ifndef NDEBUG
2147 os << "{ -- SEQUENCE/SET OF -- " << endl;
2148 indentG += stdIndentG;
2149 //SetCurrToFirst();
2150 //for (; Curr() != NULL; GoNext())
2151 for (const AsnListElmt *run=first; run; run=run->next)
2152 {
2153 Indent (os, indentG);
2154 //os << *Curr();
2155 os << *run->elmt;
2156 //if (Curr() != Last())
2157 if (run != last)
2158 os << ",";
2159 os << endl;
2160 }
2161 indentG -= stdIndentG;
2162 Indent (os, indentG);
2163 os << "}\n";
2164 #endif /* NDEBUG */
2165
2166
2167 } // Print
2168
2169
2170 void Extensions::SetCurrElmt (unsigned long int index)
2171 {
2172 unsigned long int i;
2173 curr = first;
2174 if (count)
2175 for (i = 0; (i < (count-1)) && (i < index); i++)
2176 curr = curr->next;
2177 } // Extensions::SetCurrElmt
2178
2179
2180 unsigned long int Extensions::GetCurrElmtIndex()
2181 {
2182 unsigned long int i;
2183 AsnListElmt *tmp;
2184 if (curr != NULL)
2185 {
2186 for (i = 0, tmp = first; tmp != NULL; i++)
2187 {
2188 if (tmp == curr)
2189 return i;
2190 else
2191 tmp = tmp->next;
2192 }
2193 }
2194 return count;
2195 } // Extensions::GetCurrElmtIndex
2196
2197
2198 // alloc new list elmt, put at end of list
2199 // and return the component type
2200 Extension *Extensions::Append()
2201 {
2202 AsnListElmt *newElmt;
2203 newElmt = new AsnListElmt;
2204 newElmt->elmt = new Extension;
2205 newElmt->next = NULL;
2206 if (last == NULL)
2207 {
2208 newElmt->prev = NULL;
2209 first = last = newElmt;
2210 }
2211 else
2212 {
2213 newElmt->prev = last;
2214 last->next = newElmt;
2215 last = newElmt;
2216 }
2217 count++;
2218 return (curr = newElmt)->elmt;
2219 } // Extensions::Append
2220
2221
2222 // alloc new list elmt, put at begining of list
2223 // and return the component type
2224 Extension *Extensions::Prepend()
2225 {
2226 AsnListElmt *newElmt;
2227 newElmt = new AsnListElmt;
2228 newElmt->elmt = new Extension;
2229 newElmt->prev = NULL;
2230 if (first == NULL)
2231 {
2232 newElmt->next = NULL;
2233 first = last = newElmt;
2234 }
2235 else
2236 {
2237 newElmt->next = first;
2238 first->prev = newElmt;
2239 first = newElmt;
2240 }
2241 count++;
2242 return (curr = newElmt)->elmt;
2243 } // Extensions::Prepend
2244
2245
2246 // alloc new list elmt, insert it before the
2247 // current element and return the component type
2248 // if the current element is null, the new element
2249 // is placed at the beginning of the list.
2250 Extension *Extensions::InsertBefore()
2251 {
2252 AsnListElmt *newElmt;
2253 newElmt = new AsnListElmt;
2254 newElmt->elmt = new Extension;
2255 if (curr == NULL)
2256 {
2257 newElmt->next = first;
2258 newElmt->prev = NULL;
2259 first = newElmt;
2260 if (last == NULL)
2261 last = newElmt;
2262 }
2263 else
2264 {
2265 newElmt->next = curr;
2266 newElmt->prev = curr->prev;
2267 curr->prev = newElmt;
2268 if (curr == first)
2269 first = newElmt;
2270 else
2271 newElmt->prev->next = newElmt;
2272 }
2273 count++;
2274 return (curr = newElmt)->elmt;
2275 } // Extensions::InsertBefore
2276
2277
2278 // alloc new list elmt, insert it after the
2279 // current element and return the component type
2280 // if the current element is null, the new element
2281 // is placed at the end of the list.
2282 Extension *Extensions::InsertAfter()
2283 {
2284 AsnListElmt *newElmt;
2285 newElmt = new AsnListElmt;
2286 newElmt->elmt = new Extension;
2287 if (curr == NULL)
2288 {
2289 newElmt->prev = last;
2290 newElmt->next = NULL;
2291 last = newElmt;
2292 if (first == NULL)
2293 first = newElmt;
2294 }
2295 else
2296 {
2297 newElmt->prev = curr;
2298 newElmt->next = curr->next;
2299 curr->next = newElmt;
2300 if (curr == last)
2301 last = newElmt;
2302 else
2303 newElmt->next->prev = newElmt;
2304 }
2305 count++;
2306 return (curr = newElmt)->elmt;
2307 } // Extensions::InsertAfter
2308
2309
2310 Extensions &Extensions::AppendCopy (Extension &elmt)
2311 {
2312 AsnListElmt *newElmt;
2313 newElmt = new AsnListElmt;
2314 newElmt->elmt = new Extension;
2315 *newElmt->elmt = elmt;
2316 newElmt->next = NULL;
2317 if (last == NULL)
2318 {
2319 newElmt->prev = NULL;
2320 first = last = newElmt;
2321 }
2322 else
2323 {
2324 newElmt->prev = last;
2325 last->next = newElmt;
2326 last = newElmt;
2327 }
2328 count++;
2329 return *this;
2330 } // AppendCopy
2331
2332
2333 Extensions &Extensions::PrependCopy (Extension &elmt)
2334 {
2335 AsnListElmt *newElmt;
2336 newElmt = new AsnListElmt;
2337 newElmt->elmt = new Extension;
2338 *newElmt->elmt = elmt;
2339 newElmt->prev = NULL;
2340 if (first == NULL)
2341 {
2342 newElmt->next = NULL;
2343 first = last = newElmt;
2344 }
2345 else
2346 {
2347 newElmt->next = first;
2348 first->prev = newElmt;
2349 first = newElmt;
2350 }
2351 count++;
2352 return *this;
2353 } // Extensions::PrependCopy
2354
2355
2356 // alloc new list elmt, insert it before the
2357 // current element, copy the given elmt into the new elmt
2358 // and return the component type.
2359 // if the current element is null, the new element
2360 // is placed at the beginning of the list.
2361 Extensions &Extensions::InsertBeforeAndCopy (Extension &elmt)
2362 {
2363 AsnListElmt *newElmt;
2364
2365 newElmt = new AsnListElmt;
2366 newElmt->elmt = new Extension;
2367 *newElmt->elmt = elmt;
2368
2369 if (curr == NULL)
2370 {
2371 newElmt->next = first;
2372 newElmt->prev = NULL;
2373 first = newElmt;
2374 if (last == NULL)
2375 last = newElmt;
2376 }
2377 else
2378 {
2379 newElmt->next = curr;
2380 newElmt->prev = curr->prev;
2381 curr->prev = newElmt;
2382 if (curr == first)
2383 first = newElmt;
2384 else
2385 newElmt->prev->next = newElmt;
2386 }
2387 count++;
2388 return *this;
2389 } // Extensions::InsertBeforeAndCopy
2390
2391
2392 // alloc new list elmt, insert it after the
2393 // current element, copy given elmt in to new elmt
2394 // and return the component type
2395 // if the current element is null, the new element
2396 // is placed at the end of the list.
2397 Extensions &Extensions::InsertAfterAndCopy (Extension &elmt)
2398 {
2399 AsnListElmt *newElmt;
2400
2401 newElmt = new AsnListElmt;
2402 newElmt->elmt = new Extension;
2403 *newElmt->elmt = elmt;
2404 if (curr == NULL)
2405 {
2406 newElmt->prev = last;
2407 newElmt->next = NULL;
2408 last = newElmt;
2409 if (first == NULL)
2410 first = newElmt;
2411 }
2412 else
2413 {
2414 newElmt->prev = curr;
2415 newElmt->next = curr->next;
2416 curr->next = newElmt;
2417 if (curr == last)
2418 last = newElmt;
2419 else
2420 newElmt->next->prev = newElmt;
2421 }
2422 count++;
2423 return *this;
2424 } // Extensions::InsertAfterAndCopy
2425
2426
2427 // remove current element from list if current element is not NULL
2428 // The new current element will be the next element.
2429 // If the current element is the last element in the list
2430 // the second but last element will become the new current element.
2431 void Extensions::RemoveCurrFromList()
2432 {
2433 AsnListElmt *del_elmt;
2434
2435 if (curr != NULL)
2436 {
2437 del_elmt = curr;
2438 count--;
2439
2440 if (count == 0)
2441 first = last = curr = NULL;
2442 else if (curr == first)
2443 {
2444 curr = first= first->next;
2445 first->prev = NULL;
2446 }
2447 else if (curr == last)
2448 {
2449 curr = last = last->prev;
2450 last->next = NULL;
2451 }
2452 else
2453 {
2454 curr->prev->next = curr->next;
2455 curr->next->prev = curr->prev;
2456 }
2457
2458 delete del_elmt->elmt;
2459 delete del_elmt;
2460 }
2461 }
2462
2463
2464 AsnLen Extensions::BEncContent (BUF_TYPE b)
2465 {
2466 AsnListElmt *currElmt;
2467 AsnLen elmtLen;
2468 AsnLen totalLen = 0;
2469 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
2470 {
2471 BEncEocIfNec (b);
2472 elmtLen = currElmt->elmt->BEncContent (b);
2473 elmtLen += BEncConsLen (b, elmtLen);
2474
2475 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2476 totalLen += elmtLen;
2477 }
2478 return totalLen;
2479 } // Extensions::BEncContent
2480
2481
2482 void Extensions::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
2483 AsnLen &bytesDecoded, ENV_TYPE env)
2484 {
2485 Extension *listElmt;
2486 AsnTag tag1;
2487 AsnLen listBytesDecoded = 0;
2488 AsnLen elmtLen1;
2489
2490 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
2491 {
2492 tag1 = BDecTag (b, listBytesDecoded, env);
2493 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
2494 {
2495 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
2496 break;
2497 }
2498 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
2499 {
2500 Asn1Error << "Unexpected Tag" << endl;
2501 SnaccExcep::throwMe(-125);
2502 }
2503
2504 elmtLen1 = BDecLen (b, listBytesDecoded, env);
2505 listElmt = Append();
2506 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
2507 }
2508
2509 bytesDecoded += listBytesDecoded;
2510 } // Extensions::BDecContent
2511
2512
2513 IssuerSerial::IssuerSerial()
2514 {
2515 issuerUID = NULL;
2516 }
2517
2518 IssuerSerial::IssuerSerial (const IssuerSerial &)
2519 {
2520 Asn1Error << "use of incompletely defined IssuerSerial::IssuerSerial (const IssuerSerial &)" << endl;
2521 abort();
2522 }
2523
2524 IssuerSerial::~IssuerSerial()
2525 {
2526 delete issuerUID;
2527 }
2528
2529 AsnType *IssuerSerial::Clone() const
2530 {
2531 return new IssuerSerial;
2532 }
2533
2534 AsnType *IssuerSerial::Copy() const
2535 {
2536 return new IssuerSerial (*this);
2537 }
2538
2539 #if SNACC_DEEP_COPY
2540 IssuerSerial &IssuerSerial::operator = (const IssuerSerial &that)
2541 #else // SNACC_DEEP_COPY
2542 IssuerSerial &IssuerSerial::operator = (const IssuerSerial &)
2543 #endif // SNACC_DEEP_COPY
2544 {
2545 #if SNACC_DEEP_COPY
2546 if (this != &that)
2547 {
2548 issuer = that.issuer;
2549 serial = that.serial;
2550 if (that.issuerUID)
2551 {
2552 if (!issuerUID)
2553 issuerUID = new UniqueIdentifier;
2554 *issuerUID = *that.issuerUID;
2555 }
2556 else
2557 {
2558 delete issuerUID;
2559 issuerUID = NULL;
2560 }
2561 }
2562
2563 return *this;
2564 #else // SNACC_DEEP_COPY
2565 Asn1Error << "use of incompletely defined IssuerSerial &IssuerSerial::operator = (const IssuerSerial &)" << endl;
2566 abort();
2567 // if your compiler complains here, check the -novolat option
2568 #endif // SNACC_DEEP_COPY
2569 }
2570
2571 AsnLen
2572 IssuerSerial::BEncContent (BUF_TYPE b)
2573 {
2574 AsnLen totalLen = 0;
2575 AsnLen l;
2576
2577 if (NOT_NULL (issuerUID))
2578 {
2579 l = issuerUID->BEncContent (b);
2580 l += BEncDefLen (b, l);
2581
2582 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
2583 totalLen += l;
2584 }
2585
2586 l = serial.BEncContent (b);
2587 l += BEncDefLen (b, l);
2588
2589 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
2590 totalLen += l;
2591
2592 BEncEocIfNec (b);
2593 l = issuer.BEncContent (b);
2594 l += BEncConsLen (b, l);
2595
2596 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2597 totalLen += l;
2598
2599 return totalLen;
2600 } // IssuerSerial::BEncContent
2601
2602
2603 void IssuerSerial::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
2604 {
2605 AsnTag tag1;
2606 AsnLen seqBytesDecoded = 0;
2607 AsnLen elmtLen1;
2608 tag1 = BDecTag (b, seqBytesDecoded, env);
2609
2610 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
2611 {
2612 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2613 issuer.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
2614 tag1 = BDecTag (b, seqBytesDecoded, env);
2615 }
2616 else
2617 {
2618 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
2619 SnaccExcep::throwMe(-126);
2620 }
2621
2622 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
2623 || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE)))
2624 {
2625 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2626 serial.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
2627 if (seqBytesDecoded == elmtLen0)
2628 {
2629 bytesDecoded += seqBytesDecoded;
2630 return;
2631 }
2632 else
2633 {
2634 tag1 = BDecTag (b, seqBytesDecoded, env);
2635
2636 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
2637 {
2638 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
2639 bytesDecoded += seqBytesDecoded;
2640 return;
2641 }
2642 }
2643 }
2644 else
2645 {
2646 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
2647 SnaccExcep::throwMe(-127);
2648 }
2649
2650 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
2651 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
2652 {
2653 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
2654 issuerUID = new UniqueIdentifier;
2655 issuerUID->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
2656 }
2657
2658 bytesDecoded += seqBytesDecoded;
2659 if (elmtLen0 == INDEFINITE_LEN)
2660 {
2661 BDecEoc (b, bytesDecoded, env);
2662 return;
2663 }
2664 else if (seqBytesDecoded != elmtLen0)
2665 {
2666 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
2667 SnaccExcep::throwMe(-128);
2668 }
2669 else
2670 return;
2671 } // IssuerSerial::BDecContent
2672
2673 AsnLen IssuerSerial::BEnc (BUF_TYPE b)
2674 {
2675 AsnLen l;
2676 l = BEncContent (b);
2677 l += BEncConsLen (b, l);
2678 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2679 return l;
2680 }
2681
2682 void IssuerSerial::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2683 {
2684 AsnTag tag;
2685 AsnLen elmtLen1;
2686
2687 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2688 {
2689 Asn1Error << "IssuerSerial::BDec: ERROR - wrong tag" << endl;
2690 SnaccExcep::throwMe(-129);
2691 }
2692 elmtLen1 = BDecLen (b, bytesDecoded, env);
2693 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2694 }
2695
2696 void IssuerSerial::Print (ostream &os) const
2697 {
2698 #ifndef NDEBUG
2699 os << "{ -- SEQUENCE --" << endl;
2700 indentG += stdIndentG;
2701
2702 {
2703 Indent (os, indentG);
2704 os << "issuer ";
2705 os << issuer;
2706 os << "," << endl;
2707 }
2708
2709 {
2710 Indent (os, indentG);
2711 os << "serial ";
2712 os << serial;
2713 os << "," << endl;
2714 }
2715
2716 if (NOT_NULL (issuerUID))
2717 {
2718 os << ","<< endl;
2719 Indent (os, indentG);
2720 os << "issuerUID ";
2721 os << *issuerUID;
2722 }
2723 else
2724 {
2725 Indent (os, indentG);
2726 os << "issuerUID ";
2727 os << "-- void --";
2728 os << endl;
2729 }
2730
2731 os << endl;
2732 indentG -= stdIndentG;
2733 Indent (os, indentG);
2734 os << "}";
2735 #endif /* NDEBUG */
2736 } // IssuerSerial::Print
2737
2738
2739 AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice()
2740 {
2741 choiceId = baseCertificateIDCid;
2742 #if TCL
2743 baseCertificateID = new IssuerSerial;
2744 #else
2745 baseCertificateID = NULL; // incomplete initialization of mandatory element!
2746 #endif // TCL
2747 }
2748
2749 AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice (const AttributeCertificateAssertionChoice &)
2750 {
2751 Asn1Error << "use of incompletely defined AttributeCertificateAssertionChoice::AttributeCertificateAssertionChoice (const AttributeCertificateAssertionChoice &)" << endl;
2752 abort();
2753 }
2754
2755 AttributeCertificateAssertionChoice::~AttributeCertificateAssertionChoice()
2756 {
2757 switch (choiceId)
2758 {
2759 case baseCertificateIDCid:
2760 delete baseCertificateID;
2761 break;
2762 case subjectNameCid:
2763 delete subjectName;
2764 break;
2765 } // end of switch
2766 } // end of destructor
2767
2768 AsnType *AttributeCertificateAssertionChoice::Clone() const
2769 {
2770 return new AttributeCertificateAssertionChoice;
2771 }
2772
2773 AsnType *AttributeCertificateAssertionChoice::Copy() const
2774 {
2775 return new AttributeCertificateAssertionChoice (*this);
2776 }
2777
2778 #if SNACC_DEEP_COPY
2779 AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &that)
2780 #else // SNACC_DEEP_COPY
2781 AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &)
2782 #endif // SNACC_DEEP_COPY
2783 {
2784 #if SNACC_DEEP_COPY
2785 if (this != &that)
2786 {
2787 switch (choiceId)
2788 {
2789 case baseCertificateIDCid:
2790 delete baseCertificateID;
2791 break;
2792 case subjectNameCid:
2793 delete subjectName;
2794 break;
2795 }
2796 switch (choiceId = that.choiceId)
2797 {
2798 case baseCertificateIDCid:
2799 baseCertificateID = new IssuerSerial;
2800 *baseCertificateID = *that.baseCertificateID;
2801 break;
2802 case subjectNameCid:
2803 subjectName = new Name;
2804 *subjectName = *that.subjectName;
2805 break;
2806 }
2807 }
2808
2809 return *this;
2810 #else // SNACC_DEEP_COPY
2811 Asn1Error << "use of incompletely defined AttributeCertificateAssertionChoice &AttributeCertificateAssertionChoice::operator = (const AttributeCertificateAssertionChoice &)" << endl;
2812 abort();
2813 // if your compiler complains here, check the -novolat option
2814 #endif // SNACC_DEEP_COPY
2815 }
2816
2817 AsnLen
2818 AttributeCertificateAssertionChoice::BEncContent (BUF_TYPE b)
2819 {
2820 AsnLen l;
2821 switch (choiceId)
2822 {
2823 case baseCertificateIDCid:
2824 BEncEocIfNec (b);
2825 BEncEocIfNec (b);
2826 l = baseCertificateID->BEncContent (b);
2827 l += BEncConsLen (b, l);
2828
2829 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
2830 l += BEncConsLen (b, l);
2831
2832 l += BEncTag1 (b, CNTX, CONS, 0);
2833 break;
2834
2835 case subjectNameCid:
2836 BEncEocIfNec (b);
2837 l = subjectName->BEncContent (b);
2838 l += BEncConsLen (b, l);
2839
2840 l += BEncTag1 (b, CNTX, CONS, 1);
2841 break;
2842
2843 } // end switch
2844 return l;
2845 } // AttributeCertificateAssertionChoice::BEncContent
2846
2847
2848 void AttributeCertificateAssertionChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
2849 {
2850 AsnLen elmtLen1;
2851 switch (tag)
2852 {
2853 case MAKE_TAG_ID (CNTX, CONS, 0):
2854 tag = BDecTag (b, bytesDecoded, env);
2855 if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
2856 {
2857 Asn1Error << "Unexpected Tag" << endl;
2858 SnaccExcep::throwMe(-130);
2859 }
2860
2861 elmtLen1 = BDecLen (b, bytesDecoded, env);
2862 choiceId = baseCertificateIDCid;
2863 baseCertificateID = new IssuerSerial;
2864 baseCertificateID->BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2865 if (elmtLen0 == INDEFINITE_LEN)
2866 BDecEoc (b, bytesDecoded, env);
2867 break;
2868
2869 case MAKE_TAG_ID (CNTX, CONS, 1):
2870 tag = BDecTag (b, bytesDecoded, env);
2871 elmtLen1 = BDecLen (b, bytesDecoded, env);
2872 choiceId = subjectNameCid;
2873 subjectName = new Name;
2874 subjectName->BDecContent (b, tag, elmtLen1, bytesDecoded, env);
2875 if (elmtLen0 == INDEFINITE_LEN)
2876 BDecEoc (b, bytesDecoded, env);
2877 break;
2878
2879 default:
2880 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
2881 SnaccExcep::throwMe(-131);
2882 break;
2883 } // end switch
2884 } // AttributeCertificateAssertionChoice::BDecContent
2885
2886
2887 AsnLen AttributeCertificateAssertionChoice::BEnc (BUF_TYPE b)
2888 {
2889 AsnLen l;
2890 l = BEncContent (b);
2891 return l;
2892 }
2893
2894 void AttributeCertificateAssertionChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
2895 {
2896 AsnLen elmtLen;
2897 AsnTag tag;
2898
2899 /* CHOICEs are a special case - grab identifying tag */
2900 /* this allows easier handling of nested CHOICEs */
2901 tag = BDecTag (b, bytesDecoded, env);
2902 elmtLen = BDecLen (b, bytesDecoded, env);
2903 BDecContent (b, tag, elmtLen, bytesDecoded, env);
2904 }
2905
2906 void AttributeCertificateAssertionChoice::Print (ostream &os) const
2907 {
2908 #ifndef NDEBUG
2909 switch (choiceId)
2910 {
2911 case baseCertificateIDCid:
2912 os << "baseCertificateID ";
2913 if (baseCertificateID)
2914 os << *baseCertificateID;
2915 else
2916 os << "-- void3 --\n";
2917 break;
2918
2919 case subjectNameCid:
2920 os << "subjectName ";
2921 if (subjectName)
2922 os << *subjectName;
2923 else
2924 os << "-- void3 --\n";
2925 break;
2926
2927 } // end of switch
2928 #endif /* NDEBUG */
2929 } // AttributeCertificateAssertionChoice::Print
2930
2931 AttributeCertificateInfoChoice::AttributeCertificateInfoChoice()
2932 {
2933 choiceId = baseCertificateIDCid;
2934 #if TCL
2935 baseCertificateID = new IssuerSerial;
2936 #else
2937 baseCertificateID = NULL; // incomplete initialization of mandatory element!
2938 #endif // TCL
2939 }
2940
2941 AttributeCertificateInfoChoice::AttributeCertificateInfoChoice (const AttributeCertificateInfoChoice &)
2942 {
2943 Asn1Error << "use of incompletely defined AttributeCertificateInfoChoice::AttributeCertificateInfoChoice (const AttributeCertificateInfoChoice &)" << endl;
2944 abort();
2945 }
2946
2947 AttributeCertificateInfoChoice::~AttributeCertificateInfoChoice()
2948 {
2949 switch (choiceId)
2950 {
2951 case baseCertificateIDCid:
2952 delete baseCertificateID;
2953 break;
2954 case subjectNameCid:
2955 delete subjectName;
2956 break;
2957 } // end of switch
2958 } // end of destructor
2959
2960 AsnType *AttributeCertificateInfoChoice::Clone() const
2961 {
2962 return new AttributeCertificateInfoChoice;
2963 }
2964
2965 AsnType *AttributeCertificateInfoChoice::Copy() const
2966 {
2967 return new AttributeCertificateInfoChoice (*this);
2968 }
2969
2970 #if SNACC_DEEP_COPY
2971 AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &that)
2972 #else // SNACC_DEEP_COPY
2973 AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &)
2974 #endif // SNACC_DEEP_COPY
2975 {
2976 #if SNACC_DEEP_COPY
2977 if (this != &that)
2978 {
2979 switch (choiceId)
2980 {
2981 case baseCertificateIDCid:
2982 delete baseCertificateID;
2983 break;
2984 case subjectNameCid:
2985 delete subjectName;
2986 break;
2987 }
2988 switch (choiceId = that.choiceId)
2989 {
2990 case baseCertificateIDCid:
2991 baseCertificateID = new IssuerSerial;
2992 *baseCertificateID = *that.baseCertificateID;
2993 break;
2994 case subjectNameCid:
2995 subjectName = new GeneralNames;
2996 *subjectName = *that.subjectName;
2997 break;
2998 }
2999 }
3000
3001 return *this;
3002 #else // SNACC_DEEP_COPY
3003 Asn1Error << "use of incompletely defined AttributeCertificateInfoChoice &AttributeCertificateInfoChoice::operator = (const AttributeCertificateInfoChoice &)" << endl;
3004 abort();
3005 // if your compiler complains here, check the -novolat option
3006 #endif // SNACC_DEEP_COPY
3007 }
3008
3009 AsnLen
3010 AttributeCertificateInfoChoice::BEncContent (BUF_TYPE b)
3011 {
3012 AsnLen l;
3013 switch (choiceId)
3014 {
3015 case baseCertificateIDCid:
3016 BEncEocIfNec (b);
3017 BEncEocIfNec (b);
3018 l = baseCertificateID->BEncContent (b);
3019 l += BEncConsLen (b, l);
3020
3021 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3022 l += BEncConsLen (b, l);
3023
3024 l += BEncTag1 (b, CNTX, CONS, 0);
3025 break;
3026
3027 case subjectNameCid:
3028 BEncEocIfNec (b);
3029 BEncEocIfNec (b);
3030 l = subjectName->BEncContent (b);
3031 l += BEncConsLen (b, l);
3032
3033 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3034 l += BEncConsLen (b, l);
3035
3036 l += BEncTag1 (b, CNTX, CONS, 1);
3037 break;
3038
3039 } // end switch
3040 return l;
3041 } // AttributeCertificateInfoChoice::BEncContent
3042
3043
3044 void AttributeCertificateInfoChoice::BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
3045 {
3046 AsnLen elmtLen1;
3047 switch (tag)
3048 {
3049 case MAKE_TAG_ID (CNTX, CONS, 0):
3050 tag = BDecTag (b, bytesDecoded, env);
3051 if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3052 {
3053 Asn1Error << "Unexpected Tag" << endl;
3054 SnaccExcep::throwMe(-132);
3055 }
3056
3057 elmtLen1 = BDecLen (b, bytesDecoded, env);
3058 choiceId = baseCertificateIDCid;
3059 baseCertificateID = new IssuerSerial;
3060 baseCertificateID->BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3061 if (elmtLen0 == INDEFINITE_LEN)
3062 BDecEoc (b, bytesDecoded, env);
3063 break;
3064
3065 case MAKE_TAG_ID (CNTX, CONS, 1):
3066 tag = BDecTag (b, bytesDecoded, env);
3067 if (tag != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3068 {
3069 Asn1Error << "Unexpected Tag" << endl;
3070 SnaccExcep::throwMe(-133);
3071 }
3072
3073 elmtLen1 = BDecLen (b, bytesDecoded, env);
3074 choiceId = subjectNameCid;
3075 subjectName = new GeneralNames;
3076 subjectName->BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3077 if (elmtLen0 == INDEFINITE_LEN)
3078 BDecEoc (b, bytesDecoded, env);
3079 break;
3080
3081 default:
3082 Asn1Error << "ERROR - unexpected tag in CHOICE" << endl;
3083 SnaccExcep::throwMe(-134);
3084 break;
3085 } // end switch
3086 } // AttributeCertificateInfoChoice::BDecContent
3087
3088
3089 AsnLen AttributeCertificateInfoChoice::BEnc (BUF_TYPE b)
3090 {
3091 AsnLen l;
3092 l = BEncContent (b);
3093 return l;
3094 }
3095
3096 void AttributeCertificateInfoChoice::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3097 {
3098 AsnLen elmtLen;
3099 AsnTag tag;
3100
3101 /* CHOICEs are a special case - grab identifying tag */
3102 /* this allows easier handling of nested CHOICEs */
3103 tag = BDecTag (b, bytesDecoded, env);
3104 elmtLen = BDecLen (b, bytesDecoded, env);
3105 BDecContent (b, tag, elmtLen, bytesDecoded, env);
3106 }
3107
3108 void AttributeCertificateInfoChoice::Print (ostream &os) const
3109 {
3110 #ifndef NDEBUG
3111 switch (choiceId)
3112 {
3113 case baseCertificateIDCid:
3114 os << "baseCertificateID ";
3115 if (baseCertificateID)
3116 os << *baseCertificateID;
3117 else
3118 os << "-- void3 --\n";
3119 break;
3120
3121 case subjectNameCid:
3122 os << "subjectName ";
3123 if (subjectName)
3124 os << *subjectName;
3125 else
3126 os << "-- void3 --\n";
3127 break;
3128
3129 } // end of switch
3130 #endif /* NDEBUG */
3131 } // AttributeCertificateInfoChoice::Print
3132
3133 CRLToSignSeqOfSeq::CRLToSignSeqOfSeq()
3134 {
3135 #if TCL
3136 revocationDate = new Time;
3137 #else
3138 revocationDate = NULL; // incomplete initialization of mandatory element!
3139 #endif // TCL
3140 crlEntryExtensions = NULL;
3141 }
3142
3143 CRLToSignSeqOfSeq::CRLToSignSeqOfSeq (const CRLToSignSeqOfSeq &)
3144 {
3145 Asn1Error << "use of incompletely defined CRLToSignSeqOfSeq::CRLToSignSeqOfSeq (const CRLToSignSeqOfSeq &)" << endl;
3146 abort();
3147 }
3148
3149 CRLToSignSeqOfSeq::~CRLToSignSeqOfSeq()
3150 {
3151 delete revocationDate;
3152 delete crlEntryExtensions;
3153 }
3154
3155 AsnType *CRLToSignSeqOfSeq::Clone() const
3156 {
3157 return new CRLToSignSeqOfSeq;
3158 }
3159
3160 AsnType *CRLToSignSeqOfSeq::Copy() const
3161 {
3162 return new CRLToSignSeqOfSeq (*this);
3163 }
3164
3165 #if SNACC_DEEP_COPY
3166 CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &that)
3167 #else // SNACC_DEEP_COPY
3168 CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &)
3169 #endif // SNACC_DEEP_COPY
3170 {
3171 #if SNACC_DEEP_COPY
3172 if (this != &that)
3173 {
3174 userCertificate = that.userCertificate;
3175 if (that.revocationDate)
3176 {
3177 if (!revocationDate)
3178 revocationDate = new Time;
3179 *revocationDate = *that.revocationDate;
3180 }
3181 else
3182 {
3183 delete revocationDate;
3184 revocationDate = NULL;
3185 }
3186 if (that.crlEntryExtensions)
3187 {
3188 if (!crlEntryExtensions)
3189 crlEntryExtensions = new Extensions;
3190 *crlEntryExtensions = *that.crlEntryExtensions;
3191 }
3192 else
3193 {
3194 delete crlEntryExtensions;
3195 crlEntryExtensions = NULL;
3196 }
3197 }
3198
3199 return *this;
3200 #else // SNACC_DEEP_COPY
3201 Asn1Error << "use of incompletely defined CRLToSignSeqOfSeq &CRLToSignSeqOfSeq::operator = (const CRLToSignSeqOfSeq &)" << endl;
3202 abort();
3203 // if your compiler complains here, check the -novolat option
3204 #endif // SNACC_DEEP_COPY
3205 }
3206
3207 AsnLen
3208 CRLToSignSeqOfSeq::BEncContent (BUF_TYPE b)
3209 {
3210 AsnLen totalLen = 0;
3211 AsnLen l;
3212
3213 if (NOT_NULL (crlEntryExtensions))
3214 {
3215 BEncEocIfNec (b);
3216 l = crlEntryExtensions->BEncContent (b);
3217 l += BEncConsLen (b, l);
3218
3219 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3220 totalLen += l;
3221 }
3222
3223 l = revocationDate->BEncContent (b);
3224 totalLen += l;
3225
3226 l = userCertificate.BEncContent (b);
3227 l += BEncDefLen (b, l);
3228
3229 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
3230 totalLen += l;
3231
3232 return totalLen;
3233 } // CRLToSignSeqOfSeq::BEncContent
3234
3235
3236 void CRLToSignSeqOfSeq::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
3237 {
3238 AsnTag tag1;
3239 AsnLen seqBytesDecoded = 0;
3240 AsnLen elmtLen1;
3241 tag1 = BDecTag (b, seqBytesDecoded, env);
3242
3243 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
3244 || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE)))
3245 {
3246 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3247 userCertificate.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3248 tag1 = BDecTag (b, seqBytesDecoded, env);
3249 }
3250 else
3251 {
3252 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
3253 SnaccExcep::throwMe(-135);
3254 }
3255
3256 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))
3257 || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))
3258 || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
3259 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
3260 {
3261 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3262 revocationDate = new Time;
3263 revocationDate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3264 if (seqBytesDecoded == elmtLen0)
3265 {
3266 bytesDecoded += seqBytesDecoded;
3267 return;
3268 }
3269 else
3270 {
3271 tag1 = BDecTag (b, seqBytesDecoded, env);
3272
3273 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
3274 {
3275 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
3276 bytesDecoded += seqBytesDecoded;
3277 return;
3278 }
3279 }
3280 }
3281 else
3282 {
3283 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
3284 SnaccExcep::throwMe(-136);
3285 }
3286
3287 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
3288 {
3289 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
3290 crlEntryExtensions = new Extensions;
3291 crlEntryExtensions->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
3292 }
3293
3294 bytesDecoded += seqBytesDecoded;
3295 if (elmtLen0 == INDEFINITE_LEN)
3296 {
3297 BDecEoc (b, bytesDecoded, env);
3298 return;
3299 }
3300 else if (seqBytesDecoded != elmtLen0)
3301 {
3302 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
3303 SnaccExcep::throwMe(-137);
3304 }
3305 else
3306 return;
3307 } // CRLToSignSeqOfSeq::BDecContent
3308
3309 AsnLen CRLToSignSeqOfSeq::BEnc (BUF_TYPE b)
3310 {
3311 AsnLen l;
3312 l = BEncContent (b);
3313 l += BEncConsLen (b, l);
3314 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3315 return l;
3316 }
3317
3318 void CRLToSignSeqOfSeq::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3319 {
3320 AsnTag tag;
3321 AsnLen elmtLen1;
3322
3323 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3324 {
3325 Asn1Error << "CRLToSignSeqOfSeq::BDec: ERROR - wrong tag" << endl;
3326 SnaccExcep::throwMe(-138);
3327 }
3328 elmtLen1 = BDecLen (b, bytesDecoded, env);
3329 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3330 }
3331
3332 void CRLToSignSeqOfSeq::Print (ostream &os) const
3333 {
3334 #ifndef NDEBUG
3335 os << "{ -- SEQUENCE --" << endl;
3336 indentG += stdIndentG;
3337
3338 {
3339 Indent (os, indentG);
3340 os << "userCertificate ";
3341 os << userCertificate;
3342 os << "," << endl;
3343 }
3344
3345 if (NOT_NULL (revocationDate))
3346 {
3347 Indent (os, indentG);
3348 os << "revocationDate ";
3349 os << *revocationDate;
3350 }
3351 else
3352 {
3353 Indent (os, indentG);
3354 os << "revocationDate ";
3355 os << "-- void --";
3356 os << "," << endl;
3357 }
3358
3359 if (NOT_NULL (crlEntryExtensions))
3360 {
3361 os << ","<< endl;
3362 Indent (os, indentG);
3363 os << "crlEntryExtensions ";
3364 os << *crlEntryExtensions;
3365 }
3366 else
3367 {
3368 Indent (os, indentG);
3369 os << "crlEntryExtensions ";
3370 os << "-- void --";
3371 os << endl;
3372 }
3373
3374 os << endl;
3375 indentG -= stdIndentG;
3376 Indent (os, indentG);
3377 os << "}";
3378 #endif /* NDEBUG */
3379 } // CRLToSignSeqOfSeq::Print
3380
3381
3382 AsnType *CRLToSignSeqOf::Clone() const
3383 {
3384 return new CRLToSignSeqOf;
3385 }
3386
3387 AsnType *CRLToSignSeqOf::Copy() const
3388 {
3389 return new CRLToSignSeqOf (*this);
3390 }
3391
3392 AsnLen CRLToSignSeqOf::BEnc (BUF_TYPE b)
3393 {
3394 AsnLen l;
3395 l = BEncContent (b);
3396 l += BEncConsLen (b, l);
3397 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3398 return l;
3399 }
3400
3401 void CRLToSignSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
3402 {
3403 AsnTag tag;
3404 AsnLen elmtLen1;
3405
3406 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
3407 {
3408 Asn1Error << "CRLToSignSeqOf::BDec: ERROR - wrong tag" << endl;
3409 SnaccExcep::throwMe(-139);
3410 }
3411 elmtLen1 = BDecLen (b, bytesDecoded, env);
3412 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
3413 }
3414
3415 CRLToSignSeqOf::CRLToSignSeqOf (const CRLToSignSeqOf &)
3416 {
3417 Asn1Error << "use of incompletely defined CRLToSignSeqOf::CRLToSignSeqOf (const CRLToSignSeqOf &)" << endl;
3418 abort();
3419 }
3420
3421 CRLToSignSeqOf::~CRLToSignSeqOf()
3422 {
3423 SetCurrToFirst();
3424 for (; Curr() != NULL; RemoveCurrFromList())
3425 ;
3426 } // end of destructor
3427
3428 #if SNACC_DEEP_COPY
3429 CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &that)
3430 #else // SNACC_DEEP_COPY
3431 CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &)
3432 #endif // SNACC_DEEP_COPY
3433 {
3434 #if SNACC_DEEP_COPY
3435 if (this != &that)
3436 {
3437 SetCurrToFirst();
3438 for (; Curr(); RemoveCurrFromList())
3439 ;
3440
3441 //that.SetCurrToFirst();
3442 //for (; that.Curr(); that.GoNext())
3443 // AppendCopy (*that.Curr());
3444 for (const AsnListElmt *run=that.first; run; run=run->next)
3445 AppendCopy (*run->elmt);
3446 }
3447
3448 return *this;
3449 #else // SNACC_DEEP_COPY
3450 Asn1Error << "use of incompletely defined CRLToSignSeqOf &CRLToSignSeqOf::operator = (const CRLToSignSeqOf &)" << endl;
3451 abort();
3452 // if your compiler complains here, check the -novolat option
3453 #endif // SNACC_DEEP_COPY
3454 }
3455
3456 void CRLToSignSeqOf::Print (ostream &os) const
3457 {
3458 #ifndef NDEBUG
3459 os << "{ -- SEQUENCE/SET OF -- " << endl;
3460 indentG += stdIndentG;
3461 //SetCurrToFirst();
3462 //for (; Curr() != NULL; GoNext())
3463 for (const AsnListElmt *run=first; run; run=run->next)
3464 {
3465 Indent (os, indentG);
3466 //os << *Curr();
3467 os << *run->elmt;
3468 //if (Curr() != Last())
3469 if (run != last)
3470 os << ",";
3471 os << endl;
3472 }
3473 indentG -= stdIndentG;
3474 Indent (os, indentG);
3475 os << "}\n";
3476 #endif /* NDEBUG */
3477
3478
3479 } // Print
3480
3481
3482 void CRLToSignSeqOf::SetCurrElmt (unsigned long int index)
3483 {
3484 unsigned long int i;
3485 curr = first;
3486 if (count)
3487 for (i = 0; (i < (count-1)) && (i < index); i++)
3488 curr = curr->next;
3489 } // CRLToSignSeqOf::SetCurrElmt
3490
3491
3492 unsigned long int CRLToSignSeqOf::GetCurrElmtIndex()
3493 {
3494 unsigned long int i;
3495 AsnListElmt *tmp;
3496 if (curr != NULL)
3497 {
3498 for (i = 0, tmp = first; tmp != NULL; i++)
3499 {
3500 if (tmp == curr)
3501 return i;
3502 else
3503 tmp = tmp->next;
3504 }
3505 }
3506 return count;
3507 } // CRLToSignSeqOf::GetCurrElmtIndex
3508
3509
3510 // alloc new list elmt, put at end of list
3511 // and return the component type
3512 CRLToSignSeqOfSeq *CRLToSignSeqOf::Append()
3513 {
3514 AsnListElmt *newElmt;
3515 newElmt = new AsnListElmt;
3516 newElmt->elmt = new CRLToSignSeqOfSeq;
3517 newElmt->next = NULL;
3518 if (last == NULL)
3519 {
3520 newElmt->prev = NULL;
3521 first = last = newElmt;
3522 }
3523 else
3524 {
3525 newElmt->prev = last;
3526 last->next = newElmt;
3527 last = newElmt;
3528 }
3529 count++;
3530 return (curr = newElmt)->elmt;
3531 } // CRLToSignSeqOf::Append
3532
3533
3534 // alloc new list elmt, put at begining of list
3535 // and return the component type
3536 CRLToSignSeqOfSeq *CRLToSignSeqOf::Prepend()
3537 {
3538 AsnListElmt *newElmt;
3539 newElmt = new AsnListElmt;
3540 newElmt->elmt = new CRLToSignSeqOfSeq;
3541 newElmt->prev = NULL;
3542 if (first == NULL)
3543 {
3544 newElmt->next = NULL;
3545 first = last = newElmt;
3546 }
3547 else
3548 {
3549 newElmt->next = first;
3550 first->prev = newElmt;
3551 first = newElmt;
3552 }
3553 count++;
3554 return (curr = newElmt)->elmt;
3555 } // CRLToSignSeqOf::Prepend
3556
3557
3558 // alloc new list elmt, insert it before the
3559 // current element and return the component type
3560 // if the current element is null, the new element
3561 // is placed at the beginning of the list.
3562 CRLToSignSeqOfSeq *CRLToSignSeqOf::InsertBefore()
3563 {
3564 AsnListElmt *newElmt;
3565 newElmt = new AsnListElmt;
3566 newElmt->elmt = new CRLToSignSeqOfSeq;
3567 if (curr == NULL)
3568 {
3569 newElmt->next = first;
3570 newElmt->prev = NULL;
3571 first = newElmt;
3572 if (last == NULL)
3573 last = newElmt;
3574 }
3575 else
3576 {
3577 newElmt->next = curr;
3578 newElmt->prev = curr->prev;
3579 curr->prev = newElmt;
3580 if (curr == first)
3581 first = newElmt;
3582 else
3583 newElmt->prev->next = newElmt;
3584 }
3585 count++;
3586 return (curr = newElmt)->elmt;
3587 } // CRLToSignSeqOf::InsertBefore
3588
3589
3590 // alloc new list elmt, insert it after the
3591 // current element and return the component type
3592 // if the current element is null, the new element
3593 // is placed at the end of the list.
3594 CRLToSignSeqOfSeq *CRLToSignSeqOf::InsertAfter()
3595 {
3596 AsnListElmt *newElmt;
3597 newElmt = new AsnListElmt;
3598 newElmt->elmt = new CRLToSignSeqOfSeq;
3599 if (curr == NULL)
3600 {
3601 newElmt->prev = last;
3602 newElmt->next = NULL;
3603 last = newElmt;
3604 if (first == NULL)
3605 first = newElmt;
3606 }
3607 else
3608 {
3609 newElmt->prev = curr;
3610 newElmt->next = curr->next;
3611 curr->next = newElmt;
3612 if (curr == last)
3613 last = newElmt;
3614 else
3615 newElmt->next->prev = newElmt;
3616 }
3617 count++;
3618 return (curr = newElmt)->elmt;
3619 } // CRLToSignSeqOf::InsertAfter
3620
3621
3622 CRLToSignSeqOf &CRLToSignSeqOf::AppendCopy (CRLToSignSeqOfSeq &elmt)
3623 {
3624 AsnListElmt *newElmt;
3625 newElmt = new AsnListElmt;
3626 newElmt->elmt = new CRLToSignSeqOfSeq;
3627 *newElmt->elmt = elmt;
3628 newElmt->next = NULL;
3629 if (last == NULL)
3630 {
3631 newElmt->prev = NULL;
3632 first = last = newElmt;
3633 }
3634 else
3635 {
3636 newElmt->prev = last;
3637 last->next = newElmt;
3638 last = newElmt;
3639 }
3640 count++;
3641 return *this;
3642 } // AppendCopy
3643
3644
3645 CRLToSignSeqOf &CRLToSignSeqOf::PrependCopy (CRLToSignSeqOfSeq &elmt)
3646 {
3647 AsnListElmt *newElmt;
3648 newElmt = new AsnListElmt;
3649 newElmt->elmt = new CRLToSignSeqOfSeq;
3650 *newElmt->elmt = elmt;
3651 newElmt->prev = NULL;
3652 if (first == NULL)
3653 {
3654 newElmt->next = NULL;
3655 first = last = newElmt;
3656 }
3657 else
3658 {
3659 newElmt->next = first;
3660 first->prev = newElmt;
3661 first = newElmt;
3662 }
3663 count++;
3664 return *this;
3665 } // CRLToSignSeqOf::PrependCopy
3666
3667
3668 // alloc new list elmt, insert it before the
3669 // current element, copy the given elmt into the new elmt
3670 // and return the component type.
3671 // if the current element is null, the new element
3672 // is placed at the beginning of the list.
3673 CRLToSignSeqOf &CRLToSignSeqOf::InsertBeforeAndCopy (CRLToSignSeqOfSeq &elmt)
3674 {
3675 AsnListElmt *newElmt;
3676
3677 newElmt = new AsnListElmt;
3678 newElmt->elmt = new CRLToSignSeqOfSeq;
3679 *newElmt->elmt = elmt;
3680
3681 if (curr == NULL)
3682 {
3683 newElmt->next = first;
3684 newElmt->prev = NULL;
3685 first = newElmt;
3686 if (last == NULL)
3687 last = newElmt;
3688 }
3689 else
3690 {
3691 newElmt->next = curr;
3692 newElmt->prev = curr->prev;
3693 curr->prev = newElmt;
3694 if (curr == first)
3695 first = newElmt;
3696 else
3697 newElmt->prev->next = newElmt;
3698 }
3699 count++;
3700 return *this;
3701 } // CRLToSignSeqOf::InsertBeforeAndCopy
3702
3703
3704 // alloc new list elmt, insert it after the
3705 // current element, copy given elmt in to new elmt
3706 // and return the component type
3707 // if the current element is null, the new element
3708 // is placed at the end of the list.
3709 CRLToSignSeqOf &CRLToSignSeqOf::InsertAfterAndCopy (CRLToSignSeqOfSeq &elmt)
3710 {
3711 AsnListElmt *newElmt;
3712
3713 newElmt = new AsnListElmt;
3714 newElmt->elmt = new CRLToSignSeqOfSeq;
3715 *newElmt->elmt = elmt;
3716 if (curr == NULL)
3717 {
3718 newElmt->prev = last;
3719 newElmt->next = NULL;
3720 last = newElmt;
3721 if (first == NULL)
3722 first = newElmt;
3723 }
3724 else
3725 {
3726 newElmt->prev = curr;
3727 newElmt->next = curr->next;
3728 curr->next = newElmt;
3729 if (curr == last)
3730 last = newElmt;
3731 else
3732 newElmt->next->prev = newElmt;
3733 }
3734 count++;
3735 return *this;
3736 } // CRLToSignSeqOf::InsertAfterAndCopy
3737
3738
3739 // remove current element from list if current element is not NULL
3740 // The new current element will be the next element.
3741 // If the current element is the last element in the list
3742 // the second but last element will become the new current element.
3743 void CRLToSignSeqOf::RemoveCurrFromList()
3744 {
3745 AsnListElmt *del_elmt;
3746
3747 if (curr != NULL)
3748 {
3749 del_elmt = curr;
3750 count--;
3751
3752 if (count == 0)
3753 first = last = curr = NULL;
3754 else if (curr == first)
3755 {
3756 curr = first= first->next;
3757 first->prev = NULL;
3758 }
3759 else if (curr == last)
3760 {
3761 curr = last = last->prev;
3762 last->next = NULL;
3763 }
3764 else
3765 {
3766 curr->prev->next = curr->next;
3767 curr->next->prev = curr->prev;
3768 }
3769
3770 delete del_elmt->elmt;
3771 delete del_elmt;
3772 }
3773 }
3774
3775
3776 AsnLen CRLToSignSeqOf::BEncContent (BUF_TYPE b)
3777 {
3778 AsnListElmt *currElmt;
3779 AsnLen elmtLen;
3780 AsnLen totalLen = 0;
3781 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
3782 {
3783 BEncEocIfNec (b);
3784 elmtLen = currElmt->elmt->BEncContent (b);
3785 elmtLen += BEncConsLen (b, elmtLen);
3786
3787 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
3788 totalLen += elmtLen;
3789 }
3790 return totalLen;
3791 } // CRLToSignSeqOf::BEncContent
3792
3793
3794 void CRLToSignSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
3795 AsnLen &bytesDecoded, ENV_TYPE env)
3796 {
3797 CRLToSignSeqOfSeq *listElmt;
3798 AsnTag tag1;
3799 AsnLen listBytesDecoded = 0;
3800 AsnLen elmtLen1;
3801
3802 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
3803 {
3804 tag1 = BDecTag (b, listBytesDecoded, env);
3805 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
3806 {
3807 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
3808 break;
3809 }
3810 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
3811 {
3812 Asn1Error << "Unexpected Tag" << endl;
3813 SnaccExcep::throwMe(-140);
3814 }
3815
3816 elmtLen1 = BDecLen (b, listBytesDecoded, env);
3817 listElmt = Append();
3818 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
3819 }
3820
3821 bytesDecoded += listBytesDecoded;
3822 } // CRLToSignSeqOf::BDecContent
3823
3824
3825 CertificateToSign::CertificateToSign()
3826 {
3827 version = NULL;
3828 #if TCL
3829 signature = new AlgorithmIdentifier;
3830 #else
3831 signature = NULL; // incomplete initialization of mandatory element!
3832 #endif // TCL
3833 #if TCL
3834 issuer = new Name;
3835 #else
3836 issuer = NULL; // incomplete initialization of mandatory element!
3837 #endif // TCL
3838 #if TCL
3839 validity = new Validity;
3840 #else
3841 validity = NULL; // incomplete initialization of mandatory element!
3842 #endif // TCL
3843 #if TCL
3844 subject = new Name;
3845 #else
3846 subject = NULL; // incomplete initialization of mandatory element!
3847 #endif // TCL
3848 #if TCL
3849 subjectPublicKeyInfo = new SubjectPublicKeyInfo;
3850 #else
3851 subjectPublicKeyInfo = NULL; // incomplete initialization of mandatory element!
3852 #endif // TCL
3853 issuerUniqueIdentifier = NULL;
3854 subjectUniqueIdentifier = NULL;
3855 extensions = NULL;
3856 }
3857
3858 CertificateToSign::CertificateToSign (const CertificateToSign &)
3859 {
3860 Asn1Error << "use of incompletely defined CertificateToSign::CertificateToSign (const CertificateToSign &)" << endl;
3861 abort();
3862 }
3863
3864 CertificateToSign::~CertificateToSign()
3865 {
3866 delete version;
3867 delete signature;
3868 delete issuer;
3869 delete validity;
3870 delete subject;
3871 delete subjectPublicKeyInfo;
3872 delete issuerUniqueIdentifier;
3873 delete subjectUniqueIdentifier;
3874 delete extensions;
3875 }
3876
3877 AsnType *CertificateToSign::Clone() const
3878 {
3879 return new CertificateToSign;
3880 }
3881
3882 AsnType *CertificateToSign::Copy() const
3883 {
3884 return new CertificateToSign (*this);
3885 }
3886
3887 #if SNACC_DEEP_COPY
3888 CertificateToSign &CertificateToSign::operator = (const CertificateToSign &that)
3889 #else // SNACC_DEEP_COPY
3890 CertificateToSign &CertificateToSign::operator = (const CertificateToSign &)
3891 #endif // SNACC_DEEP_COPY
3892 {
3893 #if SNACC_DEEP_COPY
3894 if (this != &that)
3895 {
3896 if (that.version)
3897 {
3898 if (!version)
3899 version = new Version;
3900 *version = *that.version;
3901 }
3902 else
3903 {
3904 delete version;
3905 version = NULL;
3906 }
3907 serialNumber = that.serialNumber;
3908 if (that.signature)
3909 {
3910 if (!signature)
3911 signature = new AlgorithmIdentifier;
3912 *signature = *that.signature;
3913 }
3914 else
3915 {
3916 delete signature;
3917 signature = NULL;
3918 }
3919 if (that.issuer)
3920 {
3921 if (!issuer)
3922 issuer = new Name;
3923 *issuer = *that.issuer;
3924 }
3925 else
3926 {
3927 delete issuer;
3928 issuer = NULL;
3929 }
3930 if (that.validity)
3931 {
3932 if (!validity)
3933 validity = new Validity;
3934 *validity = *that.validity;
3935 }
3936 else
3937 {
3938 delete validity;
3939 validity = NULL;
3940 }
3941 if (that.subject)
3942 {
3943 if (!subject)
3944 subject = new Name;
3945 *subject = *that.subject;
3946 }
3947 else
3948 {
3949 delete subject;
3950 subject = NULL;
3951 }
3952 if (that.subjectPublicKeyInfo)
3953 {
3954 if (!subjectPublicKeyInfo)
3955 subjectPublicKeyInfo = new SubjectPublicKeyInfo;
3956 *subjectPublicKeyInfo = *that.subjectPublicKeyInfo;
3957 }
3958 else
3959 {
3960 delete subjectPublicKeyInfo;
3961 subjectPublicKeyInfo = NULL;
3962 }
3963 if (that.issuerUniqueIdentifier)
3964 {
3965 if (!issuerUniqueIdentifier)
3966 issuerUniqueIdentifier = new UniqueIdentifier;
3967 *issuerUniqueIdentifier = *that.issuerUniqueIdentifier;
3968 }
3969 else
3970 {
3971 delete issuerUniqueIdentifier;
3972 issuerUniqueIdentifier = NULL;
3973 }
3974 if (that.subjectUniqueIdentifier)
3975 {
3976 if (!subjectUniqueIdentifier)
3977 subjectUniqueIdentifier = new UniqueIdentifier;
3978 *subjectUniqueIdentifier = *that.subjectUniqueIdentifier;
3979 }
3980 else
3981 {
3982 delete subjectUniqueIdentifier;
3983 subjectUniqueIdentifier = NULL;
3984 }
3985 if (that.extensions)
3986 {
3987 if (!extensions)
3988 extensions = new Extensions;
3989 *extensions = *that.extensions;
3990 }
3991 else
3992 {
3993 delete extensions;
3994 extensions = NULL;
3995 }
3996 }
3997
3998 return *this;
3999 #else // SNACC_DEEP_COPY
4000 Asn1Error << "use of incompletely defined CertificateToSign &CertificateToSign::operator = (const CertificateToSign &)" << endl;
4001 abort();
4002 // if your compiler complains here, check the -novolat option
4003 #endif // SNACC_DEEP_COPY
4004 }
4005
4006 AsnLen
4007 CertificateToSign::BEncContent (BUF_TYPE b)
4008 {
4009 AsnLen totalLen = 0;
4010 AsnLen l;
4011
4012 if (NOT_NULL (extensions))
4013 {
4014 BEncEocIfNec (b);
4015 BEncEocIfNec (b);
4016 l = extensions->BEncContent (b);
4017 l += BEncConsLen (b, l);
4018
4019 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4020 l += BEncConsLen (b, l);
4021
4022 l += BEncTag1 (b, CNTX, CONS, 3);
4023 totalLen += l;
4024 }
4025
4026 if (NOT_NULL (subjectUniqueIdentifier))
4027 {
4028 l = subjectUniqueIdentifier->BEncContent (b);
4029 l += BEncDefLen (b, l);
4030
4031 l += BEncTag1 (b, CNTX, PRIM, 2);
4032 totalLen += l;
4033 }
4034
4035 if (NOT_NULL (issuerUniqueIdentifier))
4036 {
4037 l = issuerUniqueIdentifier->BEncContent (b);
4038 l += BEncDefLen (b, l);
4039
4040 l += BEncTag1 (b, CNTX, PRIM, 1);
4041 totalLen += l;
4042 }
4043
4044 BEncEocIfNec (b);
4045 l = subjectPublicKeyInfo->BEncContent (b);
4046 l += BEncConsLen (b, l);
4047
4048 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4049 totalLen += l;
4050
4051 l = subject->BEncContent (b);
4052 totalLen += l;
4053
4054 BEncEocIfNec (b);
4055 l = validity->BEncContent (b);
4056 l += BEncConsLen (b, l);
4057
4058 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4059 totalLen += l;
4060
4061 l = issuer->BEncContent (b);
4062 totalLen += l;
4063
4064 BEncEocIfNec (b);
4065 l = signature->BEncContent (b);
4066 l += BEncConsLen (b, l);
4067
4068 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4069 totalLen += l;
4070
4071 l = serialNumber.BEncContent (b);
4072 l += BEncDefLen (b, l);
4073
4074 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
4075 totalLen += l;
4076
4077 if (NOT_NULL (version))
4078 {
4079 BEncEocIfNec (b);
4080 l = version->BEncContent (b);
4081 BEncDefLenTo127 (b, l);
4082 l++;
4083
4084 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
4085 l += BEncConsLen (b, l);
4086
4087 l += BEncTag1 (b, CNTX, CONS, 0);
4088 totalLen += l;
4089 }
4090
4091 return totalLen;
4092 } // CertificateToSign::BEncContent
4093
4094
4095 void CertificateToSign::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
4096 {
4097 AsnTag tag1;
4098 AsnLen seqBytesDecoded = 0;
4099 AsnLen elmtLen1;
4100 AsnLen elmtLen2;
4101 tag1 = BDecTag (b, seqBytesDecoded, env);
4102
4103 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
4104 {
4105 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4106 tag1 = BDecTag (b, seqBytesDecoded, env);
4107
4108 if (tag1 != MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
4109 {
4110 Asn1Error << "Unexpected Tag" << endl;
4111 SnaccExcep::throwMe(-141);
4112 }
4113
4114 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
4115 version = new Version;
4116 version->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
4117 if (elmtLen1 == INDEFINITE_LEN)
4118 BDecEoc (b, seqBytesDecoded, env);
4119
4120 tag1 = BDecTag (b, seqBytesDecoded, env);
4121 }
4122
4123 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
4124 || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE)))
4125 {
4126 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4127 serialNumber.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4128 tag1 = BDecTag (b, seqBytesDecoded, env);
4129 }
4130 else
4131 {
4132 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4133 SnaccExcep::throwMe(-142);
4134 }
4135
4136 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4137 {
4138 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4139 signature = new AlgorithmIdentifier;
4140 signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4141 tag1 = BDecTag (b, seqBytesDecoded, env);
4142 }
4143 else
4144 {
4145 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4146 SnaccExcep::throwMe(-143);
4147 }
4148
4149 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4150 {
4151 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4152 issuer = new Name;
4153 issuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4154 tag1 = BDecTag (b, seqBytesDecoded, env);
4155 }
4156 else
4157 {
4158 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4159 SnaccExcep::throwMe(-144);
4160 }
4161
4162 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4163 {
4164 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4165 validity = new Validity;
4166 validity->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4167 tag1 = BDecTag (b, seqBytesDecoded, env);
4168 }
4169 else
4170 {
4171 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4172 SnaccExcep::throwMe(-145);
4173 }
4174
4175 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4176 {
4177 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4178 subject = new Name;
4179 subject->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4180 tag1 = BDecTag (b, seqBytesDecoded, env);
4181 }
4182 else
4183 {
4184 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4185 SnaccExcep::throwMe(-146);
4186 }
4187
4188 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4189 {
4190 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4191 subjectPublicKeyInfo = new SubjectPublicKeyInfo;
4192 subjectPublicKeyInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4193 if (seqBytesDecoded == elmtLen0)
4194 {
4195 bytesDecoded += seqBytesDecoded;
4196 return;
4197 }
4198 else
4199 {
4200 tag1 = BDecTag (b, seqBytesDecoded, env);
4201
4202 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4203 {
4204 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4205 bytesDecoded += seqBytesDecoded;
4206 return;
4207 }
4208 }
4209 }
4210 else
4211 {
4212 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4213 SnaccExcep::throwMe(-147);
4214 }
4215
4216 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 1))
4217 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
4218 {
4219 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4220 issuerUniqueIdentifier = new UniqueIdentifier;
4221 issuerUniqueIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4222 if (seqBytesDecoded == elmtLen0)
4223 {
4224 bytesDecoded += seqBytesDecoded;
4225 return;
4226 }
4227 else
4228 {
4229 tag1 = BDecTag (b, seqBytesDecoded, env);
4230
4231 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4232 {
4233 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4234 bytesDecoded += seqBytesDecoded;
4235 return;
4236 }
4237 }
4238 }
4239
4240 if ((tag1 == MAKE_TAG_ID (CNTX, PRIM, 2))
4241 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 2)))
4242 {
4243 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4244 subjectUniqueIdentifier = new UniqueIdentifier;
4245 subjectUniqueIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4246 if (seqBytesDecoded == elmtLen0)
4247 {
4248 bytesDecoded += seqBytesDecoded;
4249 return;
4250 }
4251 else
4252 {
4253 tag1 = BDecTag (b, seqBytesDecoded, env);
4254
4255 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4256 {
4257 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4258 bytesDecoded += seqBytesDecoded;
4259 return;
4260 }
4261 }
4262 }
4263
4264 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 3)))
4265 {
4266 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4267 tag1 = BDecTag (b, seqBytesDecoded, env);
4268
4269 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4270 {
4271 Asn1Error << "Unexpected Tag" << endl;
4272 SnaccExcep::throwMe(-148);
4273 }
4274
4275 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
4276 extensions = new Extensions;
4277 extensions->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
4278 if (elmtLen1 == INDEFINITE_LEN)
4279 BDecEoc (b, seqBytesDecoded, env);
4280
4281 }
4282
4283 bytesDecoded += seqBytesDecoded;
4284 if (elmtLen0 == INDEFINITE_LEN)
4285 {
4286 BDecEoc (b, bytesDecoded, env);
4287 return;
4288 }
4289 else if (seqBytesDecoded != elmtLen0)
4290 {
4291 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
4292 SnaccExcep::throwMe(-149);
4293 }
4294 else
4295 return;
4296 } // CertificateToSign::BDecContent
4297
4298 AsnLen CertificateToSign::BEnc (BUF_TYPE b)
4299 {
4300 AsnLen l;
4301 l = BEncContent (b);
4302 l += BEncConsLen (b, l);
4303 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4304 return l;
4305 }
4306
4307 void CertificateToSign::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
4308 {
4309 AsnTag tag;
4310 AsnLen elmtLen1;
4311
4312 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4313 {
4314 Asn1Error << "CertificateToSign::BDec: ERROR - wrong tag" << endl;
4315 SnaccExcep::throwMe(-150);
4316 }
4317 elmtLen1 = BDecLen (b, bytesDecoded, env);
4318 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
4319 }
4320
4321 void CertificateToSign::Print (ostream &os) const
4322 {
4323 #ifndef NDEBUG
4324 os << "{ -- SEQUENCE --" << endl;
4325 indentG += stdIndentG;
4326
4327 if (NOT_NULL (version))
4328 {
4329 Indent (os, indentG);
4330 os << "version ";
4331 os << *version;
4332 }
4333 else
4334 {
4335 Indent (os, indentG);
4336 os << "version ";
4337 os << "-- void --";
4338 os << "," << endl;
4339 }
4340
4341 {
4342 Indent (os, indentG);
4343 os << "serialNumber ";
4344 os << serialNumber;
4345 os << "," << endl;
4346 }
4347
4348 if (NOT_NULL (signature))
4349 {
4350 Indent (os, indentG);
4351 os << "signature ";
4352 os << *signature;
4353 }
4354 else
4355 {
4356 Indent (os, indentG);
4357 os << "signature ";
4358 os << "-- void --";
4359 os << "," << endl;
4360 }
4361
4362 if (NOT_NULL (issuer))
4363 {
4364 Indent (os, indentG);
4365 os << "issuer ";
4366 os << *issuer;
4367 }
4368 else
4369 {
4370 Indent (os, indentG);
4371 os << "issuer ";
4372 os << "-- void --";
4373 os << "," << endl;
4374 }
4375
4376 if (NOT_NULL (validity))
4377 {
4378 Indent (os, indentG);
4379 os << "validity ";
4380 os << *validity;
4381 }
4382 else
4383 {
4384 Indent (os, indentG);
4385 os << "validity ";
4386 os << "-- void --";
4387 os << "," << endl;
4388 }
4389
4390 if (NOT_NULL (subject))
4391 {
4392 Indent (os, indentG);
4393 os << "subject ";
4394 os << *subject;
4395 }
4396 else
4397 {
4398 Indent (os, indentG);
4399 os << "subject ";
4400 os << "-- void --";
4401 os << "," << endl;
4402 }
4403
4404 if (NOT_NULL (subjectPublicKeyInfo))
4405 {
4406 Indent (os, indentG);
4407 os << "subjectPublicKeyInfo ";
4408 os << *subjectPublicKeyInfo;
4409 }
4410 else
4411 {
4412 Indent (os, indentG);
4413 os << "subjectPublicKeyInfo ";
4414 os << "-- void --";
4415 os << "," << endl;
4416 }
4417
4418 if (NOT_NULL (issuerUniqueIdentifier))
4419 {
4420 os << ","<< endl;
4421 Indent (os, indentG);
4422 os << "issuerUniqueIdentifier ";
4423 os << *issuerUniqueIdentifier;
4424 }
4425 else
4426 {
4427 Indent (os, indentG);
4428 os << "issuerUniqueIdentifier ";
4429 os << "-- void --";
4430 os << "," << endl;
4431 }
4432
4433 if (NOT_NULL (subjectUniqueIdentifier))
4434 {
4435 os << ","<< endl;
4436 Indent (os, indentG);
4437 os << "subjectUniqueIdentifier ";
4438 os << *subjectUniqueIdentifier;
4439 }
4440 else
4441 {
4442 Indent (os, indentG);
4443 os << "subjectUniqueIdentifier ";
4444 os << "-- void --";
4445 os << "," << endl;
4446 }
4447
4448 if (NOT_NULL (extensions))
4449 {
4450 os << ","<< endl;
4451 Indent (os, indentG);
4452 os << "extensions ";
4453 os << *extensions;
4454 }
4455 else
4456 {
4457 Indent (os, indentG);
4458 os << "extensions ";
4459 os << "-- void --";
4460 os << endl;
4461 }
4462
4463 os << endl;
4464 indentG -= stdIndentG;
4465 Indent (os, indentG);
4466 os << "}";
4467 #endif /* NDEBUG */
4468 } // CertificateToSign::Print
4469
4470
4471 CRLToSign::CRLToSign()
4472 {
4473 version = NULL;
4474 #if TCL
4475 signature = new AlgorithmIdentifier;
4476 #else
4477 signature = NULL; // incomplete initialization of mandatory element!
4478 #endif // TCL
4479 #if TCL
4480 issuer = new Name;
4481 #else
4482 issuer = NULL; // incomplete initialization of mandatory element!
4483 #endif // TCL
4484 #if TCL
4485 thisUpdate = new Time;
4486 #else
4487 thisUpdate = NULL; // incomplete initialization of mandatory element!
4488 #endif // TCL
4489 nextUpdate = NULL;
4490 revokedCertificates = NULL;
4491 crlExtensions = NULL;
4492 }
4493
4494 CRLToSign::CRLToSign (const CRLToSign &)
4495 {
4496 Asn1Error << "use of incompletely defined CRLToSign::CRLToSign (const CRLToSign &)" << endl;
4497 abort();
4498 }
4499
4500 CRLToSign::~CRLToSign()
4501 {
4502 delete version;
4503 delete signature;
4504 delete issuer;
4505 delete thisUpdate;
4506 delete nextUpdate;
4507 delete revokedCertificates;
4508 delete crlExtensions;
4509 }
4510
4511 AsnType *CRLToSign::Clone() const
4512 {
4513 return new CRLToSign;
4514 }
4515
4516 AsnType *CRLToSign::Copy() const
4517 {
4518 return new CRLToSign (*this);
4519 }
4520
4521 #if SNACC_DEEP_COPY
4522 CRLToSign &CRLToSign::operator = (const CRLToSign &that)
4523 #else // SNACC_DEEP_COPY
4524 CRLToSign &CRLToSign::operator = (const CRLToSign &)
4525 #endif // SNACC_DEEP_COPY
4526 {
4527 #if SNACC_DEEP_COPY
4528 if (this != &that)
4529 {
4530 if (that.version)
4531 {
4532 if (!version)
4533 version = new Version;
4534 *version = *that.version;
4535 }
4536 else
4537 {
4538 delete version;
4539 version = NULL;
4540 }
4541 if (that.signature)
4542 {
4543 if (!signature)
4544 signature = new AlgorithmIdentifier;
4545 *signature = *that.signature;
4546 }
4547 else
4548 {
4549 delete signature;
4550 signature = NULL;
4551 }
4552 if (that.issuer)
4553 {
4554 if (!issuer)
4555 issuer = new Name;
4556 *issuer = *that.issuer;
4557 }
4558 else
4559 {
4560 delete issuer;
4561 issuer = NULL;
4562 }
4563 if (that.thisUpdate)
4564 {
4565 if (!thisUpdate)
4566 thisUpdate = new Time;
4567 *thisUpdate = *that.thisUpdate;
4568 }
4569 else
4570 {
4571 delete thisUpdate;
4572 thisUpdate = NULL;
4573 }
4574 if (that.nextUpdate)
4575 {
4576 if (!nextUpdate)
4577 nextUpdate = new Time;
4578 *nextUpdate = *that.nextUpdate;
4579 }
4580 else
4581 {
4582 delete nextUpdate;
4583 nextUpdate = NULL;
4584 }
4585 if (that.revokedCertificates)
4586 {
4587 if (!revokedCertificates)
4588 revokedCertificates = new CRLToSignSeqOf;
4589 *revokedCertificates = *that.revokedCertificates;
4590 }
4591 else
4592 {
4593 delete revokedCertificates;
4594 revokedCertificates = NULL;
4595 }
4596 if (that.crlExtensions)
4597 {
4598 if (!crlExtensions)
4599 crlExtensions = new Extensions;
4600 *crlExtensions = *that.crlExtensions;
4601 }
4602 else
4603 {
4604 delete crlExtensions;
4605 crlExtensions = NULL;
4606 }
4607 }
4608
4609 return *this;
4610 #else // SNACC_DEEP_COPY
4611 Asn1Error << "use of incompletely defined CRLToSign &CRLToSign::operator = (const CRLToSign &)" << endl;
4612 abort();
4613 // if your compiler complains here, check the -novolat option
4614 #endif // SNACC_DEEP_COPY
4615 }
4616
4617 AsnLen
4618 CRLToSign::BEncContent (BUF_TYPE b)
4619 {
4620 AsnLen totalLen = 0;
4621 AsnLen l;
4622
4623 if (NOT_NULL (crlExtensions))
4624 {
4625 BEncEocIfNec (b);
4626 BEncEocIfNec (b);
4627 l = crlExtensions->BEncContent (b);
4628 l += BEncConsLen (b, l);
4629
4630 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4631 l += BEncConsLen (b, l);
4632
4633 l += BEncTag1 (b, CNTX, CONS, 0);
4634 totalLen += l;
4635 }
4636
4637 if (NOT_NULL (revokedCertificates))
4638 {
4639 BEncEocIfNec (b);
4640 l = revokedCertificates->BEncContent (b);
4641 l += BEncConsLen (b, l);
4642
4643 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4644 totalLen += l;
4645 }
4646
4647 if (NOT_NULL (nextUpdate))
4648 {
4649 l = nextUpdate->BEncContent (b);
4650 totalLen += l;
4651 }
4652
4653 l = thisUpdate->BEncContent (b);
4654 totalLen += l;
4655
4656 l = issuer->BEncContent (b);
4657 totalLen += l;
4658
4659 BEncEocIfNec (b);
4660 l = signature->BEncContent (b);
4661 l += BEncConsLen (b, l);
4662
4663 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4664 totalLen += l;
4665
4666 if (NOT_NULL (version))
4667 {
4668 l = version->BEncContent (b);
4669 BEncDefLenTo127 (b, l);
4670 l++;
4671
4672 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
4673 totalLen += l;
4674 }
4675
4676 return totalLen;
4677 } // CRLToSign::BEncContent
4678
4679
4680 void CRLToSign::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
4681 {
4682 AsnTag tag1;
4683 AsnLen seqBytesDecoded = 0;
4684 AsnLen elmtLen1;
4685 AsnLen elmtLen2;
4686 tag1 = BDecTag (b, seqBytesDecoded, env);
4687
4688 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))
4689 {
4690 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4691 version = new Version;
4692 version->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4693 tag1 = BDecTag (b, seqBytesDecoded, env);
4694 }
4695
4696 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4697 {
4698 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4699 signature = new AlgorithmIdentifier;
4700 signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4701 tag1 = BDecTag (b, seqBytesDecoded, env);
4702 }
4703 else
4704 {
4705 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4706 SnaccExcep::throwMe(-151);
4707 }
4708
4709 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4710 {
4711 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4712 issuer = new Name;
4713 issuer->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4714 tag1 = BDecTag (b, seqBytesDecoded, env);
4715 }
4716 else
4717 {
4718 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4719 SnaccExcep::throwMe(-152);
4720 }
4721
4722 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))
4723 || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))
4724 || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
4725 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
4726 {
4727 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4728 thisUpdate = new Time;
4729 thisUpdate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4730 if (seqBytesDecoded == elmtLen0)
4731 {
4732 bytesDecoded += seqBytesDecoded;
4733 return;
4734 }
4735 else
4736 {
4737 tag1 = BDecTag (b, seqBytesDecoded, env);
4738
4739 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4740 {
4741 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4742 bytesDecoded += seqBytesDecoded;
4743 return;
4744 }
4745 }
4746 }
4747 else
4748 {
4749 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
4750 SnaccExcep::throwMe(-153);
4751 }
4752
4753 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, UTCTIME_TAG_CODE))
4754 || (tag1 == MAKE_TAG_ID (UNIV, CONS, UTCTIME_TAG_CODE))
4755 || (tag1 == MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
4756 || (tag1 == MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
4757 {
4758 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4759 nextUpdate = new Time;
4760 nextUpdate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4761 if (seqBytesDecoded == elmtLen0)
4762 {
4763 bytesDecoded += seqBytesDecoded;
4764 return;
4765 }
4766 else
4767 {
4768 tag1 = BDecTag (b, seqBytesDecoded, env);
4769
4770 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4771 {
4772 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4773 bytesDecoded += seqBytesDecoded;
4774 return;
4775 }
4776 }
4777 }
4778
4779 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
4780 {
4781 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4782 revokedCertificates = new CRLToSignSeqOf;
4783 revokedCertificates->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
4784 if (seqBytesDecoded == elmtLen0)
4785 {
4786 bytesDecoded += seqBytesDecoded;
4787 return;
4788 }
4789 else
4790 {
4791 tag1 = BDecTag (b, seqBytesDecoded, env);
4792
4793 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
4794 {
4795 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
4796 bytesDecoded += seqBytesDecoded;
4797 return;
4798 }
4799 }
4800 }
4801
4802 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
4803 {
4804 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
4805 tag1 = BDecTag (b, seqBytesDecoded, env);
4806
4807 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4808 {
4809 Asn1Error << "Unexpected Tag" << endl;
4810 SnaccExcep::throwMe(-154);
4811 }
4812
4813 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
4814 crlExtensions = new Extensions;
4815 crlExtensions->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
4816 if (elmtLen1 == INDEFINITE_LEN)
4817 BDecEoc (b, seqBytesDecoded, env);
4818
4819 }
4820
4821 bytesDecoded += seqBytesDecoded;
4822 if (elmtLen0 == INDEFINITE_LEN)
4823 {
4824 BDecEoc (b, bytesDecoded, env);
4825 return;
4826 }
4827 else if (seqBytesDecoded != elmtLen0)
4828 {
4829 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
4830 SnaccExcep::throwMe(-155);
4831 }
4832 else
4833 return;
4834 } // CRLToSign::BDecContent
4835
4836 AsnLen CRLToSign::BEnc (BUF_TYPE b)
4837 {
4838 AsnLen l;
4839 l = BEncContent (b);
4840 l += BEncConsLen (b, l);
4841 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
4842 return l;
4843 }
4844
4845 void CRLToSign::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
4846 {
4847 AsnTag tag;
4848 AsnLen elmtLen1;
4849
4850 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
4851 {
4852 Asn1Error << "CRLToSign::BDec: ERROR - wrong tag" << endl;
4853 SnaccExcep::throwMe(-156);
4854 }
4855 elmtLen1 = BDecLen (b, bytesDecoded, env);
4856 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
4857 }
4858
4859 void CRLToSign::Print (ostream &os) const
4860 {
4861 #ifndef NDEBUG
4862 os << "{ -- SEQUENCE --" << endl;
4863 indentG += stdIndentG;
4864
4865 if (NOT_NULL (version))
4866 {
4867 Indent (os, indentG);
4868 os << "version ";
4869 os << *version;
4870 }
4871 else
4872 {
4873 Indent (os, indentG);
4874 os << "version ";
4875 os << "-- void --";
4876 os << "," << endl;
4877 }
4878
4879 if (NOT_NULL (signature))
4880 {
4881 Indent (os, indentG);
4882 os << "signature ";
4883 os << *signature;
4884 }
4885 else
4886 {
4887 Indent (os, indentG);
4888 os << "signature ";
4889 os << "-- void --";
4890 os << "," << endl;
4891 }
4892
4893 if (NOT_NULL (issuer))
4894 {
4895 Indent (os, indentG);
4896 os << "issuer ";
4897 os << *issuer;
4898 }
4899 else
4900 {
4901 Indent (os, indentG);
4902 os << "issuer ";
4903 os << "-- void --";
4904 os << "," << endl;
4905 }
4906
4907 if (NOT_NULL (thisUpdate))
4908 {
4909 Indent (os, indentG);
4910 os << "thisUpdate ";
4911 os << *thisUpdate;
4912 }
4913 else
4914 {
4915 Indent (os, indentG);
4916 os << "thisUpdate ";
4917 os << "-- void --";
4918 os << "," << endl;
4919 }
4920
4921 if (NOT_NULL (nextUpdate))
4922 {
4923 os << ","<< endl;
4924 Indent (os, indentG);
4925 os << "nextUpdate ";
4926 os << *nextUpdate;
4927 }
4928 else
4929 {
4930 Indent (os, indentG);
4931 os << "nextUpdate ";
4932 os << "-- void --";
4933 os << "," << endl;
4934 }
4935
4936 if (NOT_NULL (revokedCertificates))
4937 {
4938 os << ","<< endl;
4939 Indent (os, indentG);
4940 os << "revokedCertificates ";
4941 os << *revokedCertificates;
4942 }
4943 else
4944 {
4945 Indent (os, indentG);
4946 os << "revokedCertificates ";
4947 os << "-- void --";
4948 os << "," << endl;
4949 }
4950
4951 if (NOT_NULL (crlExtensions))
4952 {
4953 os << ","<< endl;
4954 Indent (os, indentG);
4955 os << "crlExtensions ";
4956 os << *crlExtensions;
4957 }
4958 else
4959 {
4960 Indent (os, indentG);
4961 os << "crlExtensions ";
4962 os << "-- void --";
4963 os << endl;
4964 }
4965
4966 os << endl;
4967 indentG -= stdIndentG;
4968 Indent (os, indentG);
4969 os << "}";
4970 #endif /* NDEBUG */
4971 } // CRLToSign::Print
4972
4973
4974 AttributeCertificateInfo::AttributeCertificateInfo()
4975 {
4976 version = NULL;
4977 #if TCL
4978 subject = new AttributeCertificateInfoChoice;
4979 #else
4980 subject = NULL; // incomplete initialization of mandatory element!
4981 #endif // TCL
4982 #if TCL
4983 signature = new AlgorithmIdentifier;
4984 #else
4985 signature = NULL; // incomplete initialization of mandatory element!
4986 #endif // TCL
4987 #if TCL
4988 attCertValidityPeriod = new AttCertValidityPeriod;
4989 #else
4990 attCertValidityPeriod = NULL; // incomplete initialization of mandatory element!
4991 #endif // TCL
4992 issuerUniqueID = NULL;
4993 extensions = NULL;
4994 }
4995
4996 AttributeCertificateInfo::AttributeCertificateInfo (const AttributeCertificateInfo &)
4997 {
4998 Asn1Error << "use of incompletely defined AttributeCertificateInfo::AttributeCertificateInfo (const AttributeCertificateInfo &)" << endl;
4999 abort();
5000 }
5001
5002 AttributeCertificateInfo::~AttributeCertificateInfo()
5003 {
5004 delete version;
5005 delete subject;
5006 delete signature;
5007 delete attCertValidityPeriod;
5008 delete issuerUniqueID;
5009 delete extensions;
5010 }
5011
5012 AsnType *AttributeCertificateInfo::Clone() const
5013 {
5014 return new AttributeCertificateInfo;
5015 }
5016
5017 AsnType *AttributeCertificateInfo::Copy() const
5018 {
5019 return new AttributeCertificateInfo (*this);
5020 }
5021
5022 #if SNACC_DEEP_COPY
5023 AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &that)
5024 #else // SNACC_DEEP_COPY
5025 AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &)
5026 #endif // SNACC_DEEP_COPY
5027 {
5028 #if SNACC_DEEP_COPY
5029 if (this != &that)
5030 {
5031 if (that.version)
5032 {
5033 if (!version)
5034 version = new Version;
5035 *version = *that.version;
5036 }
5037 else
5038 {
5039 delete version;
5040 version = NULL;
5041 }
5042 if (that.subject)
5043 {
5044 if (!subject)
5045 subject = new AttributeCertificateInfoChoice;
5046 *subject = *that.subject;
5047 }
5048 else
5049 {
5050 delete subject;
5051 subject = NULL;
5052 }
5053 issuer = that.issuer;
5054 if (that.signature)
5055 {
5056 if (!signature)
5057 signature = new AlgorithmIdentifier;
5058 *signature = *that.signature;
5059 }
5060 else
5061 {
5062 delete signature;
5063 signature = NULL;
5064 }
5065 serialNumber = that.serialNumber;
5066 if (that.attCertValidityPeriod)
5067 {
5068 if (!attCertValidityPeriod)
5069 attCertValidityPeriod = new AttCertValidityPeriod;
5070 *attCertValidityPeriod = *that.attCertValidityPeriod;
5071 }
5072 else
5073 {
5074 delete attCertValidityPeriod;
5075 attCertValidityPeriod = NULL;
5076 }
5077 attributes = that.attributes;
5078 if (that.issuerUniqueID)
5079 {
5080 if (!issuerUniqueID)
5081 issuerUniqueID = new UniqueIdentifier;
5082 *issuerUniqueID = *that.issuerUniqueID;
5083 }
5084 else
5085 {
5086 delete issuerUniqueID;
5087 issuerUniqueID = NULL;
5088 }
5089 if (that.extensions)
5090 {
5091 if (!extensions)
5092 extensions = new Extensions;
5093 *extensions = *that.extensions;
5094 }
5095 else
5096 {
5097 delete extensions;
5098 extensions = NULL;
5099 }
5100 }
5101
5102 return *this;
5103 #else // SNACC_DEEP_COPY
5104 Asn1Error << "use of incompletely defined AttributeCertificateInfo &AttributeCertificateInfo::operator = (const AttributeCertificateInfo &)" << endl;
5105 abort();
5106 // if your compiler complains here, check the -novolat option
5107 #endif // SNACC_DEEP_COPY
5108 }
5109
5110 AsnLen
5111 AttributeCertificateInfo::BEncContent (BUF_TYPE b)
5112 {
5113 AsnLen totalLen = 0;
5114 AsnLen l;
5115
5116 if (NOT_NULL (extensions))
5117 {
5118 BEncEocIfNec (b);
5119 l = extensions->BEncContent (b);
5120 l += BEncConsLen (b, l);
5121
5122 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5123 totalLen += l;
5124 }
5125
5126 if (NOT_NULL (issuerUniqueID))
5127 {
5128 l = issuerUniqueID->BEncContent (b);
5129 l += BEncDefLen (b, l);
5130
5131 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
5132 totalLen += l;
5133 }
5134
5135 BEncEocIfNec (b);
5136 l = attributes.BEncContent (b);
5137 l += BEncConsLen (b, l);
5138
5139 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5140 totalLen += l;
5141
5142 BEncEocIfNec (b);
5143 l = attCertValidityPeriod->BEncContent (b);
5144 l += BEncConsLen (b, l);
5145
5146 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5147 totalLen += l;
5148
5149 l = serialNumber.BEncContent (b);
5150 l += BEncDefLen (b, l);
5151
5152 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
5153 totalLen += l;
5154
5155 BEncEocIfNec (b);
5156 l = signature->BEncContent (b);
5157 l += BEncConsLen (b, l);
5158
5159 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5160 totalLen += l;
5161
5162 BEncEocIfNec (b);
5163 l = issuer.BEncContent (b);
5164 l += BEncConsLen (b, l);
5165
5166 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5167 totalLen += l;
5168
5169 l = subject->BEncContent (b);
5170 totalLen += l;
5171
5172 if (NOT_NULL (version))
5173 {
5174 l = version->BEncContent (b);
5175 BEncDefLenTo127 (b, l);
5176 l++;
5177
5178 l += BEncTag1 (b, UNIV, PRIM, INTEGER_TAG_CODE);
5179 totalLen += l;
5180 }
5181
5182 return totalLen;
5183 } // AttributeCertificateInfo::BEncContent
5184
5185
5186 void AttributeCertificateInfo::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
5187 {
5188 AsnTag tag1;
5189 AsnLen seqBytesDecoded = 0;
5190 AsnLen elmtLen1;
5191 tag1 = BDecTag (b, seqBytesDecoded, env);
5192
5193 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE)))
5194 {
5195 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5196 version = new Version;
5197 version->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5198 tag1 = BDecTag (b, seqBytesDecoded, env);
5199 }
5200
5201 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0))
5202 || (tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
5203 {
5204 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5205 subject = new AttributeCertificateInfoChoice;
5206 subject->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5207 tag1 = BDecTag (b, seqBytesDecoded, env);
5208 }
5209 else
5210 {
5211 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5212 SnaccExcep::throwMe(-157);
5213 }
5214
5215 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5216 {
5217 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5218 issuer.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5219 tag1 = BDecTag (b, seqBytesDecoded, env);
5220 }
5221 else
5222 {
5223 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5224 SnaccExcep::throwMe(-158);
5225 }
5226
5227 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5228 {
5229 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5230 signature = new AlgorithmIdentifier;
5231 signature->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5232 tag1 = BDecTag (b, seqBytesDecoded, env);
5233 }
5234 else
5235 {
5236 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5237 SnaccExcep::throwMe(-159);
5238 }
5239
5240 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, INTEGER_TAG_CODE))
5241 || (tag1 == MAKE_TAG_ID (UNIV, CONS, INTEGER_TAG_CODE)))
5242 {
5243 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5244 serialNumber.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5245 tag1 = BDecTag (b, seqBytesDecoded, env);
5246 }
5247 else
5248 {
5249 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5250 SnaccExcep::throwMe(-160);
5251 }
5252
5253 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5254 {
5255 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5256 attCertValidityPeriod = new AttCertValidityPeriod;
5257 attCertValidityPeriod->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5258 tag1 = BDecTag (b, seqBytesDecoded, env);
5259 }
5260 else
5261 {
5262 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5263 SnaccExcep::throwMe(-161);
5264 }
5265
5266 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5267 {
5268 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5269 attributes.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5270 if (seqBytesDecoded == elmtLen0)
5271 {
5272 bytesDecoded += seqBytesDecoded;
5273 return;
5274 }
5275 else
5276 {
5277 tag1 = BDecTag (b, seqBytesDecoded, env);
5278
5279 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5280 {
5281 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5282 bytesDecoded += seqBytesDecoded;
5283 return;
5284 }
5285 }
5286 }
5287 else
5288 {
5289 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5290 SnaccExcep::throwMe(-162);
5291 }
5292
5293 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
5294 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
5295 {
5296 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5297 issuerUniqueID = new UniqueIdentifier;
5298 issuerUniqueID->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5299 if (seqBytesDecoded == elmtLen0)
5300 {
5301 bytesDecoded += seqBytesDecoded;
5302 return;
5303 }
5304 else
5305 {
5306 tag1 = BDecTag (b, seqBytesDecoded, env);
5307
5308 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
5309 {
5310 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
5311 bytesDecoded += seqBytesDecoded;
5312 return;
5313 }
5314 }
5315 }
5316
5317 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5318 {
5319 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5320 extensions = new Extensions;
5321 extensions->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5322 }
5323
5324 bytesDecoded += seqBytesDecoded;
5325 if (elmtLen0 == INDEFINITE_LEN)
5326 {
5327 BDecEoc (b, bytesDecoded, env);
5328 return;
5329 }
5330 else if (seqBytesDecoded != elmtLen0)
5331 {
5332 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
5333 SnaccExcep::throwMe(-163);
5334 }
5335 else
5336 return;
5337 } // AttributeCertificateInfo::BDecContent
5338
5339 AsnLen AttributeCertificateInfo::BEnc (BUF_TYPE b)
5340 {
5341 AsnLen l;
5342 l = BEncContent (b);
5343 l += BEncConsLen (b, l);
5344 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5345 return l;
5346 }
5347
5348 void AttributeCertificateInfo::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5349 {
5350 AsnTag tag;
5351 AsnLen elmtLen1;
5352
5353 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5354 {
5355 Asn1Error << "AttributeCertificateInfo::BDec: ERROR - wrong tag" << endl;
5356 SnaccExcep::throwMe(-164);
5357 }
5358 elmtLen1 = BDecLen (b, bytesDecoded, env);
5359 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5360 }
5361
5362 void AttributeCertificateInfo::Print (ostream &os) const
5363 {
5364 #ifndef NDEBUG
5365 os << "{ -- SEQUENCE --" << endl;
5366 indentG += stdIndentG;
5367
5368 if (NOT_NULL (version))
5369 {
5370 Indent (os, indentG);
5371 os << "version ";
5372 os << *version;
5373 }
5374 else
5375 {
5376 Indent (os, indentG);
5377 os << "version ";
5378 os << "-- void --";
5379 os << "," << endl;
5380 }
5381
5382 if (NOT_NULL (subject))
5383 {
5384 Indent (os, indentG);
5385 os << "subject ";
5386 os << *subject;
5387 }
5388 else
5389 {
5390 Indent (os, indentG);
5391 os << "subject ";
5392 os << "-- void --";
5393 os << "," << endl;
5394 }
5395
5396 {
5397 Indent (os, indentG);
5398 os << "issuer ";
5399 os << issuer;
5400 os << "," << endl;
5401 }
5402
5403 if (NOT_NULL (signature))
5404 {
5405 Indent (os, indentG);
5406 os << "signature ";
5407 os << *signature;
5408 }
5409 else
5410 {
5411 Indent (os, indentG);
5412 os << "signature ";
5413 os << "-- void --";
5414 os << "," << endl;
5415 }
5416
5417 {
5418 Indent (os, indentG);
5419 os << "serialNumber ";
5420 os << serialNumber;
5421 os << "," << endl;
5422 }
5423
5424 if (NOT_NULL (attCertValidityPeriod))
5425 {
5426 Indent (os, indentG);
5427 os << "attCertValidityPeriod ";
5428 os << *attCertValidityPeriod;
5429 }
5430 else
5431 {
5432 Indent (os, indentG);
5433 os << "attCertValidityPeriod ";
5434 os << "-- void --";
5435 os << "," << endl;
5436 }
5437
5438 {
5439 Indent (os, indentG);
5440 os << "attributes ";
5441 os << attributes;
5442 os << "," << endl;
5443 }
5444
5445 if (NOT_NULL (issuerUniqueID))
5446 {
5447 os << ","<< endl;
5448 Indent (os, indentG);
5449 os << "issuerUniqueID ";
5450 os << *issuerUniqueID;
5451 }
5452 else
5453 {
5454 Indent (os, indentG);
5455 os << "issuerUniqueID ";
5456 os << "-- void --";
5457 os << "," << endl;
5458 }
5459
5460 if (NOT_NULL (extensions))
5461 {
5462 os << ","<< endl;
5463 Indent (os, indentG);
5464 os << "extensions ";
5465 os << *extensions;
5466 }
5467 else
5468 {
5469 Indent (os, indentG);
5470 os << "extensions ";
5471 os << "-- void --";
5472 os << endl;
5473 }
5474
5475 os << endl;
5476 indentG -= stdIndentG;
5477 Indent (os, indentG);
5478 os << "}";
5479 #endif /* NDEBUG */
5480 } // AttributeCertificateInfo::Print
5481
5482
5483 Certificate::Certificate()
5484 {
5485 #if TCL
5486 certificateToSign = new CertificateToSign;
5487 #else
5488 certificateToSign = NULL; // incomplete initialization of mandatory element!
5489 #endif // TCL
5490 #if TCL
5491 algorithmIdentifier = new AlgorithmIdentifier;
5492 #else
5493 algorithmIdentifier = NULL; // incomplete initialization of mandatory element!
5494 #endif // TCL
5495 }
5496
5497 Certificate::Certificate (const Certificate &)
5498 {
5499 Asn1Error << "use of incompletely defined Certificate::Certificate (const Certificate &)" << endl;
5500 abort();
5501 }
5502
5503 Certificate::~Certificate()
5504 {
5505 delete certificateToSign;
5506 delete algorithmIdentifier;
5507 }
5508
5509 AsnType *Certificate::Clone() const
5510 {
5511 return new Certificate;
5512 }
5513
5514 AsnType *Certificate::Copy() const
5515 {
5516 return new Certificate (*this);
5517 }
5518
5519 #if SNACC_DEEP_COPY
5520 Certificate &Certificate::operator = (const Certificate &that)
5521 #else // SNACC_DEEP_COPY
5522 Certificate &Certificate::operator = (const Certificate &)
5523 #endif // SNACC_DEEP_COPY
5524 {
5525 #if SNACC_DEEP_COPY
5526 if (this != &that)
5527 {
5528 if (that.certificateToSign)
5529 {
5530 if (!certificateToSign)
5531 certificateToSign = new CertificateToSign;
5532 *certificateToSign = *that.certificateToSign;
5533 }
5534 else
5535 {
5536 delete certificateToSign;
5537 certificateToSign = NULL;
5538 }
5539 if (that.algorithmIdentifier)
5540 {
5541 if (!algorithmIdentifier)
5542 algorithmIdentifier = new AlgorithmIdentifier;
5543 *algorithmIdentifier = *that.algorithmIdentifier;
5544 }
5545 else
5546 {
5547 delete algorithmIdentifier;
5548 algorithmIdentifier = NULL;
5549 }
5550 signatureValue = that.signatureValue;
5551 }
5552
5553 return *this;
5554 #else // SNACC_DEEP_COPY
5555 Asn1Error << "use of incompletely defined Certificate &Certificate::operator = (const Certificate &)" << endl;
5556 abort();
5557 // if your compiler complains here, check the -novolat option
5558 #endif // SNACC_DEEP_COPY
5559 }
5560
5561 AsnLen
5562 Certificate::BEncContent (BUF_TYPE b)
5563 {
5564 AsnLen totalLen = 0;
5565 AsnLen l;
5566
5567 l = signatureValue.BEncContent (b);
5568 l += BEncDefLen (b, l);
5569
5570 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
5571 totalLen += l;
5572
5573 BEncEocIfNec (b);
5574 l = algorithmIdentifier->BEncContent (b);
5575 l += BEncConsLen (b, l);
5576
5577 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5578 totalLen += l;
5579
5580 BEncEocIfNec (b);
5581 l = certificateToSign->BEncContent (b);
5582 l += BEncConsLen (b, l);
5583
5584 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5585 totalLen += l;
5586
5587 return totalLen;
5588 } // Certificate::BEncContent
5589
5590
5591 void Certificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
5592 {
5593 AsnTag tag1;
5594 AsnLen seqBytesDecoded = 0;
5595 AsnLen elmtLen1;
5596 tag1 = BDecTag (b, seqBytesDecoded, env);
5597
5598 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5599 {
5600 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5601 certificateToSign = new CertificateToSign;
5602 certificateToSign->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5603 tag1 = BDecTag (b, seqBytesDecoded, env);
5604 }
5605 else
5606 {
5607 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5608 SnaccExcep::throwMe(-165);
5609 }
5610
5611 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
5612 {
5613 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5614 algorithmIdentifier = new AlgorithmIdentifier;
5615 algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5616 tag1 = BDecTag (b, seqBytesDecoded, env);
5617 }
5618 else
5619 {
5620 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5621 SnaccExcep::throwMe(-166);
5622 }
5623
5624 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
5625 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
5626 {
5627 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
5628 signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
5629 }
5630 else
5631 {
5632 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
5633 SnaccExcep::throwMe(-167);
5634 }
5635
5636 bytesDecoded += seqBytesDecoded;
5637 if (elmtLen0 == INDEFINITE_LEN)
5638 {
5639 BDecEoc (b, bytesDecoded, env);
5640 return;
5641 }
5642 else if (seqBytesDecoded != elmtLen0)
5643 {
5644 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
5645 SnaccExcep::throwMe(-168);
5646 }
5647 else
5648 return;
5649 } // Certificate::BDecContent
5650
5651 AsnLen Certificate::BEnc (BUF_TYPE b)
5652 {
5653 AsnLen l;
5654 l = BEncContent (b);
5655 l += BEncConsLen (b, l);
5656 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
5657 return l;
5658 }
5659
5660 void Certificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5661 {
5662 AsnTag tag;
5663 AsnLen elmtLen1;
5664
5665 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
5666 {
5667 Asn1Error << "Certificate::BDec: ERROR - wrong tag" << endl;
5668 SnaccExcep::throwMe(-169);
5669 }
5670 elmtLen1 = BDecLen (b, bytesDecoded, env);
5671 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5672 }
5673
5674 void Certificate::Print (ostream &os) const
5675 {
5676 #ifndef NDEBUG
5677 os << "{ -- SEQUENCE --" << endl;
5678 indentG += stdIndentG;
5679
5680 if (NOT_NULL (certificateToSign))
5681 {
5682 Indent (os, indentG);
5683 os << "certificateToSign ";
5684 os << *certificateToSign;
5685 }
5686 else
5687 {
5688 Indent (os, indentG);
5689 os << "certificateToSign ";
5690 os << "-- void --";
5691 os << "," << endl;
5692 }
5693
5694 if (NOT_NULL (algorithmIdentifier))
5695 {
5696 Indent (os, indentG);
5697 os << "algorithmIdentifier ";
5698 os << *algorithmIdentifier;
5699 }
5700 else
5701 {
5702 Indent (os, indentG);
5703 os << "algorithmIdentifier ";
5704 os << "-- void --";
5705 os << "," << endl;
5706 }
5707
5708 {
5709 Indent (os, indentG);
5710 os << "signatureValue ";
5711 os << signatureValue;
5712 }
5713
5714 os << endl;
5715 indentG -= stdIndentG;
5716 Indent (os, indentG);
5717 os << "}";
5718 #endif /* NDEBUG */
5719 } // Certificate::Print
5720
5721
5722 AsnType *CrossCertificates::Clone() const
5723 {
5724 return new CrossCertificates;
5725 }
5726
5727 AsnType *CrossCertificates::Copy() const
5728 {
5729 return new CrossCertificates (*this);
5730 }
5731
5732 AsnLen CrossCertificates::BEnc (BUF_TYPE b)
5733 {
5734 AsnLen l;
5735 l = BEncContent (b);
5736 l += BEncConsLen (b, l);
5737 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
5738 return l;
5739 }
5740
5741 void CrossCertificates::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
5742 {
5743 AsnTag tag;
5744 AsnLen elmtLen1;
5745
5746 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
5747 {
5748 Asn1Error << "CrossCertificates::BDec: ERROR - wrong tag" << endl;
5749 SnaccExcep::throwMe(-170);
5750 }
5751 elmtLen1 = BDecLen (b, bytesDecoded, env);
5752 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
5753 }
5754
5755 CrossCertificates::CrossCertificates (const CrossCertificates &)
5756 {
5757 Asn1Error << "use of incompletely defined CrossCertificates::CrossCertificates (const CrossCertificates &)" << endl;
5758 abort();
5759 }
5760
5761 CrossCertificates::~CrossCertificates()
5762 {
5763 SetCurrToFirst();
5764 for (; Curr() != NULL; RemoveCurrFromList())
5765 ;
5766 } // end of destructor
5767
5768 #if SNACC_DEEP_COPY
5769 CrossCertificates &CrossCertificates::operator = (const CrossCertificates &that)
5770 #else // SNACC_DEEP_COPY
5771 CrossCertificates &CrossCertificates::operator = (const CrossCertificates &)
5772 #endif // SNACC_DEEP_COPY
5773 {
5774 #if SNACC_DEEP_COPY
5775 if (this != &that)
5776 {
5777 SetCurrToFirst();
5778 for (; Curr(); RemoveCurrFromList())
5779 ;
5780
5781 //that.SetCurrToFirst();
5782 //for (; that.Curr(); that.GoNext())
5783 // AppendCopy (*that.Curr());
5784 for (const AsnListElmt *run=that.first; run; run=run->next)
5785 AppendCopy (*run->elmt);
5786 }
5787
5788 return *this;
5789 #else // SNACC_DEEP_COPY
5790 Asn1Error << "use of incompletely defined CrossCertificates &CrossCertificates::operator = (const CrossCertificates &)" << endl;
5791 abort();
5792 // if your compiler complains here, check the -novolat option
5793 #endif // SNACC_DEEP_COPY
5794 }
5795
5796 void CrossCertificates::Print (ostream &os) const
5797 {
5798 #ifndef NDEBUG
5799 os << "{ -- SEQUENCE/SET OF -- " << endl;
5800 indentG += stdIndentG;
5801 //SetCurrToFirst();
5802 //for (; Curr() != NULL; GoNext())
5803 for (const AsnListElmt *run=first; run; run=run->next)
5804 {
5805 Indent (os, indentG);
5806 //os << *Curr();
5807 os << *run->elmt;
5808 //if (Curr() != Last())
5809 if (run != last)
5810 os << ",";
5811 os << endl;
5812 }
5813 indentG -= stdIndentG;
5814 Indent (os, indentG);
5815 os << "}\n";
5816 #endif /* NDEBUG */
5817
5818
5819 } // Print
5820
5821
5822 void CrossCertificates::SetCurrElmt (unsigned long int index)
5823 {
5824 unsigned long int i;
5825 curr = first;
5826 if (count)
5827 for (i = 0; (i < (count-1)) && (i < index); i++)
5828 curr = curr->next;
5829 } // CrossCertificates::SetCurrElmt
5830
5831
5832 unsigned long int CrossCertificates::GetCurrElmtIndex()
5833 {
5834 unsigned long int i;
5835 AsnListElmt *tmp;
5836 if (curr != NULL)
5837 {
5838 for (i = 0, tmp = first; tmp != NULL; i++)
5839 {
5840 if (tmp == curr)
5841 return i;
5842 else
5843 tmp = tmp->next;
5844 }
5845 }
5846 return count;
5847 } // CrossCertificates::GetCurrElmtIndex
5848
5849
5850 // alloc new list elmt, put at end of list
5851 // and return the component type
5852 Certificate *CrossCertificates::Append()
5853 {
5854 AsnListElmt *newElmt;
5855 newElmt = new AsnListElmt;
5856 newElmt->elmt = new Certificate;
5857 newElmt->next = NULL;
5858 if (last == NULL)
5859 {
5860 newElmt->prev = NULL;
5861 first = last = newElmt;
5862 }
5863 else
5864 {
5865 newElmt->prev = last;
5866 last->next = newElmt;
5867 last = newElmt;
5868 }
5869 count++;
5870 return (curr = newElmt)->elmt;
5871 } // CrossCertificates::Append
5872
5873
5874 // alloc new list elmt, put at begining of list
5875 // and return the component type
5876 Certificate *CrossCertificates::Prepend()
5877 {
5878 AsnListElmt *newElmt;
5879 newElmt = new AsnListElmt;
5880 newElmt->elmt = new Certificate;
5881 newElmt->prev = NULL;
5882 if (first == NULL)
5883 {
5884 newElmt->next = NULL;
5885 first = last = newElmt;
5886 }
5887 else
5888 {
5889 newElmt->next = first;
5890 first->prev = newElmt;
5891 first = newElmt;
5892 }
5893 count++;
5894 return (curr = newElmt)->elmt;
5895 } // CrossCertificates::Prepend
5896
5897
5898 // alloc new list elmt, insert it before the
5899 // current element and return the component type
5900 // if the current element is null, the new element
5901 // is placed at the beginning of the list.
5902 Certificate *CrossCertificates::InsertBefore()
5903 {
5904 AsnListElmt *newElmt;
5905 newElmt = new AsnListElmt;
5906 newElmt->elmt = new Certificate;
5907 if (curr == NULL)
5908 {
5909 newElmt->next = first;
5910 newElmt->prev = NULL;
5911 first = newElmt;
5912 if (last == NULL)
5913 last = newElmt;
5914 }
5915 else
5916 {
5917 newElmt->next = curr;
5918 newElmt->prev = curr->prev;
5919 curr->prev = newElmt;
5920 if (curr == first)
5921 first = newElmt;
5922 else
5923 newElmt->prev->next = newElmt;
5924 }
5925 count++;
5926 return (curr = newElmt)->elmt;
5927 } // CrossCertificates::InsertBefore
5928
5929
5930 // alloc new list elmt, insert it after the
5931 // current element and return the component type
5932 // if the current element is null, the new element
5933 // is placed at the end of the list.
5934 Certificate *CrossCertificates::InsertAfter()
5935 {
5936 AsnListElmt *newElmt;
5937 newElmt = new AsnListElmt;
5938 newElmt->elmt = new Certificate;
5939 if (curr == NULL)
5940 {
5941 newElmt->prev = last;
5942 newElmt->next = NULL;
5943 last = newElmt;
5944 if (first == NULL)
5945 first = newElmt;
5946 }
5947 else
5948 {
5949 newElmt->prev = curr;
5950 newElmt->next = curr->next;
5951 curr->next = newElmt;
5952 if (curr == last)
5953 last = newElmt;
5954 else
5955 newElmt->next->prev = newElmt;
5956 }
5957 count++;
5958 return (curr = newElmt)->elmt;
5959 } // CrossCertificates::InsertAfter
5960
5961
5962 CrossCertificates &CrossCertificates::AppendCopy (Certificate &elmt)
5963 {
5964 AsnListElmt *newElmt;
5965 newElmt = new AsnListElmt;
5966 newElmt->elmt = new Certificate;
5967 *newElmt->elmt = elmt;
5968 newElmt->next = NULL;
5969 if (last == NULL)
5970 {
5971 newElmt->prev = NULL;
5972 first = last = newElmt;
5973 }
5974 else
5975 {
5976 newElmt->prev = last;
5977 last->next = newElmt;
5978 last = newElmt;
5979 }
5980 count++;
5981 return *this;
5982 } // AppendCopy
5983
5984
5985 CrossCertificates &CrossCertificates::PrependCopy (Certificate &elmt)
5986 {
5987 AsnListElmt *newElmt;
5988 newElmt = new AsnListElmt;
5989 newElmt->elmt = new Certificate;
5990 *newElmt->elmt = elmt;
5991 newElmt->prev = NULL;
5992 if (first == NULL)
5993 {
5994 newElmt->next = NULL;
5995 first = last = newElmt;
5996 }
5997 else
5998 {
5999 newElmt->next = first;
6000 first->prev = newElmt;
6001 first = newElmt;
6002 }
6003 count++;
6004 return *this;
6005 } // CrossCertificates::PrependCopy
6006
6007
6008 // alloc new list elmt, insert it before the
6009 // current element, copy the given elmt into the new elmt
6010 // and return the component type.
6011 // if the current element is null, the new element
6012 // is placed at the beginning of the list.
6013 CrossCertificates &CrossCertificates::InsertBeforeAndCopy (Certificate &elmt)
6014 {
6015 AsnListElmt *newElmt;
6016
6017 newElmt = new AsnListElmt;
6018 newElmt->elmt = new Certificate;
6019 *newElmt->elmt = elmt;
6020
6021 if (curr == NULL)
6022 {
6023 newElmt->next = first;
6024 newElmt->prev = NULL;
6025 first = newElmt;
6026 if (last == NULL)
6027 last = newElmt;
6028 }
6029 else
6030 {
6031 newElmt->next = curr;
6032 newElmt->prev = curr->prev;
6033 curr->prev = newElmt;
6034 if (curr == first)
6035 first = newElmt;
6036 else
6037 newElmt->prev->next = newElmt;
6038 }
6039 count++;
6040 return *this;
6041 } // CrossCertificates::InsertBeforeAndCopy
6042
6043
6044 // alloc new list elmt, insert it after the
6045 // current element, copy given elmt in to new elmt
6046 // and return the component type
6047 // if the current element is null, the new element
6048 // is placed at the end of the list.
6049 CrossCertificates &CrossCertificates::InsertAfterAndCopy (Certificate &elmt)
6050 {
6051 AsnListElmt *newElmt;
6052
6053 newElmt = new AsnListElmt;
6054 newElmt->elmt = new Certificate;
6055 *newElmt->elmt = elmt;
6056 if (curr == NULL)
6057 {
6058 newElmt->prev = last;
6059 newElmt->next = NULL;
6060 last = newElmt;
6061 if (first == NULL)
6062 first = newElmt;
6063 }
6064 else
6065 {
6066 newElmt->prev = curr;
6067 newElmt->next = curr->next;
6068 curr->next = newElmt;
6069 if (curr == last)
6070 last = newElmt;
6071 else
6072 newElmt->next->prev = newElmt;
6073 }
6074 count++;
6075 return *this;
6076 } // CrossCertificates::InsertAfterAndCopy
6077
6078
6079 // remove current element from list if current element is not NULL
6080 // The new current element will be the next element.
6081 // If the current element is the last element in the list
6082 // the second but last element will become the new current element.
6083 void CrossCertificates::RemoveCurrFromList()
6084 {
6085 AsnListElmt *del_elmt;
6086
6087 if (curr != NULL)
6088 {
6089 del_elmt = curr;
6090 count--;
6091
6092 if (count == 0)
6093 first = last = curr = NULL;
6094 else if (curr == first)
6095 {
6096 curr = first= first->next;
6097 first->prev = NULL;
6098 }
6099 else if (curr == last)
6100 {
6101 curr = last = last->prev;
6102 last->next = NULL;
6103 }
6104 else
6105 {
6106 curr->prev->next = curr->next;
6107 curr->next->prev = curr->prev;
6108 }
6109
6110 delete del_elmt->elmt;
6111 delete del_elmt;
6112 }
6113 }
6114
6115
6116 AsnLen CrossCertificates::BEncContent (BUF_TYPE b)
6117 {
6118 AsnListElmt *currElmt;
6119 AsnLen elmtLen;
6120 AsnLen totalLen = 0;
6121 {
6122 int iii,icount;
6123 CSM_Buffer **tmpEnc=NULL;
6124 for (currElmt = last,icount=0; currElmt != NULL; currElmt = currElmt->prev, icount++);
6125 tmpEnc = (CSM_Buffer **) calloc(sizeof(CSM_Buffer *), icount);
6126 for (currElmt = last, iii=0; currElmt != NULL; currElmt = currElmt->prev,iii++,elmtLen=0)
6127 {
6128 BEncEocIfNec (b);
6129 ENCODE_BUF1(currElmt->elmt->BEncContent, elmtLen);
6130 elmtLen += BEncConsLen (outputBuf, elmtLen);
6131
6132 elmtLen += BEncTag1 (outputBuf, UNIV, CONS, SEQ_TAG_CODE);
6133 ENCODE_BUF2(tmpEnc[iii]);
6134 }
6135 vdasnacc_sortSetOf(tmpEnc, icount);
6136 for (iii=0,elmtLen=0; iii < icount; elmtLen+=tmpEnc[iii++]->Length())
6137 SM_WriteToAsnBuf(tmpEnc[iii], b);
6138 for (iii=0; iii < icount; iii++) delete tmpEnc[iii];
6139 free(tmpEnc);
6140 }
6141 totalLen += elmtLen;
6142 return totalLen;
6143 } // CrossCertificates::BEncContent
6144
6145
6146 void CrossCertificates::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
6147 AsnLen &bytesDecoded, ENV_TYPE env)
6148 {
6149 Certificate *listElmt;
6150 AsnTag tag1;
6151 AsnLen listBytesDecoded = 0;
6152 AsnLen elmtLen1;
6153
6154 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
6155 {
6156 tag1 = BDecTag (b, listBytesDecoded, env);
6157 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
6158 {
6159 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
6160 break;
6161 }
6162 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6163 {
6164 Asn1Error << "Unexpected Tag" << endl;
6165 SnaccExcep::throwMe(-171);
6166 }
6167
6168 elmtLen1 = BDecLen (b, listBytesDecoded, env);
6169 listElmt = Append();
6170 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
6171 }
6172
6173 bytesDecoded += listBytesDecoded;
6174 } // CrossCertificates::BDecContent
6175
6176
6177 CertificatePair::CertificatePair()
6178 {
6179 forward = NULL;
6180 reverse = NULL;
6181 }
6182
6183 CertificatePair::CertificatePair (const CertificatePair &)
6184 {
6185 Asn1Error << "use of incompletely defined CertificatePair::CertificatePair (const CertificatePair &)" << endl;
6186 abort();
6187 }
6188
6189 CertificatePair::~CertificatePair()
6190 {
6191 delete forward;
6192 delete reverse;
6193 }
6194
6195 AsnType *CertificatePair::Clone() const
6196 {
6197 return new CertificatePair;
6198 }
6199
6200 AsnType *CertificatePair::Copy() const
6201 {
6202 return new CertificatePair (*this);
6203 }
6204
6205 #if SNACC_DEEP_COPY
6206 CertificatePair &CertificatePair::operator = (const CertificatePair &that)
6207 #else // SNACC_DEEP_COPY
6208 CertificatePair &CertificatePair::operator = (const CertificatePair &)
6209 #endif // SNACC_DEEP_COPY
6210 {
6211 #if SNACC_DEEP_COPY
6212 if (this != &that)
6213 {
6214 if (that.forward)
6215 {
6216 if (!forward)
6217 forward = new Certificate;
6218 *forward = *that.forward;
6219 }
6220 else
6221 {
6222 delete forward;
6223 forward = NULL;
6224 }
6225 if (that.reverse)
6226 {
6227 if (!reverse)
6228 reverse = new Certificate;
6229 *reverse = *that.reverse;
6230 }
6231 else
6232 {
6233 delete reverse;
6234 reverse = NULL;
6235 }
6236 }
6237
6238 return *this;
6239 #else // SNACC_DEEP_COPY
6240 Asn1Error << "use of incompletely defined CertificatePair &CertificatePair::operator = (const CertificatePair &)" << endl;
6241 abort();
6242 // if your compiler complains here, check the -novolat option
6243 #endif // SNACC_DEEP_COPY
6244 }
6245
6246 AsnLen
6247 CertificatePair::BEncContent (BUF_TYPE b)
6248 {
6249 AsnLen totalLen = 0;
6250 AsnLen l;
6251
6252 if (NOT_NULL (reverse))
6253 {
6254 BEncEocIfNec (b);
6255 BEncEocIfNec (b);
6256 l = reverse->BEncContent (b);
6257 l += BEncConsLen (b, l);
6258
6259 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6260 l += BEncConsLen (b, l);
6261
6262 l += BEncTag1 (b, CNTX, CONS, 1);
6263 totalLen += l;
6264 }
6265
6266 if (NOT_NULL (forward))
6267 {
6268 BEncEocIfNec (b);
6269 BEncEocIfNec (b);
6270 l = forward->BEncContent (b);
6271 l += BEncConsLen (b, l);
6272
6273 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6274 l += BEncConsLen (b, l);
6275
6276 l += BEncTag1 (b, CNTX, CONS, 0);
6277 totalLen += l;
6278 }
6279
6280 return totalLen;
6281 } // CertificatePair::BEncContent
6282
6283
6284 void CertificatePair::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
6285 {
6286 AsnTag tag1;
6287 AsnLen seqBytesDecoded = 0;
6288 AsnLen elmtLen1;
6289 AsnLen elmtLen2;
6290 if (elmtLen0 == 0)
6291 return;
6292 else
6293 {
6294 tag1 = BDecTag (b, seqBytesDecoded, env);
6295
6296 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6297 {
6298 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6299 bytesDecoded += seqBytesDecoded;
6300 return;
6301 }
6302 }
6303
6304 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
6305 {
6306 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6307 tag1 = BDecTag (b, seqBytesDecoded, env);
6308
6309 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6310 {
6311 Asn1Error << "Unexpected Tag" << endl;
6312 SnaccExcep::throwMe(-172);
6313 }
6314
6315 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
6316 forward = new Certificate;
6317 forward->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
6318 if (elmtLen1 == INDEFINITE_LEN)
6319 BDecEoc (b, seqBytesDecoded, env);
6320
6321 if (seqBytesDecoded == elmtLen0)
6322 {
6323 bytesDecoded += seqBytesDecoded;
6324 return;
6325 }
6326 else
6327 {
6328 tag1 = BDecTag (b, seqBytesDecoded, env);
6329
6330 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
6331 {
6332 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
6333 bytesDecoded += seqBytesDecoded;
6334 return;
6335 }
6336 }
6337 }
6338
6339 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
6340 {
6341 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6342 tag1 = BDecTag (b, seqBytesDecoded, env);
6343
6344 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6345 {
6346 Asn1Error << "Unexpected Tag" << endl;
6347 SnaccExcep::throwMe(-173);
6348 }
6349
6350 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
6351 reverse = new Certificate;
6352 reverse->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
6353 if (elmtLen1 == INDEFINITE_LEN)
6354 BDecEoc (b, seqBytesDecoded, env);
6355
6356 }
6357
6358 bytesDecoded += seqBytesDecoded;
6359 if (elmtLen0 == INDEFINITE_LEN)
6360 {
6361 BDecEoc (b, bytesDecoded, env);
6362 return;
6363 }
6364 else if (seqBytesDecoded != elmtLen0)
6365 {
6366 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
6367 SnaccExcep::throwMe(-174);
6368 }
6369 else
6370 return;
6371 } // CertificatePair::BDecContent
6372
6373 AsnLen CertificatePair::BEnc (BUF_TYPE b)
6374 {
6375 AsnLen l;
6376 l = BEncContent (b);
6377 l += BEncConsLen (b, l);
6378 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6379 return l;
6380 }
6381
6382 void CertificatePair::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6383 {
6384 AsnTag tag;
6385 AsnLen elmtLen1;
6386
6387 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6388 {
6389 Asn1Error << "CertificatePair::BDec: ERROR - wrong tag" << endl;
6390 SnaccExcep::throwMe(-175);
6391 }
6392 elmtLen1 = BDecLen (b, bytesDecoded, env);
6393 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6394 }
6395
6396 void CertificatePair::Print (ostream &os) const
6397 {
6398 #ifndef NDEBUG
6399 int nonePrinted = true;
6400 os << "{ -- SEQUENCE --" << endl;
6401 indentG += stdIndentG;
6402
6403 if (NOT_NULL (forward))
6404 {
6405 nonePrinted = false;
6406 Indent (os, indentG);
6407 os << "forward ";
6408 os << *forward;
6409 }
6410 else
6411 {
6412 Indent (os, indentG);
6413 os << "forward ";
6414 os << "-- void --";
6415 os << "," << endl;
6416 }
6417
6418 if (NOT_NULL (reverse))
6419 {
6420 if (!nonePrinted)
6421 os << "," << endl;
6422 nonePrinted = false;
6423 Indent (os, indentG);
6424 os << "reverse ";
6425 os << *reverse;
6426 }
6427 else
6428 {
6429 Indent (os, indentG);
6430 os << "reverse ";
6431 os << "-- void --";
6432 os << endl;
6433 }
6434
6435 os << endl;
6436 indentG -= stdIndentG;
6437 Indent (os, indentG);
6438 os << "}";
6439 #endif /* NDEBUG */
6440 } // CertificatePair::Print
6441
6442
6443 CertificateList::CertificateList()
6444 {
6445 #if TCL
6446 crlToSign = new CRLToSign;
6447 #else
6448 crlToSign = NULL; // incomplete initialization of mandatory element!
6449 #endif // TCL
6450 #if TCL
6451 algorithmIdentifier = new AlgorithmIdentifier;
6452 #else
6453 algorithmIdentifier = NULL; // incomplete initialization of mandatory element!
6454 #endif // TCL
6455 }
6456
6457 CertificateList::CertificateList (const CertificateList &)
6458 {
6459 Asn1Error << "use of incompletely defined CertificateList::CertificateList (const CertificateList &)" << endl;
6460 abort();
6461 }
6462
6463 CertificateList::~CertificateList()
6464 {
6465 delete crlToSign;
6466 delete algorithmIdentifier;
6467 }
6468
6469 AsnType *CertificateList::Clone() const
6470 {
6471 return new CertificateList;
6472 }
6473
6474 AsnType *CertificateList::Copy() const
6475 {
6476 return new CertificateList (*this);
6477 }
6478
6479 #if SNACC_DEEP_COPY
6480 CertificateList &CertificateList::operator = (const CertificateList &that)
6481 #else // SNACC_DEEP_COPY
6482 CertificateList &CertificateList::operator = (const CertificateList &)
6483 #endif // SNACC_DEEP_COPY
6484 {
6485 #if SNACC_DEEP_COPY
6486 if (this != &that)
6487 {
6488 if (that.crlToSign)
6489 {
6490 if (!crlToSign)
6491 crlToSign = new CRLToSign;
6492 *crlToSign = *that.crlToSign;
6493 }
6494 else
6495 {
6496 delete crlToSign;
6497 crlToSign = NULL;
6498 }
6499 if (that.algorithmIdentifier)
6500 {
6501 if (!algorithmIdentifier)
6502 algorithmIdentifier = new AlgorithmIdentifier;
6503 *algorithmIdentifier = *that.algorithmIdentifier;
6504 }
6505 else
6506 {
6507 delete algorithmIdentifier;
6508 algorithmIdentifier = NULL;
6509 }
6510 signatureValue = that.signatureValue;
6511 }
6512
6513 return *this;
6514 #else // SNACC_DEEP_COPY
6515 Asn1Error << "use of incompletely defined CertificateList &CertificateList::operator = (const CertificateList &)" << endl;
6516 abort();
6517 // if your compiler complains here, check the -novolat option
6518 #endif // SNACC_DEEP_COPY
6519 }
6520
6521 AsnLen
6522 CertificateList::BEncContent (BUF_TYPE b)
6523 {
6524 AsnLen totalLen = 0;
6525 AsnLen l;
6526
6527 l = signatureValue.BEncContent (b);
6528 l += BEncDefLen (b, l);
6529
6530 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
6531 totalLen += l;
6532
6533 BEncEocIfNec (b);
6534 l = algorithmIdentifier->BEncContent (b);
6535 l += BEncConsLen (b, l);
6536
6537 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6538 totalLen += l;
6539
6540 BEncEocIfNec (b);
6541 l = crlToSign->BEncContent (b);
6542 l += BEncConsLen (b, l);
6543
6544 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6545 totalLen += l;
6546
6547 return totalLen;
6548 } // CertificateList::BEncContent
6549
6550
6551 void CertificateList::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
6552 {
6553 AsnTag tag1;
6554 AsnLen seqBytesDecoded = 0;
6555 AsnLen elmtLen1;
6556 tag1 = BDecTag (b, seqBytesDecoded, env);
6557
6558 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6559 {
6560 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6561 crlToSign = new CRLToSign;
6562 crlToSign->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6563 tag1 = BDecTag (b, seqBytesDecoded, env);
6564 }
6565 else
6566 {
6567 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6568 SnaccExcep::throwMe(-176);
6569 }
6570
6571 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6572 {
6573 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6574 algorithmIdentifier = new AlgorithmIdentifier;
6575 algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6576 tag1 = BDecTag (b, seqBytesDecoded, env);
6577 }
6578 else
6579 {
6580 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6581 SnaccExcep::throwMe(-177);
6582 }
6583
6584 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
6585 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
6586 {
6587 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6588 signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6589 }
6590 else
6591 {
6592 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6593 SnaccExcep::throwMe(-178);
6594 }
6595
6596 bytesDecoded += seqBytesDecoded;
6597 if (elmtLen0 == INDEFINITE_LEN)
6598 {
6599 BDecEoc (b, bytesDecoded, env);
6600 return;
6601 }
6602 else if (seqBytesDecoded != elmtLen0)
6603 {
6604 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
6605 SnaccExcep::throwMe(-179);
6606 }
6607 else
6608 return;
6609 } // CertificateList::BDecContent
6610
6611 AsnLen CertificateList::BEnc (BUF_TYPE b)
6612 {
6613 AsnLen l;
6614 l = BEncContent (b);
6615 l += BEncConsLen (b, l);
6616 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6617 return l;
6618 }
6619
6620 void CertificateList::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6621 {
6622 AsnTag tag;
6623 AsnLen elmtLen1;
6624
6625 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6626 {
6627 Asn1Error << "CertificateList::BDec: ERROR - wrong tag" << endl;
6628 SnaccExcep::throwMe(-180);
6629 }
6630 elmtLen1 = BDecLen (b, bytesDecoded, env);
6631 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6632 }
6633
6634 void CertificateList::Print (ostream &os) const
6635 {
6636 #ifndef NDEBUG
6637 os << "{ -- SEQUENCE --" << endl;
6638 indentG += stdIndentG;
6639
6640 if (NOT_NULL (crlToSign))
6641 {
6642 Indent (os, indentG);
6643 os << "crlToSign ";
6644 os << *crlToSign;
6645 }
6646 else
6647 {
6648 Indent (os, indentG);
6649 os << "crlToSign ";
6650 os << "-- void --";
6651 os << "," << endl;
6652 }
6653
6654 if (NOT_NULL (algorithmIdentifier))
6655 {
6656 Indent (os, indentG);
6657 os << "algorithmIdentifier ";
6658 os << *algorithmIdentifier;
6659 }
6660 else
6661 {
6662 Indent (os, indentG);
6663 os << "algorithmIdentifier ";
6664 os << "-- void --";
6665 os << "," << endl;
6666 }
6667
6668 {
6669 Indent (os, indentG);
6670 os << "signatureValue ";
6671 os << signatureValue;
6672 }
6673
6674 os << endl;
6675 indentG -= stdIndentG;
6676 Indent (os, indentG);
6677 os << "}";
6678 #endif /* NDEBUG */
6679 } // CertificateList::Print
6680
6681
6682 AttributeCertificate::AttributeCertificate()
6683 {
6684 #if TCL
6685 attributeCertificateInfo = new AttributeCertificateInfo;
6686 #else
6687 attributeCertificateInfo = NULL; // incomplete initialization of mandatory element!
6688 #endif // TCL
6689 #if TCL
6690 algorithmIdentifier = new AlgorithmIdentifier;
6691 #else
6692 algorithmIdentifier = NULL; // incomplete initialization of mandatory element!
6693 #endif // TCL
6694 }
6695
6696 AttributeCertificate::AttributeCertificate (const AttributeCertificate &)
6697 {
6698 Asn1Error << "use of incompletely defined AttributeCertificate::AttributeCertificate (const AttributeCertificate &)" << endl;
6699 abort();
6700 }
6701
6702 AttributeCertificate::~AttributeCertificate()
6703 {
6704 delete attributeCertificateInfo;
6705 delete algorithmIdentifier;
6706 }
6707
6708 AsnType *AttributeCertificate::Clone() const
6709 {
6710 return new AttributeCertificate;
6711 }
6712
6713 AsnType *AttributeCertificate::Copy() const
6714 {
6715 return new AttributeCertificate (*this);
6716 }
6717
6718 #if SNACC_DEEP_COPY
6719 AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &that)
6720 #else // SNACC_DEEP_COPY
6721 AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &)
6722 #endif // SNACC_DEEP_COPY
6723 {
6724 #if SNACC_DEEP_COPY
6725 if (this != &that)
6726 {
6727 if (that.attributeCertificateInfo)
6728 {
6729 if (!attributeCertificateInfo)
6730 attributeCertificateInfo = new AttributeCertificateInfo;
6731 *attributeCertificateInfo = *that.attributeCertificateInfo;
6732 }
6733 else
6734 {
6735 delete attributeCertificateInfo;
6736 attributeCertificateInfo = NULL;
6737 }
6738 if (that.algorithmIdentifier)
6739 {
6740 if (!algorithmIdentifier)
6741 algorithmIdentifier = new AlgorithmIdentifier;
6742 *algorithmIdentifier = *that.algorithmIdentifier;
6743 }
6744 else
6745 {
6746 delete algorithmIdentifier;
6747 algorithmIdentifier = NULL;
6748 }
6749 signatureValue = that.signatureValue;
6750 }
6751
6752 return *this;
6753 #else // SNACC_DEEP_COPY
6754 Asn1Error << "use of incompletely defined AttributeCertificate &AttributeCertificate::operator = (const AttributeCertificate &)" << endl;
6755 abort();
6756 // if your compiler complains here, check the -novolat option
6757 #endif // SNACC_DEEP_COPY
6758 }
6759
6760 AsnLen
6761 AttributeCertificate::BEncContent (BUF_TYPE b)
6762 {
6763 AsnLen totalLen = 0;
6764 AsnLen l;
6765
6766 l = signatureValue.BEncContent (b);
6767 l += BEncDefLen (b, l);
6768
6769 l += BEncTag1 (b, UNIV, PRIM, BITSTRING_TAG_CODE);
6770 totalLen += l;
6771
6772 BEncEocIfNec (b);
6773 l = algorithmIdentifier->BEncContent (b);
6774 l += BEncConsLen (b, l);
6775
6776 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6777 totalLen += l;
6778
6779 BEncEocIfNec (b);
6780 l = attributeCertificateInfo->BEncContent (b);
6781 l += BEncConsLen (b, l);
6782
6783 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6784 totalLen += l;
6785
6786 return totalLen;
6787 } // AttributeCertificate::BEncContent
6788
6789
6790 void AttributeCertificate::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
6791 {
6792 AsnTag tag1;
6793 AsnLen seqBytesDecoded = 0;
6794 AsnLen elmtLen1;
6795 tag1 = BDecTag (b, seqBytesDecoded, env);
6796
6797 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6798 {
6799 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6800 attributeCertificateInfo = new AttributeCertificateInfo;
6801 attributeCertificateInfo->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6802 tag1 = BDecTag (b, seqBytesDecoded, env);
6803 }
6804 else
6805 {
6806 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6807 SnaccExcep::throwMe(-181);
6808 }
6809
6810 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
6811 {
6812 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6813 algorithmIdentifier = new AlgorithmIdentifier;
6814 algorithmIdentifier->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6815 tag1 = BDecTag (b, seqBytesDecoded, env);
6816 }
6817 else
6818 {
6819 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6820 SnaccExcep::throwMe(-182);
6821 }
6822
6823 if ((tag1 == MAKE_TAG_ID (UNIV, PRIM, BITSTRING_TAG_CODE))
6824 || (tag1 == MAKE_TAG_ID (UNIV, CONS, BITSTRING_TAG_CODE)))
6825 {
6826 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
6827 signatureValue.BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
6828 }
6829 else
6830 {
6831 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
6832 SnaccExcep::throwMe(-183);
6833 }
6834
6835 bytesDecoded += seqBytesDecoded;
6836 if (elmtLen0 == INDEFINITE_LEN)
6837 {
6838 BDecEoc (b, bytesDecoded, env);
6839 return;
6840 }
6841 else if (seqBytesDecoded != elmtLen0)
6842 {
6843 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
6844 SnaccExcep::throwMe(-184);
6845 }
6846 else
6847 return;
6848 } // AttributeCertificate::BDecContent
6849
6850 AsnLen AttributeCertificate::BEnc (BUF_TYPE b)
6851 {
6852 AsnLen l;
6853 l = BEncContent (b);
6854 l += BEncConsLen (b, l);
6855 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6856 return l;
6857 }
6858
6859 void AttributeCertificate::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6860 {
6861 AsnTag tag;
6862 AsnLen elmtLen1;
6863
6864 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6865 {
6866 Asn1Error << "AttributeCertificate::BDec: ERROR - wrong tag" << endl;
6867 SnaccExcep::throwMe(-185);
6868 }
6869 elmtLen1 = BDecLen (b, bytesDecoded, env);
6870 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6871 }
6872
6873 void AttributeCertificate::Print (ostream &os) const
6874 {
6875 #ifndef NDEBUG
6876 os << "{ -- SEQUENCE --" << endl;
6877 indentG += stdIndentG;
6878
6879 if (NOT_NULL (attributeCertificateInfo))
6880 {
6881 Indent (os, indentG);
6882 os << "attributeCertificateInfo ";
6883 os << *attributeCertificateInfo;
6884 }
6885 else
6886 {
6887 Indent (os, indentG);
6888 os << "attributeCertificateInfo ";
6889 os << "-- void --";
6890 os << "," << endl;
6891 }
6892
6893 if (NOT_NULL (algorithmIdentifier))
6894 {
6895 Indent (os, indentG);
6896 os << "algorithmIdentifier ";
6897 os << *algorithmIdentifier;
6898 }
6899 else
6900 {
6901 Indent (os, indentG);
6902 os << "algorithmIdentifier ";
6903 os << "-- void --";
6904 os << "," << endl;
6905 }
6906
6907 {
6908 Indent (os, indentG);
6909 os << "signatureValue ";
6910 os << signatureValue;
6911 }
6912
6913 os << endl;
6914 indentG -= stdIndentG;
6915 Indent (os, indentG);
6916 os << "}";
6917 #endif /* NDEBUG */
6918 } // AttributeCertificate::Print
6919
6920
6921 AsnType *CertificationPathSeqOf::Clone() const
6922 {
6923 return new CertificationPathSeqOf;
6924 }
6925
6926 AsnType *CertificationPathSeqOf::Copy() const
6927 {
6928 return new CertificationPathSeqOf (*this);
6929 }
6930
6931 AsnLen CertificationPathSeqOf::BEnc (BUF_TYPE b)
6932 {
6933 AsnLen l;
6934 l = BEncContent (b);
6935 l += BEncConsLen (b, l);
6936 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
6937 return l;
6938 }
6939
6940 void CertificationPathSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
6941 {
6942 AsnTag tag;
6943 AsnLen elmtLen1;
6944
6945 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
6946 {
6947 Asn1Error << "CertificationPathSeqOf::BDec: ERROR - wrong tag" << endl;
6948 SnaccExcep::throwMe(-186);
6949 }
6950 elmtLen1 = BDecLen (b, bytesDecoded, env);
6951 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
6952 }
6953
6954 CertificationPathSeqOf::CertificationPathSeqOf (const CertificationPathSeqOf &)
6955 {
6956 Asn1Error << "use of incompletely defined CertificationPathSeqOf::CertificationPathSeqOf (const CertificationPathSeqOf &)" << endl;
6957 abort();
6958 }
6959
6960 CertificationPathSeqOf::~CertificationPathSeqOf()
6961 {
6962 SetCurrToFirst();
6963 for (; Curr() != NULL; RemoveCurrFromList())
6964 ;
6965 } // end of destructor
6966
6967 #if SNACC_DEEP_COPY
6968 CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &that)
6969 #else // SNACC_DEEP_COPY
6970 CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &)
6971 #endif // SNACC_DEEP_COPY
6972 {
6973 #if SNACC_DEEP_COPY
6974 if (this != &that)
6975 {
6976 SetCurrToFirst();
6977 for (; Curr(); RemoveCurrFromList())
6978 ;
6979
6980 //that.SetCurrToFirst();
6981 //for (; that.Curr(); that.GoNext())
6982 // AppendCopy (*that.Curr());
6983 for (const AsnListElmt *run=that.first; run; run=run->next)
6984 AppendCopy (*run->elmt);
6985 }
6986
6987 return *this;
6988 #else // SNACC_DEEP_COPY
6989 Asn1Error << "use of incompletely defined CertificationPathSeqOf &CertificationPathSeqOf::operator = (const CertificationPathSeqOf &)" << endl;
6990 abort();
6991 // if your compiler complains here, check the -novolat option
6992 #endif // SNACC_DEEP_COPY
6993 }
6994
6995 void CertificationPathSeqOf::Print (ostream &os) const
6996 {
6997 #ifndef NDEBUG
6998 os << "{ -- SEQUENCE/SET OF -- " << endl;
6999 indentG += stdIndentG;
7000 //SetCurrToFirst();
7001 //for (; Curr() != NULL; GoNext())
7002 for (const AsnListElmt *run=first; run; run=run->next)
7003 {
7004 Indent (os, indentG);
7005 //os << *Curr();
7006 os << *run->elmt;
7007 //if (Curr() != Last())
7008 if (run != last)
7009 os << ",";
7010 os << endl;
7011 }
7012 indentG -= stdIndentG;
7013 Indent (os, indentG);
7014 os << "}\n";
7015 #endif /* NDEBUG */
7016
7017
7018 } // Print
7019
7020
7021 void CertificationPathSeqOf::SetCurrElmt (unsigned long int index)
7022 {
7023 unsigned long int i;
7024 curr = first;
7025 if (count)
7026 for (i = 0; (i < (count-1)) && (i < index); i++)
7027 curr = curr->next;
7028 } // CertificationPathSeqOf::SetCurrElmt
7029
7030
7031 unsigned long int CertificationPathSeqOf::GetCurrElmtIndex()
7032 {
7033 unsigned long int i;
7034 AsnListElmt *tmp;
7035 if (curr != NULL)
7036 {
7037 for (i = 0, tmp = first; tmp != NULL; i++)
7038 {
7039 if (tmp == curr)
7040 return i;
7041 else
7042 tmp = tmp->next;
7043 }
7044 }
7045 return count;
7046 } // CertificationPathSeqOf::GetCurrElmtIndex
7047
7048
7049 // alloc new list elmt, put at end of list
7050 // and return the component type
7051 CertificatePair *CertificationPathSeqOf::Append()
7052 {
7053 AsnListElmt *newElmt;
7054 newElmt = new AsnListElmt;
7055 newElmt->elmt = new CertificatePair;
7056 newElmt->next = NULL;
7057 if (last == NULL)
7058 {
7059 newElmt->prev = NULL;
7060 first = last = newElmt;
7061 }
7062 else
7063 {
7064 newElmt->prev = last;
7065 last->next = newElmt;
7066 last = newElmt;
7067 }
7068 count++;
7069 return (curr = newElmt)->elmt;
7070 } // CertificationPathSeqOf::Append
7071
7072
7073 // alloc new list elmt, put at begining of list
7074 // and return the component type
7075 CertificatePair *CertificationPathSeqOf::Prepend()
7076 {
7077 AsnListElmt *newElmt;
7078 newElmt = new AsnListElmt;
7079 newElmt->elmt = new CertificatePair;
7080 newElmt->prev = NULL;
7081 if (first == NULL)
7082 {
7083 newElmt->next = NULL;
7084 first = last = newElmt;
7085 }
7086 else
7087 {
7088 newElmt->next = first;
7089 first->prev = newElmt;
7090 first = newElmt;
7091 }
7092 count++;
7093 return (curr = newElmt)->elmt;
7094 } // CertificationPathSeqOf::Prepend
7095
7096
7097 // alloc new list elmt, insert it before the
7098 // current element and return the component type
7099 // if the current element is null, the new element
7100 // is placed at the beginning of the list.
7101 CertificatePair *CertificationPathSeqOf::InsertBefore()
7102 {
7103 AsnListElmt *newElmt;
7104 newElmt = new AsnListElmt;
7105 newElmt->elmt = new CertificatePair;
7106 if (curr == NULL)
7107 {
7108 newElmt->next = first;
7109 newElmt->prev = NULL;
7110 first = newElmt;
7111 if (last == NULL)
7112 last = newElmt;
7113 }
7114 else
7115 {
7116 newElmt->next = curr;
7117 newElmt->prev = curr->prev;
7118 curr->prev = newElmt;
7119 if (curr == first)
7120 first = newElmt;
7121 else
7122 newElmt->prev->next = newElmt;
7123 }
7124 count++;
7125 return (curr = newElmt)->elmt;
7126 } // CertificationPathSeqOf::InsertBefore
7127
7128
7129 // alloc new list elmt, insert it after the
7130 // current element and return the component type
7131 // if the current element is null, the new element
7132 // is placed at the end of the list.
7133 CertificatePair *CertificationPathSeqOf::InsertAfter()
7134 {
7135 AsnListElmt *newElmt;
7136 newElmt = new AsnListElmt;
7137 newElmt->elmt = new CertificatePair;
7138 if (curr == NULL)
7139 {
7140 newElmt->prev = last;
7141 newElmt->next = NULL;
7142 last = newElmt;
7143 if (first == NULL)
7144 first = newElmt;
7145 }
7146 else
7147 {
7148 newElmt->prev = curr;
7149 newElmt->next = curr->next;
7150 curr->next = newElmt;
7151 if (curr == last)
7152 last = newElmt;
7153 else
7154 newElmt->next->prev = newElmt;
7155 }
7156 count++;
7157 return (curr = newElmt)->elmt;
7158 } // CertificationPathSeqOf::InsertAfter
7159
7160
7161 CertificationPathSeqOf &CertificationPathSeqOf::AppendCopy (CertificatePair &elmt)
7162 {
7163 AsnListElmt *newElmt;
7164 newElmt = new AsnListElmt;
7165 newElmt->elmt = new CertificatePair;
7166 *newElmt->elmt = elmt;
7167 newElmt->next = NULL;
7168 if (last == NULL)
7169 {
7170 newElmt->prev = NULL;
7171 first = last = newElmt;
7172 }
7173 else
7174 {
7175 newElmt->prev = last;
7176 last->next = newElmt;
7177 last = newElmt;
7178 }
7179 count++;
7180 return *this;
7181 } // AppendCopy
7182
7183
7184 CertificationPathSeqOf &CertificationPathSeqOf::PrependCopy (CertificatePair &elmt)
7185 {
7186 AsnListElmt *newElmt;
7187 newElmt = new AsnListElmt;
7188 newElmt->elmt = new CertificatePair;
7189 *newElmt->elmt = elmt;
7190 newElmt->prev = NULL;
7191 if (first == NULL)
7192 {
7193 newElmt->next = NULL;
7194 first = last = newElmt;
7195 }
7196 else
7197 {
7198 newElmt->next = first;
7199 first->prev = newElmt;
7200 first = newElmt;
7201 }
7202 count++;
7203 return *this;
7204 } // CertificationPathSeqOf::PrependCopy
7205
7206
7207 // alloc new list elmt, insert it before the
7208 // current element, copy the given elmt into the new elmt
7209 // and return the component type.
7210 // if the current element is null, the new element
7211 // is placed at the beginning of the list.
7212 CertificationPathSeqOf &CertificationPathSeqOf::InsertBeforeAndCopy (CertificatePair &elmt)
7213 {
7214 AsnListElmt *newElmt;
7215
7216 newElmt = new AsnListElmt;
7217 newElmt->elmt = new CertificatePair;
7218 *newElmt->elmt = elmt;
7219
7220 if (curr == NULL)
7221 {
7222 newElmt->next = first;
7223 newElmt->prev = NULL;
7224 first = newElmt;
7225 if (last == NULL)
7226 last = newElmt;
7227 }
7228 else
7229 {
7230 newElmt->next = curr;
7231 newElmt->prev = curr->prev;
7232 curr->prev = newElmt;
7233 if (curr == first)
7234 first = newElmt;
7235 else
7236 newElmt->prev->next = newElmt;
7237 }
7238 count++;
7239 return *this;
7240 } // CertificationPathSeqOf::InsertBeforeAndCopy
7241
7242
7243 // alloc new list elmt, insert it after the
7244 // current element, copy given elmt in to new elmt
7245 // and return the component type
7246 // if the current element is null, the new element
7247 // is placed at the end of the list.
7248 CertificationPathSeqOf &CertificationPathSeqOf::InsertAfterAndCopy (CertificatePair &elmt)
7249 {
7250 AsnListElmt *newElmt;
7251
7252 newElmt = new AsnListElmt;
7253 newElmt->elmt = new CertificatePair;
7254 *newElmt->elmt = elmt;
7255 if (curr == NULL)
7256 {
7257 newElmt->prev = last;
7258 newElmt->next = NULL;
7259 last = newElmt;
7260 if (first == NULL)
7261 first = newElmt;
7262 }
7263 else
7264 {
7265 newElmt->prev = curr;
7266 newElmt->next = curr->next;
7267 curr->next = newElmt;
7268 if (curr == last)
7269 last = newElmt;
7270 else
7271 newElmt->next->prev = newElmt;
7272 }
7273 count++;
7274 return *this;
7275 } // CertificationPathSeqOf::InsertAfterAndCopy
7276
7277
7278 // remove current element from list if current element is not NULL
7279 // The new current element will be the next element.
7280 // If the current element is the last element in the list
7281 // the second but last element will become the new current element.
7282 void CertificationPathSeqOf::RemoveCurrFromList()
7283 {
7284 AsnListElmt *del_elmt;
7285
7286 if (curr != NULL)
7287 {
7288 del_elmt = curr;
7289 count--;
7290
7291 if (count == 0)
7292 first = last = curr = NULL;
7293 else if (curr == first)
7294 {
7295 curr = first= first->next;
7296 first->prev = NULL;
7297 }
7298 else if (curr == last)
7299 {
7300 curr = last = last->prev;
7301 last->next = NULL;
7302 }
7303 else
7304 {
7305 curr->prev->next = curr->next;
7306 curr->next->prev = curr->prev;
7307 }
7308
7309 delete del_elmt->elmt;
7310 delete del_elmt;
7311 }
7312 }
7313
7314
7315 AsnLen CertificationPathSeqOf::BEncContent (BUF_TYPE b)
7316 {
7317 AsnListElmt *currElmt;
7318 AsnLen elmtLen;
7319 AsnLen totalLen = 0;
7320 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
7321 {
7322 BEncEocIfNec (b);
7323 elmtLen = currElmt->elmt->BEncContent (b);
7324 elmtLen += BEncConsLen (b, elmtLen);
7325
7326 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
7327 totalLen += elmtLen;
7328 }
7329 return totalLen;
7330 } // CertificationPathSeqOf::BEncContent
7331
7332
7333 void CertificationPathSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
7334 AsnLen &bytesDecoded, ENV_TYPE env)
7335 {
7336 CertificatePair *listElmt;
7337 AsnTag tag1;
7338 AsnLen listBytesDecoded = 0;
7339 AsnLen elmtLen1;
7340
7341 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
7342 {
7343 tag1 = BDecTag (b, listBytesDecoded, env);
7344 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
7345 {
7346 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
7347 break;
7348 }
7349 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
7350 {
7351 Asn1Error << "Unexpected Tag" << endl;
7352 SnaccExcep::throwMe(-187);
7353 }
7354
7355 elmtLen1 = BDecLen (b, listBytesDecoded, env);
7356 listElmt = Append();
7357 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
7358 }
7359
7360 bytesDecoded += listBytesDecoded;
7361 } // CertificationPathSeqOf::BDecContent
7362
7363
7364 AsnType *ForwardCertificationPath::Clone() const
7365 {
7366 return new ForwardCertificationPath;
7367 }
7368
7369 AsnType *ForwardCertificationPath::Copy() const
7370 {
7371 return new ForwardCertificationPath (*this);
7372 }
7373
7374 AsnLen ForwardCertificationPath::BEnc (BUF_TYPE b)
7375 {
7376 AsnLen l;
7377 l = BEncContent (b);
7378 l += BEncConsLen (b, l);
7379 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
7380 return l;
7381 }
7382
7383 void ForwardCertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
7384 {
7385 AsnTag tag;
7386 AsnLen elmtLen1;
7387
7388 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
7389 {
7390 Asn1Error << "ForwardCertificationPath::BDec: ERROR - wrong tag" << endl;
7391 SnaccExcep::throwMe(-188);
7392 }
7393 elmtLen1 = BDecLen (b, bytesDecoded, env);
7394 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
7395 }
7396
7397 ForwardCertificationPath::ForwardCertificationPath (const ForwardCertificationPath &)
7398 {
7399 Asn1Error << "use of incompletely defined ForwardCertificationPath::ForwardCertificationPath (const ForwardCertificationPath &)" << endl;
7400 abort();
7401 }
7402
7403 ForwardCertificationPath::~ForwardCertificationPath()
7404 {
7405 SetCurrToFirst();
7406 for (; Curr() != NULL; RemoveCurrFromList())
7407 ;
7408 } // end of destructor
7409
7410 #if SNACC_DEEP_COPY
7411 ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &that)
7412 #else // SNACC_DEEP_COPY
7413 ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &)
7414 #endif // SNACC_DEEP_COPY
7415 {
7416 #if SNACC_DEEP_COPY
7417 if (this != &that)
7418 {
7419 SetCurrToFirst();
7420 for (; Curr(); RemoveCurrFromList())
7421 ;
7422
7423 //that.SetCurrToFirst();
7424 //for (; that.Curr(); that.GoNext())
7425 // AppendCopy (*that.Curr());
7426 for (const AsnListElmt *run=that.first; run; run=run->next)
7427 AppendCopy (*run->elmt);
7428 }
7429
7430 return *this;
7431 #else // SNACC_DEEP_COPY
7432 Asn1Error << "use of incompletely defined ForwardCertificationPath &ForwardCertificationPath::operator = (const ForwardCertificationPath &)" << endl;
7433 abort();
7434 // if your compiler complains here, check the -novolat option
7435 #endif // SNACC_DEEP_COPY
7436 }
7437
7438 void ForwardCertificationPath::Print (ostream &os) const
7439 {
7440 #ifndef NDEBUG
7441 os << "{ -- SEQUENCE/SET OF -- " << endl;
7442 indentG += stdIndentG;
7443 //SetCurrToFirst();
7444 //for (; Curr() != NULL; GoNext())
7445 for (const AsnListElmt *run=first; run; run=run->next)
7446 {
7447 Indent (os, indentG);
7448 //os << *Curr();
7449 os << *run->elmt;
7450 //if (Curr() != Last())
7451 if (run != last)
7452 os << ",";
7453 os << endl;
7454 }
7455 indentG -= stdIndentG;
7456 Indent (os, indentG);
7457 os << "}\n";
7458 #endif /* NDEBUG */
7459
7460
7461 } // Print
7462
7463
7464 void ForwardCertificationPath::SetCurrElmt (unsigned long int index)
7465 {
7466 unsigned long int i;
7467 curr = first;
7468 if (count)
7469 for (i = 0; (i < (count-1)) && (i < index); i++)
7470 curr = curr->next;
7471 } // ForwardCertificationPath::SetCurrElmt
7472
7473
7474 unsigned long int ForwardCertificationPath::GetCurrElmtIndex()
7475 {
7476 unsigned long int i;
7477 AsnListElmt *tmp;
7478 if (curr != NULL)
7479 {
7480 for (i = 0, tmp = first; tmp != NULL; i++)
7481 {
7482 if (tmp == curr)
7483 return i;
7484 else
7485 tmp = tmp->next;
7486 }
7487 }
7488 return count;
7489 } // ForwardCertificationPath::GetCurrElmtIndex
7490
7491
7492 // alloc new list elmt, put at end of list
7493 // and return the component type
7494 CrossCertificates *ForwardCertificationPath::Append()
7495 {
7496 AsnListElmt *newElmt;
7497 newElmt = new AsnListElmt;
7498 newElmt->elmt = new CrossCertificates;
7499 newElmt->next = NULL;
7500 if (last == NULL)
7501 {
7502 newElmt->prev = NULL;
7503 first = last = newElmt;
7504 }
7505 else
7506 {
7507 newElmt->prev = last;
7508 last->next = newElmt;
7509 last = newElmt;
7510 }
7511 count++;
7512 return (curr = newElmt)->elmt;
7513 } // ForwardCertificationPath::Append
7514
7515
7516 // alloc new list elmt, put at begining of list
7517 // and return the component type
7518 CrossCertificates *ForwardCertificationPath::Prepend()
7519 {
7520 AsnListElmt *newElmt;
7521 newElmt = new AsnListElmt;
7522 newElmt->elmt = new CrossCertificates;
7523 newElmt->prev = NULL;
7524 if (first == NULL)
7525 {
7526 newElmt->next = NULL;
7527 first = last = newElmt;
7528 }
7529 else
7530 {
7531 newElmt->next = first;
7532 first->prev = newElmt;
7533 first = newElmt;
7534 }
7535 count++;
7536 return (curr = newElmt)->elmt;
7537 } // ForwardCertificationPath::Prepend
7538
7539
7540 // alloc new list elmt, insert it before the
7541 // current element and return the component type
7542 // if the current element is null, the new element
7543 // is placed at the beginning of the list.
7544 CrossCertificates *ForwardCertificationPath::InsertBefore()
7545 {
7546 AsnListElmt *newElmt;
7547 newElmt = new AsnListElmt;
7548 newElmt->elmt = new CrossCertificates;
7549 if (curr == NULL)
7550 {
7551 newElmt->next = first;
7552 newElmt->prev = NULL;
7553 first = newElmt;
7554 if (last == NULL)
7555 last = newElmt;
7556 }
7557 else
7558 {
7559 newElmt->next = curr;
7560 newElmt->prev = curr->prev;
7561 curr->prev = newElmt;
7562 if (curr == first)
7563 first = newElmt;
7564 else
7565 newElmt->prev->next = newElmt;
7566 }
7567 count++;
7568 return (curr = newElmt)->elmt;
7569 } // ForwardCertificationPath::InsertBefore
7570
7571
7572 // alloc new list elmt, insert it after the
7573 // current element and return the component type
7574 // if the current element is null, the new element
7575 // is placed at the end of the list.
7576 CrossCertificates *ForwardCertificationPath::InsertAfter()
7577 {
7578 AsnListElmt *newElmt;
7579 newElmt = new AsnListElmt;
7580 newElmt->elmt = new CrossCertificates;
7581 if (curr == NULL)
7582 {
7583 newElmt->prev = last;
7584 newElmt->next = NULL;
7585 last = newElmt;
7586 if (first == NULL)
7587 first = newElmt;
7588 }
7589 else
7590 {
7591 newElmt->prev = curr;
7592 newElmt->next = curr->next;
7593 curr->next = newElmt;
7594 if (curr == last)
7595 last = newElmt;
7596 else
7597 newElmt->next->prev = newElmt;
7598 }
7599 count++;
7600 return (curr = newElmt)->elmt;
7601 } // ForwardCertificationPath::InsertAfter
7602
7603
7604 ForwardCertificationPath &ForwardCertificationPath::AppendCopy (CrossCertificates &elmt)
7605 {
7606 AsnListElmt *newElmt;
7607 newElmt = new AsnListElmt;
7608 newElmt->elmt = new CrossCertificates;
7609 *newElmt->elmt = elmt;
7610 newElmt->next = NULL;
7611 if (last == NULL)
7612 {
7613 newElmt->prev = NULL;
7614 first = last = newElmt;
7615 }
7616 else
7617 {
7618 newElmt->prev = last;
7619 last->next = newElmt;
7620 last = newElmt;
7621 }
7622 count++;
7623 return *this;
7624 } // AppendCopy
7625
7626
7627 ForwardCertificationPath &ForwardCertificationPath::PrependCopy (CrossCertificates &elmt)
7628 {
7629 AsnListElmt *newElmt;
7630 newElmt = new AsnListElmt;
7631 newElmt->elmt = new CrossCertificates;
7632 *newElmt->elmt = elmt;
7633 newElmt->prev = NULL;
7634 if (first == NULL)
7635 {
7636 newElmt->next = NULL;
7637 first = last = newElmt;
7638 }
7639 else
7640 {
7641 newElmt->next = first;
7642 first->prev = newElmt;
7643 first = newElmt;
7644 }
7645 count++;
7646 return *this;
7647 } // ForwardCertificationPath::PrependCopy
7648
7649
7650 // alloc new list elmt, insert it before the
7651 // current element, copy the given elmt into the new elmt
7652 // and return the component type.
7653 // if the current element is null, the new element
7654 // is placed at the beginning of the list.
7655 ForwardCertificationPath &ForwardCertificationPath::InsertBeforeAndCopy (CrossCertificates &elmt)
7656 {
7657 AsnListElmt *newElmt;
7658
7659 newElmt = new AsnListElmt;
7660 newElmt->elmt = new CrossCertificates;
7661 *newElmt->elmt = elmt;
7662
7663 if (curr == NULL)
7664 {
7665 newElmt->next = first;
7666 newElmt->prev = NULL;
7667 first = newElmt;
7668 if (last == NULL)
7669 last = newElmt;
7670 }
7671 else
7672 {
7673 newElmt->next = curr;
7674 newElmt->prev = curr->prev;
7675 curr->prev = newElmt;
7676 if (curr == first)
7677 first = newElmt;
7678 else
7679 newElmt->prev->next = newElmt;
7680 }
7681 count++;
7682 return *this;
7683 } // ForwardCertificationPath::InsertBeforeAndCopy
7684
7685
7686 // alloc new list elmt, insert it after the
7687 // current element, copy given elmt in to new elmt
7688 // and return the component type
7689 // if the current element is null, the new element
7690 // is placed at the end of the list.
7691 ForwardCertificationPath &ForwardCertificationPath::InsertAfterAndCopy (CrossCertificates &elmt)
7692 {
7693 AsnListElmt *newElmt;
7694
7695 newElmt = new AsnListElmt;
7696 newElmt->elmt = new CrossCertificates;
7697 *newElmt->elmt = elmt;
7698 if (curr == NULL)
7699 {
7700 newElmt->prev = last;
7701 newElmt->next = NULL;
7702 last = newElmt;
7703 if (first == NULL)
7704 first = newElmt;
7705 }
7706 else
7707 {
7708 newElmt->prev = curr;
7709 newElmt->next = curr->next;
7710 curr->next = newElmt;
7711 if (curr == last)
7712 last = newElmt;
7713 else
7714 newElmt->next->prev = newElmt;
7715 }
7716 count++;
7717 return *this;
7718 } // ForwardCertificationPath::InsertAfterAndCopy
7719
7720
7721 // remove current element from list if current element is not NULL
7722 // The new current element will be the next element.
7723 // If the current element is the last element in the list
7724 // the second but last element will become the new current element.
7725 void ForwardCertificationPath::RemoveCurrFromList()
7726 {
7727 AsnListElmt *del_elmt;
7728
7729 if (curr != NULL)
7730 {
7731 del_elmt = curr;
7732 count--;
7733
7734 if (count == 0)
7735 first = last = curr = NULL;
7736 else if (curr == first)
7737 {
7738 curr = first= first->next;
7739 first->prev = NULL;
7740 }
7741 else if (curr == last)
7742 {
7743 curr = last = last->prev;
7744 last->next = NULL;
7745 }
7746 else
7747 {
7748 curr->prev->next = curr->next;
7749 curr->next->prev = curr->prev;
7750 }
7751
7752 delete del_elmt->elmt;
7753 delete del_elmt;
7754 }
7755 }
7756
7757
7758 AsnLen ForwardCertificationPath::BEncContent (BUF_TYPE b)
7759 {
7760 AsnListElmt *currElmt;
7761 AsnLen elmtLen;
7762 AsnLen totalLen = 0;
7763 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
7764 {
7765 BEncEocIfNec (b);
7766 elmtLen = currElmt->elmt->BEncContent (b);
7767 elmtLen += BEncConsLen (b, elmtLen);
7768
7769 elmtLen += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
7770 totalLen += elmtLen;
7771 }
7772 return totalLen;
7773 } // ForwardCertificationPath::BEncContent
7774
7775
7776 void ForwardCertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
7777 AsnLen &bytesDecoded, ENV_TYPE env)
7778 {
7779 CrossCertificates *listElmt;
7780 AsnTag tag1;
7781 AsnLen listBytesDecoded = 0;
7782 AsnLen elmtLen1;
7783
7784 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
7785 {
7786 tag1 = BDecTag (b, listBytesDecoded, env);
7787 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
7788 {
7789 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
7790 break;
7791 }
7792 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE)))
7793 {
7794 Asn1Error << "Unexpected Tag" << endl;
7795 SnaccExcep::throwMe(-189);
7796 }
7797
7798 elmtLen1 = BDecLen (b, listBytesDecoded, env);
7799 listElmt = Append();
7800 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
7801 }
7802
7803 bytesDecoded += listBytesDecoded;
7804 } // ForwardCertificationPath::BDecContent
7805
7806
7807 ACPathData::ACPathData()
7808 {
7809 certificate = NULL;
7810 attributeCertificate = NULL;
7811 }
7812
7813 ACPathData::ACPathData (const ACPathData &)
7814 {
7815 Asn1Error << "use of incompletely defined ACPathData::ACPathData (const ACPathData &)" << endl;
7816 abort();
7817 }
7818
7819 ACPathData::~ACPathData()
7820 {
7821 delete certificate;
7822 delete attributeCertificate;
7823 }
7824
7825 AsnType *ACPathData::Clone() const
7826 {
7827 return new ACPathData;
7828 }
7829
7830 AsnType *ACPathData::Copy() const
7831 {
7832 return new ACPathData (*this);
7833 }
7834
7835 #if SNACC_DEEP_COPY
7836 ACPathData &ACPathData::operator = (const ACPathData &that)
7837 #else // SNACC_DEEP_COPY
7838 ACPathData &ACPathData::operator = (const ACPathData &)
7839 #endif // SNACC_DEEP_COPY
7840 {
7841 #if SNACC_DEEP_COPY
7842 if (this != &that)
7843 {
7844 if (that.certificate)
7845 {
7846 if (!certificate)
7847 certificate = new Certificate;
7848 *certificate = *that.certificate;
7849 }
7850 else
7851 {
7852 delete certificate;
7853 certificate = NULL;
7854 }
7855 if (that.attributeCertificate)
7856 {
7857 if (!attributeCertificate)
7858 attributeCertificate = new AttributeCertificate;
7859 *attributeCertificate = *that.attributeCertificate;
7860 }
7861 else
7862 {
7863 delete attributeCertificate;
7864 attributeCertificate = NULL;
7865 }
7866 }
7867
7868 return *this;
7869 #else // SNACC_DEEP_COPY
7870 Asn1Error << "use of incompletely defined ACPathData &ACPathData::operator = (const ACPathData &)" << endl;
7871 abort();
7872 // if your compiler complains here, check the -novolat option
7873 #endif // SNACC_DEEP_COPY
7874 }
7875
7876 AsnLen
7877 ACPathData::BEncContent (BUF_TYPE b)
7878 {
7879 AsnLen totalLen = 0;
7880 AsnLen l;
7881
7882 if (NOT_NULL (attributeCertificate))
7883 {
7884 BEncEocIfNec (b);
7885 BEncEocIfNec (b);
7886 l = attributeCertificate->BEncContent (b);
7887 l += BEncConsLen (b, l);
7888
7889 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
7890 l += BEncConsLen (b, l);
7891
7892 l += BEncTag1 (b, CNTX, CONS, 1);
7893 totalLen += l;
7894 }
7895
7896 if (NOT_NULL (certificate))
7897 {
7898 BEncEocIfNec (b);
7899 BEncEocIfNec (b);
7900 l = certificate->BEncContent (b);
7901 l += BEncConsLen (b, l);
7902
7903 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
7904 l += BEncConsLen (b, l);
7905
7906 l += BEncTag1 (b, CNTX, CONS, 0);
7907 totalLen += l;
7908 }
7909
7910 return totalLen;
7911 } // ACPathData::BEncContent
7912
7913
7914 void ACPathData::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
7915 {
7916 AsnTag tag1;
7917 AsnLen seqBytesDecoded = 0;
7918 AsnLen elmtLen1;
7919 AsnLen elmtLen2;
7920 if (elmtLen0 == 0)
7921 return;
7922 else
7923 {
7924 tag1 = BDecTag (b, seqBytesDecoded, env);
7925
7926 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
7927 {
7928 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
7929 bytesDecoded += seqBytesDecoded;
7930 return;
7931 }
7932 }
7933
7934 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
7935 {
7936 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
7937 tag1 = BDecTag (b, seqBytesDecoded, env);
7938
7939 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
7940 {
7941 Asn1Error << "Unexpected Tag" << endl;
7942 SnaccExcep::throwMe(-190);
7943 }
7944
7945 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
7946 certificate = new Certificate;
7947 certificate->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
7948 if (elmtLen1 == INDEFINITE_LEN)
7949 BDecEoc (b, seqBytesDecoded, env);
7950
7951 if (seqBytesDecoded == elmtLen0)
7952 {
7953 bytesDecoded += seqBytesDecoded;
7954 return;
7955 }
7956 else
7957 {
7958 tag1 = BDecTag (b, seqBytesDecoded, env);
7959
7960 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
7961 {
7962 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
7963 bytesDecoded += seqBytesDecoded;
7964 return;
7965 }
7966 }
7967 }
7968
7969 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
7970 {
7971 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
7972 tag1 = BDecTag (b, seqBytesDecoded, env);
7973
7974 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
7975 {
7976 Asn1Error << "Unexpected Tag" << endl;
7977 SnaccExcep::throwMe(-191);
7978 }
7979
7980 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
7981 attributeCertificate = new AttributeCertificate;
7982 attributeCertificate->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
7983 if (elmtLen1 == INDEFINITE_LEN)
7984 BDecEoc (b, seqBytesDecoded, env);
7985
7986 }
7987
7988 bytesDecoded += seqBytesDecoded;
7989 if (elmtLen0 == INDEFINITE_LEN)
7990 {
7991 BDecEoc (b, bytesDecoded, env);
7992 return;
7993 }
7994 else if (seqBytesDecoded != elmtLen0)
7995 {
7996 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
7997 SnaccExcep::throwMe(-192);
7998 }
7999 else
8000 return;
8001 } // ACPathData::BDecContent
8002
8003 AsnLen ACPathData::BEnc (BUF_TYPE b)
8004 {
8005 AsnLen l;
8006 l = BEncContent (b);
8007 l += BEncConsLen (b, l);
8008 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8009 return l;
8010 }
8011
8012 void ACPathData::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
8013 {
8014 AsnTag tag;
8015 AsnLen elmtLen1;
8016
8017 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
8018 {
8019 Asn1Error << "ACPathData::BDec: ERROR - wrong tag" << endl;
8020 SnaccExcep::throwMe(-193);
8021 }
8022 elmtLen1 = BDecLen (b, bytesDecoded, env);
8023 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
8024 }
8025
8026 void ACPathData::Print (ostream &os) const
8027 {
8028 #ifndef NDEBUG
8029 int nonePrinted = true;
8030 os << "{ -- SEQUENCE --" << endl;
8031 indentG += stdIndentG;
8032
8033 if (NOT_NULL (certificate))
8034 {
8035 nonePrinted = false;
8036 Indent (os, indentG);
8037 os << "certificate ";
8038 os << *certificate;
8039 }
8040 else
8041 {
8042 Indent (os, indentG);
8043 os << "certificate ";
8044 os << "-- void --";
8045 os << "," << endl;
8046 }
8047
8048 if (NOT_NULL (attributeCertificate))
8049 {
8050 if (!nonePrinted)
8051 os << "," << endl;
8052 nonePrinted = false;
8053 Indent (os, indentG);
8054 os << "attributeCertificate ";
8055 os << *attributeCertificate;
8056 }
8057 else
8058 {
8059 Indent (os, indentG);
8060 os << "attributeCertificate ";
8061 os << "-- void --";
8062 os << endl;
8063 }
8064
8065 os << endl;
8066 indentG -= stdIndentG;
8067 Indent (os, indentG);
8068 os << "}";
8069 #endif /* NDEBUG */
8070 } // ACPathData::Print
8071
8072
8073 AsnType *AttributeCertificationPathSeqOf::Clone() const
8074 {
8075 return new AttributeCertificationPathSeqOf;
8076 }
8077
8078 AsnType *AttributeCertificationPathSeqOf::Copy() const
8079 {
8080 return new AttributeCertificationPathSeqOf (*this);
8081 }
8082
8083 AsnLen AttributeCertificationPathSeqOf::BEnc (BUF_TYPE b)
8084 {
8085 AsnLen l;
8086 l = BEncContent (b);
8087 l += BEncConsLen (b, l);
8088 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8089 return l;
8090 }
8091
8092 void AttributeCertificationPathSeqOf::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
8093 {
8094 AsnTag tag;
8095 AsnLen elmtLen1;
8096
8097 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
8098 {
8099 Asn1Error << "AttributeCertificationPathSeqOf::BDec: ERROR - wrong tag" << endl;
8100 SnaccExcep::throwMe(-194);
8101 }
8102 elmtLen1 = BDecLen (b, bytesDecoded, env);
8103 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
8104 }
8105
8106 AttributeCertificationPathSeqOf::AttributeCertificationPathSeqOf (const AttributeCertificationPathSeqOf &)
8107 {
8108 Asn1Error << "use of incompletely defined AttributeCertificationPathSeqOf::AttributeCertificationPathSeqOf (const AttributeCertificationPathSeqOf &)" << endl;
8109 abort();
8110 }
8111
8112 AttributeCertificationPathSeqOf::~AttributeCertificationPathSeqOf()
8113 {
8114 SetCurrToFirst();
8115 for (; Curr() != NULL; RemoveCurrFromList())
8116 ;
8117 } // end of destructor
8118
8119 #if SNACC_DEEP_COPY
8120 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &that)
8121 #else // SNACC_DEEP_COPY
8122 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &)
8123 #endif // SNACC_DEEP_COPY
8124 {
8125 #if SNACC_DEEP_COPY
8126 if (this != &that)
8127 {
8128 SetCurrToFirst();
8129 for (; Curr(); RemoveCurrFromList())
8130 ;
8131
8132 //that.SetCurrToFirst();
8133 //for (; that.Curr(); that.GoNext())
8134 // AppendCopy (*that.Curr());
8135 for (const AsnListElmt *run=that.first; run; run=run->next)
8136 AppendCopy (*run->elmt);
8137 }
8138
8139 return *this;
8140 #else // SNACC_DEEP_COPY
8141 Asn1Error << "use of incompletely defined AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::operator = (const AttributeCertificationPathSeqOf &)" << endl;
8142 abort();
8143 // if your compiler complains here, check the -novolat option
8144 #endif // SNACC_DEEP_COPY
8145 }
8146
8147 void AttributeCertificationPathSeqOf::Print (ostream &os) const
8148 {
8149 #ifndef NDEBUG
8150 os << "{ -- SEQUENCE/SET OF -- " << endl;
8151 indentG += stdIndentG;
8152 //SetCurrToFirst();
8153 //for (; Curr() != NULL; GoNext())
8154 for (const AsnListElmt *run=first; run; run=run->next)
8155 {
8156 Indent (os, indentG);
8157 //os << *Curr();
8158 os << *run->elmt;
8159 //if (Curr() != Last())
8160 if (run != last)
8161 os << ",";
8162 os << endl;
8163 }
8164 indentG -= stdIndentG;
8165 Indent (os, indentG);
8166 os << "}\n";
8167 #endif /* NDEBUG */
8168
8169
8170 } // Print
8171
8172
8173 void AttributeCertificationPathSeqOf::SetCurrElmt (unsigned long int index)
8174 {
8175 unsigned long int i;
8176 curr = first;
8177 if (count)
8178 for (i = 0; (i < (count-1)) && (i < index); i++)
8179 curr = curr->next;
8180 } // AttributeCertificationPathSeqOf::SetCurrElmt
8181
8182
8183 unsigned long int AttributeCertificationPathSeqOf::GetCurrElmtIndex()
8184 {
8185 unsigned long int i;
8186 AsnListElmt *tmp;
8187 if (curr != NULL)
8188 {
8189 for (i = 0, tmp = first; tmp != NULL; i++)
8190 {
8191 if (tmp == curr)
8192 return i;
8193 else
8194 tmp = tmp->next;
8195 }
8196 }
8197 return count;
8198 } // AttributeCertificationPathSeqOf::GetCurrElmtIndex
8199
8200
8201 // alloc new list elmt, put at end of list
8202 // and return the component type
8203 ACPathData *AttributeCertificationPathSeqOf::Append()
8204 {
8205 AsnListElmt *newElmt;
8206 newElmt = new AsnListElmt;
8207 newElmt->elmt = new ACPathData;
8208 newElmt->next = NULL;
8209 if (last == NULL)
8210 {
8211 newElmt->prev = NULL;
8212 first = last = newElmt;
8213 }
8214 else
8215 {
8216 newElmt->prev = last;
8217 last->next = newElmt;
8218 last = newElmt;
8219 }
8220 count++;
8221 return (curr = newElmt)->elmt;
8222 } // AttributeCertificationPathSeqOf::Append
8223
8224
8225 // alloc new list elmt, put at begining of list
8226 // and return the component type
8227 ACPathData *AttributeCertificationPathSeqOf::Prepend()
8228 {
8229 AsnListElmt *newElmt;
8230 newElmt = new AsnListElmt;
8231 newElmt->elmt = new ACPathData;
8232 newElmt->prev = NULL;
8233 if (first == NULL)
8234 {
8235 newElmt->next = NULL;
8236 first = last = newElmt;
8237 }
8238 else
8239 {
8240 newElmt->next = first;
8241 first->prev = newElmt;
8242 first = newElmt;
8243 }
8244 count++;
8245 return (curr = newElmt)->elmt;
8246 } // AttributeCertificationPathSeqOf::Prepend
8247
8248
8249 // alloc new list elmt, insert it before the
8250 // current element and return the component type
8251 // if the current element is null, the new element
8252 // is placed at the beginning of the list.
8253 ACPathData *AttributeCertificationPathSeqOf::InsertBefore()
8254 {
8255 AsnListElmt *newElmt;
8256 newElmt = new AsnListElmt;
8257 newElmt->elmt = new ACPathData;
8258 if (curr == NULL)
8259 {
8260 newElmt->next = first;
8261 newElmt->prev = NULL;
8262 first = newElmt;
8263 if (last == NULL)
8264 last = newElmt;
8265 }
8266 else
8267 {
8268 newElmt->next = curr;
8269 newElmt->prev = curr->prev;
8270 curr->prev = newElmt;
8271 if (curr == first)
8272 first = newElmt;
8273 else
8274 newElmt->prev->next = newElmt;
8275 }
8276 count++;
8277 return (curr = newElmt)->elmt;
8278 } // AttributeCertificationPathSeqOf::InsertBefore
8279
8280
8281 // alloc new list elmt, insert it after the
8282 // current element and return the component type
8283 // if the current element is null, the new element
8284 // is placed at the end of the list.
8285 ACPathData *AttributeCertificationPathSeqOf::InsertAfter()
8286 {
8287 AsnListElmt *newElmt;
8288 newElmt = new AsnListElmt;
8289 newElmt->elmt = new ACPathData;
8290 if (curr == NULL)
8291 {
8292 newElmt->prev = last;
8293 newElmt->next = NULL;
8294 last = newElmt;
8295 if (first == NULL)
8296 first = newElmt;
8297 }
8298 else
8299 {
8300 newElmt->prev = curr;
8301 newElmt->next = curr->next;
8302 curr->next = newElmt;
8303 if (curr == last)
8304 last = newElmt;
8305 else
8306 newElmt->next->prev = newElmt;
8307 }
8308 count++;
8309 return (curr = newElmt)->elmt;
8310 } // AttributeCertificationPathSeqOf::InsertAfter
8311
8312
8313 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::AppendCopy (ACPathData &elmt)
8314 {
8315 AsnListElmt *newElmt;
8316 newElmt = new AsnListElmt;
8317 newElmt->elmt = new ACPathData;
8318 *newElmt->elmt = elmt;
8319 newElmt->next = NULL;
8320 if (last == NULL)
8321 {
8322 newElmt->prev = NULL;
8323 first = last = newElmt;
8324 }
8325 else
8326 {
8327 newElmt->prev = last;
8328 last->next = newElmt;
8329 last = newElmt;
8330 }
8331 count++;
8332 return *this;
8333 } // AppendCopy
8334
8335
8336 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::PrependCopy (ACPathData &elmt)
8337 {
8338 AsnListElmt *newElmt;
8339 newElmt = new AsnListElmt;
8340 newElmt->elmt = new ACPathData;
8341 *newElmt->elmt = elmt;
8342 newElmt->prev = NULL;
8343 if (first == NULL)
8344 {
8345 newElmt->next = NULL;
8346 first = last = newElmt;
8347 }
8348 else
8349 {
8350 newElmt->next = first;
8351 first->prev = newElmt;
8352 first = newElmt;
8353 }
8354 count++;
8355 return *this;
8356 } // AttributeCertificationPathSeqOf::PrependCopy
8357
8358
8359 // alloc new list elmt, insert it before the
8360 // current element, copy the given elmt into the new elmt
8361 // and return the component type.
8362 // if the current element is null, the new element
8363 // is placed at the beginning of the list.
8364 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::InsertBeforeAndCopy (ACPathData &elmt)
8365 {
8366 AsnListElmt *newElmt;
8367
8368 newElmt = new AsnListElmt;
8369 newElmt->elmt = new ACPathData;
8370 *newElmt->elmt = elmt;
8371
8372 if (curr == NULL)
8373 {
8374 newElmt->next = first;
8375 newElmt->prev = NULL;
8376 first = newElmt;
8377 if (last == NULL)
8378 last = newElmt;
8379 }
8380 else
8381 {
8382 newElmt->next = curr;
8383 newElmt->prev = curr->prev;
8384 curr->prev = newElmt;
8385 if (curr == first)
8386 first = newElmt;
8387 else
8388 newElmt->prev->next = newElmt;
8389 }
8390 count++;
8391 return *this;
8392 } // AttributeCertificationPathSeqOf::InsertBeforeAndCopy
8393
8394
8395 // alloc new list elmt, insert it after the
8396 // current element, copy given elmt in to new elmt
8397 // and return the component type
8398 // if the current element is null, the new element
8399 // is placed at the end of the list.
8400 AttributeCertificationPathSeqOf &AttributeCertificationPathSeqOf::InsertAfterAndCopy (ACPathData &elmt)
8401 {
8402 AsnListElmt *newElmt;
8403
8404 newElmt = new AsnListElmt;
8405 newElmt->elmt = new ACPathData;
8406 *newElmt->elmt = elmt;
8407 if (curr == NULL)
8408 {
8409 newElmt->prev = last;
8410 newElmt->next = NULL;
8411 last = newElmt;
8412 if (first == NULL)
8413 first = newElmt;
8414 }
8415 else
8416 {
8417 newElmt->prev = curr;
8418 newElmt->next = curr->next;
8419 curr->next = newElmt;
8420 if (curr == last)
8421 last = newElmt;
8422 else
8423 newElmt->next->prev = newElmt;
8424 }
8425 count++;
8426 return *this;
8427 } // AttributeCertificationPathSeqOf::InsertAfterAndCopy
8428
8429
8430 // remove current element from list if current element is not NULL
8431 // The new current element will be the next element.
8432 // If the current element is the last element in the list
8433 // the second but last element will become the new current element.
8434 void AttributeCertificationPathSeqOf::RemoveCurrFromList()
8435 {
8436 AsnListElmt *del_elmt;
8437
8438 if (curr != NULL)
8439 {
8440 del_elmt = curr;
8441 count--;
8442
8443 if (count == 0)
8444 first = last = curr = NULL;
8445 else if (curr == first)
8446 {
8447 curr = first= first->next;
8448 first->prev = NULL;
8449 }
8450 else if (curr == last)
8451 {
8452 curr = last = last->prev;
8453 last->next = NULL;
8454 }
8455 else
8456 {
8457 curr->prev->next = curr->next;
8458 curr->next->prev = curr->prev;
8459 }
8460
8461 delete del_elmt->elmt;
8462 delete del_elmt;
8463 }
8464 }
8465
8466
8467 AsnLen AttributeCertificationPathSeqOf::BEncContent (BUF_TYPE b)
8468 {
8469 AsnListElmt *currElmt;
8470 AsnLen elmtLen;
8471 AsnLen totalLen = 0;
8472 for (currElmt = last; currElmt != NULL; currElmt = currElmt->prev)
8473 {
8474 BEncEocIfNec (b);
8475 elmtLen = currElmt->elmt->BEncContent (b);
8476 elmtLen += BEncConsLen (b, elmtLen);
8477
8478 elmtLen += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8479 totalLen += elmtLen;
8480 }
8481 return totalLen;
8482 } // AttributeCertificationPathSeqOf::BEncContent
8483
8484
8485 void AttributeCertificationPathSeqOf::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0,
8486 AsnLen &bytesDecoded, ENV_TYPE env)
8487 {
8488 ACPathData *listElmt;
8489 AsnTag tag1;
8490 AsnLen listBytesDecoded = 0;
8491 AsnLen elmtLen1;
8492
8493 while ((listBytesDecoded < elmtLen0) || (elmtLen0 == INDEFINITE_LEN))
8494 {
8495 tag1 = BDecTag (b, listBytesDecoded, env);
8496 if ((tag1 == EOC_TAG_ID) && (elmtLen0 == INDEFINITE_LEN))
8497 {
8498 BDEC_2ND_EOC_OCTET (b, listBytesDecoded, env);
8499 break;
8500 }
8501 if ((tag1 != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
8502 {
8503 Asn1Error << "Unexpected Tag" << endl;
8504 SnaccExcep::throwMe(-195);
8505 }
8506
8507 elmtLen1 = BDecLen (b, listBytesDecoded, env);
8508 listElmt = Append();
8509 listElmt->BDecContent (b, tag1, elmtLen1, listBytesDecoded, env);
8510 }
8511
8512 bytesDecoded += listBytesDecoded;
8513 } // AttributeCertificationPathSeqOf::BDecContent
8514
8515
8516 Certificates::Certificates()
8517 {
8518 #if TCL
8519 userCertificate = new Certificate;
8520 #else
8521 userCertificate = NULL; // incomplete initialization of mandatory element!
8522 #endif // TCL
8523 certificationPath = NULL;
8524 }
8525
8526 Certificates::Certificates (const Certificates &)
8527 {
8528 Asn1Error << "use of incompletely defined Certificates::Certificates (const Certificates &)" << endl;
8529 abort();
8530 }
8531
8532 Certificates::~Certificates()
8533 {
8534 delete userCertificate;
8535 delete certificationPath;
8536 }
8537
8538 AsnType *Certificates::Clone() const
8539 {
8540 return new Certificates;
8541 }
8542
8543 AsnType *Certificates::Copy() const
8544 {
8545 return new Certificates (*this);
8546 }
8547
8548 #if SNACC_DEEP_COPY
8549 Certificates &Certificates::operator = (const Certificates &that)
8550 #else // SNACC_DEEP_COPY
8551 Certificates &Certificates::operator = (const Certificates &)
8552 #endif // SNACC_DEEP_COPY
8553 {
8554 #if SNACC_DEEP_COPY
8555 if (this != &that)
8556 {
8557 if (that.userCertificate)
8558 {
8559 if (!userCertificate)
8560 userCertificate = new Certificate;
8561 *userCertificate = *that.userCertificate;
8562 }
8563 else
8564 {
8565 delete userCertificate;
8566 userCertificate = NULL;
8567 }
8568 if (that.certificationPath)
8569 {
8570 if (!certificationPath)
8571 certificationPath = new ForwardCertificationPath;
8572 *certificationPath = *that.certificationPath;
8573 }
8574 else
8575 {
8576 delete certificationPath;
8577 certificationPath = NULL;
8578 }
8579 }
8580
8581 return *this;
8582 #else // SNACC_DEEP_COPY
8583 Asn1Error << "use of incompletely defined Certificates &Certificates::operator = (const Certificates &)" << endl;
8584 abort();
8585 // if your compiler complains here, check the -novolat option
8586 #endif // SNACC_DEEP_COPY
8587 }
8588
8589 AsnLen
8590 Certificates::BEncContent (BUF_TYPE b)
8591 {
8592 AsnLen totalLen = 0;
8593 AsnLen l;
8594
8595 if (NOT_NULL (certificationPath))
8596 {
8597 BEncEocIfNec (b);
8598 l = certificationPath->BEncContent (b);
8599 l += BEncConsLen (b, l);
8600
8601 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8602 totalLen += l;
8603 }
8604
8605 BEncEocIfNec (b);
8606 l = userCertificate->BEncContent (b);
8607 l += BEncConsLen (b, l);
8608
8609 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8610 totalLen += l;
8611
8612 return totalLen;
8613 } // Certificates::BEncContent
8614
8615
8616 void Certificates::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
8617 {
8618 AsnTag tag1;
8619 AsnLen seqBytesDecoded = 0;
8620 AsnLen elmtLen1;
8621 tag1 = BDecTag (b, seqBytesDecoded, env);
8622
8623 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
8624 {
8625 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
8626 userCertificate = new Certificate;
8627 userCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
8628 if (seqBytesDecoded == elmtLen0)
8629 {
8630 bytesDecoded += seqBytesDecoded;
8631 return;
8632 }
8633 else
8634 {
8635 tag1 = BDecTag (b, seqBytesDecoded, env);
8636
8637 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
8638 {
8639 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
8640 bytesDecoded += seqBytesDecoded;
8641 return;
8642 }
8643 }
8644 }
8645 else
8646 {
8647 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
8648 SnaccExcep::throwMe(-196);
8649 }
8650
8651 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
8652 {
8653 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
8654 certificationPath = new ForwardCertificationPath;
8655 certificationPath->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
8656 }
8657
8658 bytesDecoded += seqBytesDecoded;
8659 if (elmtLen0 == INDEFINITE_LEN)
8660 {
8661 BDecEoc (b, bytesDecoded, env);
8662 return;
8663 }
8664 else if (seqBytesDecoded != elmtLen0)
8665 {
8666 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
8667 SnaccExcep::throwMe(-197);
8668 }
8669 else
8670 return;
8671 } // Certificates::BDecContent
8672
8673 AsnLen Certificates::BEnc (BUF_TYPE b)
8674 {
8675 AsnLen l;
8676 l = BEncContent (b);
8677 l += BEncConsLen (b, l);
8678 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8679 return l;
8680 }
8681
8682 void Certificates::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
8683 {
8684 AsnTag tag;
8685 AsnLen elmtLen1;
8686
8687 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
8688 {
8689 Asn1Error << "Certificates::BDec: ERROR - wrong tag" << endl;
8690 SnaccExcep::throwMe(-198);
8691 }
8692 elmtLen1 = BDecLen (b, bytesDecoded, env);
8693 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
8694 }
8695
8696 void Certificates::Print (ostream &os) const
8697 {
8698 #ifndef NDEBUG
8699 os << "{ -- SEQUENCE --" << endl;
8700 indentG += stdIndentG;
8701
8702 if (NOT_NULL (userCertificate))
8703 {
8704 Indent (os, indentG);
8705 os << "userCertificate ";
8706 os << *userCertificate;
8707 }
8708 else
8709 {
8710 Indent (os, indentG);
8711 os << "userCertificate ";
8712 os << "-- void --";
8713 os << "," << endl;
8714 }
8715
8716 if (NOT_NULL (certificationPath))
8717 {
8718 os << ","<< endl;
8719 Indent (os, indentG);
8720 os << "certificationPath ";
8721 os << *certificationPath;
8722 }
8723 else
8724 {
8725 Indent (os, indentG);
8726 os << "certificationPath ";
8727 os << "-- void --";
8728 os << endl;
8729 }
8730
8731 os << endl;
8732 indentG -= stdIndentG;
8733 Indent (os, indentG);
8734 os << "}";
8735 #endif /* NDEBUG */
8736 } // Certificates::Print
8737
8738
8739 CertificationPath::CertificationPath()
8740 {
8741 #if TCL
8742 userCertificate = new Certificate;
8743 #else
8744 userCertificate = NULL; // incomplete initialization of mandatory element!
8745 #endif // TCL
8746 theCACertificates = NULL;
8747 }
8748
8749 CertificationPath::CertificationPath (const CertificationPath &)
8750 {
8751 Asn1Error << "use of incompletely defined CertificationPath::CertificationPath (const CertificationPath &)" << endl;
8752 abort();
8753 }
8754
8755 CertificationPath::~CertificationPath()
8756 {
8757 delete userCertificate;
8758 delete theCACertificates;
8759 }
8760
8761 AsnType *CertificationPath::Clone() const
8762 {
8763 return new CertificationPath;
8764 }
8765
8766 AsnType *CertificationPath::Copy() const
8767 {
8768 return new CertificationPath (*this);
8769 }
8770
8771 #if SNACC_DEEP_COPY
8772 CertificationPath &CertificationPath::operator = (const CertificationPath &that)
8773 #else // SNACC_DEEP_COPY
8774 CertificationPath &CertificationPath::operator = (const CertificationPath &)
8775 #endif // SNACC_DEEP_COPY
8776 {
8777 #if SNACC_DEEP_COPY
8778 if (this != &that)
8779 {
8780 if (that.userCertificate)
8781 {
8782 if (!userCertificate)
8783 userCertificate = new Certificate;
8784 *userCertificate = *that.userCertificate;
8785 }
8786 else
8787 {
8788 delete userCertificate;
8789 userCertificate = NULL;
8790 }
8791 if (that.theCACertificates)
8792 {
8793 if (!theCACertificates)
8794 theCACertificates = new CertificationPathSeqOf;
8795 *theCACertificates = *that.theCACertificates;
8796 }
8797 else
8798 {
8799 delete theCACertificates;
8800 theCACertificates = NULL;
8801 }
8802 }
8803
8804 return *this;
8805 #else // SNACC_DEEP_COPY
8806 Asn1Error << "use of incompletely defined CertificationPath &CertificationPath::operator = (const CertificationPath &)" << endl;
8807 abort();
8808 // if your compiler complains here, check the -novolat option
8809 #endif // SNACC_DEEP_COPY
8810 }
8811
8812 AsnLen
8813 CertificationPath::BEncContent (BUF_TYPE b)
8814 {
8815 AsnLen totalLen = 0;
8816 AsnLen l;
8817
8818 if (NOT_NULL (theCACertificates))
8819 {
8820 BEncEocIfNec (b);
8821 l = theCACertificates->BEncContent (b);
8822 l += BEncConsLen (b, l);
8823
8824 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8825 totalLen += l;
8826 }
8827
8828 BEncEocIfNec (b);
8829 l = userCertificate->BEncContent (b);
8830 l += BEncConsLen (b, l);
8831
8832 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8833 totalLen += l;
8834
8835 return totalLen;
8836 } // CertificationPath::BEncContent
8837
8838
8839 void CertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
8840 {
8841 AsnTag tag1;
8842 AsnLen seqBytesDecoded = 0;
8843 AsnLen elmtLen1;
8844 tag1 = BDecTag (b, seqBytesDecoded, env);
8845
8846 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
8847 {
8848 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
8849 userCertificate = new Certificate;
8850 userCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
8851 if (seqBytesDecoded == elmtLen0)
8852 {
8853 bytesDecoded += seqBytesDecoded;
8854 return;
8855 }
8856 else
8857 {
8858 tag1 = BDecTag (b, seqBytesDecoded, env);
8859
8860 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
8861 {
8862 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
8863 bytesDecoded += seqBytesDecoded;
8864 return;
8865 }
8866 }
8867 }
8868 else
8869 {
8870 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
8871 SnaccExcep::throwMe(-199);
8872 }
8873
8874 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
8875 {
8876 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
8877 theCACertificates = new CertificationPathSeqOf;
8878 theCACertificates->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
8879 }
8880
8881 bytesDecoded += seqBytesDecoded;
8882 if (elmtLen0 == INDEFINITE_LEN)
8883 {
8884 BDecEoc (b, bytesDecoded, env);
8885 return;
8886 }
8887 else if (seqBytesDecoded != elmtLen0)
8888 {
8889 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
8890 SnaccExcep::throwMe(-200);
8891 }
8892 else
8893 return;
8894 } // CertificationPath::BDecContent
8895
8896 AsnLen CertificationPath::BEnc (BUF_TYPE b)
8897 {
8898 AsnLen l;
8899 l = BEncContent (b);
8900 l += BEncConsLen (b, l);
8901 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
8902 return l;
8903 }
8904
8905 void CertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
8906 {
8907 AsnTag tag;
8908 AsnLen elmtLen1;
8909
8910 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
8911 {
8912 Asn1Error << "CertificationPath::BDec: ERROR - wrong tag" << endl;
8913 SnaccExcep::throwMe(-201);
8914 }
8915 elmtLen1 = BDecLen (b, bytesDecoded, env);
8916 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
8917 }
8918
8919 void CertificationPath::Print (ostream &os) const
8920 {
8921 #ifndef NDEBUG
8922 os << "{ -- SEQUENCE --" << endl;
8923 indentG += stdIndentG;
8924
8925 if (NOT_NULL (userCertificate))
8926 {
8927 Indent (os, indentG);
8928 os << "userCertificate ";
8929 os << *userCertificate;
8930 }
8931 else
8932 {
8933 Indent (os, indentG);
8934 os << "userCertificate ";
8935 os << "-- void --";
8936 os << "," << endl;
8937 }
8938
8939 if (NOT_NULL (theCACertificates))
8940 {
8941 os << ","<< endl;
8942 Indent (os, indentG);
8943 os << "theCACertificates ";
8944 os << *theCACertificates;
8945 }
8946 else
8947 {
8948 Indent (os, indentG);
8949 os << "theCACertificates ";
8950 os << "-- void --";
8951 os << endl;
8952 }
8953
8954 os << endl;
8955 indentG -= stdIndentG;
8956 Indent (os, indentG);
8957 os << "}";
8958 #endif /* NDEBUG */
8959 } // CertificationPath::Print
8960
8961
8962 AttributeCertificationPath::AttributeCertificationPath()
8963 {
8964 #if TCL
8965 attributeCertificate = new AttributeCertificate;
8966 #else
8967 attributeCertificate = NULL; // incomplete initialization of mandatory element!
8968 #endif // TCL
8969 acPath = NULL;
8970 }
8971
8972 AttributeCertificationPath::AttributeCertificationPath (const AttributeCertificationPath &)
8973 {
8974 Asn1Error << "use of incompletely defined AttributeCertificationPath::AttributeCertificationPath (const AttributeCertificationPath &)" << endl;
8975 abort();
8976 }
8977
8978 AttributeCertificationPath::~AttributeCertificationPath()
8979 {
8980 delete attributeCertificate;
8981 delete acPath;
8982 }
8983
8984 AsnType *AttributeCertificationPath::Clone() const
8985 {
8986 return new AttributeCertificationPath;
8987 }
8988
8989 AsnType *AttributeCertificationPath::Copy() const
8990 {
8991 return new AttributeCertificationPath (*this);
8992 }
8993
8994 #if SNACC_DEEP_COPY
8995 AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &that)
8996 #else // SNACC_DEEP_COPY
8997 AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &)
8998 #endif // SNACC_DEEP_COPY
8999 {
9000 #if SNACC_DEEP_COPY
9001 if (this != &that)
9002 {
9003 if (that.attributeCertificate)
9004 {
9005 if (!attributeCertificate)
9006 attributeCertificate = new AttributeCertificate;
9007 *attributeCertificate = *that.attributeCertificate;
9008 }
9009 else
9010 {
9011 delete attributeCertificate;
9012 attributeCertificate = NULL;
9013 }
9014 if (that.acPath)
9015 {
9016 if (!acPath)
9017 acPath = new AttributeCertificationPathSeqOf;
9018 *acPath = *that.acPath;
9019 }
9020 else
9021 {
9022 delete acPath;
9023 acPath = NULL;
9024 }
9025 }
9026
9027 return *this;
9028 #else // SNACC_DEEP_COPY
9029 Asn1Error << "use of incompletely defined AttributeCertificationPath &AttributeCertificationPath::operator = (const AttributeCertificationPath &)" << endl;
9030 abort();
9031 // if your compiler complains here, check the -novolat option
9032 #endif // SNACC_DEEP_COPY
9033 }
9034
9035 AsnLen
9036 AttributeCertificationPath::BEncContent (BUF_TYPE b)
9037 {
9038 AsnLen totalLen = 0;
9039 AsnLen l;
9040
9041 if (NOT_NULL (acPath))
9042 {
9043 BEncEocIfNec (b);
9044 l = acPath->BEncContent (b);
9045 l += BEncConsLen (b, l);
9046
9047 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
9048 totalLen += l;
9049 }
9050
9051 BEncEocIfNec (b);
9052 l = attributeCertificate->BEncContent (b);
9053 l += BEncConsLen (b, l);
9054
9055 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
9056 totalLen += l;
9057
9058 return totalLen;
9059 } // AttributeCertificationPath::BEncContent
9060
9061
9062 void AttributeCertificationPath::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
9063 {
9064 AsnTag tag1;
9065 AsnLen seqBytesDecoded = 0;
9066 AsnLen elmtLen1;
9067 tag1 = BDecTag (b, seqBytesDecoded, env);
9068
9069 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
9070 {
9071 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9072 attributeCertificate = new AttributeCertificate;
9073 attributeCertificate->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
9074 if (seqBytesDecoded == elmtLen0)
9075 {
9076 bytesDecoded += seqBytesDecoded;
9077 return;
9078 }
9079 else
9080 {
9081 tag1 = BDecTag (b, seqBytesDecoded, env);
9082
9083 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
9084 {
9085 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
9086 bytesDecoded += seqBytesDecoded;
9087 return;
9088 }
9089 }
9090 }
9091 else
9092 {
9093 Asn1Error << "ERROR - SEQUENCE is missing non-optional elmt." << endl;
9094 SnaccExcep::throwMe(-202);
9095 }
9096
9097 if ((tag1 == MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE)))
9098 {
9099 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9100 acPath = new AttributeCertificationPathSeqOf;
9101 acPath->BDecContent (b, tag1, elmtLen1, seqBytesDecoded, env);
9102 }
9103
9104 bytesDecoded += seqBytesDecoded;
9105 if (elmtLen0 == INDEFINITE_LEN)
9106 {
9107 BDecEoc (b, bytesDecoded, env);
9108 return;
9109 }
9110 else if (seqBytesDecoded != elmtLen0)
9111 {
9112 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
9113 SnaccExcep::throwMe(-203);
9114 }
9115 else
9116 return;
9117 } // AttributeCertificationPath::BDecContent
9118
9119 AsnLen AttributeCertificationPath::BEnc (BUF_TYPE b)
9120 {
9121 AsnLen l;
9122 l = BEncContent (b);
9123 l += BEncConsLen (b, l);
9124 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
9125 return l;
9126 }
9127
9128 void AttributeCertificationPath::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
9129 {
9130 AsnTag tag;
9131 AsnLen elmtLen1;
9132
9133 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
9134 {
9135 Asn1Error << "AttributeCertificationPath::BDec: ERROR - wrong tag" << endl;
9136 SnaccExcep::throwMe(-204);
9137 }
9138 elmtLen1 = BDecLen (b, bytesDecoded, env);
9139 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
9140 }
9141
9142 void AttributeCertificationPath::Print (ostream &os) const
9143 {
9144 #ifndef NDEBUG
9145 os << "{ -- SEQUENCE --" << endl;
9146 indentG += stdIndentG;
9147
9148 if (NOT_NULL (attributeCertificate))
9149 {
9150 Indent (os, indentG);
9151 os << "attributeCertificate ";
9152 os << *attributeCertificate;
9153 }
9154 else
9155 {
9156 Indent (os, indentG);
9157 os << "attributeCertificate ";
9158 os << "-- void --";
9159 os << "," << endl;
9160 }
9161
9162 if (NOT_NULL (acPath))
9163 {
9164 os << ","<< endl;
9165 Indent (os, indentG);
9166 os << "acPath ";
9167 os << *acPath;
9168 }
9169 else
9170 {
9171 Indent (os, indentG);
9172 os << "acPath ";
9173 os << "-- void --";
9174 os << endl;
9175 }
9176
9177 os << endl;
9178 indentG -= stdIndentG;
9179 Indent (os, indentG);
9180 os << "}";
9181 #endif /* NDEBUG */
9182 } // AttributeCertificationPath::Print
9183
9184
9185 AttributeCertificateAssertion::AttributeCertificateAssertion()
9186 {
9187 subject = NULL;
9188 issuer = NULL;
9189 attCertValidity = NULL;
9190 attType = NULL;
9191 }
9192
9193 AttributeCertificateAssertion::AttributeCertificateAssertion (const AttributeCertificateAssertion &)
9194 {
9195 Asn1Error << "use of incompletely defined AttributeCertificateAssertion::AttributeCertificateAssertion (const AttributeCertificateAssertion &)" << endl;
9196 abort();
9197 }
9198
9199 AttributeCertificateAssertion::~AttributeCertificateAssertion()
9200 {
9201 delete subject;
9202 delete issuer;
9203 delete attCertValidity;
9204 delete attType;
9205 }
9206
9207 AsnType *AttributeCertificateAssertion::Clone() const
9208 {
9209 return new AttributeCertificateAssertion;
9210 }
9211
9212 AsnType *AttributeCertificateAssertion::Copy() const
9213 {
9214 return new AttributeCertificateAssertion (*this);
9215 }
9216
9217 #if SNACC_DEEP_COPY
9218 AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &that)
9219 #else // SNACC_DEEP_COPY
9220 AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &)
9221 #endif // SNACC_DEEP_COPY
9222 {
9223 #if SNACC_DEEP_COPY
9224 if (this != &that)
9225 {
9226 if (that.subject)
9227 {
9228 if (!subject)
9229 subject = new AttributeCertificateAssertionChoice;
9230 *subject = *that.subject;
9231 }
9232 else
9233 {
9234 delete subject;
9235 subject = NULL;
9236 }
9237 if (that.issuer)
9238 {
9239 if (!issuer)
9240 issuer = new Name;
9241 *issuer = *that.issuer;
9242 }
9243 else
9244 {
9245 delete issuer;
9246 issuer = NULL;
9247 }
9248 if (that.attCertValidity)
9249 {
9250 if (!attCertValidity)
9251 attCertValidity = new GeneralizedTime;
9252 *attCertValidity = *that.attCertValidity;
9253 }
9254 else
9255 {
9256 delete attCertValidity;
9257 attCertValidity = NULL;
9258 }
9259 if (that.attType)
9260 {
9261 if (!attType)
9262 attType = new AttributeCertificateAssertionSetOf;
9263 *attType = *that.attType;
9264 }
9265 else
9266 {
9267 delete attType;
9268 attType = NULL;
9269 }
9270 }
9271
9272 return *this;
9273 #else // SNACC_DEEP_COPY
9274 Asn1Error << "use of incompletely defined AttributeCertificateAssertion &AttributeCertificateAssertion::operator = (const AttributeCertificateAssertion &)" << endl;
9275 abort();
9276 // if your compiler complains here, check the -novolat option
9277 #endif // SNACC_DEEP_COPY
9278 }
9279
9280 AsnLen
9281 AttributeCertificateAssertion::BEncContent (BUF_TYPE b)
9282 {
9283 AsnLen totalLen = 0;
9284 AsnLen l;
9285
9286 if (NOT_NULL (attType))
9287 {
9288 BEncEocIfNec (b);
9289 BEncEocIfNec (b);
9290 l = attType->BEncContent (b);
9291 l += BEncConsLen (b, l);
9292
9293 l += BEncTag1 (b, UNIV, CONS, SET_TAG_CODE);
9294 l += BEncConsLen (b, l);
9295
9296 l += BEncTag1 (b, CNTX, CONS, 3);
9297 totalLen += l;
9298 }
9299
9300 if (NOT_NULL (attCertValidity))
9301 {
9302 BEncEocIfNec (b);
9303 l = attCertValidity->BEncContent (b);
9304 l += BEncDefLen (b, l);
9305
9306 l += BEncTag1 (b, UNIV, PRIM, GENERALIZEDTIME_TAG_CODE);
9307 l += BEncConsLen (b, l);
9308
9309 l += BEncTag1 (b, CNTX, CONS, 2);
9310 totalLen += l;
9311 }
9312
9313 if (NOT_NULL (issuer))
9314 {
9315 BEncEocIfNec (b);
9316 l = issuer->BEncContent (b);
9317 l += BEncConsLen (b, l);
9318
9319 l += BEncTag1 (b, CNTX, CONS, 1);
9320 totalLen += l;
9321 }
9322
9323 if (NOT_NULL (subject))
9324 {
9325 BEncEocIfNec (b);
9326 l = subject->BEncContent (b);
9327 l += BEncConsLen (b, l);
9328
9329 l += BEncTag1 (b, CNTX, CONS, 0);
9330 totalLen += l;
9331 }
9332
9333 return totalLen;
9334 } // AttributeCertificateAssertion::BEncContent
9335
9336
9337 void AttributeCertificateAssertion::BDecContent (BUF_TYPE b, AsnTag /*tag0*/, AsnLen elmtLen0, AsnLen &bytesDecoded, ENV_TYPE env)
9338 {
9339 AsnTag tag1;
9340 AsnLen seqBytesDecoded = 0;
9341 AsnLen elmtLen1;
9342 AsnLen elmtLen2;
9343 if (elmtLen0 == 0)
9344 return;
9345 else
9346 {
9347 tag1 = BDecTag (b, seqBytesDecoded, env);
9348
9349 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
9350 {
9351 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
9352 bytesDecoded += seqBytesDecoded;
9353 return;
9354 }
9355 }
9356
9357 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 0)))
9358 {
9359 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9360 tag1 = BDecTag (b, seqBytesDecoded, env);
9361 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
9362 subject = new AttributeCertificateAssertionChoice;
9363 subject->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
9364 if (elmtLen1 == INDEFINITE_LEN)
9365 BDecEoc (b, seqBytesDecoded, env);
9366
9367 if (seqBytesDecoded == elmtLen0)
9368 {
9369 bytesDecoded += seqBytesDecoded;
9370 return;
9371 }
9372 else
9373 {
9374 tag1 = BDecTag (b, seqBytesDecoded, env);
9375
9376 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
9377 {
9378 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
9379 bytesDecoded += seqBytesDecoded;
9380 return;
9381 }
9382 }
9383 }
9384
9385 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 1)))
9386 {
9387 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9388 tag1 = BDecTag (b, seqBytesDecoded, env);
9389 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
9390 issuer = new Name;
9391 issuer->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
9392 if (elmtLen1 == INDEFINITE_LEN)
9393 BDecEoc (b, seqBytesDecoded, env);
9394
9395 if (seqBytesDecoded == elmtLen0)
9396 {
9397 bytesDecoded += seqBytesDecoded;
9398 return;
9399 }
9400 else
9401 {
9402 tag1 = BDecTag (b, seqBytesDecoded, env);
9403
9404 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
9405 {
9406 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
9407 bytesDecoded += seqBytesDecoded;
9408 return;
9409 }
9410 }
9411 }
9412
9413 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 2)))
9414 {
9415 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9416 tag1 = BDecTag (b, seqBytesDecoded, env);
9417
9418 if ((tag1 != MAKE_TAG_ID (UNIV, PRIM, GENERALIZEDTIME_TAG_CODE))
9419 && (tag1 != MAKE_TAG_ID (UNIV, CONS, GENERALIZEDTIME_TAG_CODE)))
9420 {
9421 Asn1Error << "Unexpected Tag" << endl;
9422 SnaccExcep::throwMe(-205);
9423 }
9424
9425 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
9426 attCertValidity = new GeneralizedTime;
9427 attCertValidity->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
9428 if (elmtLen1 == INDEFINITE_LEN)
9429 BDecEoc (b, seqBytesDecoded, env);
9430
9431 if (seqBytesDecoded == elmtLen0)
9432 {
9433 bytesDecoded += seqBytesDecoded;
9434 return;
9435 }
9436 else
9437 {
9438 tag1 = BDecTag (b, seqBytesDecoded, env);
9439
9440 if ((elmtLen0 == INDEFINITE_LEN) && (tag1 == EOC_TAG_ID))
9441 {
9442 BDEC_2ND_EOC_OCTET (b, seqBytesDecoded, env)
9443 bytesDecoded += seqBytesDecoded;
9444 return;
9445 }
9446 }
9447 }
9448
9449 if ((tag1 == MAKE_TAG_ID (CNTX, CONS, 3)))
9450 {
9451 elmtLen1 = BDecLen (b, seqBytesDecoded, env);
9452 tag1 = BDecTag (b, seqBytesDecoded, env);
9453
9454 if (tag1 != MAKE_TAG_ID (UNIV, CONS, SET_TAG_CODE))
9455 {
9456 Asn1Error << "Unexpected Tag" << endl;
9457 SnaccExcep::throwMe(-206);
9458 }
9459
9460 elmtLen2 = BDecLen (b, seqBytesDecoded, env);
9461 attType = new AttributeCertificateAssertionSetOf;
9462 attType->BDecContent (b, tag1, elmtLen2, seqBytesDecoded, env);
9463 if (elmtLen1 == INDEFINITE_LEN)
9464 BDecEoc (b, seqBytesDecoded, env);
9465
9466 }
9467
9468 bytesDecoded += seqBytesDecoded;
9469 if (elmtLen0 == INDEFINITE_LEN)
9470 {
9471 BDecEoc (b, bytesDecoded, env);
9472 return;
9473 }
9474 else if (seqBytesDecoded != elmtLen0)
9475 {
9476 Asn1Error << "ERROR - Length discrepancy on sequence." << endl;
9477 SnaccExcep::throwMe(-207);
9478 }
9479 else
9480 return;
9481 } // AttributeCertificateAssertion::BDecContent
9482
9483 AsnLen AttributeCertificateAssertion::BEnc (BUF_TYPE b)
9484 {
9485 AsnLen l;
9486 l = BEncContent (b);
9487 l += BEncConsLen (b, l);
9488 l += BEncTag1 (b, UNIV, CONS, SEQ_TAG_CODE);
9489 return l;
9490 }
9491
9492 void AttributeCertificateAssertion::BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env)
9493 {
9494 AsnTag tag;
9495 AsnLen elmtLen1;
9496
9497 if ((tag = BDecTag (b, bytesDecoded, env)) != MAKE_TAG_ID (UNIV, CONS, SEQ_TAG_CODE))
9498 {
9499 Asn1Error << "AttributeCertificateAssertion::BDec: ERROR - wrong tag" << endl;
9500 SnaccExcep::throwMe(-208);
9501 }
9502 elmtLen1 = BDecLen (b, bytesDecoded, env);
9503 BDecContent (b, tag, elmtLen1, bytesDecoded, env);
9504 }
9505
9506 void AttributeCertificateAssertion::Print (ostream &os) const
9507 {
9508 #ifndef NDEBUG
9509 int nonePrinted = true;
9510 os << "{ -- SEQUENCE --" << endl;
9511 indentG += stdIndentG;
9512
9513 if (NOT_NULL (subject))
9514 {
9515 nonePrinted = false;
9516 Indent (os, indentG);
9517 os << "subject ";
9518 os << *subject;
9519 }
9520 else
9521 {
9522 Indent (os, indentG);
9523 os << "subject ";
9524 os << "-- void --";
9525 os << "," << endl;
9526 }
9527
9528 if (NOT_NULL (issuer))
9529 {
9530 if (!nonePrinted)
9531 os << "," << endl;
9532 nonePrinted = false;
9533 Indent (os, indentG);
9534 os << "issuer ";
9535 os << *issuer;
9536 }
9537 else
9538 {
9539 Indent (os, indentG);
9540 os << "issuer ";
9541 os << "-- void --";
9542 os << "," << endl;
9543 }
9544
9545 if (NOT_NULL (attCertValidity))
9546 {
9547 if (!nonePrinted)
9548 os << "," << endl;
9549 nonePrinted = false;
9550 Indent (os, indentG);
9551 os << "attCertValidity ";
9552 os << *attCertValidity;
9553 }
9554 else
9555 {
9556 Indent (os, indentG);
9557 os << "attCertValidity ";
9558 os << "-- void --";
9559 os << "," << endl;
9560 }
9561
9562 if (NOT_NULL (attType))
9563 {
9564 if (!nonePrinted)
9565 os << "," << endl;
9566 nonePrinted = false;
9567 Indent (os, indentG);
9568 os << "attType ";
9569 os << *attType;
9570 }
9571 else
9572 {
9573 Indent (os, indentG);
9574 os << "attType ";
9575 os << "-- void --";
9576 os << endl;
9577 }
9578
9579 os << endl;
9580 indentG -= stdIndentG;
9581 Indent (os, indentG);
9582 os << "}";
9583 #endif /* NDEBUG */
9584 } // AttributeCertificateAssertion::Print
9585
9586