1 // NOTE: this is a machine generated file--editing not recommended
3 // sm_cms.cpp - class member functions for ASN.1 module CryptographicMessageSyntax
5 // This file was generated by snacc on Mon Apr 22 22:34:19 2002
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
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"
26 #include "appleoids.h"
29 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 // class member definitions:
36 OriginatorPublicKey::OriginatorPublicKey()
39 algorithm
= new AlgorithmIdentifier
;
41 algorithm
= NULL
; // incomplete initialization of mandatory element!
45 OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey
&)
47 Asn1Error
<< "use of incompletely defined OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey &)" << endl
;
51 OriginatorPublicKey::~OriginatorPublicKey()
56 AsnType
*OriginatorPublicKey::Clone() const
58 return new OriginatorPublicKey
;
61 AsnType
*OriginatorPublicKey::Copy() const
63 return new OriginatorPublicKey (*this);
67 OriginatorPublicKey
&OriginatorPublicKey::operator = (const OriginatorPublicKey
&that
)
68 #else // SNACC_DEEP_COPY
69 OriginatorPublicKey
&OriginatorPublicKey::operator = (const OriginatorPublicKey
&)
70 #endif // SNACC_DEEP_COPY
78 algorithm
= new AlgorithmIdentifier
;
79 *algorithm
= *that
.algorithm
;
86 publicKey
= that
.publicKey
;
90 #else // SNACC_DEEP_COPY
91 Asn1Error
<< "use of incompletely defined OriginatorPublicKey &OriginatorPublicKey::operator = (const OriginatorPublicKey &)" << endl
;
93 // if your compiler complains here, check the -novolat option
94 #endif // SNACC_DEEP_COPY
98 OriginatorPublicKey::BEncContent (BUF_TYPE b
)
103 l
= publicKey
.BEncContent (b
);
104 l
+= BEncDefLen (b
, l
);
106 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
110 l
= algorithm
->BEncContent (b
);
111 l
+= BEncConsLen (b
, l
);
113 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
117 } // OriginatorPublicKey::BEncContent
120 void OriginatorPublicKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
123 AsnLen seqBytesDecoded
= 0;
125 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
127 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
129 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
130 algorithm
= new AlgorithmIdentifier
;
131 algorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
132 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
136 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
137 SnaccExcep::throwMe(-100);
140 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
141 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
143 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
144 publicKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
148 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
149 SnaccExcep::throwMe(-101);
152 bytesDecoded
+= seqBytesDecoded
;
153 if (elmtLen0
== INDEFINITE_LEN
)
155 BDecEoc (b
, bytesDecoded
, env
);
158 else if (seqBytesDecoded
!= elmtLen0
)
160 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
161 SnaccExcep::throwMe(-102);
165 } // OriginatorPublicKey::BDecContent
167 AsnLen
OriginatorPublicKey::BEnc (BUF_TYPE b
)
171 l
+= BEncConsLen (b
, l
);
172 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
176 void OriginatorPublicKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
181 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
183 Asn1Error
<< "OriginatorPublicKey::BDec: ERROR - wrong tag" << endl
;
184 SnaccExcep::throwMe(-103);
186 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
187 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
190 void OriginatorPublicKey::Print (ostream
&os
) const
193 os
<< "{ -- SEQUENCE --" << endl
;
194 indentG
+= stdIndentG
;
196 if (NOT_NULL (algorithm
))
198 Indent (os
, indentG
);
204 Indent (os
, indentG
);
211 Indent (os
, indentG
);
217 indentG
-= stdIndentG
;
218 Indent (os
, indentG
);
221 } // OriginatorPublicKey::Print
224 AsnType
*CertificateRevocationLists::Clone() const
226 return new CertificateRevocationLists
;
229 AsnType
*CertificateRevocationLists::Copy() const
231 return new CertificateRevocationLists (*this);
234 AsnLen
CertificateRevocationLists::BEnc (BUF_TYPE b
)
238 l
+= BEncConsLen (b
, l
);
239 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
243 void CertificateRevocationLists::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
248 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
250 Asn1Error
<< "CertificateRevocationLists::BDec: ERROR - wrong tag" << endl
;
251 SnaccExcep::throwMe(-104);
253 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
254 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
257 CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists
&)
259 Asn1Error
<< "use of incompletely defined CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists &)" << endl
;
263 CertificateRevocationLists::~CertificateRevocationLists()
266 for (; Curr() != NULL
; RemoveCurrFromList())
268 } // end of destructor
271 CertificateRevocationLists
&CertificateRevocationLists::operator = (const CertificateRevocationLists
&that
)
272 #else // SNACC_DEEP_COPY
273 CertificateRevocationLists
&CertificateRevocationLists::operator = (const CertificateRevocationLists
&)
274 #endif // SNACC_DEEP_COPY
280 for (; Curr(); RemoveCurrFromList())
283 //that.SetCurrToFirst();
284 //for (; that.Curr(); that.GoNext())
285 // AppendCopy (*that.Curr());
286 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
287 AppendCopy (*run
->elmt
);
291 #else // SNACC_DEEP_COPY
292 Asn1Error
<< "use of incompletely defined CertificateRevocationLists &CertificateRevocationLists::operator = (const CertificateRevocationLists &)" << endl
;
294 // if your compiler complains here, check the -novolat option
295 #endif // SNACC_DEEP_COPY
298 void CertificateRevocationLists::Print (ostream
&os
) const
301 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
302 indentG
+= stdIndentG
;
304 //for (; Curr() != NULL; GoNext())
305 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
307 Indent (os
, indentG
);
310 //if (Curr() != Last())
315 indentG
-= stdIndentG
;
316 Indent (os
, indentG
);
324 void CertificateRevocationLists::SetCurrElmt (unsigned long int index
)
329 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
331 } // CertificateRevocationLists::SetCurrElmt
334 unsigned long int CertificateRevocationLists::GetCurrElmtIndex()
340 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
349 } // CertificateRevocationLists::GetCurrElmtIndex
352 // alloc new list elmt, put at end of list
353 // and return the component type
354 CertificateList
*CertificateRevocationLists::Append()
356 AsnListElmt
*newElmt
;
357 newElmt
= new AsnListElmt
;
358 newElmt
->elmt
= new CertificateList
;
359 newElmt
->next
= NULL
;
362 newElmt
->prev
= NULL
;
363 first
= last
= newElmt
;
367 newElmt
->prev
= last
;
368 last
->next
= newElmt
;
372 return (curr
= newElmt
)->elmt
;
373 } // CertificateRevocationLists::Append
376 // alloc new list elmt, put at begining of list
377 // and return the component type
378 CertificateList
*CertificateRevocationLists::Prepend()
380 AsnListElmt
*newElmt
;
381 newElmt
= new AsnListElmt
;
382 newElmt
->elmt
= new CertificateList
;
383 newElmt
->prev
= NULL
;
386 newElmt
->next
= NULL
;
387 first
= last
= newElmt
;
391 newElmt
->next
= first
;
392 first
->prev
= newElmt
;
396 return (curr
= newElmt
)->elmt
;
397 } // CertificateRevocationLists::Prepend
400 // alloc new list elmt, insert it before the
401 // current element and return the component type
402 // if the current element is null, the new element
403 // is placed at the beginning of the list.
404 CertificateList
*CertificateRevocationLists::InsertBefore()
406 AsnListElmt
*newElmt
;
407 newElmt
= new AsnListElmt
;
408 newElmt
->elmt
= new CertificateList
;
411 newElmt
->next
= first
;
412 newElmt
->prev
= NULL
;
419 newElmt
->next
= curr
;
420 newElmt
->prev
= curr
->prev
;
421 curr
->prev
= newElmt
;
425 newElmt
->prev
->next
= newElmt
;
428 return (curr
= newElmt
)->elmt
;
429 } // CertificateRevocationLists::InsertBefore
432 // alloc new list elmt, insert it after the
433 // current element and return the component type
434 // if the current element is null, the new element
435 // is placed at the end of the list.
436 CertificateList
*CertificateRevocationLists::InsertAfter()
438 AsnListElmt
*newElmt
;
439 newElmt
= new AsnListElmt
;
440 newElmt
->elmt
= new CertificateList
;
443 newElmt
->prev
= last
;
444 newElmt
->next
= NULL
;
451 newElmt
->prev
= curr
;
452 newElmt
->next
= curr
->next
;
453 curr
->next
= newElmt
;
457 newElmt
->next
->prev
= newElmt
;
460 return (curr
= newElmt
)->elmt
;
461 } // CertificateRevocationLists::InsertAfter
464 CertificateRevocationLists
&CertificateRevocationLists::AppendCopy (CertificateList
&elmt
)
466 AsnListElmt
*newElmt
;
467 newElmt
= new AsnListElmt
;
468 newElmt
->elmt
= new CertificateList
;
469 *newElmt
->elmt
= elmt
;
470 newElmt
->next
= NULL
;
473 newElmt
->prev
= NULL
;
474 first
= last
= newElmt
;
478 newElmt
->prev
= last
;
479 last
->next
= newElmt
;
487 CertificateRevocationLists
&CertificateRevocationLists::PrependCopy (CertificateList
&elmt
)
489 AsnListElmt
*newElmt
;
490 newElmt
= new AsnListElmt
;
491 newElmt
->elmt
= new CertificateList
;
492 *newElmt
->elmt
= elmt
;
493 newElmt
->prev
= NULL
;
496 newElmt
->next
= NULL
;
497 first
= last
= newElmt
;
501 newElmt
->next
= first
;
502 first
->prev
= newElmt
;
507 } // CertificateRevocationLists::PrependCopy
510 // alloc new list elmt, insert it before the
511 // current element, copy the given elmt into the new elmt
512 // and return the component type.
513 // if the current element is null, the new element
514 // is placed at the beginning of the list.
515 CertificateRevocationLists
&CertificateRevocationLists::InsertBeforeAndCopy (CertificateList
&elmt
)
517 AsnListElmt
*newElmt
;
519 newElmt
= new AsnListElmt
;
520 newElmt
->elmt
= new CertificateList
;
521 *newElmt
->elmt
= elmt
;
525 newElmt
->next
= first
;
526 newElmt
->prev
= NULL
;
533 newElmt
->next
= curr
;
534 newElmt
->prev
= curr
->prev
;
535 curr
->prev
= newElmt
;
539 newElmt
->prev
->next
= newElmt
;
543 } // CertificateRevocationLists::InsertBeforeAndCopy
546 // alloc new list elmt, insert it after the
547 // current element, copy given elmt in to new elmt
548 // and return the component type
549 // if the current element is null, the new element
550 // is placed at the end of the list.
551 CertificateRevocationLists
&CertificateRevocationLists::InsertAfterAndCopy (CertificateList
&elmt
)
553 AsnListElmt
*newElmt
;
555 newElmt
= new AsnListElmt
;
556 newElmt
->elmt
= new CertificateList
;
557 *newElmt
->elmt
= elmt
;
560 newElmt
->prev
= last
;
561 newElmt
->next
= NULL
;
568 newElmt
->prev
= curr
;
569 newElmt
->next
= curr
->next
;
570 curr
->next
= newElmt
;
574 newElmt
->next
->prev
= newElmt
;
578 } // CertificateRevocationLists::InsertAfterAndCopy
581 // remove current element from list if current element is not NULL
582 // The new current element will be the next element.
583 // If the current element is the last element in the list
584 // the second but last element will become the new current element.
585 void CertificateRevocationLists::RemoveCurrFromList()
587 AsnListElmt
*del_elmt
;
595 first
= last
= curr
= NULL
;
596 else if (curr
== first
)
598 curr
= first
= first
->next
;
601 else if (curr
== last
)
603 curr
= last
= last
->prev
;
608 curr
->prev
->next
= curr
->next
;
609 curr
->next
->prev
= curr
->prev
;
612 delete del_elmt
->elmt
;
618 AsnLen
CertificateRevocationLists::BEncContent (BUF_TYPE b
)
620 AsnListElmt
*currElmt
;
625 CSM_Buffer
**tmpEnc
=NULL
;
626 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
627 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
628 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
631 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
632 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
634 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
635 ENCODE_BUF2(tmpEnc
[iii
]);
637 vdasnacc_sortSetOf(tmpEnc
, icount
);
638 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
639 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
640 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
645 } // CertificateRevocationLists::BEncContent
648 void CertificateRevocationLists::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
649 AsnLen
&bytesDecoded
, ENV_TYPE env
)
651 CertificateList
*listElmt
;
653 AsnLen listBytesDecoded
= 0;
656 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
658 tag1
= BDecTag (b
, listBytesDecoded
, env
);
659 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
661 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
664 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
666 Asn1Error
<< "Unexpected Tag" << endl
;
667 SnaccExcep::throwMe(-105);
670 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
672 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
675 bytesDecoded
+= listBytesDecoded
;
676 } // CertificateRevocationLists::BDecContent
679 IssuerAndSerialNumber::IssuerAndSerialNumber()
684 issuer
= NULL
; // incomplete initialization of mandatory element!
688 IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber
&)
690 Asn1Error
<< "use of incompletely defined IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber &)" << endl
;
694 IssuerAndSerialNumber::~IssuerAndSerialNumber()
699 AsnType
*IssuerAndSerialNumber::Clone() const
701 return new IssuerAndSerialNumber
;
704 AsnType
*IssuerAndSerialNumber::Copy() const
706 return new IssuerAndSerialNumber (*this);
710 IssuerAndSerialNumber
&IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber
&that
)
711 #else // SNACC_DEEP_COPY
712 IssuerAndSerialNumber
&IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber
&)
713 #endif // SNACC_DEEP_COPY
722 *issuer
= *that
.issuer
;
729 serialNumber
= that
.serialNumber
;
733 #else // SNACC_DEEP_COPY
734 Asn1Error
<< "use of incompletely defined IssuerAndSerialNumber &IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber &)" << endl
;
736 // if your compiler complains here, check the -novolat option
737 #endif // SNACC_DEEP_COPY
741 IssuerAndSerialNumber::BEncContent (BUF_TYPE b
)
746 l
= serialNumber
.BEncContent (b
);
747 l
+= BEncDefLen (b
, l
);
749 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
752 l
= issuer
->BEncContent (b
);
756 } // IssuerAndSerialNumber::BEncContent
759 void IssuerAndSerialNumber::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
762 AsnLen seqBytesDecoded
= 0;
764 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
766 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
768 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
770 issuer
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
771 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
775 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
776 SnaccExcep::throwMe(-106);
779 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
780 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
782 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
783 serialNumber
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
787 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
788 SnaccExcep::throwMe(-107);
791 bytesDecoded
+= seqBytesDecoded
;
792 if (elmtLen0
== INDEFINITE_LEN
)
794 BDecEoc (b
, bytesDecoded
, env
);
797 else if (seqBytesDecoded
!= elmtLen0
)
799 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
800 SnaccExcep::throwMe(-108);
804 } // IssuerAndSerialNumber::BDecContent
806 AsnLen
IssuerAndSerialNumber::BEnc (BUF_TYPE b
)
810 l
+= BEncConsLen (b
, l
);
811 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
815 void IssuerAndSerialNumber::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
820 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
822 Asn1Error
<< "IssuerAndSerialNumber::BDec: ERROR - wrong tag" << endl
;
823 SnaccExcep::throwMe(-109);
825 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
826 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
829 void IssuerAndSerialNumber::Print (ostream
&os
) const
832 os
<< "{ -- SEQUENCE --" << endl
;
833 indentG
+= stdIndentG
;
835 if (NOT_NULL (issuer
))
837 Indent (os
, indentG
);
843 Indent (os
, indentG
);
850 Indent (os
, indentG
);
851 os
<< "serialNumber ";
856 indentG
-= stdIndentG
;
857 Indent (os
, indentG
);
860 } // IssuerAndSerialNumber::Print
863 OtherKeyAttribute::OtherKeyAttribute()
868 OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute
&)
870 Asn1Error
<< "use of incompletely defined OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute &)" << endl
;
874 OtherKeyAttribute::~OtherKeyAttribute()
879 AsnType
*OtherKeyAttribute::Clone() const
881 return new OtherKeyAttribute
;
884 AsnType
*OtherKeyAttribute::Copy() const
886 return new OtherKeyAttribute (*this);
890 OtherKeyAttribute
&OtherKeyAttribute::operator = (const OtherKeyAttribute
&that
)
891 #else // SNACC_DEEP_COPY
892 OtherKeyAttribute
&OtherKeyAttribute::operator = (const OtherKeyAttribute
&)
893 #endif // SNACC_DEEP_COPY
898 keyAttrId
= that
.keyAttrId
;
902 keyAttr
= new AsnAny
;
903 *keyAttr
= *that
.keyAttr
;
913 #else // SNACC_DEEP_COPY
914 Asn1Error
<< "use of incompletely defined OtherKeyAttribute &OtherKeyAttribute::operator = (const OtherKeyAttribute &)" << endl
;
916 // if your compiler complains here, check the -novolat option
917 #endif // SNACC_DEEP_COPY
921 OtherKeyAttribute::BEncContent (BUF_TYPE b
)
926 if (NOT_NULL (keyAttr
))
928 ENC_LOAD_ANYBUF(keyAttr
, b
, l
);
932 l
= keyAttrId
.BEncContent (b
);
933 l
+= BEncDefLen (b
, l
);
935 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
939 } // OtherKeyAttribute::BEncContent
942 void OtherKeyAttribute::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
945 AsnLen seqBytesDecoded
= 0;
947 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
949 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
951 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
952 keyAttrId
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
953 if (seqBytesDecoded
== elmtLen0
)
955 bytesDecoded
+= seqBytesDecoded
;
962 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
964 BDecEoc (b
, seqBytesDecoded
, env
);
966 bytesDecoded
+= seqBytesDecoded
;
973 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
974 SnaccExcep::throwMe(-110);
978 keyAttr
= new AsnAny
;
979 DEC_LOAD_ANYBUF(keyAttr
, b
, seqBytesDecoded
, env
);
982 bytesDecoded
+= seqBytesDecoded
;
983 if (elmtLen0
== INDEFINITE_LEN
)
985 BDecEoc (b
, bytesDecoded
, env
);
988 else if (seqBytesDecoded
!= elmtLen0
)
990 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
991 SnaccExcep::throwMe(-111);
995 } // OtherKeyAttribute::BDecContent
997 AsnLen
OtherKeyAttribute::BEnc (BUF_TYPE b
)
1000 l
= BEncContent (b
);
1001 l
+= BEncConsLen (b
, l
);
1002 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1006 void OtherKeyAttribute::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1011 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1013 Asn1Error
<< "OtherKeyAttribute::BDec: ERROR - wrong tag" << endl
;
1014 SnaccExcep::throwMe(-112);
1016 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1017 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1020 void OtherKeyAttribute::Print (ostream
&os
) const
1023 os
<< "{ -- SEQUENCE --" << endl
;
1024 indentG
+= stdIndentG
;
1027 Indent (os
, indentG
);
1033 if (NOT_NULL (keyAttr
))
1036 Indent (os
, indentG
);
1042 Indent (os
, indentG
);
1049 indentG
-= stdIndentG
;
1050 Indent (os
, indentG
);
1053 } // OtherKeyAttribute::Print
1056 AsnType
*DigestAlgorithmIdentifiers::Clone() const
1058 return new DigestAlgorithmIdentifiers
;
1061 AsnType
*DigestAlgorithmIdentifiers::Copy() const
1063 return new DigestAlgorithmIdentifiers (*this);
1066 AsnLen
DigestAlgorithmIdentifiers::BEnc (BUF_TYPE b
)
1069 l
= BEncContent (b
);
1070 l
+= BEncConsLen (b
, l
);
1071 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1075 void DigestAlgorithmIdentifiers::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1080 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
1082 Asn1Error
<< "DigestAlgorithmIdentifiers::BDec: ERROR - wrong tag" << endl
;
1083 SnaccExcep::throwMe(-113);
1085 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1086 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1089 DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers
&)
1091 Asn1Error
<< "use of incompletely defined DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &)" << endl
;
1095 DigestAlgorithmIdentifiers::~DigestAlgorithmIdentifiers()
1098 for (; Curr() != NULL
; RemoveCurrFromList())
1100 } // end of destructor
1103 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers
&that
)
1104 #else // SNACC_DEEP_COPY
1105 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers
&)
1106 #endif // SNACC_DEEP_COPY
1112 for (; Curr(); RemoveCurrFromList())
1115 //that.SetCurrToFirst();
1116 //for (; that.Curr(); that.GoNext())
1117 // AppendCopy (*that.Curr());
1118 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
1119 AppendCopy (*run
->elmt
);
1123 #else // SNACC_DEEP_COPY
1124 Asn1Error
<< "use of incompletely defined DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers &)" << endl
;
1126 // if your compiler complains here, check the -novolat option
1127 #endif // SNACC_DEEP_COPY
1130 void DigestAlgorithmIdentifiers::Print (ostream
&os
) const
1133 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
1134 indentG
+= stdIndentG
;
1136 //for (; Curr() != NULL; GoNext())
1137 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
1139 Indent (os
, indentG
);
1142 //if (Curr() != Last())
1147 indentG
-= stdIndentG
;
1148 Indent (os
, indentG
);
1156 void DigestAlgorithmIdentifiers::SetCurrElmt (unsigned long int index
)
1158 unsigned long int i
;
1161 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
1163 } // DigestAlgorithmIdentifiers::SetCurrElmt
1166 unsigned long int DigestAlgorithmIdentifiers::GetCurrElmtIndex()
1168 unsigned long int i
;
1172 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
1181 } // DigestAlgorithmIdentifiers::GetCurrElmtIndex
1184 // alloc new list elmt, put at end of list
1185 // and return the component type
1186 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::Append()
1188 AsnListElmt
*newElmt
;
1189 newElmt
= new AsnListElmt
;
1190 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1191 newElmt
->next
= NULL
;
1194 newElmt
->prev
= NULL
;
1195 first
= last
= newElmt
;
1199 newElmt
->prev
= last
;
1200 last
->next
= newElmt
;
1204 return (curr
= newElmt
)->elmt
;
1205 } // DigestAlgorithmIdentifiers::Append
1208 // alloc new list elmt, put at begining of list
1209 // and return the component type
1210 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::Prepend()
1212 AsnListElmt
*newElmt
;
1213 newElmt
= new AsnListElmt
;
1214 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1215 newElmt
->prev
= NULL
;
1218 newElmt
->next
= NULL
;
1219 first
= last
= newElmt
;
1223 newElmt
->next
= first
;
1224 first
->prev
= newElmt
;
1228 return (curr
= newElmt
)->elmt
;
1229 } // DigestAlgorithmIdentifiers::Prepend
1232 // alloc new list elmt, insert it before the
1233 // current element and return the component type
1234 // if the current element is null, the new element
1235 // is placed at the beginning of the list.
1236 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::InsertBefore()
1238 AsnListElmt
*newElmt
;
1239 newElmt
= new AsnListElmt
;
1240 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1243 newElmt
->next
= first
;
1244 newElmt
->prev
= NULL
;
1251 newElmt
->next
= curr
;
1252 newElmt
->prev
= curr
->prev
;
1253 curr
->prev
= newElmt
;
1257 newElmt
->prev
->next
= newElmt
;
1260 return (curr
= newElmt
)->elmt
;
1261 } // DigestAlgorithmIdentifiers::InsertBefore
1264 // alloc new list elmt, insert it after the
1265 // current element and return the component type
1266 // if the current element is null, the new element
1267 // is placed at the end of the list.
1268 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::InsertAfter()
1270 AsnListElmt
*newElmt
;
1271 newElmt
= new AsnListElmt
;
1272 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1275 newElmt
->prev
= last
;
1276 newElmt
->next
= NULL
;
1283 newElmt
->prev
= curr
;
1284 newElmt
->next
= curr
->next
;
1285 curr
->next
= newElmt
;
1289 newElmt
->next
->prev
= newElmt
;
1292 return (curr
= newElmt
)->elmt
;
1293 } // DigestAlgorithmIdentifiers::InsertAfter
1296 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::AppendCopy (DigestAlgorithmIdentifier
&elmt
)
1298 AsnListElmt
*newElmt
;
1299 newElmt
= new AsnListElmt
;
1300 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1301 *newElmt
->elmt
= elmt
;
1302 newElmt
->next
= NULL
;
1305 newElmt
->prev
= NULL
;
1306 first
= last
= newElmt
;
1310 newElmt
->prev
= last
;
1311 last
->next
= newElmt
;
1319 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::PrependCopy (DigestAlgorithmIdentifier
&elmt
)
1321 AsnListElmt
*newElmt
;
1322 newElmt
= new AsnListElmt
;
1323 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1324 *newElmt
->elmt
= elmt
;
1325 newElmt
->prev
= NULL
;
1328 newElmt
->next
= NULL
;
1329 first
= last
= newElmt
;
1333 newElmt
->next
= first
;
1334 first
->prev
= newElmt
;
1339 } // DigestAlgorithmIdentifiers::PrependCopy
1342 // alloc new list elmt, insert it before the
1343 // current element, copy the given elmt into the new elmt
1344 // and return the component type.
1345 // if the current element is null, the new element
1346 // is placed at the beginning of the list.
1347 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::InsertBeforeAndCopy (DigestAlgorithmIdentifier
&elmt
)
1349 AsnListElmt
*newElmt
;
1351 newElmt
= new AsnListElmt
;
1352 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1353 *newElmt
->elmt
= elmt
;
1357 newElmt
->next
= first
;
1358 newElmt
->prev
= NULL
;
1365 newElmt
->next
= curr
;
1366 newElmt
->prev
= curr
->prev
;
1367 curr
->prev
= newElmt
;
1371 newElmt
->prev
->next
= newElmt
;
1375 } // DigestAlgorithmIdentifiers::InsertBeforeAndCopy
1378 // alloc new list elmt, insert it after the
1379 // current element, copy given elmt in to new elmt
1380 // and return the component type
1381 // if the current element is null, the new element
1382 // is placed at the end of the list.
1383 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::InsertAfterAndCopy (DigestAlgorithmIdentifier
&elmt
)
1385 AsnListElmt
*newElmt
;
1387 newElmt
= new AsnListElmt
;
1388 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1389 *newElmt
->elmt
= elmt
;
1392 newElmt
->prev
= last
;
1393 newElmt
->next
= NULL
;
1400 newElmt
->prev
= curr
;
1401 newElmt
->next
= curr
->next
;
1402 curr
->next
= newElmt
;
1406 newElmt
->next
->prev
= newElmt
;
1410 } // DigestAlgorithmIdentifiers::InsertAfterAndCopy
1413 // remove current element from list if current element is not NULL
1414 // The new current element will be the next element.
1415 // If the current element is the last element in the list
1416 // the second but last element will become the new current element.
1417 void DigestAlgorithmIdentifiers::RemoveCurrFromList()
1419 AsnListElmt
*del_elmt
;
1427 first
= last
= curr
= NULL
;
1428 else if (curr
== first
)
1430 curr
= first
= first
->next
;
1433 else if (curr
== last
)
1435 curr
= last
= last
->prev
;
1440 curr
->prev
->next
= curr
->next
;
1441 curr
->next
->prev
= curr
->prev
;
1444 delete del_elmt
->elmt
;
1450 AsnLen
DigestAlgorithmIdentifiers::BEncContent (BUF_TYPE b
)
1452 AsnListElmt
*currElmt
;
1454 AsnLen totalLen
= 0;
1457 CSM_Buffer
**tmpEnc
=NULL
;
1458 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
1459 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
1460 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
1463 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
1464 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
1466 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
1467 ENCODE_BUF2(tmpEnc
[iii
]);
1469 vdasnacc_sortSetOf(tmpEnc
, icount
);
1470 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
1471 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
1472 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
1475 totalLen
+= elmtLen
;
1477 } // DigestAlgorithmIdentifiers::BEncContent
1480 void DigestAlgorithmIdentifiers::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
1481 AsnLen
&bytesDecoded
, ENV_TYPE env
)
1483 DigestAlgorithmIdentifier
*listElmt
;
1485 AsnLen listBytesDecoded
= 0;
1488 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
1490 tag1
= BDecTag (b
, listBytesDecoded
, env
);
1491 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
1493 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
1496 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
1498 Asn1Error
<< "Unexpected Tag" << endl
;
1499 SnaccExcep::throwMe(-114);
1502 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
1503 listElmt
= Append();
1504 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
1507 bytesDecoded
+= listBytesDecoded
;
1508 } // DigestAlgorithmIdentifiers::BDecContent
1511 EncapsulatedContentInfo::EncapsulatedContentInfo()
1516 EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo
&)
1518 Asn1Error
<< "use of incompletely defined EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo &)" << endl
;
1522 EncapsulatedContentInfo::~EncapsulatedContentInfo()
1527 AsnType
*EncapsulatedContentInfo::Clone() const
1529 return new EncapsulatedContentInfo
;
1532 AsnType
*EncapsulatedContentInfo::Copy() const
1534 return new EncapsulatedContentInfo (*this);
1538 EncapsulatedContentInfo
&EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo
&that
)
1539 #else // SNACC_DEEP_COPY
1540 EncapsulatedContentInfo
&EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo
&)
1541 #endif // SNACC_DEEP_COPY
1546 eContentType
= that
.eContentType
;
1550 eContent
= new AsnOcts
;
1551 *eContent
= *that
.eContent
;
1561 #else // SNACC_DEEP_COPY
1562 Asn1Error
<< "use of incompletely defined EncapsulatedContentInfo &EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo &)" << endl
;
1564 // if your compiler complains here, check the -novolat option
1565 #endif // SNACC_DEEP_COPY
1569 EncapsulatedContentInfo::BEncContent (BUF_TYPE b
)
1571 AsnLen totalLen
= 0;
1574 if (NOT_NULL (eContent
))
1577 l
= eContent
->BEncContent (b
);
1578 l
+= BEncDefLen (b
, l
);
1580 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
1581 l
+= BEncConsLen (b
, l
);
1583 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
1587 l
= eContentType
.BEncContent (b
);
1588 l
+= BEncDefLen (b
, l
);
1590 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
1594 } // EncapsulatedContentInfo::BEncContent
1597 void EncapsulatedContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1600 AsnLen seqBytesDecoded
= 0;
1603 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1605 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
1607 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1608 eContentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1609 if (seqBytesDecoded
== elmtLen0
)
1611 bytesDecoded
+= seqBytesDecoded
;
1616 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1618 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
1620 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
1621 bytesDecoded
+= seqBytesDecoded
;
1628 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1629 SnaccExcep::throwMe(-115);
1632 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
1634 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1635 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1637 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
1638 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
1640 Asn1Error
<< "Unexpected Tag" << endl
;
1641 SnaccExcep::throwMe(-116);
1644 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
1645 eContent
= new AsnOcts
;
1646 eContent
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
1647 if (elmtLen1
== INDEFINITE_LEN
)
1648 BDecEoc (b
, seqBytesDecoded
, env
);
1652 bytesDecoded
+= seqBytesDecoded
;
1653 if (elmtLen0
== INDEFINITE_LEN
)
1655 BDecEoc (b
, bytesDecoded
, env
);
1658 else if (seqBytesDecoded
!= elmtLen0
)
1660 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1661 SnaccExcep::throwMe(-117);
1665 } // EncapsulatedContentInfo::BDecContent
1667 AsnLen
EncapsulatedContentInfo::BEnc (BUF_TYPE b
)
1670 l
= BEncContent (b
);
1671 l
+= BEncConsLen (b
, l
);
1672 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1676 void EncapsulatedContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1681 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1683 Asn1Error
<< "EncapsulatedContentInfo::BDec: ERROR - wrong tag" << endl
;
1684 SnaccExcep::throwMe(-118);
1686 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1687 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1690 void EncapsulatedContentInfo::Print (ostream
&os
) const
1693 os
<< "{ -- SEQUENCE --" << endl
;
1694 indentG
+= stdIndentG
;
1697 Indent (os
, indentG
);
1698 os
<< "eContentType ";
1703 if (NOT_NULL (eContent
))
1706 Indent (os
, indentG
);
1712 Indent (os
, indentG
);
1719 indentG
-= stdIndentG
;
1720 Indent (os
, indentG
);
1723 } // EncapsulatedContentInfo::Print
1726 SignerIdentifier::SignerIdentifier()
1728 choiceId
= issuerAndSerialNumberCid
;
1730 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1732 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
1736 SignerIdentifier::SignerIdentifier (const SignerIdentifier
&)
1738 Asn1Error
<< "use of incompletely defined SignerIdentifier::SignerIdentifier (const SignerIdentifier &)" << endl
;
1742 SignerIdentifier::~SignerIdentifier()
1746 case issuerAndSerialNumberCid
:
1747 delete issuerAndSerialNumber
;
1749 case subjectKeyIdentifierCid
:
1750 delete subjectKeyIdentifier
;
1753 } // end of destructor
1755 AsnType
*SignerIdentifier::Clone() const
1757 return new SignerIdentifier
;
1760 AsnType
*SignerIdentifier::Copy() const
1762 return new SignerIdentifier (*this);
1766 SignerIdentifier
&SignerIdentifier::operator = (const SignerIdentifier
&that
)
1767 #else // SNACC_DEEP_COPY
1768 SignerIdentifier
&SignerIdentifier::operator = (const SignerIdentifier
&)
1769 #endif // SNACC_DEEP_COPY
1776 case issuerAndSerialNumberCid
:
1777 delete issuerAndSerialNumber
;
1779 case subjectKeyIdentifierCid
:
1780 delete subjectKeyIdentifier
;
1783 switch (choiceId
= that
.choiceId
)
1785 case issuerAndSerialNumberCid
:
1786 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1787 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
1789 case subjectKeyIdentifierCid
:
1790 subjectKeyIdentifier
= new KeyIdentifier
;
1791 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
1797 #else // SNACC_DEEP_COPY
1798 Asn1Error
<< "use of incompletely defined SignerIdentifier &SignerIdentifier::operator = (const SignerIdentifier &)" << endl
;
1800 // if your compiler complains here, check the -novolat option
1801 #endif // SNACC_DEEP_COPY
1805 SignerIdentifier::BEncContent (BUF_TYPE b
)
1810 case issuerAndSerialNumberCid
:
1812 l
= issuerAndSerialNumber
->BEncContent (b
);
1813 l
+= BEncConsLen (b
, l
);
1815 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1818 case subjectKeyIdentifierCid
:
1819 l
= subjectKeyIdentifier
->BEncContent (b
);
1820 l
+= BEncDefLen (b
, l
);
1822 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
1827 } // SignerIdentifier::BEncContent
1830 void SignerIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1834 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
1835 choiceId
= issuerAndSerialNumberCid
;
1836 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1837 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1840 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
1841 case MAKE_TAG_ID (CNTX
, CONS
, 0):
1842 choiceId
= subjectKeyIdentifierCid
;
1843 subjectKeyIdentifier
= new KeyIdentifier
;
1844 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1848 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
1849 SnaccExcep::throwMe(-119);
1852 } // SignerIdentifier::BDecContent
1855 AsnLen
SignerIdentifier::BEnc (BUF_TYPE b
)
1858 l
= BEncContent (b
);
1862 void SignerIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1867 /* CHOICEs are a special case - grab identifying tag */
1868 /* this allows easier handling of nested CHOICEs */
1869 tag
= BDecTag (b
, bytesDecoded
, env
);
1870 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
1871 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
1874 void SignerIdentifier::Print (ostream
&os
) const
1879 case issuerAndSerialNumberCid
:
1880 os
<< "issuerAndSerialNumber ";
1881 if (issuerAndSerialNumber
)
1882 os
<< *issuerAndSerialNumber
;
1884 os
<< "-- void3 --\n";
1887 case subjectKeyIdentifierCid
:
1888 os
<< "subjectKeyIdentifier ";
1889 if (subjectKeyIdentifier
)
1890 os
<< *subjectKeyIdentifier
;
1892 os
<< "-- void3 --\n";
1897 } // SignerIdentifier::Print
1899 EncryptedContentInfo::EncryptedContentInfo()
1902 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
1904 contentEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
1906 encryptedContent
= NULL
;
1909 EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo
&)
1911 Asn1Error
<< "use of incompletely defined EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo &)" << endl
;
1915 EncryptedContentInfo::~EncryptedContentInfo()
1917 delete contentEncryptionAlgorithm
;
1918 delete encryptedContent
;
1921 AsnType
*EncryptedContentInfo::Clone() const
1923 return new EncryptedContentInfo
;
1926 AsnType
*EncryptedContentInfo::Copy() const
1928 return new EncryptedContentInfo (*this);
1932 EncryptedContentInfo
&EncryptedContentInfo::operator = (const EncryptedContentInfo
&that
)
1933 #else // SNACC_DEEP_COPY
1934 EncryptedContentInfo
&EncryptedContentInfo::operator = (const EncryptedContentInfo
&)
1935 #endif // SNACC_DEEP_COPY
1940 contentType
= that
.contentType
;
1941 if (that
.contentEncryptionAlgorithm
)
1943 if (!contentEncryptionAlgorithm
)
1944 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
1945 *contentEncryptionAlgorithm
= *that
.contentEncryptionAlgorithm
;
1949 delete contentEncryptionAlgorithm
;
1950 contentEncryptionAlgorithm
= NULL
;
1952 if (that
.encryptedContent
)
1954 if (!encryptedContent
)
1955 encryptedContent
= new EncryptedContent
;
1956 *encryptedContent
= *that
.encryptedContent
;
1960 delete encryptedContent
;
1961 encryptedContent
= NULL
;
1966 #else // SNACC_DEEP_COPY
1967 Asn1Error
<< "use of incompletely defined EncryptedContentInfo &EncryptedContentInfo::operator = (const EncryptedContentInfo &)" << endl
;
1969 // if your compiler complains here, check the -novolat option
1970 #endif // SNACC_DEEP_COPY
1974 EncryptedContentInfo::BEncContent (BUF_TYPE b
)
1976 AsnLen totalLen
= 0;
1979 if (NOT_NULL (encryptedContent
))
1981 l
= encryptedContent
->BEncContent (b
);
1982 l
+= BEncDefLen (b
, l
);
1984 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
1989 l
= contentEncryptionAlgorithm
->BEncContent (b
);
1990 l
+= BEncConsLen (b
, l
);
1992 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1995 l
= contentType
.BEncContent (b
);
1996 l
+= BEncDefLen (b
, l
);
1998 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
2002 } // EncryptedContentInfo::BEncContent
2005 void EncryptedContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2008 AsnLen seqBytesDecoded
= 0;
2010 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2012 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
2014 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2015 contentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2016 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2020 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2021 SnaccExcep::throwMe(-120);
2024 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2026 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2027 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
2028 contentEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2029 if (seqBytesDecoded
== elmtLen0
)
2031 bytesDecoded
+= seqBytesDecoded
;
2036 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2038 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2040 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2041 bytesDecoded
+= seqBytesDecoded
;
2048 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2049 SnaccExcep::throwMe(-121);
2052 if ((tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
2053 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
2055 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2056 encryptedContent
= new EncryptedContent
;
2057 encryptedContent
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2060 bytesDecoded
+= seqBytesDecoded
;
2061 if (elmtLen0
== INDEFINITE_LEN
)
2063 BDecEoc (b
, bytesDecoded
, env
);
2066 else if (seqBytesDecoded
!= elmtLen0
)
2068 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
2069 SnaccExcep::throwMe(-122);
2073 } // EncryptedContentInfo::BDecContent
2075 AsnLen
EncryptedContentInfo::BEnc (BUF_TYPE b
)
2078 l
= BEncContent (b
);
2079 l
+= BEncConsLen (b
, l
);
2080 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2084 void EncryptedContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2089 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2091 Asn1Error
<< "EncryptedContentInfo::BDec: ERROR - wrong tag" << endl
;
2092 SnaccExcep::throwMe(-123);
2094 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2095 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2098 void EncryptedContentInfo::Print (ostream
&os
) const
2101 os
<< "{ -- SEQUENCE --" << endl
;
2102 indentG
+= stdIndentG
;
2105 Indent (os
, indentG
);
2106 os
<< "contentType ";
2111 if (NOT_NULL (contentEncryptionAlgorithm
))
2113 Indent (os
, indentG
);
2114 os
<< "contentEncryptionAlgorithm ";
2115 os
<< *contentEncryptionAlgorithm
;
2119 Indent (os
, indentG
);
2120 os
<< "contentEncryptionAlgorithm ";
2125 if (NOT_NULL (encryptedContent
))
2128 Indent (os
, indentG
);
2129 os
<< "encryptedContent ";
2130 os
<< *encryptedContent
;
2134 Indent (os
, indentG
);
2135 os
<< "encryptedContent ";
2141 indentG
-= stdIndentG
;
2142 Indent (os
, indentG
);
2145 } // EncryptedContentInfo::Print
2148 RecipientIdentifier::RecipientIdentifier()
2150 choiceId
= issuerAndSerialNumberCid
;
2152 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2154 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
2158 RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier
&)
2160 Asn1Error
<< "use of incompletely defined RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier &)" << endl
;
2164 RecipientIdentifier::~RecipientIdentifier()
2168 case issuerAndSerialNumberCid
:
2169 delete issuerAndSerialNumber
;
2171 case subjectKeyIdentifierCid
:
2172 delete subjectKeyIdentifier
;
2175 } // end of destructor
2177 AsnType
*RecipientIdentifier::Clone() const
2179 return new RecipientIdentifier
;
2182 AsnType
*RecipientIdentifier::Copy() const
2184 return new RecipientIdentifier (*this);
2188 RecipientIdentifier
&RecipientIdentifier::operator = (const RecipientIdentifier
&that
)
2189 #else // SNACC_DEEP_COPY
2190 RecipientIdentifier
&RecipientIdentifier::operator = (const RecipientIdentifier
&)
2191 #endif // SNACC_DEEP_COPY
2198 case issuerAndSerialNumberCid
:
2199 delete issuerAndSerialNumber
;
2201 case subjectKeyIdentifierCid
:
2202 delete subjectKeyIdentifier
;
2205 switch (choiceId
= that
.choiceId
)
2207 case issuerAndSerialNumberCid
:
2208 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2209 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
2211 case subjectKeyIdentifierCid
:
2212 subjectKeyIdentifier
= new KeyIdentifier
;
2213 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
2219 #else // SNACC_DEEP_COPY
2220 Asn1Error
<< "use of incompletely defined RecipientIdentifier &RecipientIdentifier::operator = (const RecipientIdentifier &)" << endl
;
2222 // if your compiler complains here, check the -novolat option
2223 #endif // SNACC_DEEP_COPY
2227 RecipientIdentifier::BEncContent (BUF_TYPE b
)
2232 case issuerAndSerialNumberCid
:
2234 l
= issuerAndSerialNumber
->BEncContent (b
);
2235 l
+= BEncConsLen (b
, l
);
2237 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2240 case subjectKeyIdentifierCid
:
2241 l
= subjectKeyIdentifier
->BEncContent (b
);
2242 l
+= BEncDefLen (b
, l
);
2244 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
2249 } // RecipientIdentifier::BEncContent
2252 void RecipientIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2256 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
2257 choiceId
= issuerAndSerialNumberCid
;
2258 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2259 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2262 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
2263 case MAKE_TAG_ID (CNTX
, CONS
, 0):
2264 choiceId
= subjectKeyIdentifierCid
;
2265 subjectKeyIdentifier
= new KeyIdentifier
;
2266 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2270 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
2271 SnaccExcep::throwMe(-124);
2274 } // RecipientIdentifier::BDecContent
2277 AsnLen
RecipientIdentifier::BEnc (BUF_TYPE b
)
2280 l
= BEncContent (b
);
2284 void RecipientIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2289 /* CHOICEs are a special case - grab identifying tag */
2290 /* this allows easier handling of nested CHOICEs */
2291 tag
= BDecTag (b
, bytesDecoded
, env
);
2292 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
2293 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
2296 void RecipientIdentifier::Print (ostream
&os
) const
2301 case issuerAndSerialNumberCid
:
2302 os
<< "issuerAndSerialNumber ";
2303 if (issuerAndSerialNumber
)
2304 os
<< *issuerAndSerialNumber
;
2306 os
<< "-- void3 --\n";
2309 case subjectKeyIdentifierCid
:
2310 os
<< "subjectKeyIdentifier ";
2311 if (subjectKeyIdentifier
)
2312 os
<< *subjectKeyIdentifier
;
2314 os
<< "-- void3 --\n";
2319 } // RecipientIdentifier::Print
2321 OriginatorIdentifierOrKey::OriginatorIdentifierOrKey()
2323 choiceId
= issuerAndSerialNumberCid
;
2325 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2327 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
2331 OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey
&)
2333 Asn1Error
<< "use of incompletely defined OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &)" << endl
;
2337 OriginatorIdentifierOrKey::~OriginatorIdentifierOrKey()
2341 case issuerAndSerialNumberCid
:
2342 delete issuerAndSerialNumber
;
2344 case subjectKeyIdentifierCid
:
2345 delete subjectKeyIdentifier
;
2347 case originatorKeyCid
:
2348 delete originatorKey
;
2351 } // end of destructor
2353 AsnType
*OriginatorIdentifierOrKey::Clone() const
2355 return new OriginatorIdentifierOrKey
;
2358 AsnType
*OriginatorIdentifierOrKey::Copy() const
2360 return new OriginatorIdentifierOrKey (*this);
2364 OriginatorIdentifierOrKey
&OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey
&that
)
2365 #else // SNACC_DEEP_COPY
2366 OriginatorIdentifierOrKey
&OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey
&)
2367 #endif // SNACC_DEEP_COPY
2374 case issuerAndSerialNumberCid
:
2375 delete issuerAndSerialNumber
;
2377 case subjectKeyIdentifierCid
:
2378 delete subjectKeyIdentifier
;
2380 case originatorKeyCid
:
2381 delete originatorKey
;
2384 switch (choiceId
= that
.choiceId
)
2386 case issuerAndSerialNumberCid
:
2387 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2388 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
2390 case subjectKeyIdentifierCid
:
2391 subjectKeyIdentifier
= new KeyIdentifier
;
2392 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
2394 case originatorKeyCid
:
2395 originatorKey
= new OriginatorPublicKey
;
2396 *originatorKey
= *that
.originatorKey
;
2402 #else // SNACC_DEEP_COPY
2403 Asn1Error
<< "use of incompletely defined OriginatorIdentifierOrKey &OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey &)" << endl
;
2405 // if your compiler complains here, check the -novolat option
2406 #endif // SNACC_DEEP_COPY
2410 OriginatorIdentifierOrKey::BEncContent (BUF_TYPE b
)
2415 case issuerAndSerialNumberCid
:
2417 l
= issuerAndSerialNumber
->BEncContent (b
);
2418 l
+= BEncConsLen (b
, l
);
2420 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2423 case subjectKeyIdentifierCid
:
2424 l
= subjectKeyIdentifier
->BEncContent (b
);
2425 l
+= BEncDefLen (b
, l
);
2427 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
2430 case originatorKeyCid
:
2432 l
= originatorKey
->BEncContent (b
);
2433 l
+= BEncConsLen (b
, l
);
2435 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
2440 } // OriginatorIdentifierOrKey::BEncContent
2443 void OriginatorIdentifierOrKey::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2447 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
2448 choiceId
= issuerAndSerialNumberCid
;
2449 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2450 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2453 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
2454 case MAKE_TAG_ID (CNTX
, CONS
, 0):
2455 choiceId
= subjectKeyIdentifierCid
;
2456 subjectKeyIdentifier
= new KeyIdentifier
;
2457 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2460 case MAKE_TAG_ID (CNTX
, CONS
, 1):
2461 choiceId
= originatorKeyCid
;
2462 originatorKey
= new OriginatorPublicKey
;
2463 originatorKey
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2467 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
2468 SnaccExcep::throwMe(-125);
2471 } // OriginatorIdentifierOrKey::BDecContent
2474 AsnLen
OriginatorIdentifierOrKey::BEnc (BUF_TYPE b
)
2477 l
= BEncContent (b
);
2481 void OriginatorIdentifierOrKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2486 /* CHOICEs are a special case - grab identifying tag */
2487 /* this allows easier handling of nested CHOICEs */
2488 tag
= BDecTag (b
, bytesDecoded
, env
);
2489 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
2490 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
2493 void OriginatorIdentifierOrKey::Print (ostream
&os
) const
2498 case issuerAndSerialNumberCid
:
2499 os
<< "issuerAndSerialNumber ";
2500 if (issuerAndSerialNumber
)
2501 os
<< *issuerAndSerialNumber
;
2503 os
<< "-- void3 --\n";
2506 case subjectKeyIdentifierCid
:
2507 os
<< "subjectKeyIdentifier ";
2508 if (subjectKeyIdentifier
)
2509 os
<< *subjectKeyIdentifier
;
2511 os
<< "-- void3 --\n";
2514 case originatorKeyCid
:
2515 os
<< "originatorKey ";
2517 os
<< *originatorKey
;
2519 os
<< "-- void3 --\n";
2524 } // OriginatorIdentifierOrKey::Print
2526 RecipientKeyIdentifier::RecipientKeyIdentifier()
2532 RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier
&)
2534 Asn1Error
<< "use of incompletely defined RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier &)" << endl
;
2538 RecipientKeyIdentifier::~RecipientKeyIdentifier()
2544 AsnType
*RecipientKeyIdentifier::Clone() const
2546 return new RecipientKeyIdentifier
;
2549 AsnType
*RecipientKeyIdentifier::Copy() const
2551 return new RecipientKeyIdentifier (*this);
2555 RecipientKeyIdentifier
&RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier
&that
)
2556 #else // SNACC_DEEP_COPY
2557 RecipientKeyIdentifier
&RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier
&)
2558 #endif // SNACC_DEEP_COPY
2563 subjectKeyIdentifier
= that
.subjectKeyIdentifier
;
2567 date
= new GeneralizedTime
;
2578 other
= new OtherKeyAttribute
;
2579 *other
= *that
.other
;
2589 #else // SNACC_DEEP_COPY
2590 Asn1Error
<< "use of incompletely defined RecipientKeyIdentifier &RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier &)" << endl
;
2592 // if your compiler complains here, check the -novolat option
2593 #endif // SNACC_DEEP_COPY
2597 RecipientKeyIdentifier::BEncContent (BUF_TYPE b
)
2599 AsnLen totalLen
= 0;
2602 if (NOT_NULL (other
))
2605 l
= other
->BEncContent (b
);
2606 l
+= BEncConsLen (b
, l
);
2608 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2612 if (NOT_NULL (date
))
2614 l
= date
->BEncContent (b
);
2615 l
+= BEncDefLen (b
, l
);
2617 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
2621 l
= subjectKeyIdentifier
.BEncContent (b
);
2622 l
+= BEncDefLen (b
, l
);
2624 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
2628 } // RecipientKeyIdentifier::BEncContent
2631 void RecipientKeyIdentifier::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2634 AsnLen seqBytesDecoded
= 0;
2636 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2638 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
2639 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
2641 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2642 subjectKeyIdentifier
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2643 if (seqBytesDecoded
== elmtLen0
)
2645 bytesDecoded
+= seqBytesDecoded
;
2650 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2652 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2654 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2655 bytesDecoded
+= seqBytesDecoded
;
2662 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2663 SnaccExcep::throwMe(-126);
2666 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
))
2667 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, GENERALIZEDTIME_TAG_CODE
)))
2669 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2670 date
= new GeneralizedTime
;
2671 date
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2672 if (seqBytesDecoded
== elmtLen0
)
2674 bytesDecoded
+= seqBytesDecoded
;
2679 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2681 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2683 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2684 bytesDecoded
+= seqBytesDecoded
;
2690 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2692 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2693 other
= new OtherKeyAttribute
;
2694 other
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2697 bytesDecoded
+= seqBytesDecoded
;
2698 if (elmtLen0
== INDEFINITE_LEN
)
2700 BDecEoc (b
, bytesDecoded
, env
);
2703 else if (seqBytesDecoded
!= elmtLen0
)
2705 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
2706 SnaccExcep::throwMe(-127);
2710 } // RecipientKeyIdentifier::BDecContent
2712 AsnLen
RecipientKeyIdentifier::BEnc (BUF_TYPE b
)
2715 l
= BEncContent (b
);
2716 l
+= BEncConsLen (b
, l
);
2717 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2721 void RecipientKeyIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2726 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2728 Asn1Error
<< "RecipientKeyIdentifier::BDec: ERROR - wrong tag" << endl
;
2729 SnaccExcep::throwMe(-128);
2731 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2732 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2735 void RecipientKeyIdentifier::Print (ostream
&os
) const
2738 os
<< "{ -- SEQUENCE --" << endl
;
2739 indentG
+= stdIndentG
;
2742 Indent (os
, indentG
);
2743 os
<< "subjectKeyIdentifier ";
2744 os
<< subjectKeyIdentifier
;
2748 if (NOT_NULL (date
))
2751 Indent (os
, indentG
);
2757 Indent (os
, indentG
);
2763 if (NOT_NULL (other
))
2766 Indent (os
, indentG
);
2772 Indent (os
, indentG
);
2779 indentG
-= stdIndentG
;
2780 Indent (os
, indentG
);
2783 } // RecipientKeyIdentifier::Print
2786 KEKIdentifier::KEKIdentifier()
2792 KEKIdentifier::KEKIdentifier (const KEKIdentifier
&)
2794 Asn1Error
<< "use of incompletely defined KEKIdentifier::KEKIdentifier (const KEKIdentifier &)" << endl
;
2798 KEKIdentifier::~KEKIdentifier()
2804 AsnType
*KEKIdentifier::Clone() const
2806 return new KEKIdentifier
;
2809 AsnType
*KEKIdentifier::Copy() const
2811 return new KEKIdentifier (*this);
2815 KEKIdentifier
&KEKIdentifier::operator = (const KEKIdentifier
&that
)
2816 #else // SNACC_DEEP_COPY
2817 KEKIdentifier
&KEKIdentifier::operator = (const KEKIdentifier
&)
2818 #endif // SNACC_DEEP_COPY
2823 keyIdentifier
= that
.keyIdentifier
;
2827 date
= new GeneralizedTime
;
2838 other
= new OtherKeyAttribute
;
2839 *other
= *that
.other
;
2849 #else // SNACC_DEEP_COPY
2850 Asn1Error
<< "use of incompletely defined KEKIdentifier &KEKIdentifier::operator = (const KEKIdentifier &)" << endl
;
2852 // if your compiler complains here, check the -novolat option
2853 #endif // SNACC_DEEP_COPY
2857 KEKIdentifier::BEncContent (BUF_TYPE b
)
2859 AsnLen totalLen
= 0;
2862 if (NOT_NULL (other
))
2865 l
= other
->BEncContent (b
);
2866 l
+= BEncConsLen (b
, l
);
2868 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2872 if (NOT_NULL (date
))
2874 l
= date
->BEncContent (b
);
2875 l
+= BEncDefLen (b
, l
);
2877 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
2881 l
= keyIdentifier
.BEncContent (b
);
2882 l
+= BEncDefLen (b
, l
);
2884 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
2888 } // KEKIdentifier::BEncContent
2891 void KEKIdentifier::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2894 AsnLen seqBytesDecoded
= 0;
2896 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2898 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
2899 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
2901 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2902 keyIdentifier
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2903 if (seqBytesDecoded
== elmtLen0
)
2905 bytesDecoded
+= seqBytesDecoded
;
2910 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2912 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2914 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2915 bytesDecoded
+= seqBytesDecoded
;
2922 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2923 SnaccExcep::throwMe(-129);
2926 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
))
2927 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, GENERALIZEDTIME_TAG_CODE
)))
2929 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2930 date
= new GeneralizedTime
;
2931 date
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2932 if (seqBytesDecoded
== elmtLen0
)
2934 bytesDecoded
+= seqBytesDecoded
;
2939 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2941 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2943 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2944 bytesDecoded
+= seqBytesDecoded
;
2950 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2952 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2953 other
= new OtherKeyAttribute
;
2954 other
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2957 bytesDecoded
+= seqBytesDecoded
;
2958 if (elmtLen0
== INDEFINITE_LEN
)
2960 BDecEoc (b
, bytesDecoded
, env
);
2963 else if (seqBytesDecoded
!= elmtLen0
)
2965 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
2966 SnaccExcep::throwMe(-130);
2970 } // KEKIdentifier::BDecContent
2972 AsnLen
KEKIdentifier::BEnc (BUF_TYPE b
)
2975 l
= BEncContent (b
);
2976 l
+= BEncConsLen (b
, l
);
2977 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2981 void KEKIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2986 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2988 Asn1Error
<< "KEKIdentifier::BDec: ERROR - wrong tag" << endl
;
2989 SnaccExcep::throwMe(-131);
2991 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2992 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2995 void KEKIdentifier::Print (ostream
&os
) const
2998 os
<< "{ -- SEQUENCE --" << endl
;
2999 indentG
+= stdIndentG
;
3002 Indent (os
, indentG
);
3003 os
<< "keyIdentifier ";
3004 os
<< keyIdentifier
;
3008 if (NOT_NULL (date
))
3011 Indent (os
, indentG
);
3017 Indent (os
, indentG
);
3023 if (NOT_NULL (other
))
3026 Indent (os
, indentG
);
3032 Indent (os
, indentG
);
3039 indentG
-= stdIndentG
;
3040 Indent (os
, indentG
);
3043 } // KEKIdentifier::Print
3046 ExtendedCertificateInfo::ExtendedCertificateInfo()
3049 certificate
= new Certificate
;
3051 certificate
= NULL
; // incomplete initialization of mandatory element!
3055 ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo
&)
3057 Asn1Error
<< "use of incompletely defined ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo &)" << endl
;
3061 ExtendedCertificateInfo::~ExtendedCertificateInfo()
3066 AsnType
*ExtendedCertificateInfo::Clone() const
3068 return new ExtendedCertificateInfo
;
3071 AsnType
*ExtendedCertificateInfo::Copy() const
3073 return new ExtendedCertificateInfo (*this);
3077 ExtendedCertificateInfo
&ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo
&that
)
3078 #else // SNACC_DEEP_COPY
3079 ExtendedCertificateInfo
&ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo
&)
3080 #endif // SNACC_DEEP_COPY
3085 version
= that
.version
;
3086 if (that
.certificate
)
3089 certificate
= new Certificate
;
3090 *certificate
= *that
.certificate
;
3097 attributes
= that
.attributes
;
3101 #else // SNACC_DEEP_COPY
3102 Asn1Error
<< "use of incompletely defined ExtendedCertificateInfo &ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo &)" << endl
;
3104 // if your compiler complains here, check the -novolat option
3105 #endif // SNACC_DEEP_COPY
3109 ExtendedCertificateInfo::BEncContent (BUF_TYPE b
)
3111 AsnLen totalLen
= 0;
3115 l
= attributes
.BEncContent (b
);
3116 l
+= BEncConsLen (b
, l
);
3118 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
3122 l
= certificate
->BEncContent (b
);
3123 l
+= BEncConsLen (b
, l
);
3125 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3128 l
= version
.BEncContent (b
);
3129 BEncDefLenTo127 (b
, l
);
3132 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
3136 } // ExtendedCertificateInfo::BEncContent
3139 void ExtendedCertificateInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3142 AsnLen seqBytesDecoded
= 0;
3144 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3146 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
3148 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3149 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3150 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3154 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3155 SnaccExcep::throwMe(-132);
3158 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3160 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3161 certificate
= new Certificate
;
3162 certificate
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3163 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3167 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3168 SnaccExcep::throwMe(-133);
3171 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
3173 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3174 attributes
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3178 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3179 SnaccExcep::throwMe(-134);
3182 bytesDecoded
+= seqBytesDecoded
;
3183 if (elmtLen0
== INDEFINITE_LEN
)
3185 BDecEoc (b
, bytesDecoded
, env
);
3188 else if (seqBytesDecoded
!= elmtLen0
)
3190 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3191 SnaccExcep::throwMe(-135);
3195 } // ExtendedCertificateInfo::BDecContent
3197 AsnLen
ExtendedCertificateInfo::BEnc (BUF_TYPE b
)
3200 l
= BEncContent (b
);
3201 l
+= BEncConsLen (b
, l
);
3202 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3206 void ExtendedCertificateInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3211 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3213 Asn1Error
<< "ExtendedCertificateInfo::BDec: ERROR - wrong tag" << endl
;
3214 SnaccExcep::throwMe(-136);
3216 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3217 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3220 void ExtendedCertificateInfo::Print (ostream
&os
) const
3223 os
<< "{ -- SEQUENCE --" << endl
;
3224 indentG
+= stdIndentG
;
3227 Indent (os
, indentG
);
3233 if (NOT_NULL (certificate
))
3235 Indent (os
, indentG
);
3236 os
<< "certificate ";
3241 Indent (os
, indentG
);
3242 os
<< "certificate ";
3248 Indent (os
, indentG
);
3249 os
<< "attributes ";
3254 indentG
-= stdIndentG
;
3255 Indent (os
, indentG
);
3258 } // ExtendedCertificateInfo::Print
3261 SignerInfo::SignerInfo()
3264 sid
= new SignerIdentifier
;
3266 sid
= NULL
; // incomplete initialization of mandatory element!
3269 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3271 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3275 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3277 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3279 unsignedAttrs
= NULL
;
3282 SignerInfo::SignerInfo (const SignerInfo
&)
3284 Asn1Error
<< "use of incompletely defined SignerInfo::SignerInfo (const SignerInfo &)" << endl
;
3288 SignerInfo::~SignerInfo()
3291 delete digestAlgorithm
;
3293 delete signatureAlgorithm
;
3294 delete unsignedAttrs
;
3297 AsnType
*SignerInfo::Clone() const
3299 return new SignerInfo
;
3302 AsnType
*SignerInfo::Copy() const
3304 return new SignerInfo (*this);
3308 SignerInfo
&SignerInfo::operator = (const SignerInfo
&that
)
3309 #else // SNACC_DEEP_COPY
3310 SignerInfo
&SignerInfo::operator = (const SignerInfo
&)
3311 #endif // SNACC_DEEP_COPY
3316 version
= that
.version
;
3320 sid
= new SignerIdentifier
;
3328 if (that
.digestAlgorithm
)
3330 if (!digestAlgorithm
)
3331 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3332 *digestAlgorithm
= *that
.digestAlgorithm
;
3336 delete digestAlgorithm
;
3337 digestAlgorithm
= NULL
;
3339 if (that
.signedAttrs
)
3342 signedAttrs
= new Attributes
;
3343 *signedAttrs
= *that
.signedAttrs
;
3350 if (that
.signatureAlgorithm
)
3352 if (!signatureAlgorithm
)
3353 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3354 *signatureAlgorithm
= *that
.signatureAlgorithm
;
3358 delete signatureAlgorithm
;
3359 signatureAlgorithm
= NULL
;
3361 signature
= that
.signature
;
3362 if (that
.unsignedAttrs
)
3365 unsignedAttrs
= new Attributes
;
3366 *unsignedAttrs
= *that
.unsignedAttrs
;
3370 delete unsignedAttrs
;
3371 unsignedAttrs
= NULL
;
3376 #else // SNACC_DEEP_COPY
3377 Asn1Error
<< "use of incompletely defined SignerInfo &SignerInfo::operator = (const SignerInfo &)" << endl
;
3379 // if your compiler complains here, check the -novolat option
3380 #endif // SNACC_DEEP_COPY
3384 SignerInfo::BEncContent (BUF_TYPE b
)
3386 AsnLen totalLen
= 0;
3389 if (NOT_NULL (unsignedAttrs
))
3392 l
= unsignedAttrs
->BEncContent (b
);
3393 l
+= BEncConsLen (b
, l
);
3395 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
3399 l
= signature
.BEncContent (b
);
3400 l
+= BEncDefLen (b
, l
);
3402 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
3406 l
= signatureAlgorithm
->BEncContent (b
);
3407 l
+= BEncConsLen (b
, l
);
3409 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3412 if (NOT_NULL (signedAttrs
))
3415 l
= signedAttrs
->BEncContent (b
);
3416 l
+= BEncConsLen (b
, l
);
3418 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
3423 l
= digestAlgorithm
->BEncContent (b
);
3424 l
+= BEncConsLen (b
, l
);
3426 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3429 l
= sid
->BEncContent (b
);
3432 l
= version
.BEncContent (b
);
3433 BEncDefLenTo127 (b
, l
);
3436 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
3440 } // SignerInfo::BEncContent
3443 void SignerInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3446 AsnLen seqBytesDecoded
= 0;
3448 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3450 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
3452 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3453 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3454 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3458 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3459 SnaccExcep::throwMe(-137);
3462 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3463 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
3464 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
3466 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3467 sid
= new SignerIdentifier
;
3468 sid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3469 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3473 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3474 SnaccExcep::throwMe(-138);
3477 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3479 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3480 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3481 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3482 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3486 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3487 SnaccExcep::throwMe(-139);
3490 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
3492 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3493 signedAttrs
= new Attributes
;
3494 signedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3495 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3498 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3500 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3501 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3502 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3503 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3507 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3508 SnaccExcep::throwMe(-140);
3511 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
3512 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
3514 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3515 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3516 if (seqBytesDecoded
== elmtLen0
)
3518 bytesDecoded
+= seqBytesDecoded
;
3523 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3525 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
3527 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
3528 bytesDecoded
+= seqBytesDecoded
;
3535 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3536 SnaccExcep::throwMe(-141);
3539 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
3541 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3542 unsignedAttrs
= new Attributes
;
3543 unsignedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3546 bytesDecoded
+= seqBytesDecoded
;
3547 if (elmtLen0
== INDEFINITE_LEN
)
3549 BDecEoc (b
, bytesDecoded
, env
);
3552 else if (seqBytesDecoded
!= elmtLen0
)
3554 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3555 SnaccExcep::throwMe(-142);
3559 } // SignerInfo::BDecContent
3561 AsnLen
SignerInfo::BEnc (BUF_TYPE b
)
3564 l
= BEncContent (b
);
3565 l
+= BEncConsLen (b
, l
);
3566 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3570 void SignerInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3575 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3577 Asn1Error
<< "SignerInfo::BDec: ERROR - wrong tag" << endl
;
3578 SnaccExcep::throwMe(-143);
3580 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3581 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3584 void SignerInfo::Print (ostream
&os
) const
3587 os
<< "{ -- SEQUENCE --" << endl
;
3588 indentG
+= stdIndentG
;
3591 Indent (os
, indentG
);
3599 Indent (os
, indentG
);
3605 Indent (os
, indentG
);
3611 if (NOT_NULL (digestAlgorithm
))
3613 Indent (os
, indentG
);
3614 os
<< "digestAlgorithm ";
3615 os
<< *digestAlgorithm
;
3619 Indent (os
, indentG
);
3620 os
<< "digestAlgorithm ";
3625 if (NOT_NULL (signedAttrs
))
3627 Indent (os
, indentG
);
3628 os
<< "signedAttrs ";
3633 Indent (os
, indentG
);
3634 os
<< "signedAttrs ";
3639 if (NOT_NULL (signatureAlgorithm
))
3641 Indent (os
, indentG
);
3642 os
<< "signatureAlgorithm ";
3643 os
<< *signatureAlgorithm
;
3647 Indent (os
, indentG
);
3648 os
<< "signatureAlgorithm ";
3654 Indent (os
, indentG
);
3660 if (NOT_NULL (unsignedAttrs
))
3663 Indent (os
, indentG
);
3664 os
<< "unsignedAttrs ";
3665 os
<< *unsignedAttrs
;
3669 Indent (os
, indentG
);
3670 os
<< "unsignedAttrs ";
3676 indentG
-= stdIndentG
;
3677 Indent (os
, indentG
);
3680 } // SignerInfo::Print
3683 KeyTransRecipientInfo::KeyTransRecipientInfo()
3686 rid
= new RecipientIdentifier
;
3688 rid
= NULL
; // incomplete initialization of mandatory element!
3691 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
3693 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3697 KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo
&)
3699 Asn1Error
<< "use of incompletely defined KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo &)" << endl
;
3703 KeyTransRecipientInfo::~KeyTransRecipientInfo()
3706 delete keyEncryptionAlgorithm
;
3709 AsnType
*KeyTransRecipientInfo::Clone() const
3711 return new KeyTransRecipientInfo
;
3714 AsnType
*KeyTransRecipientInfo::Copy() const
3716 return new KeyTransRecipientInfo (*this);
3720 KeyTransRecipientInfo
&KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo
&that
)
3721 #else // SNACC_DEEP_COPY
3722 KeyTransRecipientInfo
&KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo
&)
3723 #endif // SNACC_DEEP_COPY
3728 version
= that
.version
;
3732 rid
= new RecipientIdentifier
;
3740 if (that
.keyEncryptionAlgorithm
)
3742 if (!keyEncryptionAlgorithm
)
3743 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
3744 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
3748 delete keyEncryptionAlgorithm
;
3749 keyEncryptionAlgorithm
= NULL
;
3751 encryptedKey
= that
.encryptedKey
;
3755 #else // SNACC_DEEP_COPY
3756 Asn1Error
<< "use of incompletely defined KeyTransRecipientInfo &KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo &)" << endl
;
3758 // if your compiler complains here, check the -novolat option
3759 #endif // SNACC_DEEP_COPY
3763 KeyTransRecipientInfo::BEncContent (BUF_TYPE b
)
3765 AsnLen totalLen
= 0;
3768 l
= encryptedKey
.BEncContent (b
);
3769 l
+= BEncDefLen (b
, l
);
3771 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
3775 l
= keyEncryptionAlgorithm
->BEncContent (b
);
3776 l
+= BEncConsLen (b
, l
);
3778 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3781 l
= rid
->BEncContent (b
);
3784 l
= version
.BEncContent (b
);
3785 BEncDefLenTo127 (b
, l
);
3788 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
3792 } // KeyTransRecipientInfo::BEncContent
3795 void KeyTransRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3798 AsnLen seqBytesDecoded
= 0;
3800 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3802 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
3804 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3805 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3806 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3810 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3811 SnaccExcep::throwMe(-144);
3814 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3815 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
3816 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
3818 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3819 rid
= new RecipientIdentifier
;
3820 rid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3821 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3825 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3826 SnaccExcep::throwMe(-145);
3829 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3831 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3832 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
3833 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3834 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3838 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3839 SnaccExcep::throwMe(-146);
3842 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
3843 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
3845 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3846 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3850 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3851 SnaccExcep::throwMe(-147);
3854 bytesDecoded
+= seqBytesDecoded
;
3855 if (elmtLen0
== INDEFINITE_LEN
)
3857 BDecEoc (b
, bytesDecoded
, env
);
3860 else if (seqBytesDecoded
!= elmtLen0
)
3862 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3863 SnaccExcep::throwMe(-148);
3867 } // KeyTransRecipientInfo::BDecContent
3869 AsnLen
KeyTransRecipientInfo::BEnc (BUF_TYPE b
)
3872 l
= BEncContent (b
);
3873 l
+= BEncConsLen (b
, l
);
3874 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3878 void KeyTransRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3883 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3885 Asn1Error
<< "KeyTransRecipientInfo::BDec: ERROR - wrong tag" << endl
;
3886 SnaccExcep::throwMe(-149);
3888 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3889 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3892 void KeyTransRecipientInfo::Print (ostream
&os
) const
3895 os
<< "{ -- SEQUENCE --" << endl
;
3896 indentG
+= stdIndentG
;
3899 Indent (os
, indentG
);
3907 Indent (os
, indentG
);
3913 Indent (os
, indentG
);
3919 if (NOT_NULL (keyEncryptionAlgorithm
))
3921 Indent (os
, indentG
);
3922 os
<< "keyEncryptionAlgorithm ";
3923 os
<< *keyEncryptionAlgorithm
;
3927 Indent (os
, indentG
);
3928 os
<< "keyEncryptionAlgorithm ";
3934 Indent (os
, indentG
);
3935 os
<< "encryptedKey ";
3940 indentG
-= stdIndentG
;
3941 Indent (os
, indentG
);
3944 } // KeyTransRecipientInfo::Print
3947 KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier()
3949 choiceId
= issuerAndSerialNumberCid
;
3951 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
3953 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
3957 KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier
&)
3959 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &)" << endl
;
3963 KeyAgreeRecipientIdentifier::~KeyAgreeRecipientIdentifier()
3967 case issuerAndSerialNumberCid
:
3968 delete issuerAndSerialNumber
;
3974 } // end of destructor
3976 AsnType
*KeyAgreeRecipientIdentifier::Clone() const
3978 return new KeyAgreeRecipientIdentifier
;
3981 AsnType
*KeyAgreeRecipientIdentifier::Copy() const
3983 return new KeyAgreeRecipientIdentifier (*this);
3987 KeyAgreeRecipientIdentifier
&KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier
&that
)
3988 #else // SNACC_DEEP_COPY
3989 KeyAgreeRecipientIdentifier
&KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier
&)
3990 #endif // SNACC_DEEP_COPY
3997 case issuerAndSerialNumberCid
:
3998 delete issuerAndSerialNumber
;
4004 switch (choiceId
= that
.choiceId
)
4006 case issuerAndSerialNumberCid
:
4007 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
4008 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
4011 rKeyId
= new RecipientKeyIdentifier
;
4012 *rKeyId
= *that
.rKeyId
;
4018 #else // SNACC_DEEP_COPY
4019 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientIdentifier &KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier &)" << endl
;
4021 // if your compiler complains here, check the -novolat option
4022 #endif // SNACC_DEEP_COPY
4026 KeyAgreeRecipientIdentifier::BEncContent (BUF_TYPE b
)
4031 case issuerAndSerialNumberCid
:
4033 l
= issuerAndSerialNumber
->BEncContent (b
);
4034 l
+= BEncConsLen (b
, l
);
4036 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4041 l
= rKeyId
->BEncContent (b
);
4042 l
+= BEncConsLen (b
, l
);
4044 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
4049 } // KeyAgreeRecipientIdentifier::BEncContent
4052 void KeyAgreeRecipientIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4056 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
4057 choiceId
= issuerAndSerialNumberCid
;
4058 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
4059 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
4062 case MAKE_TAG_ID (CNTX
, CONS
, 0):
4063 choiceId
= rKeyIdCid
;
4064 rKeyId
= new RecipientKeyIdentifier
;
4065 rKeyId
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
4069 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
4070 SnaccExcep::throwMe(-150);
4073 } // KeyAgreeRecipientIdentifier::BDecContent
4076 AsnLen
KeyAgreeRecipientIdentifier::BEnc (BUF_TYPE b
)
4079 l
= BEncContent (b
);
4083 void KeyAgreeRecipientIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4088 /* CHOICEs are a special case - grab identifying tag */
4089 /* this allows easier handling of nested CHOICEs */
4090 tag
= BDecTag (b
, bytesDecoded
, env
);
4091 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
4092 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
4095 void KeyAgreeRecipientIdentifier::Print (ostream
&os
) const
4100 case issuerAndSerialNumberCid
:
4101 os
<< "issuerAndSerialNumber ";
4102 if (issuerAndSerialNumber
)
4103 os
<< *issuerAndSerialNumber
;
4105 os
<< "-- void3 --\n";
4113 os
<< "-- void3 --\n";
4118 } // KeyAgreeRecipientIdentifier::Print
4120 KEKRecipientInfo::KEKRecipientInfo()
4123 kekid
= new KEKIdentifier
;
4125 kekid
= NULL
; // incomplete initialization of mandatory element!
4128 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4130 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
4134 KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo
&)
4136 Asn1Error
<< "use of incompletely defined KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo &)" << endl
;
4140 KEKRecipientInfo::~KEKRecipientInfo()
4143 delete keyEncryptionAlgorithm
;
4146 AsnType
*KEKRecipientInfo::Clone() const
4148 return new KEKRecipientInfo
;
4151 AsnType
*KEKRecipientInfo::Copy() const
4153 return new KEKRecipientInfo (*this);
4157 KEKRecipientInfo
&KEKRecipientInfo::operator = (const KEKRecipientInfo
&that
)
4158 #else // SNACC_DEEP_COPY
4159 KEKRecipientInfo
&KEKRecipientInfo::operator = (const KEKRecipientInfo
&)
4160 #endif // SNACC_DEEP_COPY
4165 version
= that
.version
;
4169 kekid
= new KEKIdentifier
;
4170 *kekid
= *that
.kekid
;
4177 if (that
.keyEncryptionAlgorithm
)
4179 if (!keyEncryptionAlgorithm
)
4180 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4181 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
4185 delete keyEncryptionAlgorithm
;
4186 keyEncryptionAlgorithm
= NULL
;
4188 encryptedKey
= that
.encryptedKey
;
4192 #else // SNACC_DEEP_COPY
4193 Asn1Error
<< "use of incompletely defined KEKRecipientInfo &KEKRecipientInfo::operator = (const KEKRecipientInfo &)" << endl
;
4195 // if your compiler complains here, check the -novolat option
4196 #endif // SNACC_DEEP_COPY
4200 KEKRecipientInfo::BEncContent (BUF_TYPE b
)
4202 AsnLen totalLen
= 0;
4205 l
= encryptedKey
.BEncContent (b
);
4206 l
+= BEncDefLen (b
, l
);
4208 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
4212 l
= keyEncryptionAlgorithm
->BEncContent (b
);
4213 l
+= BEncConsLen (b
, l
);
4215 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4219 l
= kekid
->BEncContent (b
);
4220 l
+= BEncConsLen (b
, l
);
4222 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4225 l
= version
.BEncContent (b
);
4226 BEncDefLenTo127 (b
, l
);
4229 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
4233 } // KEKRecipientInfo::BEncContent
4236 void KEKRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4239 AsnLen seqBytesDecoded
= 0;
4241 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4243 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
4245 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4246 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4247 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4251 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4252 SnaccExcep::throwMe(-151);
4255 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4257 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4258 kekid
= new KEKIdentifier
;
4259 kekid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4260 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4264 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4265 SnaccExcep::throwMe(-152);
4268 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4270 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4271 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4272 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4273 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4277 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4278 SnaccExcep::throwMe(-153);
4281 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
4282 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
4284 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4285 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4289 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4290 SnaccExcep::throwMe(-154);
4293 bytesDecoded
+= seqBytesDecoded
;
4294 if (elmtLen0
== INDEFINITE_LEN
)
4296 BDecEoc (b
, bytesDecoded
, env
);
4299 else if (seqBytesDecoded
!= elmtLen0
)
4301 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
4302 SnaccExcep::throwMe(-155);
4306 } // KEKRecipientInfo::BDecContent
4308 AsnLen
KEKRecipientInfo::BEnc (BUF_TYPE b
)
4311 l
= BEncContent (b
);
4312 l
+= BEncConsLen (b
, l
);
4313 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4317 void KEKRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4322 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4324 Asn1Error
<< "KEKRecipientInfo::BDec: ERROR - wrong tag" << endl
;
4325 SnaccExcep::throwMe(-156);
4327 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4328 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4331 void KEKRecipientInfo::Print (ostream
&os
) const
4334 os
<< "{ -- SEQUENCE --" << endl
;
4335 indentG
+= stdIndentG
;
4338 Indent (os
, indentG
);
4344 if (NOT_NULL (kekid
))
4346 Indent (os
, indentG
);
4352 Indent (os
, indentG
);
4358 if (NOT_NULL (keyEncryptionAlgorithm
))
4360 Indent (os
, indentG
);
4361 os
<< "keyEncryptionAlgorithm ";
4362 os
<< *keyEncryptionAlgorithm
;
4366 Indent (os
, indentG
);
4367 os
<< "keyEncryptionAlgorithm ";
4373 Indent (os
, indentG
);
4374 os
<< "encryptedKey ";
4379 indentG
-= stdIndentG
;
4380 Indent (os
, indentG
);
4383 } // KEKRecipientInfo::Print
4386 ExtendedCertificate::ExtendedCertificate()
4389 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4391 extendedCertificateInfo
= NULL
; // incomplete initialization of mandatory element!
4394 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4396 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
4400 ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate
&)
4402 Asn1Error
<< "use of incompletely defined ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate &)" << endl
;
4406 ExtendedCertificate::~ExtendedCertificate()
4408 delete extendedCertificateInfo
;
4409 delete signatureAlgorithm
;
4412 AsnType
*ExtendedCertificate::Clone() const
4414 return new ExtendedCertificate
;
4417 AsnType
*ExtendedCertificate::Copy() const
4419 return new ExtendedCertificate (*this);
4423 ExtendedCertificate
&ExtendedCertificate::operator = (const ExtendedCertificate
&that
)
4424 #else // SNACC_DEEP_COPY
4425 ExtendedCertificate
&ExtendedCertificate::operator = (const ExtendedCertificate
&)
4426 #endif // SNACC_DEEP_COPY
4431 if (that
.extendedCertificateInfo
)
4433 if (!extendedCertificateInfo
)
4434 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4435 *extendedCertificateInfo
= *that
.extendedCertificateInfo
;
4439 delete extendedCertificateInfo
;
4440 extendedCertificateInfo
= NULL
;
4442 if (that
.signatureAlgorithm
)
4444 if (!signatureAlgorithm
)
4445 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4446 *signatureAlgorithm
= *that
.signatureAlgorithm
;
4450 delete signatureAlgorithm
;
4451 signatureAlgorithm
= NULL
;
4453 signature
= that
.signature
;
4457 #else // SNACC_DEEP_COPY
4458 Asn1Error
<< "use of incompletely defined ExtendedCertificate &ExtendedCertificate::operator = (const ExtendedCertificate &)" << endl
;
4460 // if your compiler complains here, check the -novolat option
4461 #endif // SNACC_DEEP_COPY
4465 ExtendedCertificate::BEncContent (BUF_TYPE b
)
4467 AsnLen totalLen
= 0;
4470 l
= signature
.BEncContent (b
);
4471 l
+= BEncDefLen (b
, l
);
4473 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
4477 l
= signatureAlgorithm
->BEncContent (b
);
4478 l
+= BEncConsLen (b
, l
);
4480 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4484 l
= extendedCertificateInfo
->BEncContent (b
);
4485 l
+= BEncConsLen (b
, l
);
4487 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4491 } // ExtendedCertificate::BEncContent
4494 void ExtendedCertificate::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4497 AsnLen seqBytesDecoded
= 0;
4499 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4501 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4503 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4504 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4505 extendedCertificateInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4506 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4510 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4511 SnaccExcep::throwMe(-157);
4514 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4516 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4517 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4518 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4519 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4523 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4524 SnaccExcep::throwMe(-158);
4527 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
4528 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
4530 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4531 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4535 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4536 SnaccExcep::throwMe(-159);
4539 bytesDecoded
+= seqBytesDecoded
;
4540 if (elmtLen0
== INDEFINITE_LEN
)
4542 BDecEoc (b
, bytesDecoded
, env
);
4545 else if (seqBytesDecoded
!= elmtLen0
)
4547 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
4548 SnaccExcep::throwMe(-160);
4552 } // ExtendedCertificate::BDecContent
4554 AsnLen
ExtendedCertificate::BEnc (BUF_TYPE b
)
4557 l
= BEncContent (b
);
4558 l
+= BEncConsLen (b
, l
);
4559 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4563 void ExtendedCertificate::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4568 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4570 Asn1Error
<< "ExtendedCertificate::BDec: ERROR - wrong tag" << endl
;
4571 SnaccExcep::throwMe(-161);
4573 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4574 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4577 void ExtendedCertificate::Print (ostream
&os
) const
4580 os
<< "{ -- SEQUENCE --" << endl
;
4581 indentG
+= stdIndentG
;
4583 if (NOT_NULL (extendedCertificateInfo
))
4585 Indent (os
, indentG
);
4586 os
<< "extendedCertificateInfo ";
4587 os
<< *extendedCertificateInfo
;
4591 Indent (os
, indentG
);
4592 os
<< "extendedCertificateInfo ";
4597 if (NOT_NULL (signatureAlgorithm
))
4599 Indent (os
, indentG
);
4600 os
<< "signatureAlgorithm ";
4601 os
<< *signatureAlgorithm
;
4605 Indent (os
, indentG
);
4606 os
<< "signatureAlgorithm ";
4612 Indent (os
, indentG
);
4618 indentG
-= stdIndentG
;
4619 Indent (os
, indentG
);
4622 } // ExtendedCertificate::Print
4625 AsnType
*SignerInfos::Clone() const
4627 return new SignerInfos
;
4630 AsnType
*SignerInfos::Copy() const
4632 return new SignerInfos (*this);
4635 AsnLen
SignerInfos::BEnc (BUF_TYPE b
)
4638 l
= BEncContent (b
);
4639 l
+= BEncConsLen (b
, l
);
4640 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
4644 void SignerInfos::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4649 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
4651 Asn1Error
<< "SignerInfos::BDec: ERROR - wrong tag" << endl
;
4652 SnaccExcep::throwMe(-162);
4654 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4655 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4658 SignerInfos::SignerInfos (const SignerInfos
&)
4660 Asn1Error
<< "use of incompletely defined SignerInfos::SignerInfos (const SignerInfos &)" << endl
;
4664 SignerInfos::~SignerInfos()
4667 for (; Curr() != NULL
; RemoveCurrFromList())
4669 } // end of destructor
4672 SignerInfos
&SignerInfos::operator = (const SignerInfos
&that
)
4673 #else // SNACC_DEEP_COPY
4674 SignerInfos
&SignerInfos::operator = (const SignerInfos
&)
4675 #endif // SNACC_DEEP_COPY
4681 for (; Curr(); RemoveCurrFromList())
4684 //that.SetCurrToFirst();
4685 //for (; that.Curr(); that.GoNext())
4686 // AppendCopy (*that.Curr());
4687 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
4688 AppendCopy (*run
->elmt
);
4692 #else // SNACC_DEEP_COPY
4693 Asn1Error
<< "use of incompletely defined SignerInfos &SignerInfos::operator = (const SignerInfos &)" << endl
;
4695 // if your compiler complains here, check the -novolat option
4696 #endif // SNACC_DEEP_COPY
4699 void SignerInfos::Print (ostream
&os
) const
4702 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
4703 indentG
+= stdIndentG
;
4705 //for (; Curr() != NULL; GoNext())
4706 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
4708 Indent (os
, indentG
);
4711 //if (Curr() != Last())
4716 indentG
-= stdIndentG
;
4717 Indent (os
, indentG
);
4725 void SignerInfos::SetCurrElmt (unsigned long int index
)
4727 unsigned long int i
;
4730 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
4732 } // SignerInfos::SetCurrElmt
4735 unsigned long int SignerInfos::GetCurrElmtIndex()
4737 unsigned long int i
;
4741 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
4750 } // SignerInfos::GetCurrElmtIndex
4753 // alloc new list elmt, put at end of list
4754 // and return the component type
4755 SignerInfo
*SignerInfos::Append()
4757 AsnListElmt
*newElmt
;
4758 newElmt
= new AsnListElmt
;
4759 newElmt
->elmt
= new SignerInfo
;
4760 newElmt
->next
= NULL
;
4763 newElmt
->prev
= NULL
;
4764 first
= last
= newElmt
;
4768 newElmt
->prev
= last
;
4769 last
->next
= newElmt
;
4773 return (curr
= newElmt
)->elmt
;
4774 } // SignerInfos::Append
4777 // alloc new list elmt, put at begining of list
4778 // and return the component type
4779 SignerInfo
*SignerInfos::Prepend()
4781 AsnListElmt
*newElmt
;
4782 newElmt
= new AsnListElmt
;
4783 newElmt
->elmt
= new SignerInfo
;
4784 newElmt
->prev
= NULL
;
4787 newElmt
->next
= NULL
;
4788 first
= last
= newElmt
;
4792 newElmt
->next
= first
;
4793 first
->prev
= newElmt
;
4797 return (curr
= newElmt
)->elmt
;
4798 } // SignerInfos::Prepend
4801 // alloc new list elmt, insert it before the
4802 // current element and return the component type
4803 // if the current element is null, the new element
4804 // is placed at the beginning of the list.
4805 SignerInfo
*SignerInfos::InsertBefore()
4807 AsnListElmt
*newElmt
;
4808 newElmt
= new AsnListElmt
;
4809 newElmt
->elmt
= new SignerInfo
;
4812 newElmt
->next
= first
;
4813 newElmt
->prev
= NULL
;
4820 newElmt
->next
= curr
;
4821 newElmt
->prev
= curr
->prev
;
4822 curr
->prev
= newElmt
;
4826 newElmt
->prev
->next
= newElmt
;
4829 return (curr
= newElmt
)->elmt
;
4830 } // SignerInfos::InsertBefore
4833 // alloc new list elmt, insert it after the
4834 // current element and return the component type
4835 // if the current element is null, the new element
4836 // is placed at the end of the list.
4837 SignerInfo
*SignerInfos::InsertAfter()
4839 AsnListElmt
*newElmt
;
4840 newElmt
= new AsnListElmt
;
4841 newElmt
->elmt
= new SignerInfo
;
4844 newElmt
->prev
= last
;
4845 newElmt
->next
= NULL
;
4852 newElmt
->prev
= curr
;
4853 newElmt
->next
= curr
->next
;
4854 curr
->next
= newElmt
;
4858 newElmt
->next
->prev
= newElmt
;
4861 return (curr
= newElmt
)->elmt
;
4862 } // SignerInfos::InsertAfter
4865 SignerInfos
&SignerInfos::AppendCopy (SignerInfo
&elmt
)
4867 AsnListElmt
*newElmt
;
4868 newElmt
= new AsnListElmt
;
4869 newElmt
->elmt
= new SignerInfo
;
4870 *newElmt
->elmt
= elmt
;
4871 newElmt
->next
= NULL
;
4874 newElmt
->prev
= NULL
;
4875 first
= last
= newElmt
;
4879 newElmt
->prev
= last
;
4880 last
->next
= newElmt
;
4888 SignerInfos
&SignerInfos::PrependCopy (SignerInfo
&elmt
)
4890 AsnListElmt
*newElmt
;
4891 newElmt
= new AsnListElmt
;
4892 newElmt
->elmt
= new SignerInfo
;
4893 *newElmt
->elmt
= elmt
;
4894 newElmt
->prev
= NULL
;
4897 newElmt
->next
= NULL
;
4898 first
= last
= newElmt
;
4902 newElmt
->next
= first
;
4903 first
->prev
= newElmt
;
4908 } // SignerInfos::PrependCopy
4911 // alloc new list elmt, insert it before the
4912 // current element, copy the given elmt into the new elmt
4913 // and return the component type.
4914 // if the current element is null, the new element
4915 // is placed at the beginning of the list.
4916 SignerInfos
&SignerInfos::InsertBeforeAndCopy (SignerInfo
&elmt
)
4918 AsnListElmt
*newElmt
;
4920 newElmt
= new AsnListElmt
;
4921 newElmt
->elmt
= new SignerInfo
;
4922 *newElmt
->elmt
= elmt
;
4926 newElmt
->next
= first
;
4927 newElmt
->prev
= NULL
;
4934 newElmt
->next
= curr
;
4935 newElmt
->prev
= curr
->prev
;
4936 curr
->prev
= newElmt
;
4940 newElmt
->prev
->next
= newElmt
;
4944 } // SignerInfos::InsertBeforeAndCopy
4947 // alloc new list elmt, insert it after the
4948 // current element, copy given elmt in to new elmt
4949 // and return the component type
4950 // if the current element is null, the new element
4951 // is placed at the end of the list.
4952 SignerInfos
&SignerInfos::InsertAfterAndCopy (SignerInfo
&elmt
)
4954 AsnListElmt
*newElmt
;
4956 newElmt
= new AsnListElmt
;
4957 newElmt
->elmt
= new SignerInfo
;
4958 *newElmt
->elmt
= elmt
;
4961 newElmt
->prev
= last
;
4962 newElmt
->next
= NULL
;
4969 newElmt
->prev
= curr
;
4970 newElmt
->next
= curr
->next
;
4971 curr
->next
= newElmt
;
4975 newElmt
->next
->prev
= newElmt
;
4979 } // SignerInfos::InsertAfterAndCopy
4982 // remove current element from list if current element is not NULL
4983 // The new current element will be the next element.
4984 // If the current element is the last element in the list
4985 // the second but last element will become the new current element.
4986 void SignerInfos::RemoveCurrFromList()
4988 AsnListElmt
*del_elmt
;
4996 first
= last
= curr
= NULL
;
4997 else if (curr
== first
)
4999 curr
= first
= first
->next
;
5002 else if (curr
== last
)
5004 curr
= last
= last
->prev
;
5009 curr
->prev
->next
= curr
->next
;
5010 curr
->next
->prev
= curr
->prev
;
5013 delete del_elmt
->elmt
;
5019 AsnLen
SignerInfos::BEncContent (BUF_TYPE b
)
5021 AsnListElmt
*currElmt
;
5023 AsnLen totalLen
= 0;
5026 CSM_Buffer
**tmpEnc
=NULL
;
5027 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
5028 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
5029 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
5032 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
5033 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
5035 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
5036 ENCODE_BUF2(tmpEnc
[iii
]);
5038 vdasnacc_sortSetOf(tmpEnc
, icount
);
5039 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
5040 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
5041 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
5044 totalLen
+= elmtLen
;
5046 } // SignerInfos::BEncContent
5049 void SignerInfos::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
5050 AsnLen
&bytesDecoded
, ENV_TYPE env
)
5052 SignerInfo
*listElmt
;
5054 AsnLen listBytesDecoded
= 0;
5057 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
5059 tag1
= BDecTag (b
, listBytesDecoded
, env
);
5060 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
5062 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
5065 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
5067 Asn1Error
<< "Unexpected Tag" << endl
;
5068 SnaccExcep::throwMe(-163);
5071 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
5072 listElmt
= Append();
5073 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
5076 bytesDecoded
+= listBytesDecoded
;
5077 } // SignerInfos::BDecContent
5080 RecipientEncryptedKey::RecipientEncryptedKey()
5083 rid
= new KeyAgreeRecipientIdentifier
;
5085 rid
= NULL
; // incomplete initialization of mandatory element!
5089 RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey
&)
5091 Asn1Error
<< "use of incompletely defined RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey &)" << endl
;
5095 RecipientEncryptedKey::~RecipientEncryptedKey()
5100 AsnType
*RecipientEncryptedKey::Clone() const
5102 return new RecipientEncryptedKey
;
5105 AsnType
*RecipientEncryptedKey::Copy() const
5107 return new RecipientEncryptedKey (*this);
5111 RecipientEncryptedKey
&RecipientEncryptedKey::operator = (const RecipientEncryptedKey
&that
)
5112 #else // SNACC_DEEP_COPY
5113 RecipientEncryptedKey
&RecipientEncryptedKey::operator = (const RecipientEncryptedKey
&)
5114 #endif // SNACC_DEEP_COPY
5122 rid
= new KeyAgreeRecipientIdentifier
;
5130 encryptedKey
= that
.encryptedKey
;
5134 #else // SNACC_DEEP_COPY
5135 Asn1Error
<< "use of incompletely defined RecipientEncryptedKey &RecipientEncryptedKey::operator = (const RecipientEncryptedKey &)" << endl
;
5137 // if your compiler complains here, check the -novolat option
5138 #endif // SNACC_DEEP_COPY
5142 RecipientEncryptedKey::BEncContent (BUF_TYPE b
)
5144 AsnLen totalLen
= 0;
5147 l
= encryptedKey
.BEncContent (b
);
5148 l
+= BEncDefLen (b
, l
);
5150 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
5153 l
= rid
->BEncContent (b
);
5157 } // RecipientEncryptedKey::BEncContent
5160 void RecipientEncryptedKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5163 AsnLen seqBytesDecoded
= 0;
5165 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
5167 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
5168 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
5170 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
5171 rid
= new KeyAgreeRecipientIdentifier
;
5172 rid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
5173 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
5177 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
5178 SnaccExcep::throwMe(-164);
5181 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
5182 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
5184 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
5185 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
5189 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
5190 SnaccExcep::throwMe(-165);
5193 bytesDecoded
+= seqBytesDecoded
;
5194 if (elmtLen0
== INDEFINITE_LEN
)
5196 BDecEoc (b
, bytesDecoded
, env
);
5199 else if (seqBytesDecoded
!= elmtLen0
)
5201 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
5202 SnaccExcep::throwMe(-166);
5206 } // RecipientEncryptedKey::BDecContent
5208 AsnLen
RecipientEncryptedKey::BEnc (BUF_TYPE b
)
5211 l
= BEncContent (b
);
5212 l
+= BEncConsLen (b
, l
);
5213 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
5217 void RecipientEncryptedKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5222 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
5224 Asn1Error
<< "RecipientEncryptedKey::BDec: ERROR - wrong tag" << endl
;
5225 SnaccExcep::throwMe(-167);
5227 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
5228 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
5231 void RecipientEncryptedKey::Print (ostream
&os
) const
5234 os
<< "{ -- SEQUENCE --" << endl
;
5235 indentG
+= stdIndentG
;
5239 Indent (os
, indentG
);
5245 Indent (os
, indentG
);
5252 Indent (os
, indentG
);
5253 os
<< "encryptedKey ";
5258 indentG
-= stdIndentG
;
5259 Indent (os
, indentG
);
5262 } // RecipientEncryptedKey::Print
5265 CertificateChoices::CertificateChoices()
5267 choiceId
= certificateCid
;
5269 certificate
= new Certificate
;
5271 certificate
= NULL
; // incomplete initialization of mandatory element!
5275 CertificateChoices::CertificateChoices (const CertificateChoices
&)
5277 Asn1Error
<< "use of incompletely defined CertificateChoices::CertificateChoices (const CertificateChoices &)" << endl
;
5281 CertificateChoices::~CertificateChoices()
5285 case certificateCid
:
5288 case extendedCertificateCid
:
5289 delete extendedCertificate
;
5295 } // end of destructor
5297 AsnType
*CertificateChoices::Clone() const
5299 return new CertificateChoices
;
5302 AsnType
*CertificateChoices::Copy() const
5304 return new CertificateChoices (*this);
5308 CertificateChoices
&CertificateChoices::operator = (const CertificateChoices
&that
)
5309 #else // SNACC_DEEP_COPY
5310 CertificateChoices
&CertificateChoices::operator = (const CertificateChoices
&)
5311 #endif // SNACC_DEEP_COPY
5318 case certificateCid
:
5321 case extendedCertificateCid
:
5322 delete extendedCertificate
;
5328 switch (choiceId
= that
.choiceId
)
5330 case certificateCid
:
5331 certificate
= new Certificate
;
5332 *certificate
= *that
.certificate
;
5334 case extendedCertificateCid
:
5335 extendedCertificate
= new ExtendedCertificate
;
5336 *extendedCertificate
= *that
.extendedCertificate
;
5339 attrCert
= new AttributeCertificate
;
5340 *attrCert
= *that
.attrCert
;
5346 #else // SNACC_DEEP_COPY
5347 Asn1Error
<< "use of incompletely defined CertificateChoices &CertificateChoices::operator = (const CertificateChoices &)" << endl
;
5349 // if your compiler complains here, check the -novolat option
5350 #endif // SNACC_DEEP_COPY
5354 CertificateChoices::BEncContent (BUF_TYPE b
)
5359 case certificateCid
:
5361 l
= certificate
->BEncContent (b
);
5362 l
+= BEncConsLen (b
, l
);
5364 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
5367 case extendedCertificateCid
:
5369 l
= extendedCertificate
->BEncContent (b
);
5370 l
+= BEncConsLen (b
, l
);
5372 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
5377 l
= attrCert
->BEncContent (b
);
5378 l
+= BEncConsLen (b
, l
);
5380 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
5385 } // CertificateChoices::BEncContent
5388 void CertificateChoices::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5392 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
5393 choiceId
= certificateCid
;
5394 certificate
= new Certificate
;
5395 certificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5398 case MAKE_TAG_ID (CNTX
, CONS
, 0):
5399 choiceId
= extendedCertificateCid
;
5400 extendedCertificate
= new ExtendedCertificate
;
5401 extendedCertificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5404 case MAKE_TAG_ID (CNTX
, CONS
, 1):
5405 choiceId
= attrCertCid
;
5406 attrCert
= new AttributeCertificate
;
5407 attrCert
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5411 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
5412 SnaccExcep::throwMe(-168);
5415 } // CertificateChoices::BDecContent
5418 AsnLen
CertificateChoices::BEnc (BUF_TYPE b
)
5421 l
= BEncContent (b
);
5425 void CertificateChoices::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5430 /* CHOICEs are a special case - grab identifying tag */
5431 /* this allows easier handling of nested CHOICEs */
5432 tag
= BDecTag (b
, bytesDecoded
, env
);
5433 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
5434 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
5437 void CertificateChoices::Print (ostream
&os
) const
5442 case certificateCid
:
5443 os
<< "certificate ";
5447 os
<< "-- void3 --\n";
5450 case extendedCertificateCid
:
5451 os
<< "extendedCertificate ";
5452 if (extendedCertificate
)
5453 os
<< *extendedCertificate
;
5455 os
<< "-- void3 --\n";
5463 os
<< "-- void3 --\n";
5468 } // CertificateChoices::Print
5470 AsnType
*CertificateSet::Clone() const
5472 return new CertificateSet
;
5475 AsnType
*CertificateSet::Copy() const
5477 return new CertificateSet (*this);
5480 AsnLen
CertificateSet::BEnc (BUF_TYPE b
)
5483 l
= BEncContent (b
);
5484 l
+= BEncConsLen (b
, l
);
5485 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
5489 void CertificateSet::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5494 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
5496 Asn1Error
<< "CertificateSet::BDec: ERROR - wrong tag" << endl
;
5497 SnaccExcep::throwMe(-169);
5499 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
5500 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
5503 CertificateSet::CertificateSet (const CertificateSet
&)
5505 Asn1Error
<< "use of incompletely defined CertificateSet::CertificateSet (const CertificateSet &)" << endl
;
5509 CertificateSet::~CertificateSet()
5512 for (; Curr() != NULL
; RemoveCurrFromList())
5514 } // end of destructor
5517 CertificateSet
&CertificateSet::operator = (const CertificateSet
&that
)
5518 #else // SNACC_DEEP_COPY
5519 CertificateSet
&CertificateSet::operator = (const CertificateSet
&)
5520 #endif // SNACC_DEEP_COPY
5526 for (; Curr(); RemoveCurrFromList())
5529 //that.SetCurrToFirst();
5530 //for (; that.Curr(); that.GoNext())
5531 // AppendCopy (*that.Curr());
5532 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
5533 AppendCopy (*run
->elmt
);
5537 #else // SNACC_DEEP_COPY
5538 Asn1Error
<< "use of incompletely defined CertificateSet &CertificateSet::operator = (const CertificateSet &)" << endl
;
5540 // if your compiler complains here, check the -novolat option
5541 #endif // SNACC_DEEP_COPY
5544 void CertificateSet::Print (ostream
&os
) const
5547 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
5548 indentG
+= stdIndentG
;
5550 //for (; Curr() != NULL; GoNext())
5551 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
5553 Indent (os
, indentG
);
5556 //if (Curr() != Last())
5561 indentG
-= stdIndentG
;
5562 Indent (os
, indentG
);
5570 void CertificateSet::SetCurrElmt (unsigned long int index
)
5572 unsigned long int i
;
5575 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
5577 } // CertificateSet::SetCurrElmt
5580 unsigned long int CertificateSet::GetCurrElmtIndex()
5582 unsigned long int i
;
5586 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
5595 } // CertificateSet::GetCurrElmtIndex
5598 // alloc new list elmt, put at end of list
5599 // and return the component type
5600 CertificateChoices
*CertificateSet::Append()
5602 AsnListElmt
*newElmt
;
5603 newElmt
= new AsnListElmt
;
5604 newElmt
->elmt
= new CertificateChoices
;
5605 newElmt
->next
= NULL
;
5608 newElmt
->prev
= NULL
;
5609 first
= last
= newElmt
;
5613 newElmt
->prev
= last
;
5614 last
->next
= newElmt
;
5618 return (curr
= newElmt
)->elmt
;
5619 } // CertificateSet::Append
5622 // alloc new list elmt, put at begining of list
5623 // and return the component type
5624 CertificateChoices
*CertificateSet::Prepend()
5626 AsnListElmt
*newElmt
;
5627 newElmt
= new AsnListElmt
;
5628 newElmt
->elmt
= new CertificateChoices
;
5629 newElmt
->prev
= NULL
;
5632 newElmt
->next
= NULL
;
5633 first
= last
= newElmt
;
5637 newElmt
->next
= first
;
5638 first
->prev
= newElmt
;
5642 return (curr
= newElmt
)->elmt
;
5643 } // CertificateSet::Prepend
5646 // alloc new list elmt, insert it before the
5647 // current element and return the component type
5648 // if the current element is null, the new element
5649 // is placed at the beginning of the list.
5650 CertificateChoices
*CertificateSet::InsertBefore()
5652 AsnListElmt
*newElmt
;
5653 newElmt
= new AsnListElmt
;
5654 newElmt
->elmt
= new CertificateChoices
;
5657 newElmt
->next
= first
;
5658 newElmt
->prev
= NULL
;
5665 newElmt
->next
= curr
;
5666 newElmt
->prev
= curr
->prev
;
5667 curr
->prev
= newElmt
;
5671 newElmt
->prev
->next
= newElmt
;
5674 return (curr
= newElmt
)->elmt
;
5675 } // CertificateSet::InsertBefore
5678 // alloc new list elmt, insert it after the
5679 // current element and return the component type
5680 // if the current element is null, the new element
5681 // is placed at the end of the list.
5682 CertificateChoices
*CertificateSet::InsertAfter()
5684 AsnListElmt
*newElmt
;
5685 newElmt
= new AsnListElmt
;
5686 newElmt
->elmt
= new CertificateChoices
;
5689 newElmt
->prev
= last
;
5690 newElmt
->next
= NULL
;
5697 newElmt
->prev
= curr
;
5698 newElmt
->next
= curr
->next
;
5699 curr
->next
= newElmt
;
5703 newElmt
->next
->prev
= newElmt
;
5706 return (curr
= newElmt
)->elmt
;
5707 } // CertificateSet::InsertAfter
5710 CertificateSet
&CertificateSet::AppendCopy (CertificateChoices
&elmt
)
5712 AsnListElmt
*newElmt
;
5713 newElmt
= new AsnListElmt
;
5714 newElmt
->elmt
= new CertificateChoices
;
5715 *newElmt
->elmt
= elmt
;
5716 newElmt
->next
= NULL
;
5719 newElmt
->prev
= NULL
;
5720 first
= last
= newElmt
;
5724 newElmt
->prev
= last
;
5725 last
->next
= newElmt
;
5733 CertificateSet
&CertificateSet::PrependCopy (CertificateChoices
&elmt
)
5735 AsnListElmt
*newElmt
;
5736 newElmt
= new AsnListElmt
;
5737 newElmt
->elmt
= new CertificateChoices
;
5738 *newElmt
->elmt
= elmt
;
5739 newElmt
->prev
= NULL
;
5742 newElmt
->next
= NULL
;
5743 first
= last
= newElmt
;
5747 newElmt
->next
= first
;
5748 first
->prev
= newElmt
;
5753 } // CertificateSet::PrependCopy
5756 // alloc new list elmt, insert it before the
5757 // current element, copy the given elmt into the new elmt
5758 // and return the component type.
5759 // if the current element is null, the new element
5760 // is placed at the beginning of the list.
5761 CertificateSet
&CertificateSet::InsertBeforeAndCopy (CertificateChoices
&elmt
)
5763 AsnListElmt
*newElmt
;
5765 newElmt
= new AsnListElmt
;
5766 newElmt
->elmt
= new CertificateChoices
;
5767 *newElmt
->elmt
= elmt
;
5771 newElmt
->next
= first
;
5772 newElmt
->prev
= NULL
;
5779 newElmt
->next
= curr
;
5780 newElmt
->prev
= curr
->prev
;
5781 curr
->prev
= newElmt
;
5785 newElmt
->prev
->next
= newElmt
;
5789 } // CertificateSet::InsertBeforeAndCopy
5792 // alloc new list elmt, insert it after the
5793 // current element, copy given elmt in to new elmt
5794 // and return the component type
5795 // if the current element is null, the new element
5796 // is placed at the end of the list.
5797 CertificateSet
&CertificateSet::InsertAfterAndCopy (CertificateChoices
&elmt
)
5799 AsnListElmt
*newElmt
;
5801 newElmt
= new AsnListElmt
;
5802 newElmt
->elmt
= new CertificateChoices
;
5803 *newElmt
->elmt
= elmt
;
5806 newElmt
->prev
= last
;
5807 newElmt
->next
= NULL
;
5814 newElmt
->prev
= curr
;
5815 newElmt
->next
= curr
->next
;
5816 curr
->next
= newElmt
;
5820 newElmt
->next
->prev
= newElmt
;
5824 } // CertificateSet::InsertAfterAndCopy
5827 // remove current element from list if current element is not NULL
5828 // The new current element will be the next element.
5829 // If the current element is the last element in the list
5830 // the second but last element will become the new current element.
5831 void CertificateSet::RemoveCurrFromList()
5833 AsnListElmt
*del_elmt
;
5841 first
= last
= curr
= NULL
;
5842 else if (curr
== first
)
5844 curr
= first
= first
->next
;
5847 else if (curr
== last
)
5849 curr
= last
= last
->prev
;
5854 curr
->prev
->next
= curr
->next
;
5855 curr
->next
->prev
= curr
->prev
;
5858 delete del_elmt
->elmt
;
5864 AsnLen
CertificateSet::BEncContent (BUF_TYPE b
)
5866 AsnListElmt
*currElmt
;
5868 AsnLen totalLen
= 0;
5871 CSM_Buffer
**tmpEnc
=NULL
;
5872 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
5873 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
5874 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
5876 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
5877 ENCODE_BUF2(tmpEnc
[iii
]);
5879 vdasnacc_sortSetOf(tmpEnc
, icount
);
5880 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
5881 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
5882 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
5885 totalLen
+= elmtLen
;
5887 } // CertificateSet::BEncContent
5890 void CertificateSet::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
5891 AsnLen
&bytesDecoded
, ENV_TYPE env
)
5893 CertificateChoices
*listElmt
;
5895 AsnLen listBytesDecoded
= 0;
5898 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
5900 tag1
= BDecTag (b
, listBytesDecoded
, env
);
5901 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
5903 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
5906 if (!((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
5907 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0))
5908 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1))))
5910 Asn1Error
<< "Unexpected Tag" << endl
;
5911 SnaccExcep::throwMe(-170);
5914 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
5915 listElmt
= Append();
5916 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
5919 bytesDecoded
+= listBytesDecoded
;
5920 } // CertificateSet::BDecContent
5923 OriginatorInfo::OriginatorInfo()
5929 OriginatorInfo::OriginatorInfo (const OriginatorInfo
&)
5931 Asn1Error
<< "use of incompletely defined OriginatorInfo::OriginatorInfo (const OriginatorInfo &)" << endl
;
5935 OriginatorInfo::~OriginatorInfo()
5941 AsnType
*OriginatorInfo::Clone() const
5943 return new OriginatorInfo
;
5946 AsnType
*OriginatorInfo::Copy() const
5948 return new OriginatorInfo (*this);
5952 OriginatorInfo
&OriginatorInfo::operator = (const OriginatorInfo
&that
)
5953 #else // SNACC_DEEP_COPY
5954 OriginatorInfo
&OriginatorInfo::operator = (const OriginatorInfo
&)
5955 #endif // SNACC_DEEP_COPY
5963 certs
= new CertificateSet
;
5964 *certs
= *that
.certs
;
5974 crls
= new CertificateRevocationLists
;
5985 #else // SNACC_DEEP_COPY
5986 Asn1Error
<< "use of incompletely defined OriginatorInfo &OriginatorInfo::operator = (const OriginatorInfo &)" << endl
;
5988 // if your compiler complains here, check the -novolat option
5989 #endif // SNACC_DEEP_COPY
5993 OriginatorInfo::BEncContent (BUF_TYPE b
)
5995 AsnLen totalLen
= 0;
5998 if (NOT_NULL (crls
))
6001 l
= crls
->BEncContent (b
);
6002 l
+= BEncConsLen (b
, l
);
6004 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
6008 if (NOT_NULL (certs
))
6011 l
= certs
->BEncContent (b
);
6012 l
+= BEncConsLen (b
, l
);
6014 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
6019 } // OriginatorInfo::BEncContent
6022 void OriginatorInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6025 AsnLen seqBytesDecoded
= 0;
6031 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6033 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
6035 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
6036 bytesDecoded
+= seqBytesDecoded
;
6041 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
6043 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6044 certs
= new CertificateSet
;
6045 certs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6046 if (seqBytesDecoded
== elmtLen0
)
6048 bytesDecoded
+= seqBytesDecoded
;
6053 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6055 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
6057 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
6058 bytesDecoded
+= seqBytesDecoded
;
6064 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
6066 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6067 crls
= new CertificateRevocationLists
;
6068 crls
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6071 bytesDecoded
+= seqBytesDecoded
;
6072 if (elmtLen0
== INDEFINITE_LEN
)
6074 BDecEoc (b
, bytesDecoded
, env
);
6077 else if (seqBytesDecoded
!= elmtLen0
)
6079 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
6080 SnaccExcep::throwMe(-171);
6084 } // OriginatorInfo::BDecContent
6086 AsnLen
OriginatorInfo::BEnc (BUF_TYPE b
)
6089 l
= BEncContent (b
);
6090 l
+= BEncConsLen (b
, l
);
6091 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6095 void OriginatorInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6100 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6102 Asn1Error
<< "OriginatorInfo::BDec: ERROR - wrong tag" << endl
;
6103 SnaccExcep::throwMe(-172);
6105 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
6106 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
6109 void OriginatorInfo::Print (ostream
&os
) const
6112 int nonePrinted
= true;
6113 os
<< "{ -- SEQUENCE --" << endl
;
6114 indentG
+= stdIndentG
;
6116 if (NOT_NULL (certs
))
6118 nonePrinted
= false;
6119 Indent (os
, indentG
);
6125 Indent (os
, indentG
);
6131 if (NOT_NULL (crls
))
6135 nonePrinted
= false;
6136 Indent (os
, indentG
);
6142 Indent (os
, indentG
);
6149 indentG
-= stdIndentG
;
6150 Indent (os
, indentG
);
6153 } // OriginatorInfo::Print
6156 AsnType
*RecipientEncryptedKeys::Clone() const
6158 return new RecipientEncryptedKeys
;
6161 AsnType
*RecipientEncryptedKeys::Copy() const
6163 return new RecipientEncryptedKeys (*this);
6166 AsnLen
RecipientEncryptedKeys::BEnc (BUF_TYPE b
)
6169 l
= BEncContent (b
);
6170 l
+= BEncConsLen (b
, l
);
6171 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6175 void RecipientEncryptedKeys::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6180 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6182 Asn1Error
<< "RecipientEncryptedKeys::BDec: ERROR - wrong tag" << endl
;
6183 SnaccExcep::throwMe(-173);
6185 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
6186 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
6189 RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys
&)
6191 Asn1Error
<< "use of incompletely defined RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys &)" << endl
;
6195 RecipientEncryptedKeys::~RecipientEncryptedKeys()
6198 for (; Curr() != NULL
; RemoveCurrFromList())
6200 } // end of destructor
6203 RecipientEncryptedKeys
&RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys
&that
)
6204 #else // SNACC_DEEP_COPY
6205 RecipientEncryptedKeys
&RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys
&)
6206 #endif // SNACC_DEEP_COPY
6212 for (; Curr(); RemoveCurrFromList())
6215 //that.SetCurrToFirst();
6216 //for (; that.Curr(); that.GoNext())
6217 // AppendCopy (*that.Curr());
6218 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
6219 AppendCopy (*run
->elmt
);
6223 #else // SNACC_DEEP_COPY
6224 Asn1Error
<< "use of incompletely defined RecipientEncryptedKeys &RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys &)" << endl
;
6226 // if your compiler complains here, check the -novolat option
6227 #endif // SNACC_DEEP_COPY
6230 void RecipientEncryptedKeys::Print (ostream
&os
) const
6233 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
6234 indentG
+= stdIndentG
;
6236 //for (; Curr() != NULL; GoNext())
6237 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
6239 Indent (os
, indentG
);
6242 //if (Curr() != Last())
6247 indentG
-= stdIndentG
;
6248 Indent (os
, indentG
);
6256 void RecipientEncryptedKeys::SetCurrElmt (unsigned long int index
)
6258 unsigned long int i
;
6261 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
6263 } // RecipientEncryptedKeys::SetCurrElmt
6266 unsigned long int RecipientEncryptedKeys::GetCurrElmtIndex()
6268 unsigned long int i
;
6272 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
6281 } // RecipientEncryptedKeys::GetCurrElmtIndex
6284 // alloc new list elmt, put at end of list
6285 // and return the component type
6286 RecipientEncryptedKey
*RecipientEncryptedKeys::Append()
6288 AsnListElmt
*newElmt
;
6289 newElmt
= new AsnListElmt
;
6290 newElmt
->elmt
= new RecipientEncryptedKey
;
6291 newElmt
->next
= NULL
;
6294 newElmt
->prev
= NULL
;
6295 first
= last
= newElmt
;
6299 newElmt
->prev
= last
;
6300 last
->next
= newElmt
;
6304 return (curr
= newElmt
)->elmt
;
6305 } // RecipientEncryptedKeys::Append
6308 // alloc new list elmt, put at begining of list
6309 // and return the component type
6310 RecipientEncryptedKey
*RecipientEncryptedKeys::Prepend()
6312 AsnListElmt
*newElmt
;
6313 newElmt
= new AsnListElmt
;
6314 newElmt
->elmt
= new RecipientEncryptedKey
;
6315 newElmt
->prev
= NULL
;
6318 newElmt
->next
= NULL
;
6319 first
= last
= newElmt
;
6323 newElmt
->next
= first
;
6324 first
->prev
= newElmt
;
6328 return (curr
= newElmt
)->elmt
;
6329 } // RecipientEncryptedKeys::Prepend
6332 // alloc new list elmt, insert it before the
6333 // current element and return the component type
6334 // if the current element is null, the new element
6335 // is placed at the beginning of the list.
6336 RecipientEncryptedKey
*RecipientEncryptedKeys::InsertBefore()
6338 AsnListElmt
*newElmt
;
6339 newElmt
= new AsnListElmt
;
6340 newElmt
->elmt
= new RecipientEncryptedKey
;
6343 newElmt
->next
= first
;
6344 newElmt
->prev
= NULL
;
6351 newElmt
->next
= curr
;
6352 newElmt
->prev
= curr
->prev
;
6353 curr
->prev
= newElmt
;
6357 newElmt
->prev
->next
= newElmt
;
6360 return (curr
= newElmt
)->elmt
;
6361 } // RecipientEncryptedKeys::InsertBefore
6364 // alloc new list elmt, insert it after the
6365 // current element and return the component type
6366 // if the current element is null, the new element
6367 // is placed at the end of the list.
6368 RecipientEncryptedKey
*RecipientEncryptedKeys::InsertAfter()
6370 AsnListElmt
*newElmt
;
6371 newElmt
= new AsnListElmt
;
6372 newElmt
->elmt
= new RecipientEncryptedKey
;
6375 newElmt
->prev
= last
;
6376 newElmt
->next
= NULL
;
6383 newElmt
->prev
= curr
;
6384 newElmt
->next
= curr
->next
;
6385 curr
->next
= newElmt
;
6389 newElmt
->next
->prev
= newElmt
;
6392 return (curr
= newElmt
)->elmt
;
6393 } // RecipientEncryptedKeys::InsertAfter
6396 RecipientEncryptedKeys
&RecipientEncryptedKeys::AppendCopy (RecipientEncryptedKey
&elmt
)
6398 AsnListElmt
*newElmt
;
6399 newElmt
= new AsnListElmt
;
6400 newElmt
->elmt
= new RecipientEncryptedKey
;
6401 *newElmt
->elmt
= elmt
;
6402 newElmt
->next
= NULL
;
6405 newElmt
->prev
= NULL
;
6406 first
= last
= newElmt
;
6410 newElmt
->prev
= last
;
6411 last
->next
= newElmt
;
6419 RecipientEncryptedKeys
&RecipientEncryptedKeys::PrependCopy (RecipientEncryptedKey
&elmt
)
6421 AsnListElmt
*newElmt
;
6422 newElmt
= new AsnListElmt
;
6423 newElmt
->elmt
= new RecipientEncryptedKey
;
6424 *newElmt
->elmt
= elmt
;
6425 newElmt
->prev
= NULL
;
6428 newElmt
->next
= NULL
;
6429 first
= last
= newElmt
;
6433 newElmt
->next
= first
;
6434 first
->prev
= newElmt
;
6439 } // RecipientEncryptedKeys::PrependCopy
6442 // alloc new list elmt, insert it before the
6443 // current element, copy the given elmt into the new elmt
6444 // and return the component type.
6445 // if the current element is null, the new element
6446 // is placed at the beginning of the list.
6447 RecipientEncryptedKeys
&RecipientEncryptedKeys::InsertBeforeAndCopy (RecipientEncryptedKey
&elmt
)
6449 AsnListElmt
*newElmt
;
6451 newElmt
= new AsnListElmt
;
6452 newElmt
->elmt
= new RecipientEncryptedKey
;
6453 *newElmt
->elmt
= elmt
;
6457 newElmt
->next
= first
;
6458 newElmt
->prev
= NULL
;
6465 newElmt
->next
= curr
;
6466 newElmt
->prev
= curr
->prev
;
6467 curr
->prev
= newElmt
;
6471 newElmt
->prev
->next
= newElmt
;
6475 } // RecipientEncryptedKeys::InsertBeforeAndCopy
6478 // alloc new list elmt, insert it after the
6479 // current element, copy given elmt in to new elmt
6480 // and return the component type
6481 // if the current element is null, the new element
6482 // is placed at the end of the list.
6483 RecipientEncryptedKeys
&RecipientEncryptedKeys::InsertAfterAndCopy (RecipientEncryptedKey
&elmt
)
6485 AsnListElmt
*newElmt
;
6487 newElmt
= new AsnListElmt
;
6488 newElmt
->elmt
= new RecipientEncryptedKey
;
6489 *newElmt
->elmt
= elmt
;
6492 newElmt
->prev
= last
;
6493 newElmt
->next
= NULL
;
6500 newElmt
->prev
= curr
;
6501 newElmt
->next
= curr
->next
;
6502 curr
->next
= newElmt
;
6506 newElmt
->next
->prev
= newElmt
;
6510 } // RecipientEncryptedKeys::InsertAfterAndCopy
6513 // remove current element from list if current element is not NULL
6514 // The new current element will be the next element.
6515 // If the current element is the last element in the list
6516 // the second but last element will become the new current element.
6517 void RecipientEncryptedKeys::RemoveCurrFromList()
6519 AsnListElmt
*del_elmt
;
6527 first
= last
= curr
= NULL
;
6528 else if (curr
== first
)
6530 curr
= first
= first
->next
;
6533 else if (curr
== last
)
6535 curr
= last
= last
->prev
;
6540 curr
->prev
->next
= curr
->next
;
6541 curr
->next
->prev
= curr
->prev
;
6544 delete del_elmt
->elmt
;
6550 AsnLen
RecipientEncryptedKeys::BEncContent (BUF_TYPE b
)
6552 AsnListElmt
*currElmt
;
6554 AsnLen totalLen
= 0;
6555 for (currElmt
= last
; currElmt
!= NULL
; currElmt
= currElmt
->prev
)
6558 elmtLen
= currElmt
->elmt
->BEncContent (b
);
6559 elmtLen
+= BEncConsLen (b
, elmtLen
);
6561 elmtLen
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6562 totalLen
+= elmtLen
;
6565 } // RecipientEncryptedKeys::BEncContent
6568 void RecipientEncryptedKeys::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
6569 AsnLen
&bytesDecoded
, ENV_TYPE env
)
6571 RecipientEncryptedKey
*listElmt
;
6573 AsnLen listBytesDecoded
= 0;
6576 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
6578 tag1
= BDecTag (b
, listBytesDecoded
, env
);
6579 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
6581 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
6584 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
6586 Asn1Error
<< "Unexpected Tag" << endl
;
6587 SnaccExcep::throwMe(-174);
6590 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
6591 listElmt
= Append();
6592 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
6595 bytesDecoded
+= listBytesDecoded
;
6596 } // RecipientEncryptedKeys::BDecContent
6599 KeyAgreeRecipientInfo::KeyAgreeRecipientInfo()
6602 originator
= new OriginatorIdentifierOrKey
;
6604 originator
= NULL
; // incomplete initialization of mandatory element!
6608 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
6610 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
6614 KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo
&)
6616 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &)" << endl
;
6620 KeyAgreeRecipientInfo::~KeyAgreeRecipientInfo()
6624 delete keyEncryptionAlgorithm
;
6627 AsnType
*KeyAgreeRecipientInfo::Clone() const
6629 return new KeyAgreeRecipientInfo
;
6632 AsnType
*KeyAgreeRecipientInfo::Copy() const
6634 return new KeyAgreeRecipientInfo (*this);
6638 KeyAgreeRecipientInfo
&KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo
&that
)
6639 #else // SNACC_DEEP_COPY
6640 KeyAgreeRecipientInfo
&KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo
&)
6641 #endif // SNACC_DEEP_COPY
6646 version
= that
.version
;
6647 if (that
.originator
)
6650 originator
= new OriginatorIdentifierOrKey
;
6651 *originator
= *that
.originator
;
6661 ukm
= new UserKeyingMaterial
;
6669 if (that
.keyEncryptionAlgorithm
)
6671 if (!keyEncryptionAlgorithm
)
6672 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
6673 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
6677 delete keyEncryptionAlgorithm
;
6678 keyEncryptionAlgorithm
= NULL
;
6680 recipientEncryptedKeys
= that
.recipientEncryptedKeys
;
6684 #else // SNACC_DEEP_COPY
6685 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientInfo &KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo &)" << endl
;
6687 // if your compiler complains here, check the -novolat option
6688 #endif // SNACC_DEEP_COPY
6692 KeyAgreeRecipientInfo::BEncContent (BUF_TYPE b
)
6694 AsnLen totalLen
= 0;
6698 l
= recipientEncryptedKeys
.BEncContent (b
);
6699 l
+= BEncConsLen (b
, l
);
6701 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6705 l
= keyEncryptionAlgorithm
->BEncContent (b
);
6706 l
+= BEncConsLen (b
, l
);
6708 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6714 l
= ukm
->BEncContent (b
);
6715 l
+= BEncDefLen (b
, l
);
6717 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
6718 l
+= BEncConsLen (b
, l
);
6720 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
6725 l
= originator
->BEncContent (b
);
6726 l
+= BEncConsLen (b
, l
);
6728 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
6731 l
= version
.BEncContent (b
);
6732 BEncDefLenTo127 (b
, l
);
6735 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
6739 } // KeyAgreeRecipientInfo::BEncContent
6742 void KeyAgreeRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6745 AsnLen seqBytesDecoded
= 0;
6748 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6750 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
6752 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6753 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6754 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6758 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
6759 SnaccExcep::throwMe(-175);
6762 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
6764 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6765 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6766 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
6767 originator
= new OriginatorIdentifierOrKey
;
6768 originator
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
6769 if (elmtLen1
== INDEFINITE_LEN
)
6770 BDecEoc (b
, seqBytesDecoded
, env
);
6772 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6776 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
6777 SnaccExcep::throwMe(-176);
6780 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
6782 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6783 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6785 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
6786 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
6788 Asn1Error
<< "Unexpected Tag" << endl
;
6789 SnaccExcep::throwMe(-177);
6792 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
6793 ukm
= new UserKeyingMaterial
;
6794 ukm
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
6795 if (elmtLen1
== INDEFINITE_LEN
)
6796 BDecEoc (b
, seqBytesDecoded
, env
);
6798 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6801 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
6803 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6804 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
6805 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6806 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6810 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
6811 SnaccExcep::throwMe(-178);
6814 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
6816 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6817 recipientEncryptedKeys
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6821 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
6822 SnaccExcep::throwMe(-179);
6825 bytesDecoded
+= seqBytesDecoded
;
6826 if (elmtLen0
== INDEFINITE_LEN
)
6828 BDecEoc (b
, bytesDecoded
, env
);
6831 else if (seqBytesDecoded
!= elmtLen0
)
6833 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
6834 SnaccExcep::throwMe(-180);
6838 } // KeyAgreeRecipientInfo::BDecContent
6840 AsnLen
KeyAgreeRecipientInfo::BEnc (BUF_TYPE b
)
6843 l
= BEncContent (b
);
6844 l
+= BEncConsLen (b
, l
);
6845 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6849 void KeyAgreeRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6854 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6856 Asn1Error
<< "KeyAgreeRecipientInfo::BDec: ERROR - wrong tag" << endl
;
6857 SnaccExcep::throwMe(-181);
6859 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
6860 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
6863 void KeyAgreeRecipientInfo::Print (ostream
&os
) const
6866 os
<< "{ -- SEQUENCE --" << endl
;
6867 indentG
+= stdIndentG
;
6870 Indent (os
, indentG
);
6876 if (NOT_NULL (originator
))
6878 Indent (os
, indentG
);
6879 os
<< "originator ";
6884 Indent (os
, indentG
);
6885 os
<< "originator ";
6892 Indent (os
, indentG
);
6898 Indent (os
, indentG
);
6904 if (NOT_NULL (keyEncryptionAlgorithm
))
6906 Indent (os
, indentG
);
6907 os
<< "keyEncryptionAlgorithm ";
6908 os
<< *keyEncryptionAlgorithm
;
6912 Indent (os
, indentG
);
6913 os
<< "keyEncryptionAlgorithm ";
6919 Indent (os
, indentG
);
6920 os
<< "recipientEncryptedKeys ";
6921 os
<< recipientEncryptedKeys
;
6925 indentG
-= stdIndentG
;
6926 Indent (os
, indentG
);
6929 } // KeyAgreeRecipientInfo::Print
6932 RecipientInfo::RecipientInfo()
6936 ktri
= new KeyTransRecipientInfo
;
6938 ktri
= NULL
; // incomplete initialization of mandatory element!
6942 RecipientInfo::RecipientInfo (const RecipientInfo
&)
6944 Asn1Error
<< "use of incompletely defined RecipientInfo::RecipientInfo (const RecipientInfo &)" << endl
;
6948 RecipientInfo::~RecipientInfo()
6962 } // end of destructor
6964 AsnType
*RecipientInfo::Clone() const
6966 return new RecipientInfo
;
6969 AsnType
*RecipientInfo::Copy() const
6971 return new RecipientInfo (*this);
6975 RecipientInfo
&RecipientInfo::operator = (const RecipientInfo
&that
)
6976 #else // SNACC_DEEP_COPY
6977 RecipientInfo
&RecipientInfo::operator = (const RecipientInfo
&)
6978 #endif // SNACC_DEEP_COPY
6995 switch (choiceId
= that
.choiceId
)
6998 ktri
= new KeyTransRecipientInfo
;
7002 kari
= new KeyAgreeRecipientInfo
;
7006 kekri
= new KEKRecipientInfo
;
7007 *kekri
= *that
.kekri
;
7013 #else // SNACC_DEEP_COPY
7014 Asn1Error
<< "use of incompletely defined RecipientInfo &RecipientInfo::operator = (const RecipientInfo &)" << endl
;
7016 // if your compiler complains here, check the -novolat option
7017 #endif // SNACC_DEEP_COPY
7021 RecipientInfo::BEncContent (BUF_TYPE b
)
7028 l
= ktri
->BEncContent (b
);
7029 l
+= BEncConsLen (b
, l
);
7031 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7036 l
= kari
->BEncContent (b
);
7037 l
+= BEncConsLen (b
, l
);
7039 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
7044 l
= kekri
->BEncContent (b
);
7045 l
+= BEncConsLen (b
, l
);
7047 l
+= BEncTag1 (b
, CNTX
, CONS
, 2);
7052 } // RecipientInfo::BEncContent
7055 void RecipientInfo::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7059 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
7061 ktri
= new KeyTransRecipientInfo
;
7062 ktri
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7065 case MAKE_TAG_ID (CNTX
, CONS
, 1):
7067 kari
= new KeyAgreeRecipientInfo
;
7068 kari
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7071 case MAKE_TAG_ID (CNTX
, CONS
, 2):
7072 choiceId
= kekriCid
;
7073 kekri
= new KEKRecipientInfo
;
7074 kekri
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7078 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
7079 SnaccExcep::throwMe(-182);
7082 } // RecipientInfo::BDecContent
7085 AsnLen
RecipientInfo::BEnc (BUF_TYPE b
)
7088 l
= BEncContent (b
);
7092 void RecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7097 /* CHOICEs are a special case - grab identifying tag */
7098 /* this allows easier handling of nested CHOICEs */
7099 tag
= BDecTag (b
, bytesDecoded
, env
);
7100 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
7101 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
7104 void RecipientInfo::Print (ostream
&os
) const
7114 os
<< "-- void3 --\n";
7122 os
<< "-- void3 --\n";
7130 os
<< "-- void3 --\n";
7135 } // RecipientInfo::Print
7137 AsnType
*RecipientInfos::Clone() const
7139 return new RecipientInfos
;
7142 AsnType
*RecipientInfos::Copy() const
7144 return new RecipientInfos (*this);
7147 AsnLen
RecipientInfos::BEnc (BUF_TYPE b
)
7150 l
= BEncContent (b
);
7151 l
+= BEncConsLen (b
, l
);
7152 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
7156 void RecipientInfos::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7161 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
7163 Asn1Error
<< "RecipientInfos::BDec: ERROR - wrong tag" << endl
;
7164 SnaccExcep::throwMe(-183);
7166 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
7167 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
7170 RecipientInfos::RecipientInfos (const RecipientInfos
&)
7172 Asn1Error
<< "use of incompletely defined RecipientInfos::RecipientInfos (const RecipientInfos &)" << endl
;
7176 RecipientInfos::~RecipientInfos()
7179 for (; Curr() != NULL
; RemoveCurrFromList())
7181 } // end of destructor
7184 RecipientInfos
&RecipientInfos::operator = (const RecipientInfos
&that
)
7185 #else // SNACC_DEEP_COPY
7186 RecipientInfos
&RecipientInfos::operator = (const RecipientInfos
&)
7187 #endif // SNACC_DEEP_COPY
7193 for (; Curr(); RemoveCurrFromList())
7196 //that.SetCurrToFirst();
7197 //for (; that.Curr(); that.GoNext())
7198 // AppendCopy (*that.Curr());
7199 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
7200 AppendCopy (*run
->elmt
);
7204 #else // SNACC_DEEP_COPY
7205 Asn1Error
<< "use of incompletely defined RecipientInfos &RecipientInfos::operator = (const RecipientInfos &)" << endl
;
7207 // if your compiler complains here, check the -novolat option
7208 #endif // SNACC_DEEP_COPY
7211 void RecipientInfos::Print (ostream
&os
) const
7214 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
7215 indentG
+= stdIndentG
;
7217 //for (; Curr() != NULL; GoNext())
7218 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
7220 Indent (os
, indentG
);
7223 //if (Curr() != Last())
7228 indentG
-= stdIndentG
;
7229 Indent (os
, indentG
);
7237 void RecipientInfos::SetCurrElmt (unsigned long int index
)
7239 unsigned long int i
;
7242 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
7244 } // RecipientInfos::SetCurrElmt
7247 unsigned long int RecipientInfos::GetCurrElmtIndex()
7249 unsigned long int i
;
7253 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
7262 } // RecipientInfos::GetCurrElmtIndex
7265 // alloc new list elmt, put at end of list
7266 // and return the component type
7267 RecipientInfo
*RecipientInfos::Append()
7269 AsnListElmt
*newElmt
;
7270 newElmt
= new AsnListElmt
;
7271 newElmt
->elmt
= new RecipientInfo
;
7272 newElmt
->next
= NULL
;
7275 newElmt
->prev
= NULL
;
7276 first
= last
= newElmt
;
7280 newElmt
->prev
= last
;
7281 last
->next
= newElmt
;
7285 return (curr
= newElmt
)->elmt
;
7286 } // RecipientInfos::Append
7289 // alloc new list elmt, put at begining of list
7290 // and return the component type
7291 RecipientInfo
*RecipientInfos::Prepend()
7293 AsnListElmt
*newElmt
;
7294 newElmt
= new AsnListElmt
;
7295 newElmt
->elmt
= new RecipientInfo
;
7296 newElmt
->prev
= NULL
;
7299 newElmt
->next
= NULL
;
7300 first
= last
= newElmt
;
7304 newElmt
->next
= first
;
7305 first
->prev
= newElmt
;
7309 return (curr
= newElmt
)->elmt
;
7310 } // RecipientInfos::Prepend
7313 // alloc new list elmt, insert it before the
7314 // current element and return the component type
7315 // if the current element is null, the new element
7316 // is placed at the beginning of the list.
7317 RecipientInfo
*RecipientInfos::InsertBefore()
7319 AsnListElmt
*newElmt
;
7320 newElmt
= new AsnListElmt
;
7321 newElmt
->elmt
= new RecipientInfo
;
7324 newElmt
->next
= first
;
7325 newElmt
->prev
= NULL
;
7332 newElmt
->next
= curr
;
7333 newElmt
->prev
= curr
->prev
;
7334 curr
->prev
= newElmt
;
7338 newElmt
->prev
->next
= newElmt
;
7341 return (curr
= newElmt
)->elmt
;
7342 } // RecipientInfos::InsertBefore
7345 // alloc new list elmt, insert it after the
7346 // current element and return the component type
7347 // if the current element is null, the new element
7348 // is placed at the end of the list.
7349 RecipientInfo
*RecipientInfos::InsertAfter()
7351 AsnListElmt
*newElmt
;
7352 newElmt
= new AsnListElmt
;
7353 newElmt
->elmt
= new RecipientInfo
;
7356 newElmt
->prev
= last
;
7357 newElmt
->next
= NULL
;
7364 newElmt
->prev
= curr
;
7365 newElmt
->next
= curr
->next
;
7366 curr
->next
= newElmt
;
7370 newElmt
->next
->prev
= newElmt
;
7373 return (curr
= newElmt
)->elmt
;
7374 } // RecipientInfos::InsertAfter
7377 RecipientInfos
&RecipientInfos::AppendCopy (RecipientInfo
&elmt
)
7379 AsnListElmt
*newElmt
;
7380 newElmt
= new AsnListElmt
;
7381 newElmt
->elmt
= new RecipientInfo
;
7382 *newElmt
->elmt
= elmt
;
7383 newElmt
->next
= NULL
;
7386 newElmt
->prev
= NULL
;
7387 first
= last
= newElmt
;
7391 newElmt
->prev
= last
;
7392 last
->next
= newElmt
;
7400 RecipientInfos
&RecipientInfos::PrependCopy (RecipientInfo
&elmt
)
7402 AsnListElmt
*newElmt
;
7403 newElmt
= new AsnListElmt
;
7404 newElmt
->elmt
= new RecipientInfo
;
7405 *newElmt
->elmt
= elmt
;
7406 newElmt
->prev
= NULL
;
7409 newElmt
->next
= NULL
;
7410 first
= last
= newElmt
;
7414 newElmt
->next
= first
;
7415 first
->prev
= newElmt
;
7420 } // RecipientInfos::PrependCopy
7423 // alloc new list elmt, insert it before the
7424 // current element, copy the given elmt into the new elmt
7425 // and return the component type.
7426 // if the current element is null, the new element
7427 // is placed at the beginning of the list.
7428 RecipientInfos
&RecipientInfos::InsertBeforeAndCopy (RecipientInfo
&elmt
)
7430 AsnListElmt
*newElmt
;
7432 newElmt
= new AsnListElmt
;
7433 newElmt
->elmt
= new RecipientInfo
;
7434 *newElmt
->elmt
= elmt
;
7438 newElmt
->next
= first
;
7439 newElmt
->prev
= NULL
;
7446 newElmt
->next
= curr
;
7447 newElmt
->prev
= curr
->prev
;
7448 curr
->prev
= newElmt
;
7452 newElmt
->prev
->next
= newElmt
;
7456 } // RecipientInfos::InsertBeforeAndCopy
7459 // alloc new list elmt, insert it after the
7460 // current element, copy given elmt in to new elmt
7461 // and return the component type
7462 // if the current element is null, the new element
7463 // is placed at the end of the list.
7464 RecipientInfos
&RecipientInfos::InsertAfterAndCopy (RecipientInfo
&elmt
)
7466 AsnListElmt
*newElmt
;
7468 newElmt
= new AsnListElmt
;
7469 newElmt
->elmt
= new RecipientInfo
;
7470 *newElmt
->elmt
= elmt
;
7473 newElmt
->prev
= last
;
7474 newElmt
->next
= NULL
;
7481 newElmt
->prev
= curr
;
7482 newElmt
->next
= curr
->next
;
7483 curr
->next
= newElmt
;
7487 newElmt
->next
->prev
= newElmt
;
7491 } // RecipientInfos::InsertAfterAndCopy
7494 // remove current element from list if current element is not NULL
7495 // The new current element will be the next element.
7496 // If the current element is the last element in the list
7497 // the second but last element will become the new current element.
7498 void RecipientInfos::RemoveCurrFromList()
7500 AsnListElmt
*del_elmt
;
7508 first
= last
= curr
= NULL
;
7509 else if (curr
== first
)
7511 curr
= first
= first
->next
;
7514 else if (curr
== last
)
7516 curr
= last
= last
->prev
;
7521 curr
->prev
->next
= curr
->next
;
7522 curr
->next
->prev
= curr
->prev
;
7525 delete del_elmt
->elmt
;
7531 AsnLen
RecipientInfos::BEncContent (BUF_TYPE b
)
7533 AsnListElmt
*currElmt
;
7535 AsnLen totalLen
= 0;
7538 CSM_Buffer
**tmpEnc
=NULL
;
7539 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
7540 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
7541 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
7543 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
7544 ENCODE_BUF2(tmpEnc
[iii
]);
7546 vdasnacc_sortSetOf(tmpEnc
, icount
);
7547 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
7548 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
7549 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
7552 totalLen
+= elmtLen
;
7554 } // RecipientInfos::BEncContent
7557 void RecipientInfos::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
7558 AsnLen
&bytesDecoded
, ENV_TYPE env
)
7560 RecipientInfo
*listElmt
;
7562 AsnLen listBytesDecoded
= 0;
7565 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
7567 tag1
= BDecTag (b
, listBytesDecoded
, env
);
7568 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
7570 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
7573 if (!((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
7574 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1))
7575 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 2))))
7577 Asn1Error
<< "Unexpected Tag" << endl
;
7578 SnaccExcep::throwMe(-184);
7581 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
7582 listElmt
= Append();
7583 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
7586 bytesDecoded
+= listBytesDecoded
;
7587 } // RecipientInfos::BDecContent
7590 ContentInfo::ContentInfo()
7594 ContentInfo::ContentInfo (const ContentInfo
&)
7596 Asn1Error
<< "use of incompletely defined ContentInfo::ContentInfo (const ContentInfo &)" << endl
;
7600 ContentInfo::~ContentInfo()
7604 AsnType
*ContentInfo::Clone() const
7606 return new ContentInfo
;
7609 AsnType
*ContentInfo::Copy() const
7611 return new ContentInfo (*this);
7615 ContentInfo
&ContentInfo::operator = (const ContentInfo
&that
)
7616 #else // SNACC_DEEP_COPY
7617 ContentInfo
&ContentInfo::operator = (const ContentInfo
&)
7618 #endif // SNACC_DEEP_COPY
7623 contentType
= that
.contentType
;
7624 content
= that
.content
;
7628 #else // SNACC_DEEP_COPY
7629 Asn1Error
<< "use of incompletely defined ContentInfo &ContentInfo::operator = (const ContentInfo &)" << endl
;
7631 // if your compiler complains here, check the -novolat option
7632 #endif // SNACC_DEEP_COPY
7636 ContentInfo::BEncContent (BUF_TYPE b
)
7638 AsnLen totalLen
= 0;
7642 ENC_LOAD_ANYBUF(&content
, b
, l
);
7643 l
+= BEncConsLen (b
, l
);
7645 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
7648 l
= contentType
.BEncContent (b
);
7649 l
+= BEncDefLen (b
, l
);
7651 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
7655 } // ContentInfo::BEncContent
7658 void ContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7661 AsnLen seqBytesDecoded
= 0;
7663 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7665 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
7667 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7668 contentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7669 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7673 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7674 SnaccExcep::throwMe(-185);
7677 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
7679 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7680 DEC_LOAD_ANYBUF(&content
, b
, seqBytesDecoded
, env
);
7681 if (elmtLen1
== INDEFINITE_LEN
)
7682 BDecEoc (b
, seqBytesDecoded
, env
);
7687 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7688 SnaccExcep::throwMe(-186);
7691 bytesDecoded
+= seqBytesDecoded
;
7692 if (elmtLen0
== INDEFINITE_LEN
)
7694 BDecEoc (b
, bytesDecoded
, env
);
7697 else if (seqBytesDecoded
!= elmtLen0
)
7699 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
7700 SnaccExcep::throwMe(-187);
7704 } // ContentInfo::BDecContent
7706 AsnLen
ContentInfo::BEnc (BUF_TYPE b
)
7709 l
= BEncContent (b
);
7710 l
+= BEncConsLen (b
, l
);
7711 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7715 void ContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7720 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
7722 Asn1Error
<< "ContentInfo::BDec: ERROR - wrong tag" << endl
;
7723 SnaccExcep::throwMe(-188);
7725 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
7726 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
7729 void ContentInfo::Print (ostream
&os
) const
7732 os
<< "{ -- SEQUENCE --" << endl
;
7733 indentG
+= stdIndentG
;
7736 Indent (os
, indentG
);
7737 os
<< "contentType ";
7743 Indent (os
, indentG
);
7749 indentG
-= stdIndentG
;
7750 Indent (os
, indentG
);
7753 } // ContentInfo::Print
7756 SignedData::SignedData()
7759 encapContentInfo
= new EncapsulatedContentInfo
;
7761 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
7763 certificates
= NULL
;
7767 SignedData::SignedData (const SignedData
&)
7769 Asn1Error
<< "use of incompletely defined SignedData::SignedData (const SignedData &)" << endl
;
7773 SignedData::~SignedData()
7775 delete encapContentInfo
;
7776 delete certificates
;
7780 AsnType
*SignedData::Clone() const
7782 return new SignedData
;
7785 AsnType
*SignedData::Copy() const
7787 return new SignedData (*this);
7791 SignedData
&SignedData::operator = (const SignedData
&that
)
7792 #else // SNACC_DEEP_COPY
7793 SignedData
&SignedData::operator = (const SignedData
&)
7794 #endif // SNACC_DEEP_COPY
7799 version
= that
.version
;
7800 digestAlgorithms
= that
.digestAlgorithms
;
7801 if (that
.encapContentInfo
)
7803 if (!encapContentInfo
)
7804 encapContentInfo
= new EncapsulatedContentInfo
;
7805 *encapContentInfo
= *that
.encapContentInfo
;
7809 delete encapContentInfo
;
7810 encapContentInfo
= NULL
;
7812 if (that
.certificates
)
7815 certificates
= new CertificateSet
;
7816 *certificates
= *that
.certificates
;
7820 delete certificates
;
7821 certificates
= NULL
;
7826 crls
= new CertificateRevocationLists
;
7834 signerInfos
= that
.signerInfos
;
7838 #else // SNACC_DEEP_COPY
7839 Asn1Error
<< "use of incompletely defined SignedData &SignedData::operator = (const SignedData &)" << endl
;
7841 // if your compiler complains here, check the -novolat option
7842 #endif // SNACC_DEEP_COPY
7846 SignedData::BEncContent (BUF_TYPE b
)
7848 AsnLen totalLen
= 0;
7852 l
= signerInfos
.BEncContent (b
);
7853 l
+= BEncConsLen (b
, l
);
7855 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
7858 if (NOT_NULL (crls
))
7861 l
= crls
->BEncContent (b
);
7862 l
+= BEncConsLen (b
, l
);
7864 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
7868 if (NOT_NULL (certificates
))
7871 l
= certificates
->BEncContent (b
);
7872 l
+= BEncConsLen (b
, l
);
7874 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
7879 l
= encapContentInfo
->BEncContent (b
);
7880 l
+= BEncConsLen (b
, l
);
7882 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7886 l
= digestAlgorithms
.BEncContent (b
);
7887 l
+= BEncConsLen (b
, l
);
7889 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
7892 l
= version
.BEncContent (b
);
7893 BEncDefLenTo127 (b
, l
);
7896 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
7900 } // SignedData::BEncContent
7903 void SignedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7906 AsnLen seqBytesDecoded
= 0;
7908 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7910 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
7912 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7913 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7914 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7918 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7919 SnaccExcep::throwMe(-189);
7922 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
7924 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7925 digestAlgorithms
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7926 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7930 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7931 SnaccExcep::throwMe(-190);
7934 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
7936 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7937 encapContentInfo
= new EncapsulatedContentInfo
;
7938 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7939 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7943 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7944 SnaccExcep::throwMe(-191);
7947 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
7949 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7950 certificates
= new CertificateSet
;
7951 certificates
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7952 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7955 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
7957 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7958 crls
= new CertificateRevocationLists
;
7959 crls
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7960 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7963 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
7965 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7966 signerInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7970 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7971 SnaccExcep::throwMe(-192);
7974 bytesDecoded
+= seqBytesDecoded
;
7975 if (elmtLen0
== INDEFINITE_LEN
)
7977 BDecEoc (b
, bytesDecoded
, env
);
7980 else if (seqBytesDecoded
!= elmtLen0
)
7982 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
7983 SnaccExcep::throwMe(-193);
7987 } // SignedData::BDecContent
7989 AsnLen
SignedData::BEnc (BUF_TYPE b
)
7992 l
= BEncContent (b
);
7993 l
+= BEncConsLen (b
, l
);
7994 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7998 void SignedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8003 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8005 Asn1Error
<< "SignedData::BDec: ERROR - wrong tag" << endl
;
8006 SnaccExcep::throwMe(-194);
8008 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8009 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8012 void SignedData::Print (ostream
&os
) const
8015 os
<< "{ -- SEQUENCE --" << endl
;
8016 indentG
+= stdIndentG
;
8019 Indent (os
, indentG
);
8026 Indent (os
, indentG
);
8027 os
<< "digestAlgorithms ";
8028 os
<< digestAlgorithms
;
8032 if (NOT_NULL (encapContentInfo
))
8034 Indent (os
, indentG
);
8035 os
<< "encapContentInfo ";
8036 os
<< *encapContentInfo
;
8040 Indent (os
, indentG
);
8041 os
<< "encapContentInfo ";
8046 if (NOT_NULL (certificates
))
8048 Indent (os
, indentG
);
8049 os
<< "certificates ";
8050 os
<< *certificates
;
8054 Indent (os
, indentG
);
8055 os
<< "certificates ";
8060 if (NOT_NULL (crls
))
8062 Indent (os
, indentG
);
8068 Indent (os
, indentG
);
8075 Indent (os
, indentG
);
8076 os
<< "signerInfos ";
8081 indentG
-= stdIndentG
;
8082 Indent (os
, indentG
);
8085 } // SignedData::Print
8088 EnvelopedData::EnvelopedData()
8090 originatorInfo
= NULL
;
8092 encryptedContentInfo
= new EncryptedContentInfo
;
8094 encryptedContentInfo
= NULL
; // incomplete initialization of mandatory element!
8096 unprotectedAttrs
= NULL
;
8099 EnvelopedData::EnvelopedData (const EnvelopedData
&)
8101 Asn1Error
<< "use of incompletely defined EnvelopedData::EnvelopedData (const EnvelopedData &)" << endl
;
8105 EnvelopedData::~EnvelopedData()
8107 delete originatorInfo
;
8108 delete encryptedContentInfo
;
8109 delete unprotectedAttrs
;
8112 AsnType
*EnvelopedData::Clone() const
8114 return new EnvelopedData
;
8117 AsnType
*EnvelopedData::Copy() const
8119 return new EnvelopedData (*this);
8123 EnvelopedData
&EnvelopedData::operator = (const EnvelopedData
&that
)
8124 #else // SNACC_DEEP_COPY
8125 EnvelopedData
&EnvelopedData::operator = (const EnvelopedData
&)
8126 #endif // SNACC_DEEP_COPY
8131 version
= that
.version
;
8132 if (that
.originatorInfo
)
8134 if (!originatorInfo
)
8135 originatorInfo
= new OriginatorInfo
;
8136 *originatorInfo
= *that
.originatorInfo
;
8140 delete originatorInfo
;
8141 originatorInfo
= NULL
;
8143 recipientInfos
= that
.recipientInfos
;
8144 if (that
.encryptedContentInfo
)
8146 if (!encryptedContentInfo
)
8147 encryptedContentInfo
= new EncryptedContentInfo
;
8148 *encryptedContentInfo
= *that
.encryptedContentInfo
;
8152 delete encryptedContentInfo
;
8153 encryptedContentInfo
= NULL
;
8155 if (that
.unprotectedAttrs
)
8157 if (!unprotectedAttrs
)
8158 unprotectedAttrs
= new Attributes
;
8159 *unprotectedAttrs
= *that
.unprotectedAttrs
;
8163 delete unprotectedAttrs
;
8164 unprotectedAttrs
= NULL
;
8169 #else // SNACC_DEEP_COPY
8170 Asn1Error
<< "use of incompletely defined EnvelopedData &EnvelopedData::operator = (const EnvelopedData &)" << endl
;
8172 // if your compiler complains here, check the -novolat option
8173 #endif // SNACC_DEEP_COPY
8177 EnvelopedData::BEncContent (BUF_TYPE b
)
8179 AsnLen totalLen
= 0;
8182 if (NOT_NULL (unprotectedAttrs
))
8185 l
= unprotectedAttrs
->BEncContent (b
);
8186 l
+= BEncConsLen (b
, l
);
8188 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
8193 l
= encryptedContentInfo
->BEncContent (b
);
8194 l
+= BEncConsLen (b
, l
);
8196 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8200 l
= recipientInfos
.BEncContent (b
);
8201 l
+= BEncConsLen (b
, l
);
8203 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
8206 if (NOT_NULL (originatorInfo
))
8209 l
= originatorInfo
->BEncContent (b
);
8210 l
+= BEncConsLen (b
, l
);
8212 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
8216 l
= version
.BEncContent (b
);
8217 BEncDefLenTo127 (b
, l
);
8220 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
8224 } // EnvelopedData::BEncContent
8227 void EnvelopedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8230 AsnLen seqBytesDecoded
= 0;
8232 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8234 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
8236 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8237 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8238 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8242 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8243 SnaccExcep::throwMe(-195);
8246 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
8248 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8249 originatorInfo
= new OriginatorInfo
;
8250 originatorInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8251 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8254 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
8256 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8257 recipientInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8258 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8262 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8263 SnaccExcep::throwMe(-196);
8266 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8268 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8269 encryptedContentInfo
= new EncryptedContentInfo
;
8270 encryptedContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8271 if (seqBytesDecoded
== elmtLen0
)
8273 bytesDecoded
+= seqBytesDecoded
;
8278 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8280 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
8282 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
8283 bytesDecoded
+= seqBytesDecoded
;
8290 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8291 SnaccExcep::throwMe(-197);
8294 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
8296 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8297 unprotectedAttrs
= new Attributes
;
8298 unprotectedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8301 bytesDecoded
+= seqBytesDecoded
;
8302 if (elmtLen0
== INDEFINITE_LEN
)
8304 BDecEoc (b
, bytesDecoded
, env
);
8307 else if (seqBytesDecoded
!= elmtLen0
)
8309 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8310 SnaccExcep::throwMe(-198);
8314 } // EnvelopedData::BDecContent
8316 AsnLen
EnvelopedData::BEnc (BUF_TYPE b
)
8319 l
= BEncContent (b
);
8320 l
+= BEncConsLen (b
, l
);
8321 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8325 void EnvelopedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8330 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8332 Asn1Error
<< "EnvelopedData::BDec: ERROR - wrong tag" << endl
;
8333 SnaccExcep::throwMe(-199);
8335 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8336 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8339 void EnvelopedData::Print (ostream
&os
) const
8342 os
<< "{ -- SEQUENCE --" << endl
;
8343 indentG
+= stdIndentG
;
8346 Indent (os
, indentG
);
8352 if (NOT_NULL (originatorInfo
))
8354 Indent (os
, indentG
);
8355 os
<< "originatorInfo ";
8356 os
<< *originatorInfo
;
8360 Indent (os
, indentG
);
8361 os
<< "originatorInfo ";
8367 Indent (os
, indentG
);
8368 os
<< "recipientInfos ";
8369 os
<< recipientInfos
;
8373 if (NOT_NULL (encryptedContentInfo
))
8375 Indent (os
, indentG
);
8376 os
<< "encryptedContentInfo ";
8377 os
<< *encryptedContentInfo
;
8381 Indent (os
, indentG
);
8382 os
<< "encryptedContentInfo ";
8387 if (NOT_NULL (unprotectedAttrs
))
8390 Indent (os
, indentG
);
8391 os
<< "unprotectedAttrs ";
8392 os
<< *unprotectedAttrs
;
8396 Indent (os
, indentG
);
8397 os
<< "unprotectedAttrs ";
8403 indentG
-= stdIndentG
;
8404 Indent (os
, indentG
);
8407 } // EnvelopedData::Print
8410 DigestedData::DigestedData()
8413 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8415 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
8418 encapContentInfo
= new EncapsulatedContentInfo
;
8420 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
8424 DigestedData::DigestedData (const DigestedData
&)
8426 Asn1Error
<< "use of incompletely defined DigestedData::DigestedData (const DigestedData &)" << endl
;
8430 DigestedData::~DigestedData()
8432 delete digestAlgorithm
;
8433 delete encapContentInfo
;
8436 AsnType
*DigestedData::Clone() const
8438 return new DigestedData
;
8441 AsnType
*DigestedData::Copy() const
8443 return new DigestedData (*this);
8447 DigestedData
&DigestedData::operator = (const DigestedData
&that
)
8448 #else // SNACC_DEEP_COPY
8449 DigestedData
&DigestedData::operator = (const DigestedData
&)
8450 #endif // SNACC_DEEP_COPY
8455 version
= that
.version
;
8456 if (that
.digestAlgorithm
)
8458 if (!digestAlgorithm
)
8459 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8460 *digestAlgorithm
= *that
.digestAlgorithm
;
8464 delete digestAlgorithm
;
8465 digestAlgorithm
= NULL
;
8467 if (that
.encapContentInfo
)
8469 if (!encapContentInfo
)
8470 encapContentInfo
= new EncapsulatedContentInfo
;
8471 *encapContentInfo
= *that
.encapContentInfo
;
8475 delete encapContentInfo
;
8476 encapContentInfo
= NULL
;
8478 digest
= that
.digest
;
8482 #else // SNACC_DEEP_COPY
8483 Asn1Error
<< "use of incompletely defined DigestedData &DigestedData::operator = (const DigestedData &)" << endl
;
8485 // if your compiler complains here, check the -novolat option
8486 #endif // SNACC_DEEP_COPY
8490 DigestedData::BEncContent (BUF_TYPE b
)
8492 AsnLen totalLen
= 0;
8495 l
= digest
.BEncContent (b
);
8496 l
+= BEncDefLen (b
, l
);
8498 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
8502 l
= encapContentInfo
->BEncContent (b
);
8503 l
+= BEncConsLen (b
, l
);
8505 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8509 l
= digestAlgorithm
->BEncContent (b
);
8510 l
+= BEncConsLen (b
, l
);
8512 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8515 l
= version
.BEncContent (b
);
8516 BEncDefLenTo127 (b
, l
);
8519 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
8523 } // DigestedData::BEncContent
8526 void DigestedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8529 AsnLen seqBytesDecoded
= 0;
8531 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8533 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
8535 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8536 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8537 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8541 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8542 SnaccExcep::throwMe(-200);
8545 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8547 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8548 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8549 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8550 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8554 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8555 SnaccExcep::throwMe(-201);
8558 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8560 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8561 encapContentInfo
= new EncapsulatedContentInfo
;
8562 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8563 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8567 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8568 SnaccExcep::throwMe(-202);
8571 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
8572 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
8574 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8575 digest
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8579 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8580 SnaccExcep::throwMe(-203);
8583 bytesDecoded
+= seqBytesDecoded
;
8584 if (elmtLen0
== INDEFINITE_LEN
)
8586 BDecEoc (b
, bytesDecoded
, env
);
8589 else if (seqBytesDecoded
!= elmtLen0
)
8591 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8592 SnaccExcep::throwMe(-204);
8596 } // DigestedData::BDecContent
8598 AsnLen
DigestedData::BEnc (BUF_TYPE b
)
8601 l
= BEncContent (b
);
8602 l
+= BEncConsLen (b
, l
);
8603 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8607 void DigestedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8612 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8614 Asn1Error
<< "DigestedData::BDec: ERROR - wrong tag" << endl
;
8615 SnaccExcep::throwMe(-205);
8617 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8618 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8621 void DigestedData::Print (ostream
&os
) const
8624 os
<< "{ -- SEQUENCE --" << endl
;
8625 indentG
+= stdIndentG
;
8628 Indent (os
, indentG
);
8634 if (NOT_NULL (digestAlgorithm
))
8636 Indent (os
, indentG
);
8637 os
<< "digestAlgorithm ";
8638 os
<< *digestAlgorithm
;
8642 Indent (os
, indentG
);
8643 os
<< "digestAlgorithm ";
8648 if (NOT_NULL (encapContentInfo
))
8650 Indent (os
, indentG
);
8651 os
<< "encapContentInfo ";
8652 os
<< *encapContentInfo
;
8656 Indent (os
, indentG
);
8657 os
<< "encapContentInfo ";
8663 Indent (os
, indentG
);
8669 indentG
-= stdIndentG
;
8670 Indent (os
, indentG
);
8673 } // DigestedData::Print
8676 EncryptedData::EncryptedData()
8679 encryptedContentInfo
= new EncryptedContentInfo
;
8681 encryptedContentInfo
= NULL
; // incomplete initialization of mandatory element!
8685 EncryptedData::EncryptedData (const EncryptedData
&)
8687 Asn1Error
<< "use of incompletely defined EncryptedData::EncryptedData (const EncryptedData &)" << endl
;
8691 EncryptedData::~EncryptedData()
8693 delete encryptedContentInfo
;
8696 AsnType
*EncryptedData::Clone() const
8698 return new EncryptedData
;
8701 AsnType
*EncryptedData::Copy() const
8703 return new EncryptedData (*this);
8707 EncryptedData
&EncryptedData::operator = (const EncryptedData
&that
)
8708 #else // SNACC_DEEP_COPY
8709 EncryptedData
&EncryptedData::operator = (const EncryptedData
&)
8710 #endif // SNACC_DEEP_COPY
8715 version
= that
.version
;
8716 if (that
.encryptedContentInfo
)
8718 if (!encryptedContentInfo
)
8719 encryptedContentInfo
= new EncryptedContentInfo
;
8720 *encryptedContentInfo
= *that
.encryptedContentInfo
;
8724 delete encryptedContentInfo
;
8725 encryptedContentInfo
= NULL
;
8730 #else // SNACC_DEEP_COPY
8731 Asn1Error
<< "use of incompletely defined EncryptedData &EncryptedData::operator = (const EncryptedData &)" << endl
;
8733 // if your compiler complains here, check the -novolat option
8734 #endif // SNACC_DEEP_COPY
8738 EncryptedData::BEncContent (BUF_TYPE b
)
8740 AsnLen totalLen
= 0;
8744 l
= encryptedContentInfo
->BEncContent (b
);
8745 l
+= BEncConsLen (b
, l
);
8747 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8750 l
= version
.BEncContent (b
);
8751 BEncDefLenTo127 (b
, l
);
8754 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
8758 } // EncryptedData::BEncContent
8761 void EncryptedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8764 AsnLen seqBytesDecoded
= 0;
8766 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8768 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
8770 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8771 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8772 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8776 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8777 SnaccExcep::throwMe(-206);
8780 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8782 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8783 encryptedContentInfo
= new EncryptedContentInfo
;
8784 encryptedContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8788 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8789 SnaccExcep::throwMe(-207);
8792 bytesDecoded
+= seqBytesDecoded
;
8793 if (elmtLen0
== INDEFINITE_LEN
)
8795 BDecEoc (b
, bytesDecoded
, env
);
8798 else if (seqBytesDecoded
!= elmtLen0
)
8800 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8801 SnaccExcep::throwMe(-208);
8805 } // EncryptedData::BDecContent
8807 AsnLen
EncryptedData::BEnc (BUF_TYPE b
)
8810 l
= BEncContent (b
);
8811 l
+= BEncConsLen (b
, l
);
8812 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8816 void EncryptedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8821 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8823 Asn1Error
<< "EncryptedData::BDec: ERROR - wrong tag" << endl
;
8824 SnaccExcep::throwMe(-209);
8826 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8827 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8830 void EncryptedData::Print (ostream
&os
) const
8833 os
<< "{ -- SEQUENCE --" << endl
;
8834 indentG
+= stdIndentG
;
8837 Indent (os
, indentG
);
8843 if (NOT_NULL (encryptedContentInfo
))
8845 Indent (os
, indentG
);
8846 os
<< "encryptedContentInfo ";
8847 os
<< *encryptedContentInfo
;
8851 Indent (os
, indentG
);
8852 os
<< "encryptedContentInfo ";
8858 indentG
-= stdIndentG
;
8859 Indent (os
, indentG
);
8862 } // EncryptedData::Print
8865 AuthenticatedData::AuthenticatedData()
8867 originatorInfo
= NULL
;
8869 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
8871 macAlgorithm
= NULL
; // incomplete initialization of mandatory element!
8873 digestAlgorithm
= NULL
;
8875 encapContentInfo
= new EncapsulatedContentInfo
;
8877 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
8879 authenctiatedAttributes
= NULL
;
8880 unauthenticatedAttributes
= NULL
;
8883 AuthenticatedData::AuthenticatedData (const AuthenticatedData
&)
8885 Asn1Error
<< "use of incompletely defined AuthenticatedData::AuthenticatedData (const AuthenticatedData &)" << endl
;
8889 AuthenticatedData::~AuthenticatedData()
8891 delete originatorInfo
;
8892 delete macAlgorithm
;
8893 delete digestAlgorithm
;
8894 delete encapContentInfo
;
8895 delete authenctiatedAttributes
;
8896 delete unauthenticatedAttributes
;
8899 AsnType
*AuthenticatedData::Clone() const
8901 return new AuthenticatedData
;
8904 AsnType
*AuthenticatedData::Copy() const
8906 return new AuthenticatedData (*this);
8910 AuthenticatedData
&AuthenticatedData::operator = (const AuthenticatedData
&that
)
8911 #else // SNACC_DEEP_COPY
8912 AuthenticatedData
&AuthenticatedData::operator = (const AuthenticatedData
&)
8913 #endif // SNACC_DEEP_COPY
8918 version
= that
.version
;
8919 if (that
.originatorInfo
)
8921 if (!originatorInfo
)
8922 originatorInfo
= new OriginatorInfo
;
8923 *originatorInfo
= *that
.originatorInfo
;
8927 delete originatorInfo
;
8928 originatorInfo
= NULL
;
8930 recipientInfos
= that
.recipientInfos
;
8931 if (that
.macAlgorithm
)
8934 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
8935 *macAlgorithm
= *that
.macAlgorithm
;
8939 delete macAlgorithm
;
8940 macAlgorithm
= NULL
;
8942 if (that
.digestAlgorithm
)
8944 if (!digestAlgorithm
)
8945 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8946 *digestAlgorithm
= *that
.digestAlgorithm
;
8950 delete digestAlgorithm
;
8951 digestAlgorithm
= NULL
;
8953 if (that
.encapContentInfo
)
8955 if (!encapContentInfo
)
8956 encapContentInfo
= new EncapsulatedContentInfo
;
8957 *encapContentInfo
= *that
.encapContentInfo
;
8961 delete encapContentInfo
;
8962 encapContentInfo
= NULL
;
8964 if (that
.authenctiatedAttributes
)
8966 if (!authenctiatedAttributes
)
8967 authenctiatedAttributes
= new Attributes
;
8968 *authenctiatedAttributes
= *that
.authenctiatedAttributes
;
8972 delete authenctiatedAttributes
;
8973 authenctiatedAttributes
= NULL
;
8976 if (that
.unauthenticatedAttributes
)
8978 if (!unauthenticatedAttributes
)
8979 unauthenticatedAttributes
= new Attributes
;
8980 *unauthenticatedAttributes
= *that
.unauthenticatedAttributes
;
8984 delete unauthenticatedAttributes
;
8985 unauthenticatedAttributes
= NULL
;
8990 #else // SNACC_DEEP_COPY
8991 Asn1Error
<< "use of incompletely defined AuthenticatedData &AuthenticatedData::operator = (const AuthenticatedData &)" << endl
;
8993 // if your compiler complains here, check the -novolat option
8994 #endif // SNACC_DEEP_COPY
8998 AuthenticatedData::BEncContent (BUF_TYPE b
)
9000 AsnLen totalLen
= 0;
9003 if (NOT_NULL (unauthenticatedAttributes
))
9006 l
= unauthenticatedAttributes
->BEncContent (b
);
9007 l
+= BEncConsLen (b
, l
);
9009 l
+= BEncTag1 (b
, CNTX
, CONS
, 3);
9013 l
= mac
.BEncContent (b
);
9014 l
+= BEncDefLen (b
, l
);
9016 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
9019 if (NOT_NULL (authenctiatedAttributes
))
9022 l
= authenctiatedAttributes
->BEncContent (b
);
9023 l
+= BEncConsLen (b
, l
);
9025 l
+= BEncTag1 (b
, CNTX
, CONS
, 2);
9030 l
= encapContentInfo
->BEncContent (b
);
9031 l
+= BEncConsLen (b
, l
);
9033 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9036 if (NOT_NULL (digestAlgorithm
))
9039 l
= digestAlgorithm
->BEncContent (b
);
9040 l
+= BEncConsLen (b
, l
);
9042 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
9047 l
= macAlgorithm
->BEncContent (b
);
9048 l
+= BEncConsLen (b
, l
);
9050 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9054 l
= recipientInfos
.BEncContent (b
);
9055 l
+= BEncConsLen (b
, l
);
9057 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
9060 if (NOT_NULL (originatorInfo
))
9063 l
= originatorInfo
->BEncContent (b
);
9064 l
+= BEncConsLen (b
, l
);
9066 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
9070 l
= version
.BEncContent (b
);
9071 BEncDefLenTo127 (b
, l
);
9074 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
9078 } // AuthenticatedData::BEncContent
9081 void AuthenticatedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9084 AsnLen seqBytesDecoded
= 0;
9086 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9088 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
9090 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9091 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9092 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9096 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9097 SnaccExcep::throwMe(-210);
9100 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
9102 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9103 originatorInfo
= new OriginatorInfo
;
9104 originatorInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9105 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9108 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
9110 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9111 recipientInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9112 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9116 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9117 SnaccExcep::throwMe(-211);
9120 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9122 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9123 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
9124 macAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9125 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9129 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9130 SnaccExcep::throwMe(-212);
9133 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
9135 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9136 digestAlgorithm
= new DigestAlgorithmIdentifier
;
9137 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9138 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9141 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9143 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9144 encapContentInfo
= new EncapsulatedContentInfo
;
9145 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9146 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9150 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9151 SnaccExcep::throwMe(-213);
9154 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 2)))
9156 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9157 authenctiatedAttributes
= new Attributes
;
9158 authenctiatedAttributes
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9159 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9162 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
9163 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
9165 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9166 mac
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9167 if (seqBytesDecoded
== elmtLen0
)
9169 bytesDecoded
+= seqBytesDecoded
;
9174 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9176 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
9178 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
9179 bytesDecoded
+= seqBytesDecoded
;
9186 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9187 SnaccExcep::throwMe(-214);
9190 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 3)))
9192 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9193 unauthenticatedAttributes
= new Attributes
;
9194 unauthenticatedAttributes
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9197 bytesDecoded
+= seqBytesDecoded
;
9198 if (elmtLen0
== INDEFINITE_LEN
)
9200 BDecEoc (b
, bytesDecoded
, env
);
9203 else if (seqBytesDecoded
!= elmtLen0
)
9205 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
9206 SnaccExcep::throwMe(-215);
9210 } // AuthenticatedData::BDecContent
9212 AsnLen
AuthenticatedData::BEnc (BUF_TYPE b
)
9215 l
= BEncContent (b
);
9216 l
+= BEncConsLen (b
, l
);
9217 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9221 void AuthenticatedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9226 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
9228 Asn1Error
<< "AuthenticatedData::BDec: ERROR - wrong tag" << endl
;
9229 SnaccExcep::throwMe(-216);
9231 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9232 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9235 void AuthenticatedData::Print (ostream
&os
) const
9238 os
<< "{ -- SEQUENCE --" << endl
;
9239 indentG
+= stdIndentG
;
9242 Indent (os
, indentG
);
9248 if (NOT_NULL (originatorInfo
))
9250 Indent (os
, indentG
);
9251 os
<< "originatorInfo ";
9252 os
<< *originatorInfo
;
9256 Indent (os
, indentG
);
9257 os
<< "originatorInfo ";
9263 Indent (os
, indentG
);
9264 os
<< "recipientInfos ";
9265 os
<< recipientInfos
;
9269 if (NOT_NULL (macAlgorithm
))
9271 Indent (os
, indentG
);
9272 os
<< "macAlgorithm ";
9273 os
<< *macAlgorithm
;
9277 Indent (os
, indentG
);
9278 os
<< "macAlgorithm ";
9283 if (NOT_NULL (digestAlgorithm
))
9285 Indent (os
, indentG
);
9286 os
<< "digestAlgorithm ";
9287 os
<< *digestAlgorithm
;
9291 Indent (os
, indentG
);
9292 os
<< "digestAlgorithm ";
9297 if (NOT_NULL (encapContentInfo
))
9299 Indent (os
, indentG
);
9300 os
<< "encapContentInfo ";
9301 os
<< *encapContentInfo
;
9305 Indent (os
, indentG
);
9306 os
<< "encapContentInfo ";
9311 if (NOT_NULL (authenctiatedAttributes
))
9313 Indent (os
, indentG
);
9314 os
<< "authenctiatedAttributes ";
9315 os
<< *authenctiatedAttributes
;
9319 Indent (os
, indentG
);
9320 os
<< "authenctiatedAttributes ";
9326 Indent (os
, indentG
);
9332 if (NOT_NULL (unauthenticatedAttributes
))
9335 Indent (os
, indentG
);
9336 os
<< "unauthenticatedAttributes ";
9337 os
<< *unauthenticatedAttributes
;
9341 Indent (os
, indentG
);
9342 os
<< "unauthenticatedAttributes ";
9348 indentG
-= stdIndentG
;
9349 Indent (os
, indentG
);
9352 } // AuthenticatedData::Print
9355 AsnType
*UserKeyingMaterials::Clone() const
9357 return new UserKeyingMaterials
;
9360 AsnType
*UserKeyingMaterials::Copy() const
9362 return new UserKeyingMaterials (*this);
9365 AsnLen
UserKeyingMaterials::BEnc (BUF_TYPE b
)
9368 l
= BEncContent (b
);
9369 l
+= BEncConsLen (b
, l
);
9370 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
9374 void UserKeyingMaterials::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9379 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
9381 Asn1Error
<< "UserKeyingMaterials::BDec: ERROR - wrong tag" << endl
;
9382 SnaccExcep::throwMe(-217);
9384 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9385 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9388 UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials
&)
9390 Asn1Error
<< "use of incompletely defined UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials &)" << endl
;
9394 UserKeyingMaterials::~UserKeyingMaterials()
9397 for (; Curr() != NULL
; RemoveCurrFromList())
9399 } // end of destructor
9402 UserKeyingMaterials
&UserKeyingMaterials::operator = (const UserKeyingMaterials
&that
)
9403 #else // SNACC_DEEP_COPY
9404 UserKeyingMaterials
&UserKeyingMaterials::operator = (const UserKeyingMaterials
&)
9405 #endif // SNACC_DEEP_COPY
9411 for (; Curr(); RemoveCurrFromList())
9414 //that.SetCurrToFirst();
9415 //for (; that.Curr(); that.GoNext())
9416 // AppendCopy (*that.Curr());
9417 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
9418 AppendCopy (*run
->elmt
);
9422 #else // SNACC_DEEP_COPY
9423 Asn1Error
<< "use of incompletely defined UserKeyingMaterials &UserKeyingMaterials::operator = (const UserKeyingMaterials &)" << endl
;
9425 // if your compiler complains here, check the -novolat option
9426 #endif // SNACC_DEEP_COPY
9429 void UserKeyingMaterials::Print (ostream
&os
) const
9432 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
9433 indentG
+= stdIndentG
;
9435 //for (; Curr() != NULL; GoNext())
9436 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
9438 Indent (os
, indentG
);
9441 //if (Curr() != Last())
9446 indentG
-= stdIndentG
;
9447 Indent (os
, indentG
);
9455 void UserKeyingMaterials::SetCurrElmt (unsigned long int index
)
9457 unsigned long int i
;
9460 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
9462 } // UserKeyingMaterials::SetCurrElmt
9465 unsigned long int UserKeyingMaterials::GetCurrElmtIndex()
9467 unsigned long int i
;
9471 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
9480 } // UserKeyingMaterials::GetCurrElmtIndex
9483 // alloc new list elmt, put at end of list
9484 // and return the component type
9485 UserKeyingMaterial
*UserKeyingMaterials::Append()
9487 AsnListElmt
*newElmt
;
9488 newElmt
= new AsnListElmt
;
9489 newElmt
->elmt
= new UserKeyingMaterial
;
9490 newElmt
->next
= NULL
;
9493 newElmt
->prev
= NULL
;
9494 first
= last
= newElmt
;
9498 newElmt
->prev
= last
;
9499 last
->next
= newElmt
;
9503 return (curr
= newElmt
)->elmt
;
9504 } // UserKeyingMaterials::Append
9507 // alloc new list elmt, put at begining of list
9508 // and return the component type
9509 UserKeyingMaterial
*UserKeyingMaterials::Prepend()
9511 AsnListElmt
*newElmt
;
9512 newElmt
= new AsnListElmt
;
9513 newElmt
->elmt
= new UserKeyingMaterial
;
9514 newElmt
->prev
= NULL
;
9517 newElmt
->next
= NULL
;
9518 first
= last
= newElmt
;
9522 newElmt
->next
= first
;
9523 first
->prev
= newElmt
;
9527 return (curr
= newElmt
)->elmt
;
9528 } // UserKeyingMaterials::Prepend
9531 // alloc new list elmt, insert it before the
9532 // current element and return the component type
9533 // if the current element is null, the new element
9534 // is placed at the beginning of the list.
9535 UserKeyingMaterial
*UserKeyingMaterials::InsertBefore()
9537 AsnListElmt
*newElmt
;
9538 newElmt
= new AsnListElmt
;
9539 newElmt
->elmt
= new UserKeyingMaterial
;
9542 newElmt
->next
= first
;
9543 newElmt
->prev
= NULL
;
9550 newElmt
->next
= curr
;
9551 newElmt
->prev
= curr
->prev
;
9552 curr
->prev
= newElmt
;
9556 newElmt
->prev
->next
= newElmt
;
9559 return (curr
= newElmt
)->elmt
;
9560 } // UserKeyingMaterials::InsertBefore
9563 // alloc new list elmt, insert it after the
9564 // current element and return the component type
9565 // if the current element is null, the new element
9566 // is placed at the end of the list.
9567 UserKeyingMaterial
*UserKeyingMaterials::InsertAfter()
9569 AsnListElmt
*newElmt
;
9570 newElmt
= new AsnListElmt
;
9571 newElmt
->elmt
= new UserKeyingMaterial
;
9574 newElmt
->prev
= last
;
9575 newElmt
->next
= NULL
;
9582 newElmt
->prev
= curr
;
9583 newElmt
->next
= curr
->next
;
9584 curr
->next
= newElmt
;
9588 newElmt
->next
->prev
= newElmt
;
9591 return (curr
= newElmt
)->elmt
;
9592 } // UserKeyingMaterials::InsertAfter
9595 UserKeyingMaterials
&UserKeyingMaterials::AppendCopy (UserKeyingMaterial
&elmt
)
9597 AsnListElmt
*newElmt
;
9598 newElmt
= new AsnListElmt
;
9599 newElmt
->elmt
= new UserKeyingMaterial
;
9600 *newElmt
->elmt
= elmt
;
9601 newElmt
->next
= NULL
;
9604 newElmt
->prev
= NULL
;
9605 first
= last
= newElmt
;
9609 newElmt
->prev
= last
;
9610 last
->next
= newElmt
;
9618 UserKeyingMaterials
&UserKeyingMaterials::PrependCopy (UserKeyingMaterial
&elmt
)
9620 AsnListElmt
*newElmt
;
9621 newElmt
= new AsnListElmt
;
9622 newElmt
->elmt
= new UserKeyingMaterial
;
9623 *newElmt
->elmt
= elmt
;
9624 newElmt
->prev
= NULL
;
9627 newElmt
->next
= NULL
;
9628 first
= last
= newElmt
;
9632 newElmt
->next
= first
;
9633 first
->prev
= newElmt
;
9638 } // UserKeyingMaterials::PrependCopy
9641 // alloc new list elmt, insert it before the
9642 // current element, copy the given elmt into the new elmt
9643 // and return the component type.
9644 // if the current element is null, the new element
9645 // is placed at the beginning of the list.
9646 UserKeyingMaterials
&UserKeyingMaterials::InsertBeforeAndCopy (UserKeyingMaterial
&elmt
)
9648 AsnListElmt
*newElmt
;
9650 newElmt
= new AsnListElmt
;
9651 newElmt
->elmt
= new UserKeyingMaterial
;
9652 *newElmt
->elmt
= elmt
;
9656 newElmt
->next
= first
;
9657 newElmt
->prev
= NULL
;
9664 newElmt
->next
= curr
;
9665 newElmt
->prev
= curr
->prev
;
9666 curr
->prev
= newElmt
;
9670 newElmt
->prev
->next
= newElmt
;
9674 } // UserKeyingMaterials::InsertBeforeAndCopy
9677 // alloc new list elmt, insert it after the
9678 // current element, copy given elmt in to new elmt
9679 // and return the component type
9680 // if the current element is null, the new element
9681 // is placed at the end of the list.
9682 UserKeyingMaterials
&UserKeyingMaterials::InsertAfterAndCopy (UserKeyingMaterial
&elmt
)
9684 AsnListElmt
*newElmt
;
9686 newElmt
= new AsnListElmt
;
9687 newElmt
->elmt
= new UserKeyingMaterial
;
9688 *newElmt
->elmt
= elmt
;
9691 newElmt
->prev
= last
;
9692 newElmt
->next
= NULL
;
9699 newElmt
->prev
= curr
;
9700 newElmt
->next
= curr
->next
;
9701 curr
->next
= newElmt
;
9705 newElmt
->next
->prev
= newElmt
;
9709 } // UserKeyingMaterials::InsertAfterAndCopy
9712 // remove current element from list if current element is not NULL
9713 // The new current element will be the next element.
9714 // If the current element is the last element in the list
9715 // the second but last element will become the new current element.
9716 void UserKeyingMaterials::RemoveCurrFromList()
9718 AsnListElmt
*del_elmt
;
9726 first
= last
= curr
= NULL
;
9727 else if (curr
== first
)
9729 curr
= first
= first
->next
;
9732 else if (curr
== last
)
9734 curr
= last
= last
->prev
;
9739 curr
->prev
->next
= curr
->next
;
9740 curr
->next
->prev
= curr
->prev
;
9743 delete del_elmt
->elmt
;
9749 AsnLen
UserKeyingMaterials::BEncContent (BUF_TYPE b
)
9751 AsnListElmt
*currElmt
;
9753 AsnLen totalLen
= 0;
9756 CSM_Buffer
**tmpEnc
=NULL
;
9757 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
9758 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
9759 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
9761 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
9762 elmtLen
+= BEncDefLen (outputBuf
, elmtLen
);
9764 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
9765 ENCODE_BUF2(tmpEnc
[iii
]);
9767 vdasnacc_sortSetOf(tmpEnc
, icount
);
9768 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
9769 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
9770 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
9773 totalLen
+= elmtLen
;
9775 } // UserKeyingMaterials::BEncContent
9778 void UserKeyingMaterials::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
9779 AsnLen
&bytesDecoded
, ENV_TYPE env
)
9781 UserKeyingMaterial
*listElmt
;
9783 AsnLen listBytesDecoded
= 0;
9786 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
9788 tag1
= BDecTag (b
, listBytesDecoded
, env
);
9789 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
9791 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
9794 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
9795 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
9797 Asn1Error
<< "Unexpected Tag" << endl
;
9798 SnaccExcep::throwMe(-218);
9801 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
9802 listElmt
= Append();
9803 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
9806 bytesDecoded
+= listBytesDecoded
;
9807 } // UserKeyingMaterials::BDecContent
9810 RC2CBCParameter::RC2CBCParameter()
9814 RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter
&)
9816 Asn1Error
<< "use of incompletely defined RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter &)" << endl
;
9820 RC2CBCParameter::~RC2CBCParameter()
9824 AsnType
*RC2CBCParameter::Clone() const
9826 return new RC2CBCParameter
;
9829 AsnType
*RC2CBCParameter::Copy() const
9831 return new RC2CBCParameter (*this);
9835 RC2CBCParameter
&RC2CBCParameter::operator = (const RC2CBCParameter
&that
)
9836 #else // SNACC_DEEP_COPY
9837 RC2CBCParameter
&RC2CBCParameter::operator = (const RC2CBCParameter
&)
9838 #endif // SNACC_DEEP_COPY
9843 rc2ParameterVersion
= that
.rc2ParameterVersion
;
9848 #else // SNACC_DEEP_COPY
9849 Asn1Error
<< "use of incompletely defined RC2CBCParameter &RC2CBCParameter::operator = (const RC2CBCParameter &)" << endl
;
9851 // if your compiler complains here, check the -novolat option
9852 #endif // SNACC_DEEP_COPY
9856 RC2CBCParameter::BEncContent (BUF_TYPE b
)
9858 AsnLen totalLen
= 0;
9861 l
= iv
.BEncContent (b
);
9862 l
+= BEncDefLen (b
, l
);
9864 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
9867 l
= rc2ParameterVersion
.BEncContent (b
);
9868 BEncDefLenTo127 (b
, l
);
9871 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
9875 } // RC2CBCParameter::BEncContent
9878 void RC2CBCParameter::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9881 AsnLen seqBytesDecoded
= 0;
9883 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9885 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
9887 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9888 rc2ParameterVersion
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9889 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9893 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9894 SnaccExcep::throwMe(-219);
9897 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
9898 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
9900 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9901 iv
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9905 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9906 SnaccExcep::throwMe(-220);
9909 bytesDecoded
+= seqBytesDecoded
;
9910 if (elmtLen0
== INDEFINITE_LEN
)
9912 BDecEoc (b
, bytesDecoded
, env
);
9915 else if (seqBytesDecoded
!= elmtLen0
)
9917 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
9918 SnaccExcep::throwMe(-221);
9922 } // RC2CBCParameter::BDecContent
9924 AsnLen
RC2CBCParameter::BEnc (BUF_TYPE b
)
9927 l
= BEncContent (b
);
9928 l
+= BEncConsLen (b
, l
);
9929 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9933 void RC2CBCParameter::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9938 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
9940 Asn1Error
<< "RC2CBCParameter::BDec: ERROR - wrong tag" << endl
;
9941 SnaccExcep::throwMe(-222);
9943 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9944 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9947 void RC2CBCParameter::Print (ostream
&os
) const
9950 os
<< "{ -- SEQUENCE --" << endl
;
9951 indentG
+= stdIndentG
;
9954 Indent (os
, indentG
);
9955 os
<< "rc2ParameterVersion ";
9956 os
<< rc2ParameterVersion
;
9961 Indent (os
, indentG
);
9967 indentG
-= stdIndentG
;
9968 Indent (os
, indentG
);
9971 } // RC2CBCParameter::Print
9974 ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate()
9976 choiceId
= certificateCid
;
9978 certificate
= new Certificate
;
9980 certificate
= NULL
; // incomplete initialization of mandatory element!
9984 ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate
&)
9986 Asn1Error
<< "use of incompletely defined ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &)" << endl
;
9990 ExtendedCertificateOrCertificate::~ExtendedCertificateOrCertificate()
9994 case certificateCid
:
9997 case extendedCertificateCid
:
9998 delete extendedCertificate
;
10001 } // end of destructor
10003 AsnType
*ExtendedCertificateOrCertificate::Clone() const
10005 return new ExtendedCertificateOrCertificate
;
10008 AsnType
*ExtendedCertificateOrCertificate::Copy() const
10010 return new ExtendedCertificateOrCertificate (*this);
10013 #if SNACC_DEEP_COPY
10014 ExtendedCertificateOrCertificate
&ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate
&that
)
10015 #else // SNACC_DEEP_COPY
10016 ExtendedCertificateOrCertificate
&ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate
&)
10017 #endif // SNACC_DEEP_COPY
10019 #if SNACC_DEEP_COPY
10024 case certificateCid
:
10025 delete certificate
;
10027 case extendedCertificateCid
:
10028 delete extendedCertificate
;
10031 switch (choiceId
= that
.choiceId
)
10033 case certificateCid
:
10034 certificate
= new Certificate
;
10035 *certificate
= *that
.certificate
;
10037 case extendedCertificateCid
:
10038 extendedCertificate
= new ExtendedCertificate
;
10039 *extendedCertificate
= *that
.extendedCertificate
;
10045 #else // SNACC_DEEP_COPY
10046 Asn1Error
<< "use of incompletely defined ExtendedCertificateOrCertificate &ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate &)" << endl
;
10048 // if your compiler complains here, check the -novolat option
10049 #endif // SNACC_DEEP_COPY
10053 ExtendedCertificateOrCertificate::BEncContent (BUF_TYPE b
)
10058 case certificateCid
:
10060 l
= certificate
->BEncContent (b
);
10061 l
+= BEncConsLen (b
, l
);
10063 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10066 case extendedCertificateCid
:
10068 l
= extendedCertificate
->BEncContent (b
);
10069 l
+= BEncConsLen (b
, l
);
10071 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
10076 } // ExtendedCertificateOrCertificate::BEncContent
10079 void ExtendedCertificateOrCertificate::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10083 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
10084 choiceId
= certificateCid
;
10085 certificate
= new Certificate
;
10086 certificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
10089 case MAKE_TAG_ID (CNTX
, CONS
, 0):
10090 choiceId
= extendedCertificateCid
;
10091 extendedCertificate
= new ExtendedCertificate
;
10092 extendedCertificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
10096 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
10097 SnaccExcep::throwMe(-223);
10100 } // ExtendedCertificateOrCertificate::BDecContent
10103 AsnLen
ExtendedCertificateOrCertificate::BEnc (BUF_TYPE b
)
10106 l
= BEncContent (b
);
10110 void ExtendedCertificateOrCertificate::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10115 /* CHOICEs are a special case - grab identifying tag */
10116 /* this allows easier handling of nested CHOICEs */
10117 tag
= BDecTag (b
, bytesDecoded
, env
);
10118 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
10119 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
10122 void ExtendedCertificateOrCertificate::Print (ostream
&os
) const
10127 case certificateCid
:
10128 os
<< "certificate ";
10130 os
<< *certificate
;
10132 os
<< "-- void3 --\n";
10135 case extendedCertificateCid
:
10136 os
<< "extendedCertificate ";
10137 if (extendedCertificate
)
10138 os
<< *extendedCertificate
;
10140 os
<< "-- void3 --\n";
10144 #endif /* NDEBUG */
10145 } // ExtendedCertificateOrCertificate::Print
10147 DigestInfo::DigestInfo()
10150 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10152 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
10156 DigestInfo::DigestInfo (const DigestInfo
&)
10158 Asn1Error
<< "use of incompletely defined DigestInfo::DigestInfo (const DigestInfo &)" << endl
;
10162 DigestInfo::~DigestInfo()
10164 delete digestAlgorithm
;
10167 AsnType
*DigestInfo::Clone() const
10169 return new DigestInfo
;
10172 AsnType
*DigestInfo::Copy() const
10174 return new DigestInfo (*this);
10177 #if SNACC_DEEP_COPY
10178 DigestInfo
&DigestInfo::operator = (const DigestInfo
&that
)
10179 #else // SNACC_DEEP_COPY
10180 DigestInfo
&DigestInfo::operator = (const DigestInfo
&)
10181 #endif // SNACC_DEEP_COPY
10183 #if SNACC_DEEP_COPY
10186 if (that
.digestAlgorithm
)
10188 if (!digestAlgorithm
)
10189 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10190 *digestAlgorithm
= *that
.digestAlgorithm
;
10194 delete digestAlgorithm
;
10195 digestAlgorithm
= NULL
;
10197 digest
= that
.digest
;
10201 #else // SNACC_DEEP_COPY
10202 Asn1Error
<< "use of incompletely defined DigestInfo &DigestInfo::operator = (const DigestInfo &)" << endl
;
10204 // if your compiler complains here, check the -novolat option
10205 #endif // SNACC_DEEP_COPY
10209 DigestInfo::BEncContent (BUF_TYPE b
)
10211 AsnLen totalLen
= 0;
10214 l
= digest
.BEncContent (b
);
10215 l
+= BEncDefLen (b
, l
);
10217 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
10221 l
= digestAlgorithm
->BEncContent (b
);
10222 l
+= BEncConsLen (b
, l
);
10224 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10228 } // DigestInfo::BEncContent
10231 void DigestInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10234 AsnLen seqBytesDecoded
= 0;
10236 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10238 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
10240 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10241 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10242 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10243 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10247 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10248 SnaccExcep::throwMe(-224);
10251 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
10252 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
10254 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10255 digest
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10259 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10260 SnaccExcep::throwMe(-225);
10263 bytesDecoded
+= seqBytesDecoded
;
10264 if (elmtLen0
== INDEFINITE_LEN
)
10266 BDecEoc (b
, bytesDecoded
, env
);
10269 else if (seqBytesDecoded
!= elmtLen0
)
10271 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
10272 SnaccExcep::throwMe(-226);
10276 } // DigestInfo::BDecContent
10278 AsnLen
DigestInfo::BEnc (BUF_TYPE b
)
10281 l
= BEncContent (b
);
10282 l
+= BEncConsLen (b
, l
);
10283 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10287 void DigestInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10292 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
10294 Asn1Error
<< "DigestInfo::BDec: ERROR - wrong tag" << endl
;
10295 SnaccExcep::throwMe(-227);
10297 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
10298 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
10301 void DigestInfo::Print (ostream
&os
) const
10304 os
<< "{ -- SEQUENCE --" << endl
;
10305 indentG
+= stdIndentG
;
10307 if (NOT_NULL (digestAlgorithm
))
10309 Indent (os
, indentG
);
10310 os
<< "digestAlgorithm ";
10311 os
<< *digestAlgorithm
;
10315 Indent (os
, indentG
);
10316 os
<< "digestAlgorithm ";
10317 os
<< "-- void --";
10322 Indent (os
, indentG
);
10328 indentG
-= stdIndentG
;
10329 Indent (os
, indentG
);
10331 #endif /* NDEBUG */
10332 } // DigestInfo::Print