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