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 Wed Jun 27 16:40:55 2001
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
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"
28 //------------------------------------------------------------------------------
32 //------------------------------------------------------------------------------
33 // class member definitions:
35 OriginatorPublicKey::OriginatorPublicKey()
38 algorithm
= new AlgorithmIdentifier
;
40 algorithm
= NULL
; // incomplete initialization of mandatory element!
44 OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey
&)
46 Asn1Error
<< "use of incompletely defined OriginatorPublicKey::OriginatorPublicKey (const OriginatorPublicKey &)" << endl
;
50 OriginatorPublicKey::~OriginatorPublicKey()
55 AsnType
*OriginatorPublicKey::Clone() const
57 return new OriginatorPublicKey
;
60 AsnType
*OriginatorPublicKey::Copy() const
62 return new OriginatorPublicKey (*this);
66 OriginatorPublicKey
&OriginatorPublicKey::operator = (const OriginatorPublicKey
&that
)
67 #else // SNACC_DEEP_COPY
68 OriginatorPublicKey
&OriginatorPublicKey::operator = (const OriginatorPublicKey
&)
69 #endif // SNACC_DEEP_COPY
77 algorithm
= new AlgorithmIdentifier
;
78 *algorithm
= *that
.algorithm
;
85 publicKey
= that
.publicKey
;
89 #else // SNACC_DEEP_COPY
90 Asn1Error
<< "use of incompletely defined OriginatorPublicKey &OriginatorPublicKey::operator = (const OriginatorPublicKey &)" << endl
;
92 // if your compiler complains here, check the -novolat option
93 #endif // SNACC_DEEP_COPY
97 OriginatorPublicKey::BEncContent (BUF_TYPE b
)
102 l
= publicKey
.BEncContent (b
);
103 l
+= BEncDefLen (b
, l
);
105 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
109 l
= algorithm
->BEncContent (b
);
110 l
+= BEncConsLen (b
, l
);
112 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
116 } // OriginatorPublicKey::BEncContent
119 void OriginatorPublicKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
122 AsnLen seqBytesDecoded
= 0;
124 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
126 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
128 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
129 algorithm
= new AlgorithmIdentifier
;
130 algorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
131 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
135 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
139 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
140 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
142 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
143 publicKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
147 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
151 bytesDecoded
+= seqBytesDecoded
;
152 if (elmtLen0
== INDEFINITE_LEN
)
154 BDecEoc (b
, bytesDecoded
, env
);
157 else if (seqBytesDecoded
!= elmtLen0
)
159 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
164 } // OriginatorPublicKey::BDecContent
166 AsnLen
OriginatorPublicKey::BEnc (BUF_TYPE b
)
170 l
+= BEncConsLen (b
, l
);
171 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
175 void OriginatorPublicKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
180 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
182 Asn1Error
<< "OriginatorPublicKey::BDec: ERROR - wrong tag" << endl
;
185 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
186 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
189 int OriginatorPublicKey::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
191 bytesEncoded
= BEnc (b
);
192 return !b
.WriteError();
195 int OriginatorPublicKey::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
201 if ((val
= setjmp (env
)) == 0)
203 BDec (b
, bytesDecoded
, env
);
204 return !b
.ReadError();
210 void OriginatorPublicKey::Print (ostream
&os
) const
213 os
<< "{ -- SEQUENCE --" << endl
;
214 indentG
+= stdIndentG
;
216 if (NOT_NULL (algorithm
))
218 Indent (os
, indentG
);
224 Indent (os
, indentG
);
231 Indent (os
, indentG
);
237 indentG
-= stdIndentG
;
238 Indent (os
, indentG
);
241 } // OriginatorPublicKey::Print
244 AsnType
*CertificateRevocationLists::Clone() const
246 return new CertificateRevocationLists
;
249 AsnType
*CertificateRevocationLists::Copy() const
251 return new CertificateRevocationLists (*this);
254 AsnLen
CertificateRevocationLists::BEnc (BUF_TYPE b
)
258 l
+= BEncConsLen (b
, l
);
259 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
263 void CertificateRevocationLists::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
268 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
270 Asn1Error
<< "CertificateRevocationLists::BDec: ERROR - wrong tag" << endl
;
273 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
274 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
277 CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists
&)
279 Asn1Error
<< "use of incompletely defined CertificateRevocationLists::CertificateRevocationLists (const CertificateRevocationLists &)" << endl
;
283 CertificateRevocationLists::~CertificateRevocationLists()
286 for (; Curr() != NULL
; RemoveCurrFromList())
288 } // end of destructor
291 CertificateRevocationLists
&CertificateRevocationLists::operator = (const CertificateRevocationLists
&that
)
292 #else // SNACC_DEEP_COPY
293 CertificateRevocationLists
&CertificateRevocationLists::operator = (const CertificateRevocationLists
&)
294 #endif // SNACC_DEEP_COPY
300 for (; Curr(); RemoveCurrFromList())
303 //that.SetCurrToFirst();
304 //for (; that.Curr(); that.GoNext())
305 // AppendCopy (*that.Curr());
306 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
307 AppendCopy (*run
->elmt
);
311 #else // SNACC_DEEP_COPY
312 Asn1Error
<< "use of incompletely defined CertificateRevocationLists &CertificateRevocationLists::operator = (const CertificateRevocationLists &)" << endl
;
314 // if your compiler complains here, check the -novolat option
315 #endif // SNACC_DEEP_COPY
318 void CertificateRevocationLists::Print (ostream
&os
) const
321 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
322 indentG
+= stdIndentG
;
324 //for (; Curr() != NULL; GoNext())
325 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
327 Indent (os
, indentG
);
330 //if (Curr() != Last())
335 indentG
-= stdIndentG
;
336 Indent (os
, indentG
);
344 void CertificateRevocationLists::SetCurrElmt (unsigned long int index
)
349 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
351 } // CertificateRevocationLists::SetCurrElmt
354 unsigned long int CertificateRevocationLists::GetCurrElmtIndex()
360 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
369 } // CertificateRevocationLists::GetCurrElmtIndex
372 // alloc new list elmt, put at end of list
373 // and return the component type
374 CertificateList
*CertificateRevocationLists::Append()
376 AsnListElmt
*newElmt
;
377 newElmt
= new AsnListElmt
;
378 newElmt
->elmt
= new CertificateList
;
379 newElmt
->next
= NULL
;
382 newElmt
->prev
= NULL
;
383 first
= last
= newElmt
;
387 newElmt
->prev
= last
;
388 last
->next
= newElmt
;
392 return (curr
= newElmt
)->elmt
;
393 } // CertificateRevocationLists::Append
396 // alloc new list elmt, put at begining of list
397 // and return the component type
398 CertificateList
*CertificateRevocationLists::Prepend()
400 AsnListElmt
*newElmt
;
401 newElmt
= new AsnListElmt
;
402 newElmt
->elmt
= new CertificateList
;
403 newElmt
->prev
= NULL
;
406 newElmt
->next
= NULL
;
407 first
= last
= newElmt
;
411 newElmt
->next
= first
;
412 first
->prev
= newElmt
;
416 return (curr
= newElmt
)->elmt
;
417 } // CertificateRevocationLists::Prepend
420 // alloc new list elmt, insert it before the
421 // current element and return the component type
422 // if the current element is null, the new element
423 // is placed at the beginning of the list.
424 CertificateList
*CertificateRevocationLists::InsertBefore()
426 AsnListElmt
*newElmt
;
427 newElmt
= new AsnListElmt
;
428 newElmt
->elmt
= new CertificateList
;
431 newElmt
->next
= first
;
432 newElmt
->prev
= NULL
;
439 newElmt
->next
= curr
;
440 newElmt
->prev
= curr
->prev
;
441 curr
->prev
= newElmt
;
445 newElmt
->prev
->next
= newElmt
;
448 return (curr
= newElmt
)->elmt
;
449 } // CertificateRevocationLists::InsertBefore
452 // alloc new list elmt, insert it after the
453 // current element and return the component type
454 // if the current element is null, the new element
455 // is placed at the end of the list.
456 CertificateList
*CertificateRevocationLists::InsertAfter()
458 AsnListElmt
*newElmt
;
459 newElmt
= new AsnListElmt
;
460 newElmt
->elmt
= new CertificateList
;
463 newElmt
->prev
= last
;
464 newElmt
->next
= NULL
;
471 newElmt
->prev
= curr
;
472 newElmt
->next
= curr
->next
;
473 curr
->next
= newElmt
;
477 newElmt
->next
->prev
= newElmt
;
480 return (curr
= newElmt
)->elmt
;
481 } // CertificateRevocationLists::InsertAfter
484 CertificateRevocationLists
&CertificateRevocationLists::AppendCopy (CertificateList
&elmt
)
486 AsnListElmt
*newElmt
;
487 newElmt
= new AsnListElmt
;
488 newElmt
->elmt
= new CertificateList
;
489 *newElmt
->elmt
= elmt
;
490 newElmt
->next
= NULL
;
493 newElmt
->prev
= NULL
;
494 first
= last
= newElmt
;
498 newElmt
->prev
= last
;
499 last
->next
= newElmt
;
507 CertificateRevocationLists
&CertificateRevocationLists::PrependCopy (CertificateList
&elmt
)
509 AsnListElmt
*newElmt
;
510 newElmt
= new AsnListElmt
;
511 newElmt
->elmt
= new CertificateList
;
512 *newElmt
->elmt
= elmt
;
513 newElmt
->prev
= NULL
;
516 newElmt
->next
= NULL
;
517 first
= last
= newElmt
;
521 newElmt
->next
= first
;
522 first
->prev
= newElmt
;
527 } // CertificateRevocationLists::PrependCopy
530 // alloc new list elmt, insert it before the
531 // current element, copy the given elmt into the new elmt
532 // and return the component type.
533 // if the current element is null, the new element
534 // is placed at the beginning of the list.
535 CertificateRevocationLists
&CertificateRevocationLists::InsertBeforeAndCopy (CertificateList
&elmt
)
537 AsnListElmt
*newElmt
;
539 newElmt
= new AsnListElmt
;
540 newElmt
->elmt
= new CertificateList
;
541 *newElmt
->elmt
= elmt
;
545 newElmt
->next
= first
;
546 newElmt
->prev
= NULL
;
553 newElmt
->next
= curr
;
554 newElmt
->prev
= curr
->prev
;
555 curr
->prev
= newElmt
;
559 newElmt
->prev
->next
= newElmt
;
563 } // CertificateRevocationLists::InsertBeforeAndCopy
566 // alloc new list elmt, insert it after the
567 // current element, copy given elmt in to new elmt
568 // and return the component type
569 // if the current element is null, the new element
570 // is placed at the end of the list.
571 CertificateRevocationLists
&CertificateRevocationLists::InsertAfterAndCopy (CertificateList
&elmt
)
573 AsnListElmt
*newElmt
;
575 newElmt
= new AsnListElmt
;
576 newElmt
->elmt
= new CertificateList
;
577 *newElmt
->elmt
= elmt
;
580 newElmt
->prev
= last
;
581 newElmt
->next
= NULL
;
588 newElmt
->prev
= curr
;
589 newElmt
->next
= curr
->next
;
590 curr
->next
= newElmt
;
594 newElmt
->next
->prev
= newElmt
;
598 } // CertificateRevocationLists::InsertAfterAndCopy
601 // remove current element from list if current element is not NULL
602 // The new current element will be the next element.
603 // If the current element is the last element in the list
604 // the second but last element will become the new current element.
605 void CertificateRevocationLists::RemoveCurrFromList()
607 AsnListElmt
*del_elmt
;
615 first
= last
= curr
= NULL
;
616 else if (curr
== first
)
618 curr
= first
= first
->next
;
621 else if (curr
== last
)
623 curr
= last
= last
->prev
;
628 curr
->prev
->next
= curr
->next
;
629 curr
->next
->prev
= curr
->prev
;
632 delete del_elmt
->elmt
;
638 AsnLen
CertificateRevocationLists::BEncContent (BUF_TYPE b
)
640 AsnListElmt
*currElmt
;
645 CSM_Buffer
**tmpEnc
=NULL
;
646 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
647 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
648 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
651 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
652 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
654 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
655 ENCODE_BUF2(tmpEnc
[iii
]);
657 vdasnacc_sortSetOf(tmpEnc
, icount
);
658 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
659 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
660 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
665 } // CertificateRevocationLists::BEncContent
668 void CertificateRevocationLists::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
669 AsnLen
&bytesDecoded
, ENV_TYPE env
)
671 CertificateList
*listElmt
;
673 AsnLen listBytesDecoded
= 0;
676 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
678 tag1
= BDecTag (b
, listBytesDecoded
, env
);
679 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
681 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
684 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
686 Asn1Error
<< "Unexpected Tag" << endl
;
690 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
692 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
695 bytesDecoded
+= listBytesDecoded
;
696 } // CertificateRevocationLists::BDecContent
699 IssuerAndSerialNumber::IssuerAndSerialNumber()
704 issuer
= NULL
; // incomplete initialization of mandatory element!
708 IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber
&)
710 Asn1Error
<< "use of incompletely defined IssuerAndSerialNumber::IssuerAndSerialNumber (const IssuerAndSerialNumber &)" << endl
;
714 IssuerAndSerialNumber::~IssuerAndSerialNumber()
719 AsnType
*IssuerAndSerialNumber::Clone() const
721 return new IssuerAndSerialNumber
;
724 AsnType
*IssuerAndSerialNumber::Copy() const
726 return new IssuerAndSerialNumber (*this);
730 IssuerAndSerialNumber
&IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber
&that
)
731 #else // SNACC_DEEP_COPY
732 IssuerAndSerialNumber
&IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber
&)
733 #endif // SNACC_DEEP_COPY
742 *issuer
= *that
.issuer
;
749 serialNumber
= that
.serialNumber
;
753 #else // SNACC_DEEP_COPY
754 Asn1Error
<< "use of incompletely defined IssuerAndSerialNumber &IssuerAndSerialNumber::operator = (const IssuerAndSerialNumber &)" << endl
;
756 // if your compiler complains here, check the -novolat option
757 #endif // SNACC_DEEP_COPY
761 IssuerAndSerialNumber::BEncContent (BUF_TYPE b
)
766 l
= serialNumber
.BEncContent (b
);
767 l
+= BEncDefLen (b
, l
);
769 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
772 l
= issuer
->BEncContent (b
);
776 } // IssuerAndSerialNumber::BEncContent
779 void IssuerAndSerialNumber::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
782 AsnLen seqBytesDecoded
= 0;
784 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
786 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
788 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
790 issuer
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
791 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
795 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
799 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
800 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
802 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
803 serialNumber
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
807 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
811 bytesDecoded
+= seqBytesDecoded
;
812 if (elmtLen0
== INDEFINITE_LEN
)
814 BDecEoc (b
, bytesDecoded
, env
);
817 else if (seqBytesDecoded
!= elmtLen0
)
819 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
824 } // IssuerAndSerialNumber::BDecContent
826 AsnLen
IssuerAndSerialNumber::BEnc (BUF_TYPE b
)
830 l
+= BEncConsLen (b
, l
);
831 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
835 void IssuerAndSerialNumber::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
840 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
842 Asn1Error
<< "IssuerAndSerialNumber::BDec: ERROR - wrong tag" << endl
;
845 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
846 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
849 int IssuerAndSerialNumber::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
851 bytesEncoded
= BEnc (b
);
852 return !b
.WriteError();
855 int IssuerAndSerialNumber::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
861 if ((val
= setjmp (env
)) == 0)
863 BDec (b
, bytesDecoded
, env
);
864 return !b
.ReadError();
870 void IssuerAndSerialNumber::Print (ostream
&os
) const
873 os
<< "{ -- SEQUENCE --" << endl
;
874 indentG
+= stdIndentG
;
876 if (NOT_NULL (issuer
))
878 Indent (os
, indentG
);
884 Indent (os
, indentG
);
891 Indent (os
, indentG
);
892 os
<< "serialNumber ";
897 indentG
-= stdIndentG
;
898 Indent (os
, indentG
);
901 } // IssuerAndSerialNumber::Print
904 OtherKeyAttribute::OtherKeyAttribute()
909 OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute
&)
911 Asn1Error
<< "use of incompletely defined OtherKeyAttribute::OtherKeyAttribute (const OtherKeyAttribute &)" << endl
;
915 OtherKeyAttribute::~OtherKeyAttribute()
920 AsnType
*OtherKeyAttribute::Clone() const
922 return new OtherKeyAttribute
;
925 AsnType
*OtherKeyAttribute::Copy() const
927 return new OtherKeyAttribute (*this);
931 OtherKeyAttribute
&OtherKeyAttribute::operator = (const OtherKeyAttribute
&that
)
932 #else // SNACC_DEEP_COPY
933 OtherKeyAttribute
&OtherKeyAttribute::operator = (const OtherKeyAttribute
&)
934 #endif // SNACC_DEEP_COPY
939 keyAttrId
= that
.keyAttrId
;
943 keyAttr
= new AsnAny
;
944 *keyAttr
= *that
.keyAttr
;
954 #else // SNACC_DEEP_COPY
955 Asn1Error
<< "use of incompletely defined OtherKeyAttribute &OtherKeyAttribute::operator = (const OtherKeyAttribute &)" << endl
;
957 // if your compiler complains here, check the -novolat option
958 #endif // SNACC_DEEP_COPY
962 OtherKeyAttribute::BEncContent (BUF_TYPE b
)
967 if (NOT_NULL (keyAttr
))
969 ENC_LOAD_ANYBUF(keyAttr
, b
, l
);
973 l
= keyAttrId
.BEncContent (b
);
974 l
+= BEncDefLen (b
, l
);
976 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
980 } // OtherKeyAttribute::BEncContent
983 void OtherKeyAttribute::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
986 AsnLen seqBytesDecoded
= 0;
988 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
990 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
992 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
993 keyAttrId
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
994 if (seqBytesDecoded
== elmtLen0
)
996 bytesDecoded
+= seqBytesDecoded
;
1001 tag1
= b
.PeekByte();
1003 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
1005 BDecEoc (b
, seqBytesDecoded
, env
);
1007 bytesDecoded
+= seqBytesDecoded
;
1014 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1015 longjmp (env
, -110);
1019 keyAttr
= new AsnAny
;
1020 DEC_LOAD_ANYBUF(keyAttr
, b
, seqBytesDecoded
, env
);
1023 bytesDecoded
+= seqBytesDecoded
;
1024 if (elmtLen0
== INDEFINITE_LEN
)
1026 BDecEoc (b
, bytesDecoded
, env
);
1029 else if (seqBytesDecoded
!= elmtLen0
)
1031 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1032 longjmp (env
, -111);
1036 } // OtherKeyAttribute::BDecContent
1038 AsnLen
OtherKeyAttribute::BEnc (BUF_TYPE b
)
1041 l
= BEncContent (b
);
1042 l
+= BEncConsLen (b
, l
);
1043 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1047 void OtherKeyAttribute::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1052 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1054 Asn1Error
<< "OtherKeyAttribute::BDec: ERROR - wrong tag" << endl
;
1055 longjmp (env
, -112);
1057 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1058 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1061 int OtherKeyAttribute::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
1063 bytesEncoded
= BEnc (b
);
1064 return !b
.WriteError();
1067 int OtherKeyAttribute::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
1073 if ((val
= setjmp (env
)) == 0)
1075 BDec (b
, bytesDecoded
, env
);
1076 return !b
.ReadError();
1082 void OtherKeyAttribute::Print (ostream
&os
) const
1085 os
<< "{ -- SEQUENCE --" << endl
;
1086 indentG
+= stdIndentG
;
1089 Indent (os
, indentG
);
1095 if (NOT_NULL (keyAttr
))
1098 Indent (os
, indentG
);
1104 Indent (os
, indentG
);
1111 indentG
-= stdIndentG
;
1112 Indent (os
, indentG
);
1115 } // OtherKeyAttribute::Print
1118 AsnType
*DigestAlgorithmIdentifiers::Clone() const
1120 return new DigestAlgorithmIdentifiers
;
1123 AsnType
*DigestAlgorithmIdentifiers::Copy() const
1125 return new DigestAlgorithmIdentifiers (*this);
1128 AsnLen
DigestAlgorithmIdentifiers::BEnc (BUF_TYPE b
)
1131 l
= BEncContent (b
);
1132 l
+= BEncConsLen (b
, l
);
1133 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
1137 void DigestAlgorithmIdentifiers::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1142 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
1144 Asn1Error
<< "DigestAlgorithmIdentifiers::BDec: ERROR - wrong tag" << endl
;
1145 longjmp (env
, -113);
1147 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1148 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1151 DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers
&)
1153 Asn1Error
<< "use of incompletely defined DigestAlgorithmIdentifiers::DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &)" << endl
;
1157 DigestAlgorithmIdentifiers::~DigestAlgorithmIdentifiers()
1160 for (; Curr() != NULL
; RemoveCurrFromList())
1162 } // end of destructor
1165 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers
&that
)
1166 #else // SNACC_DEEP_COPY
1167 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers
&)
1168 #endif // SNACC_DEEP_COPY
1174 for (; Curr(); RemoveCurrFromList())
1177 //that.SetCurrToFirst();
1178 //for (; that.Curr(); that.GoNext())
1179 // AppendCopy (*that.Curr());
1180 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
1181 AppendCopy (*run
->elmt
);
1185 #else // SNACC_DEEP_COPY
1186 Asn1Error
<< "use of incompletely defined DigestAlgorithmIdentifiers &DigestAlgorithmIdentifiers::operator = (const DigestAlgorithmIdentifiers &)" << endl
;
1188 // if your compiler complains here, check the -novolat option
1189 #endif // SNACC_DEEP_COPY
1192 void DigestAlgorithmIdentifiers::Print (ostream
&os
) const
1195 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
1196 indentG
+= stdIndentG
;
1198 //for (; Curr() != NULL; GoNext())
1199 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
1201 Indent (os
, indentG
);
1204 //if (Curr() != Last())
1209 indentG
-= stdIndentG
;
1210 Indent (os
, indentG
);
1218 void DigestAlgorithmIdentifiers::SetCurrElmt (unsigned long int index
)
1220 unsigned long int i
;
1223 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
1225 } // DigestAlgorithmIdentifiers::SetCurrElmt
1228 unsigned long int DigestAlgorithmIdentifiers::GetCurrElmtIndex()
1230 unsigned long int i
;
1234 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
1243 } // DigestAlgorithmIdentifiers::GetCurrElmtIndex
1246 // alloc new list elmt, put at end of list
1247 // and return the component type
1248 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::Append()
1250 AsnListElmt
*newElmt
;
1251 newElmt
= new AsnListElmt
;
1252 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1253 newElmt
->next
= NULL
;
1256 newElmt
->prev
= NULL
;
1257 first
= last
= newElmt
;
1261 newElmt
->prev
= last
;
1262 last
->next
= newElmt
;
1266 return (curr
= newElmt
)->elmt
;
1267 } // DigestAlgorithmIdentifiers::Append
1270 // alloc new list elmt, put at begining of list
1271 // and return the component type
1272 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::Prepend()
1274 AsnListElmt
*newElmt
;
1275 newElmt
= new AsnListElmt
;
1276 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1277 newElmt
->prev
= NULL
;
1280 newElmt
->next
= NULL
;
1281 first
= last
= newElmt
;
1285 newElmt
->next
= first
;
1286 first
->prev
= newElmt
;
1290 return (curr
= newElmt
)->elmt
;
1291 } // DigestAlgorithmIdentifiers::Prepend
1294 // alloc new list elmt, insert it before the
1295 // current element and return the component type
1296 // if the current element is null, the new element
1297 // is placed at the beginning of the list.
1298 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::InsertBefore()
1300 AsnListElmt
*newElmt
;
1301 newElmt
= new AsnListElmt
;
1302 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1305 newElmt
->next
= first
;
1306 newElmt
->prev
= NULL
;
1313 newElmt
->next
= curr
;
1314 newElmt
->prev
= curr
->prev
;
1315 curr
->prev
= newElmt
;
1319 newElmt
->prev
->next
= newElmt
;
1322 return (curr
= newElmt
)->elmt
;
1323 } // DigestAlgorithmIdentifiers::InsertBefore
1326 // alloc new list elmt, insert it after the
1327 // current element and return the component type
1328 // if the current element is null, the new element
1329 // is placed at the end of the list.
1330 DigestAlgorithmIdentifier
*DigestAlgorithmIdentifiers::InsertAfter()
1332 AsnListElmt
*newElmt
;
1333 newElmt
= new AsnListElmt
;
1334 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1337 newElmt
->prev
= last
;
1338 newElmt
->next
= NULL
;
1345 newElmt
->prev
= curr
;
1346 newElmt
->next
= curr
->next
;
1347 curr
->next
= newElmt
;
1351 newElmt
->next
->prev
= newElmt
;
1354 return (curr
= newElmt
)->elmt
;
1355 } // DigestAlgorithmIdentifiers::InsertAfter
1358 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::AppendCopy (DigestAlgorithmIdentifier
&elmt
)
1360 AsnListElmt
*newElmt
;
1361 newElmt
= new AsnListElmt
;
1362 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1363 *newElmt
->elmt
= elmt
;
1364 newElmt
->next
= NULL
;
1367 newElmt
->prev
= NULL
;
1368 first
= last
= newElmt
;
1372 newElmt
->prev
= last
;
1373 last
->next
= newElmt
;
1381 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::PrependCopy (DigestAlgorithmIdentifier
&elmt
)
1383 AsnListElmt
*newElmt
;
1384 newElmt
= new AsnListElmt
;
1385 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1386 *newElmt
->elmt
= elmt
;
1387 newElmt
->prev
= NULL
;
1390 newElmt
->next
= NULL
;
1391 first
= last
= newElmt
;
1395 newElmt
->next
= first
;
1396 first
->prev
= newElmt
;
1401 } // DigestAlgorithmIdentifiers::PrependCopy
1404 // alloc new list elmt, insert it before the
1405 // current element, copy the given elmt into the new elmt
1406 // and return the component type.
1407 // if the current element is null, the new element
1408 // is placed at the beginning of the list.
1409 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::InsertBeforeAndCopy (DigestAlgorithmIdentifier
&elmt
)
1411 AsnListElmt
*newElmt
;
1413 newElmt
= new AsnListElmt
;
1414 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1415 *newElmt
->elmt
= elmt
;
1419 newElmt
->next
= first
;
1420 newElmt
->prev
= NULL
;
1427 newElmt
->next
= curr
;
1428 newElmt
->prev
= curr
->prev
;
1429 curr
->prev
= newElmt
;
1433 newElmt
->prev
->next
= newElmt
;
1437 } // DigestAlgorithmIdentifiers::InsertBeforeAndCopy
1440 // alloc new list elmt, insert it after the
1441 // current element, copy given elmt in to new elmt
1442 // and return the component type
1443 // if the current element is null, the new element
1444 // is placed at the end of the list.
1445 DigestAlgorithmIdentifiers
&DigestAlgorithmIdentifiers::InsertAfterAndCopy (DigestAlgorithmIdentifier
&elmt
)
1447 AsnListElmt
*newElmt
;
1449 newElmt
= new AsnListElmt
;
1450 newElmt
->elmt
= new DigestAlgorithmIdentifier
;
1451 *newElmt
->elmt
= elmt
;
1454 newElmt
->prev
= last
;
1455 newElmt
->next
= NULL
;
1462 newElmt
->prev
= curr
;
1463 newElmt
->next
= curr
->next
;
1464 curr
->next
= newElmt
;
1468 newElmt
->next
->prev
= newElmt
;
1472 } // DigestAlgorithmIdentifiers::InsertAfterAndCopy
1475 // remove current element from list if current element is not NULL
1476 // The new current element will be the next element.
1477 // If the current element is the last element in the list
1478 // the second but last element will become the new current element.
1479 void DigestAlgorithmIdentifiers::RemoveCurrFromList()
1481 AsnListElmt
*del_elmt
;
1489 first
= last
= curr
= NULL
;
1490 else if (curr
== first
)
1492 curr
= first
= first
->next
;
1495 else if (curr
== last
)
1497 curr
= last
= last
->prev
;
1502 curr
->prev
->next
= curr
->next
;
1503 curr
->next
->prev
= curr
->prev
;
1506 delete del_elmt
->elmt
;
1512 AsnLen
DigestAlgorithmIdentifiers::BEncContent (BUF_TYPE b
)
1514 AsnListElmt
*currElmt
;
1516 AsnLen totalLen
= 0;
1519 CSM_Buffer
**tmpEnc
=NULL
;
1520 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
1521 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
1522 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
1525 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
1526 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
1528 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
1529 ENCODE_BUF2(tmpEnc
[iii
]);
1531 vdasnacc_sortSetOf(tmpEnc
, icount
);
1532 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
1533 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
1534 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
1537 totalLen
+= elmtLen
;
1539 } // DigestAlgorithmIdentifiers::BEncContent
1542 void DigestAlgorithmIdentifiers::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
1543 AsnLen
&bytesDecoded
, ENV_TYPE env
)
1545 DigestAlgorithmIdentifier
*listElmt
;
1547 AsnLen listBytesDecoded
= 0;
1550 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
1552 tag1
= BDecTag (b
, listBytesDecoded
, env
);
1553 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
1555 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
1558 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
1560 Asn1Error
<< "Unexpected Tag" << endl
;
1561 longjmp (env
, -114);
1564 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
1565 listElmt
= Append();
1566 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
1569 bytesDecoded
+= listBytesDecoded
;
1570 } // DigestAlgorithmIdentifiers::BDecContent
1573 EncapsulatedContentInfo::EncapsulatedContentInfo()
1578 EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo
&)
1580 Asn1Error
<< "use of incompletely defined EncapsulatedContentInfo::EncapsulatedContentInfo (const EncapsulatedContentInfo &)" << endl
;
1584 EncapsulatedContentInfo::~EncapsulatedContentInfo()
1589 AsnType
*EncapsulatedContentInfo::Clone() const
1591 return new EncapsulatedContentInfo
;
1594 AsnType
*EncapsulatedContentInfo::Copy() const
1596 return new EncapsulatedContentInfo (*this);
1600 EncapsulatedContentInfo
&EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo
&that
)
1601 #else // SNACC_DEEP_COPY
1602 EncapsulatedContentInfo
&EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo
&)
1603 #endif // SNACC_DEEP_COPY
1608 eContentType
= that
.eContentType
;
1612 eContent
= new AsnOcts
;
1613 *eContent
= *that
.eContent
;
1623 #else // SNACC_DEEP_COPY
1624 Asn1Error
<< "use of incompletely defined EncapsulatedContentInfo &EncapsulatedContentInfo::operator = (const EncapsulatedContentInfo &)" << endl
;
1626 // if your compiler complains here, check the -novolat option
1627 #endif // SNACC_DEEP_COPY
1631 EncapsulatedContentInfo::BEncContent (BUF_TYPE b
)
1633 AsnLen totalLen
= 0;
1636 if (NOT_NULL (eContent
))
1639 l
= eContent
->BEncContent (b
);
1640 l
+= BEncDefLen (b
, l
);
1642 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
1643 l
+= BEncConsLen (b
, l
);
1645 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
1649 l
= eContentType
.BEncContent (b
);
1650 l
+= BEncDefLen (b
, l
);
1652 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
1656 } // EncapsulatedContentInfo::BEncContent
1659 void EncapsulatedContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1662 AsnLen seqBytesDecoded
= 0;
1665 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1667 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
1669 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1670 eContentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
1671 if (seqBytesDecoded
== elmtLen0
)
1673 bytesDecoded
+= seqBytesDecoded
;
1678 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1680 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
1682 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
1683 bytesDecoded
+= seqBytesDecoded
;
1690 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
1691 longjmp (env
, -115);
1694 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
1696 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
1697 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
1699 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
1700 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
1702 Asn1Error
<< "Unexpected Tag" << endl
;
1703 longjmp (env
, -116);
1706 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
1707 eContent
= new AsnOcts
;
1708 eContent
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
1709 if (elmtLen1
== INDEFINITE_LEN
)
1710 BDecEoc (b
, seqBytesDecoded
, env
);
1714 bytesDecoded
+= seqBytesDecoded
;
1715 if (elmtLen0
== INDEFINITE_LEN
)
1717 BDecEoc (b
, bytesDecoded
, env
);
1720 else if (seqBytesDecoded
!= elmtLen0
)
1722 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
1723 longjmp (env
, -117);
1727 } // EncapsulatedContentInfo::BDecContent
1729 AsnLen
EncapsulatedContentInfo::BEnc (BUF_TYPE b
)
1732 l
= BEncContent (b
);
1733 l
+= BEncConsLen (b
, l
);
1734 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1738 void EncapsulatedContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1743 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
1745 Asn1Error
<< "EncapsulatedContentInfo::BDec: ERROR - wrong tag" << endl
;
1746 longjmp (env
, -118);
1748 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
1749 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
1752 int EncapsulatedContentInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
1754 bytesEncoded
= BEnc (b
);
1755 return !b
.WriteError();
1758 int EncapsulatedContentInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
1764 if ((val
= setjmp (env
)) == 0)
1766 BDec (b
, bytesDecoded
, env
);
1767 return !b
.ReadError();
1773 void EncapsulatedContentInfo::Print (ostream
&os
) const
1776 os
<< "{ -- SEQUENCE --" << endl
;
1777 indentG
+= stdIndentG
;
1780 Indent (os
, indentG
);
1781 os
<< "eContentType ";
1786 if (NOT_NULL (eContent
))
1789 Indent (os
, indentG
);
1795 Indent (os
, indentG
);
1802 indentG
-= stdIndentG
;
1803 Indent (os
, indentG
);
1806 } // EncapsulatedContentInfo::Print
1809 SignerIdentifier::SignerIdentifier()
1811 choiceId
= issuerAndSerialNumberCid
;
1813 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1815 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
1819 SignerIdentifier::SignerIdentifier (const SignerIdentifier
&)
1821 Asn1Error
<< "use of incompletely defined SignerIdentifier::SignerIdentifier (const SignerIdentifier &)" << endl
;
1825 SignerIdentifier::~SignerIdentifier()
1829 case issuerAndSerialNumberCid
:
1830 delete issuerAndSerialNumber
;
1832 case subjectKeyIdentifierCid
:
1833 delete subjectKeyIdentifier
;
1836 } // end of destructor
1838 AsnType
*SignerIdentifier::Clone() const
1840 return new SignerIdentifier
;
1843 AsnType
*SignerIdentifier::Copy() const
1845 return new SignerIdentifier (*this);
1849 SignerIdentifier
&SignerIdentifier::operator = (const SignerIdentifier
&that
)
1850 #else // SNACC_DEEP_COPY
1851 SignerIdentifier
&SignerIdentifier::operator = (const SignerIdentifier
&)
1852 #endif // SNACC_DEEP_COPY
1859 case issuerAndSerialNumberCid
:
1860 delete issuerAndSerialNumber
;
1862 case subjectKeyIdentifierCid
:
1863 delete subjectKeyIdentifier
;
1866 switch (choiceId
= that
.choiceId
)
1868 case issuerAndSerialNumberCid
:
1869 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1870 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
1872 case subjectKeyIdentifierCid
:
1873 subjectKeyIdentifier
= new KeyIdentifier
;
1874 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
1880 #else // SNACC_DEEP_COPY
1881 Asn1Error
<< "use of incompletely defined SignerIdentifier &SignerIdentifier::operator = (const SignerIdentifier &)" << endl
;
1883 // if your compiler complains here, check the -novolat option
1884 #endif // SNACC_DEEP_COPY
1888 SignerIdentifier::BEncContent (BUF_TYPE b
)
1893 case issuerAndSerialNumberCid
:
1895 l
= issuerAndSerialNumber
->BEncContent (b
);
1896 l
+= BEncConsLen (b
, l
);
1898 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
1901 case subjectKeyIdentifierCid
:
1902 l
= subjectKeyIdentifier
->BEncContent (b
);
1903 l
+= BEncDefLen (b
, l
);
1905 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
1910 } // SignerIdentifier::BEncContent
1913 void SignerIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1917 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
1918 choiceId
= issuerAndSerialNumberCid
;
1919 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
1920 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1923 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
1924 case MAKE_TAG_ID (CNTX
, CONS
, 0):
1925 choiceId
= subjectKeyIdentifierCid
;
1926 subjectKeyIdentifier
= new KeyIdentifier
;
1927 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
1931 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
1932 longjmp (env
, -119);
1935 } // SignerIdentifier::BDecContent
1938 AsnLen
SignerIdentifier::BEnc (BUF_TYPE b
)
1941 l
= BEncContent (b
);
1945 void SignerIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
1950 /* CHOICEs are a special case - grab identifying tag */
1951 /* this allows easier handling of nested CHOICEs */
1952 tag
= BDecTag (b
, bytesDecoded
, env
);
1953 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
1954 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
1957 int SignerIdentifier::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
1959 bytesEncoded
= BEnc (b
);
1960 return !b
.WriteError();
1963 int SignerIdentifier::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
1969 if ((val
= setjmp (env
)) == 0)
1971 BDec (b
, bytesDecoded
, env
);
1972 return !b
.ReadError();
1978 void SignerIdentifier::Print (ostream
&os
) const
1983 case issuerAndSerialNumberCid
:
1984 os
<< "issuerAndSerialNumber ";
1985 if (issuerAndSerialNumber
)
1986 os
<< *issuerAndSerialNumber
;
1988 os
<< "-- void3 --\n";
1991 case subjectKeyIdentifierCid
:
1992 os
<< "subjectKeyIdentifier ";
1993 if (subjectKeyIdentifier
)
1994 os
<< *subjectKeyIdentifier
;
1996 os
<< "-- void3 --\n";
2001 } // SignerIdentifier::Print
2003 EncryptedContentInfo::EncryptedContentInfo()
2006 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
2008 contentEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
2010 encryptedContent
= NULL
;
2013 EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo
&)
2015 Asn1Error
<< "use of incompletely defined EncryptedContentInfo::EncryptedContentInfo (const EncryptedContentInfo &)" << endl
;
2019 EncryptedContentInfo::~EncryptedContentInfo()
2021 delete contentEncryptionAlgorithm
;
2022 delete encryptedContent
;
2025 AsnType
*EncryptedContentInfo::Clone() const
2027 return new EncryptedContentInfo
;
2030 AsnType
*EncryptedContentInfo::Copy() const
2032 return new EncryptedContentInfo (*this);
2036 EncryptedContentInfo
&EncryptedContentInfo::operator = (const EncryptedContentInfo
&that
)
2037 #else // SNACC_DEEP_COPY
2038 EncryptedContentInfo
&EncryptedContentInfo::operator = (const EncryptedContentInfo
&)
2039 #endif // SNACC_DEEP_COPY
2044 contentType
= that
.contentType
;
2045 if (that
.contentEncryptionAlgorithm
)
2047 if (!contentEncryptionAlgorithm
)
2048 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
2049 *contentEncryptionAlgorithm
= *that
.contentEncryptionAlgorithm
;
2053 delete contentEncryptionAlgorithm
;
2054 contentEncryptionAlgorithm
= NULL
;
2056 if (that
.encryptedContent
)
2058 if (!encryptedContent
)
2059 encryptedContent
= new EncryptedContent
;
2060 *encryptedContent
= *that
.encryptedContent
;
2064 delete encryptedContent
;
2065 encryptedContent
= NULL
;
2070 #else // SNACC_DEEP_COPY
2071 Asn1Error
<< "use of incompletely defined EncryptedContentInfo &EncryptedContentInfo::operator = (const EncryptedContentInfo &)" << endl
;
2073 // if your compiler complains here, check the -novolat option
2074 #endif // SNACC_DEEP_COPY
2078 EncryptedContentInfo::BEncContent (BUF_TYPE b
)
2080 AsnLen totalLen
= 0;
2083 if (NOT_NULL (encryptedContent
))
2085 l
= encryptedContent
->BEncContent (b
);
2086 l
+= BEncDefLen (b
, l
);
2088 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
2093 l
= contentEncryptionAlgorithm
->BEncContent (b
);
2094 l
+= BEncConsLen (b
, l
);
2096 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2099 l
= contentType
.BEncContent (b
);
2100 l
+= BEncDefLen (b
, l
);
2102 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
2106 } // EncryptedContentInfo::BEncContent
2109 void EncryptedContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2112 AsnLen seqBytesDecoded
= 0;
2114 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2116 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
2118 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2119 contentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2120 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2124 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2125 longjmp (env
, -120);
2128 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2130 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2131 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier
;
2132 contentEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2133 if (seqBytesDecoded
== elmtLen0
)
2135 bytesDecoded
+= seqBytesDecoded
;
2140 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2142 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2144 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2145 bytesDecoded
+= seqBytesDecoded
;
2152 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2153 longjmp (env
, -121);
2156 if ((tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
2157 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
2159 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2160 encryptedContent
= new EncryptedContent
;
2161 encryptedContent
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2164 bytesDecoded
+= seqBytesDecoded
;
2165 if (elmtLen0
== INDEFINITE_LEN
)
2167 BDecEoc (b
, bytesDecoded
, env
);
2170 else if (seqBytesDecoded
!= elmtLen0
)
2172 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
2173 longjmp (env
, -122);
2177 } // EncryptedContentInfo::BDecContent
2179 AsnLen
EncryptedContentInfo::BEnc (BUF_TYPE b
)
2182 l
= BEncContent (b
);
2183 l
+= BEncConsLen (b
, l
);
2184 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2188 void EncryptedContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2193 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2195 Asn1Error
<< "EncryptedContentInfo::BDec: ERROR - wrong tag" << endl
;
2196 longjmp (env
, -123);
2198 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2199 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2202 int EncryptedContentInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
2204 bytesEncoded
= BEnc (b
);
2205 return !b
.WriteError();
2208 int EncryptedContentInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
2214 if ((val
= setjmp (env
)) == 0)
2216 BDec (b
, bytesDecoded
, env
);
2217 return !b
.ReadError();
2223 void EncryptedContentInfo::Print (ostream
&os
) const
2226 os
<< "{ -- SEQUENCE --" << endl
;
2227 indentG
+= stdIndentG
;
2230 Indent (os
, indentG
);
2231 os
<< "contentType ";
2236 if (NOT_NULL (contentEncryptionAlgorithm
))
2238 Indent (os
, indentG
);
2239 os
<< "contentEncryptionAlgorithm ";
2240 os
<< *contentEncryptionAlgorithm
;
2244 Indent (os
, indentG
);
2245 os
<< "contentEncryptionAlgorithm ";
2250 if (NOT_NULL (encryptedContent
))
2253 Indent (os
, indentG
);
2254 os
<< "encryptedContent ";
2255 os
<< *encryptedContent
;
2259 Indent (os
, indentG
);
2260 os
<< "encryptedContent ";
2266 indentG
-= stdIndentG
;
2267 Indent (os
, indentG
);
2270 } // EncryptedContentInfo::Print
2273 RecipientIdentifier::RecipientIdentifier()
2275 choiceId
= issuerAndSerialNumberCid
;
2277 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2279 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
2283 RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier
&)
2285 Asn1Error
<< "use of incompletely defined RecipientIdentifier::RecipientIdentifier (const RecipientIdentifier &)" << endl
;
2289 RecipientIdentifier::~RecipientIdentifier()
2293 case issuerAndSerialNumberCid
:
2294 delete issuerAndSerialNumber
;
2296 case subjectKeyIdentifierCid
:
2297 delete subjectKeyIdentifier
;
2300 } // end of destructor
2302 AsnType
*RecipientIdentifier::Clone() const
2304 return new RecipientIdentifier
;
2307 AsnType
*RecipientIdentifier::Copy() const
2309 return new RecipientIdentifier (*this);
2313 RecipientIdentifier
&RecipientIdentifier::operator = (const RecipientIdentifier
&that
)
2314 #else // SNACC_DEEP_COPY
2315 RecipientIdentifier
&RecipientIdentifier::operator = (const RecipientIdentifier
&)
2316 #endif // SNACC_DEEP_COPY
2323 case issuerAndSerialNumberCid
:
2324 delete issuerAndSerialNumber
;
2326 case subjectKeyIdentifierCid
:
2327 delete subjectKeyIdentifier
;
2330 switch (choiceId
= that
.choiceId
)
2332 case issuerAndSerialNumberCid
:
2333 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2334 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
2336 case subjectKeyIdentifierCid
:
2337 subjectKeyIdentifier
= new KeyIdentifier
;
2338 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
2344 #else // SNACC_DEEP_COPY
2345 Asn1Error
<< "use of incompletely defined RecipientIdentifier &RecipientIdentifier::operator = (const RecipientIdentifier &)" << endl
;
2347 // if your compiler complains here, check the -novolat option
2348 #endif // SNACC_DEEP_COPY
2352 RecipientIdentifier::BEncContent (BUF_TYPE b
)
2357 case issuerAndSerialNumberCid
:
2359 l
= issuerAndSerialNumber
->BEncContent (b
);
2360 l
+= BEncConsLen (b
, l
);
2362 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2365 case subjectKeyIdentifierCid
:
2366 l
= subjectKeyIdentifier
->BEncContent (b
);
2367 l
+= BEncDefLen (b
, l
);
2369 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
2374 } // RecipientIdentifier::BEncContent
2377 void RecipientIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2381 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
2382 choiceId
= issuerAndSerialNumberCid
;
2383 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2384 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2387 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
2388 case MAKE_TAG_ID (CNTX
, CONS
, 0):
2389 choiceId
= subjectKeyIdentifierCid
;
2390 subjectKeyIdentifier
= new KeyIdentifier
;
2391 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2395 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
2396 longjmp (env
, -124);
2399 } // RecipientIdentifier::BDecContent
2402 AsnLen
RecipientIdentifier::BEnc (BUF_TYPE b
)
2405 l
= BEncContent (b
);
2409 void RecipientIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2414 /* CHOICEs are a special case - grab identifying tag */
2415 /* this allows easier handling of nested CHOICEs */
2416 tag
= BDecTag (b
, bytesDecoded
, env
);
2417 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
2418 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
2421 int RecipientIdentifier::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
2423 bytesEncoded
= BEnc (b
);
2424 return !b
.WriteError();
2427 int RecipientIdentifier::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
2433 if ((val
= setjmp (env
)) == 0)
2435 BDec (b
, bytesDecoded
, env
);
2436 return !b
.ReadError();
2442 void RecipientIdentifier::Print (ostream
&os
) const
2447 case issuerAndSerialNumberCid
:
2448 os
<< "issuerAndSerialNumber ";
2449 if (issuerAndSerialNumber
)
2450 os
<< *issuerAndSerialNumber
;
2452 os
<< "-- void3 --\n";
2455 case subjectKeyIdentifierCid
:
2456 os
<< "subjectKeyIdentifier ";
2457 if (subjectKeyIdentifier
)
2458 os
<< *subjectKeyIdentifier
;
2460 os
<< "-- void3 --\n";
2465 } // RecipientIdentifier::Print
2467 OriginatorIdentifierOrKey::OriginatorIdentifierOrKey()
2469 choiceId
= issuerAndSerialNumberCid
;
2471 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2473 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
2477 OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey
&)
2479 Asn1Error
<< "use of incompletely defined OriginatorIdentifierOrKey::OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &)" << endl
;
2483 OriginatorIdentifierOrKey::~OriginatorIdentifierOrKey()
2487 case issuerAndSerialNumberCid
:
2488 delete issuerAndSerialNumber
;
2490 case subjectKeyIdentifierCid
:
2491 delete subjectKeyIdentifier
;
2493 case originatorKeyCid
:
2494 delete originatorKey
;
2497 } // end of destructor
2499 AsnType
*OriginatorIdentifierOrKey::Clone() const
2501 return new OriginatorIdentifierOrKey
;
2504 AsnType
*OriginatorIdentifierOrKey::Copy() const
2506 return new OriginatorIdentifierOrKey (*this);
2510 OriginatorIdentifierOrKey
&OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey
&that
)
2511 #else // SNACC_DEEP_COPY
2512 OriginatorIdentifierOrKey
&OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey
&)
2513 #endif // SNACC_DEEP_COPY
2520 case issuerAndSerialNumberCid
:
2521 delete issuerAndSerialNumber
;
2523 case subjectKeyIdentifierCid
:
2524 delete subjectKeyIdentifier
;
2526 case originatorKeyCid
:
2527 delete originatorKey
;
2530 switch (choiceId
= that
.choiceId
)
2532 case issuerAndSerialNumberCid
:
2533 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2534 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
2536 case subjectKeyIdentifierCid
:
2537 subjectKeyIdentifier
= new KeyIdentifier
;
2538 *subjectKeyIdentifier
= *that
.subjectKeyIdentifier
;
2540 case originatorKeyCid
:
2541 originatorKey
= new OriginatorPublicKey
;
2542 *originatorKey
= *that
.originatorKey
;
2548 #else // SNACC_DEEP_COPY
2549 Asn1Error
<< "use of incompletely defined OriginatorIdentifierOrKey &OriginatorIdentifierOrKey::operator = (const OriginatorIdentifierOrKey &)" << endl
;
2551 // if your compiler complains here, check the -novolat option
2552 #endif // SNACC_DEEP_COPY
2556 OriginatorIdentifierOrKey::BEncContent (BUF_TYPE b
)
2561 case issuerAndSerialNumberCid
:
2563 l
= issuerAndSerialNumber
->BEncContent (b
);
2564 l
+= BEncConsLen (b
, l
);
2566 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2569 case subjectKeyIdentifierCid
:
2570 l
= subjectKeyIdentifier
->BEncContent (b
);
2571 l
+= BEncDefLen (b
, l
);
2573 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
2576 case originatorKeyCid
:
2578 l
= originatorKey
->BEncContent (b
);
2579 l
+= BEncConsLen (b
, l
);
2581 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
2586 } // OriginatorIdentifierOrKey::BEncContent
2589 void OriginatorIdentifierOrKey::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2593 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
2594 choiceId
= issuerAndSerialNumberCid
;
2595 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
2596 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2599 case MAKE_TAG_ID (CNTX
, PRIM
, 0):
2600 case MAKE_TAG_ID (CNTX
, CONS
, 0):
2601 choiceId
= subjectKeyIdentifierCid
;
2602 subjectKeyIdentifier
= new KeyIdentifier
;
2603 subjectKeyIdentifier
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2606 case MAKE_TAG_ID (CNTX
, CONS
, 1):
2607 choiceId
= originatorKeyCid
;
2608 originatorKey
= new OriginatorPublicKey
;
2609 originatorKey
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
2613 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
2614 longjmp (env
, -125);
2617 } // OriginatorIdentifierOrKey::BDecContent
2620 AsnLen
OriginatorIdentifierOrKey::BEnc (BUF_TYPE b
)
2623 l
= BEncContent (b
);
2627 void OriginatorIdentifierOrKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2632 /* CHOICEs are a special case - grab identifying tag */
2633 /* this allows easier handling of nested CHOICEs */
2634 tag
= BDecTag (b
, bytesDecoded
, env
);
2635 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
2636 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
2639 int OriginatorIdentifierOrKey::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
2641 bytesEncoded
= BEnc (b
);
2642 return !b
.WriteError();
2645 int OriginatorIdentifierOrKey::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
2651 if ((val
= setjmp (env
)) == 0)
2653 BDec (b
, bytesDecoded
, env
);
2654 return !b
.ReadError();
2660 void OriginatorIdentifierOrKey::Print (ostream
&os
) const
2665 case issuerAndSerialNumberCid
:
2666 os
<< "issuerAndSerialNumber ";
2667 if (issuerAndSerialNumber
)
2668 os
<< *issuerAndSerialNumber
;
2670 os
<< "-- void3 --\n";
2673 case subjectKeyIdentifierCid
:
2674 os
<< "subjectKeyIdentifier ";
2675 if (subjectKeyIdentifier
)
2676 os
<< *subjectKeyIdentifier
;
2678 os
<< "-- void3 --\n";
2681 case originatorKeyCid
:
2682 os
<< "originatorKey ";
2684 os
<< *originatorKey
;
2686 os
<< "-- void3 --\n";
2691 } // OriginatorIdentifierOrKey::Print
2693 RecipientKeyIdentifier::RecipientKeyIdentifier()
2699 RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier
&)
2701 Asn1Error
<< "use of incompletely defined RecipientKeyIdentifier::RecipientKeyIdentifier (const RecipientKeyIdentifier &)" << endl
;
2705 RecipientKeyIdentifier::~RecipientKeyIdentifier()
2711 AsnType
*RecipientKeyIdentifier::Clone() const
2713 return new RecipientKeyIdentifier
;
2716 AsnType
*RecipientKeyIdentifier::Copy() const
2718 return new RecipientKeyIdentifier (*this);
2722 RecipientKeyIdentifier
&RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier
&that
)
2723 #else // SNACC_DEEP_COPY
2724 RecipientKeyIdentifier
&RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier
&)
2725 #endif // SNACC_DEEP_COPY
2730 subjectKeyIdentifier
= that
.subjectKeyIdentifier
;
2734 date
= new GeneralizedTime
;
2745 other
= new OtherKeyAttribute
;
2746 *other
= *that
.other
;
2756 #else // SNACC_DEEP_COPY
2757 Asn1Error
<< "use of incompletely defined RecipientKeyIdentifier &RecipientKeyIdentifier::operator = (const RecipientKeyIdentifier &)" << endl
;
2759 // if your compiler complains here, check the -novolat option
2760 #endif // SNACC_DEEP_COPY
2764 RecipientKeyIdentifier::BEncContent (BUF_TYPE b
)
2766 AsnLen totalLen
= 0;
2769 if (NOT_NULL (other
))
2772 l
= other
->BEncContent (b
);
2773 l
+= BEncConsLen (b
, l
);
2775 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2779 if (NOT_NULL (date
))
2781 l
= date
->BEncContent (b
);
2782 l
+= BEncDefLen (b
, l
);
2784 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
2788 l
= subjectKeyIdentifier
.BEncContent (b
);
2789 l
+= BEncDefLen (b
, l
);
2791 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
2795 } // RecipientKeyIdentifier::BEncContent
2798 void RecipientKeyIdentifier::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2801 AsnLen seqBytesDecoded
= 0;
2803 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2805 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
2806 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
2808 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2809 subjectKeyIdentifier
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2810 if (seqBytesDecoded
== elmtLen0
)
2812 bytesDecoded
+= seqBytesDecoded
;
2817 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2819 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2821 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2822 bytesDecoded
+= seqBytesDecoded
;
2829 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
2830 longjmp (env
, -126);
2833 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
))
2834 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, GENERALIZEDTIME_TAG_CODE
)))
2836 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2837 date
= new GeneralizedTime
;
2838 date
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2839 if (seqBytesDecoded
== elmtLen0
)
2841 bytesDecoded
+= seqBytesDecoded
;
2846 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
2848 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
2850 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
2851 bytesDecoded
+= seqBytesDecoded
;
2857 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
2859 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
2860 other
= new OtherKeyAttribute
;
2861 other
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
2864 bytesDecoded
+= seqBytesDecoded
;
2865 if (elmtLen0
== INDEFINITE_LEN
)
2867 BDecEoc (b
, bytesDecoded
, env
);
2870 else if (seqBytesDecoded
!= elmtLen0
)
2872 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
2873 longjmp (env
, -127);
2877 } // RecipientKeyIdentifier::BDecContent
2879 AsnLen
RecipientKeyIdentifier::BEnc (BUF_TYPE b
)
2882 l
= BEncContent (b
);
2883 l
+= BEncConsLen (b
, l
);
2884 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
2888 void RecipientKeyIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
2893 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
2895 Asn1Error
<< "RecipientKeyIdentifier::BDec: ERROR - wrong tag" << endl
;
2896 longjmp (env
, -128);
2898 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
2899 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
2902 int RecipientKeyIdentifier::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
2904 bytesEncoded
= BEnc (b
);
2905 return !b
.WriteError();
2908 int RecipientKeyIdentifier::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
2914 if ((val
= setjmp (env
)) == 0)
2916 BDec (b
, bytesDecoded
, env
);
2917 return !b
.ReadError();
2923 void RecipientKeyIdentifier::Print (ostream
&os
) const
2926 os
<< "{ -- SEQUENCE --" << endl
;
2927 indentG
+= stdIndentG
;
2930 Indent (os
, indentG
);
2931 os
<< "subjectKeyIdentifier ";
2932 os
<< subjectKeyIdentifier
;
2936 if (NOT_NULL (date
))
2939 Indent (os
, indentG
);
2945 Indent (os
, indentG
);
2951 if (NOT_NULL (other
))
2954 Indent (os
, indentG
);
2960 Indent (os
, indentG
);
2967 indentG
-= stdIndentG
;
2968 Indent (os
, indentG
);
2971 } // RecipientKeyIdentifier::Print
2974 KEKIdentifier::KEKIdentifier()
2980 KEKIdentifier::KEKIdentifier (const KEKIdentifier
&)
2982 Asn1Error
<< "use of incompletely defined KEKIdentifier::KEKIdentifier (const KEKIdentifier &)" << endl
;
2986 KEKIdentifier::~KEKIdentifier()
2992 AsnType
*KEKIdentifier::Clone() const
2994 return new KEKIdentifier
;
2997 AsnType
*KEKIdentifier::Copy() const
2999 return new KEKIdentifier (*this);
3003 KEKIdentifier
&KEKIdentifier::operator = (const KEKIdentifier
&that
)
3004 #else // SNACC_DEEP_COPY
3005 KEKIdentifier
&KEKIdentifier::operator = (const KEKIdentifier
&)
3006 #endif // SNACC_DEEP_COPY
3011 keyIdentifier
= that
.keyIdentifier
;
3015 date
= new GeneralizedTime
;
3026 other
= new OtherKeyAttribute
;
3027 *other
= *that
.other
;
3037 #else // SNACC_DEEP_COPY
3038 Asn1Error
<< "use of incompletely defined KEKIdentifier &KEKIdentifier::operator = (const KEKIdentifier &)" << endl
;
3040 // if your compiler complains here, check the -novolat option
3041 #endif // SNACC_DEEP_COPY
3045 KEKIdentifier::BEncContent (BUF_TYPE b
)
3047 AsnLen totalLen
= 0;
3050 if (NOT_NULL (other
))
3053 l
= other
->BEncContent (b
);
3054 l
+= BEncConsLen (b
, l
);
3056 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3060 if (NOT_NULL (date
))
3062 l
= date
->BEncContent (b
);
3063 l
+= BEncDefLen (b
, l
);
3065 l
+= BEncTag1 (b
, UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
);
3069 l
= keyIdentifier
.BEncContent (b
);
3070 l
+= BEncDefLen (b
, l
);
3072 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
3076 } // KEKIdentifier::BEncContent
3079 void KEKIdentifier::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3082 AsnLen seqBytesDecoded
= 0;
3084 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3086 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
3087 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
3089 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3090 keyIdentifier
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3091 if (seqBytesDecoded
== elmtLen0
)
3093 bytesDecoded
+= seqBytesDecoded
;
3098 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3100 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
3102 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
3103 bytesDecoded
+= seqBytesDecoded
;
3110 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3111 longjmp (env
, -129);
3114 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, GENERALIZEDTIME_TAG_CODE
))
3115 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, GENERALIZEDTIME_TAG_CODE
)))
3117 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3118 date
= new GeneralizedTime
;
3119 date
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3120 if (seqBytesDecoded
== elmtLen0
)
3122 bytesDecoded
+= seqBytesDecoded
;
3127 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3129 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
3131 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
3132 bytesDecoded
+= seqBytesDecoded
;
3138 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3140 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3141 other
= new OtherKeyAttribute
;
3142 other
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3145 bytesDecoded
+= seqBytesDecoded
;
3146 if (elmtLen0
== INDEFINITE_LEN
)
3148 BDecEoc (b
, bytesDecoded
, env
);
3151 else if (seqBytesDecoded
!= elmtLen0
)
3153 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3154 longjmp (env
, -130);
3158 } // KEKIdentifier::BDecContent
3160 AsnLen
KEKIdentifier::BEnc (BUF_TYPE b
)
3163 l
= BEncContent (b
);
3164 l
+= BEncConsLen (b
, l
);
3165 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3169 void KEKIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3174 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3176 Asn1Error
<< "KEKIdentifier::BDec: ERROR - wrong tag" << endl
;
3177 longjmp (env
, -131);
3179 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3180 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3183 int KEKIdentifier::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
3185 bytesEncoded
= BEnc (b
);
3186 return !b
.WriteError();
3189 int KEKIdentifier::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
3195 if ((val
= setjmp (env
)) == 0)
3197 BDec (b
, bytesDecoded
, env
);
3198 return !b
.ReadError();
3204 void KEKIdentifier::Print (ostream
&os
) const
3207 os
<< "{ -- SEQUENCE --" << endl
;
3208 indentG
+= stdIndentG
;
3211 Indent (os
, indentG
);
3212 os
<< "keyIdentifier ";
3213 os
<< keyIdentifier
;
3217 if (NOT_NULL (date
))
3220 Indent (os
, indentG
);
3226 Indent (os
, indentG
);
3232 if (NOT_NULL (other
))
3235 Indent (os
, indentG
);
3241 Indent (os
, indentG
);
3248 indentG
-= stdIndentG
;
3249 Indent (os
, indentG
);
3252 } // KEKIdentifier::Print
3255 ExtendedCertificateInfo::ExtendedCertificateInfo()
3258 certificate
= new Certificate
;
3260 certificate
= NULL
; // incomplete initialization of mandatory element!
3264 ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo
&)
3266 Asn1Error
<< "use of incompletely defined ExtendedCertificateInfo::ExtendedCertificateInfo (const ExtendedCertificateInfo &)" << endl
;
3270 ExtendedCertificateInfo::~ExtendedCertificateInfo()
3275 AsnType
*ExtendedCertificateInfo::Clone() const
3277 return new ExtendedCertificateInfo
;
3280 AsnType
*ExtendedCertificateInfo::Copy() const
3282 return new ExtendedCertificateInfo (*this);
3286 ExtendedCertificateInfo
&ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo
&that
)
3287 #else // SNACC_DEEP_COPY
3288 ExtendedCertificateInfo
&ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo
&)
3289 #endif // SNACC_DEEP_COPY
3294 version
= that
.version
;
3295 if (that
.certificate
)
3298 certificate
= new Certificate
;
3299 *certificate
= *that
.certificate
;
3306 attributes
= that
.attributes
;
3310 #else // SNACC_DEEP_COPY
3311 Asn1Error
<< "use of incompletely defined ExtendedCertificateInfo &ExtendedCertificateInfo::operator = (const ExtendedCertificateInfo &)" << endl
;
3313 // if your compiler complains here, check the -novolat option
3314 #endif // SNACC_DEEP_COPY
3318 ExtendedCertificateInfo::BEncContent (BUF_TYPE b
)
3320 AsnLen totalLen
= 0;
3324 l
= attributes
.BEncContent (b
);
3325 l
+= BEncConsLen (b
, l
);
3327 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
3331 l
= certificate
->BEncContent (b
);
3332 l
+= BEncConsLen (b
, l
);
3334 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3337 l
= version
.BEncContent (b
);
3338 BEncDefLenTo127 (b
, l
);
3341 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
3345 } // ExtendedCertificateInfo::BEncContent
3348 void ExtendedCertificateInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3351 AsnLen seqBytesDecoded
= 0;
3353 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3355 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
3357 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3358 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3359 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3363 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3364 longjmp (env
, -132);
3367 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3369 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3370 certificate
= new Certificate
;
3371 certificate
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3372 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3376 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3377 longjmp (env
, -133);
3380 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
3382 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3383 attributes
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3387 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3388 longjmp (env
, -134);
3391 bytesDecoded
+= seqBytesDecoded
;
3392 if (elmtLen0
== INDEFINITE_LEN
)
3394 BDecEoc (b
, bytesDecoded
, env
);
3397 else if (seqBytesDecoded
!= elmtLen0
)
3399 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3400 longjmp (env
, -135);
3404 } // ExtendedCertificateInfo::BDecContent
3406 AsnLen
ExtendedCertificateInfo::BEnc (BUF_TYPE b
)
3409 l
= BEncContent (b
);
3410 l
+= BEncConsLen (b
, l
);
3411 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3415 void ExtendedCertificateInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3420 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3422 Asn1Error
<< "ExtendedCertificateInfo::BDec: ERROR - wrong tag" << endl
;
3423 longjmp (env
, -136);
3425 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3426 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3429 int ExtendedCertificateInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
3431 bytesEncoded
= BEnc (b
);
3432 return !b
.WriteError();
3435 int ExtendedCertificateInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
3441 if ((val
= setjmp (env
)) == 0)
3443 BDec (b
, bytesDecoded
, env
);
3444 return !b
.ReadError();
3450 void ExtendedCertificateInfo::Print (ostream
&os
) const
3453 os
<< "{ -- SEQUENCE --" << endl
;
3454 indentG
+= stdIndentG
;
3457 Indent (os
, indentG
);
3463 if (NOT_NULL (certificate
))
3465 Indent (os
, indentG
);
3466 os
<< "certificate ";
3471 Indent (os
, indentG
);
3472 os
<< "certificate ";
3478 Indent (os
, indentG
);
3479 os
<< "attributes ";
3484 indentG
-= stdIndentG
;
3485 Indent (os
, indentG
);
3488 } // ExtendedCertificateInfo::Print
3491 SignerInfo::SignerInfo()
3494 sid
= new SignerIdentifier
;
3496 sid
= NULL
; // incomplete initialization of mandatory element!
3499 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3501 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3505 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3507 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3509 unsignedAttrs
= NULL
;
3512 SignerInfo::SignerInfo (const SignerInfo
&)
3514 Asn1Error
<< "use of incompletely defined SignerInfo::SignerInfo (const SignerInfo &)" << endl
;
3518 SignerInfo::~SignerInfo()
3521 delete digestAlgorithm
;
3523 delete signatureAlgorithm
;
3524 delete unsignedAttrs
;
3527 AsnType
*SignerInfo::Clone() const
3529 return new SignerInfo
;
3532 AsnType
*SignerInfo::Copy() const
3534 return new SignerInfo (*this);
3538 SignerInfo
&SignerInfo::operator = (const SignerInfo
&that
)
3539 #else // SNACC_DEEP_COPY
3540 SignerInfo
&SignerInfo::operator = (const SignerInfo
&)
3541 #endif // SNACC_DEEP_COPY
3546 version
= that
.version
;
3550 sid
= new SignerIdentifier
;
3558 if (that
.digestAlgorithm
)
3560 if (!digestAlgorithm
)
3561 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3562 *digestAlgorithm
= *that
.digestAlgorithm
;
3566 delete digestAlgorithm
;
3567 digestAlgorithm
= NULL
;
3569 if (that
.signedAttrs
)
3572 signedAttrs
= new Attributes
;
3573 *signedAttrs
= *that
.signedAttrs
;
3580 if (that
.signatureAlgorithm
)
3582 if (!signatureAlgorithm
)
3583 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3584 *signatureAlgorithm
= *that
.signatureAlgorithm
;
3588 delete signatureAlgorithm
;
3589 signatureAlgorithm
= NULL
;
3591 signature
= that
.signature
;
3592 if (that
.unsignedAttrs
)
3595 unsignedAttrs
= new Attributes
;
3596 *unsignedAttrs
= *that
.unsignedAttrs
;
3600 delete unsignedAttrs
;
3601 unsignedAttrs
= NULL
;
3606 #else // SNACC_DEEP_COPY
3607 Asn1Error
<< "use of incompletely defined SignerInfo &SignerInfo::operator = (const SignerInfo &)" << endl
;
3609 // if your compiler complains here, check the -novolat option
3610 #endif // SNACC_DEEP_COPY
3614 SignerInfo::BEncContent (BUF_TYPE b
)
3616 AsnLen totalLen
= 0;
3619 if (NOT_NULL (unsignedAttrs
))
3622 l
= unsignedAttrs
->BEncContent (b
);
3623 l
+= BEncConsLen (b
, l
);
3625 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
3629 l
= signature
.BEncContent (b
);
3630 l
+= BEncDefLen (b
, l
);
3632 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
3636 l
= signatureAlgorithm
->BEncContent (b
);
3637 l
+= BEncConsLen (b
, l
);
3639 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3642 if (NOT_NULL (signedAttrs
))
3645 l
= signedAttrs
->BEncContent (b
);
3646 l
+= BEncConsLen (b
, l
);
3648 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
3653 l
= digestAlgorithm
->BEncContent (b
);
3654 l
+= BEncConsLen (b
, l
);
3656 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3659 l
= sid
->BEncContent (b
);
3662 l
= version
.BEncContent (b
);
3663 BEncDefLenTo127 (b
, l
);
3666 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
3670 } // SignerInfo::BEncContent
3673 void SignerInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3676 AsnLen seqBytesDecoded
= 0;
3678 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3680 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
3682 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3683 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3684 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3688 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3689 longjmp (env
, -137);
3692 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3693 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
3694 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
3696 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3697 sid
= new SignerIdentifier
;
3698 sid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3699 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3703 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3704 longjmp (env
, -138);
3707 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3709 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3710 digestAlgorithm
= new DigestAlgorithmIdentifier
;
3711 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3712 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3716 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3717 longjmp (env
, -139);
3720 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
3722 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3723 signedAttrs
= new Attributes
;
3724 signedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3725 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3728 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
3730 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3731 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
3732 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3733 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3737 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3738 longjmp (env
, -140);
3741 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
3742 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
3744 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3745 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3746 if (seqBytesDecoded
== elmtLen0
)
3748 bytesDecoded
+= seqBytesDecoded
;
3753 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
3755 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
3757 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
3758 bytesDecoded
+= seqBytesDecoded
;
3765 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
3766 longjmp (env
, -141);
3769 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
3771 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
3772 unsignedAttrs
= new Attributes
;
3773 unsignedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
3776 bytesDecoded
+= seqBytesDecoded
;
3777 if (elmtLen0
== INDEFINITE_LEN
)
3779 BDecEoc (b
, bytesDecoded
, env
);
3782 else if (seqBytesDecoded
!= elmtLen0
)
3784 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
3785 longjmp (env
, -142);
3789 } // SignerInfo::BDecContent
3791 AsnLen
SignerInfo::BEnc (BUF_TYPE b
)
3794 l
= BEncContent (b
);
3795 l
+= BEncConsLen (b
, l
);
3796 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
3800 void SignerInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
3805 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
3807 Asn1Error
<< "SignerInfo::BDec: ERROR - wrong tag" << endl
;
3808 longjmp (env
, -143);
3810 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
3811 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
3814 int SignerInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
3816 bytesEncoded
= BEnc (b
);
3817 return !b
.WriteError();
3820 int SignerInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
3826 if ((val
= setjmp (env
)) == 0)
3828 BDec (b
, bytesDecoded
, env
);
3829 return !b
.ReadError();
3835 void SignerInfo::Print (ostream
&os
) const
3838 os
<< "{ -- SEQUENCE --" << endl
;
3839 indentG
+= stdIndentG
;
3842 Indent (os
, indentG
);
3850 Indent (os
, indentG
);
3856 Indent (os
, indentG
);
3862 if (NOT_NULL (digestAlgorithm
))
3864 Indent (os
, indentG
);
3865 os
<< "digestAlgorithm ";
3866 os
<< *digestAlgorithm
;
3870 Indent (os
, indentG
);
3871 os
<< "digestAlgorithm ";
3876 if (NOT_NULL (signedAttrs
))
3878 Indent (os
, indentG
);
3879 os
<< "signedAttrs ";
3884 Indent (os
, indentG
);
3885 os
<< "signedAttrs ";
3890 if (NOT_NULL (signatureAlgorithm
))
3892 Indent (os
, indentG
);
3893 os
<< "signatureAlgorithm ";
3894 os
<< *signatureAlgorithm
;
3898 Indent (os
, indentG
);
3899 os
<< "signatureAlgorithm ";
3905 Indent (os
, indentG
);
3911 if (NOT_NULL (unsignedAttrs
))
3914 Indent (os
, indentG
);
3915 os
<< "unsignedAttrs ";
3916 os
<< *unsignedAttrs
;
3920 Indent (os
, indentG
);
3921 os
<< "unsignedAttrs ";
3927 indentG
-= stdIndentG
;
3928 Indent (os
, indentG
);
3931 } // SignerInfo::Print
3934 KeyTransRecipientInfo::KeyTransRecipientInfo()
3937 rid
= new RecipientIdentifier
;
3939 rid
= NULL
; // incomplete initialization of mandatory element!
3942 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
3944 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
3948 KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo
&)
3950 Asn1Error
<< "use of incompletely defined KeyTransRecipientInfo::KeyTransRecipientInfo (const KeyTransRecipientInfo &)" << endl
;
3954 KeyTransRecipientInfo::~KeyTransRecipientInfo()
3957 delete keyEncryptionAlgorithm
;
3960 AsnType
*KeyTransRecipientInfo::Clone() const
3962 return new KeyTransRecipientInfo
;
3965 AsnType
*KeyTransRecipientInfo::Copy() const
3967 return new KeyTransRecipientInfo (*this);
3971 KeyTransRecipientInfo
&KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo
&that
)
3972 #else // SNACC_DEEP_COPY
3973 KeyTransRecipientInfo
&KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo
&)
3974 #endif // SNACC_DEEP_COPY
3979 version
= that
.version
;
3983 rid
= new RecipientIdentifier
;
3991 if (that
.keyEncryptionAlgorithm
)
3993 if (!keyEncryptionAlgorithm
)
3994 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
3995 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
3999 delete keyEncryptionAlgorithm
;
4000 keyEncryptionAlgorithm
= NULL
;
4002 encryptedKey
= that
.encryptedKey
;
4006 #else // SNACC_DEEP_COPY
4007 Asn1Error
<< "use of incompletely defined KeyTransRecipientInfo &KeyTransRecipientInfo::operator = (const KeyTransRecipientInfo &)" << endl
;
4009 // if your compiler complains here, check the -novolat option
4010 #endif // SNACC_DEEP_COPY
4014 KeyTransRecipientInfo::BEncContent (BUF_TYPE b
)
4016 AsnLen totalLen
= 0;
4019 l
= encryptedKey
.BEncContent (b
);
4020 l
+= BEncDefLen (b
, l
);
4022 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
4026 l
= keyEncryptionAlgorithm
->BEncContent (b
);
4027 l
+= BEncConsLen (b
, l
);
4029 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4032 l
= rid
->BEncContent (b
);
4035 l
= version
.BEncContent (b
);
4036 BEncDefLenTo127 (b
, l
);
4039 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
4043 } // KeyTransRecipientInfo::BEncContent
4046 void KeyTransRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4049 AsnLen seqBytesDecoded
= 0;
4051 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4053 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
4055 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4056 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4057 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4061 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4062 longjmp (env
, -144);
4065 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4066 || (tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
4067 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
4069 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4070 rid
= new RecipientIdentifier
;
4071 rid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4072 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4076 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4077 longjmp (env
, -145);
4080 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4082 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4083 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4084 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4085 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4089 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4090 longjmp (env
, -146);
4093 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
4094 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
4096 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4097 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4101 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4102 longjmp (env
, -147);
4105 bytesDecoded
+= seqBytesDecoded
;
4106 if (elmtLen0
== INDEFINITE_LEN
)
4108 BDecEoc (b
, bytesDecoded
, env
);
4111 else if (seqBytesDecoded
!= elmtLen0
)
4113 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
4114 longjmp (env
, -148);
4118 } // KeyTransRecipientInfo::BDecContent
4120 AsnLen
KeyTransRecipientInfo::BEnc (BUF_TYPE b
)
4123 l
= BEncContent (b
);
4124 l
+= BEncConsLen (b
, l
);
4125 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4129 void KeyTransRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4134 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4136 Asn1Error
<< "KeyTransRecipientInfo::BDec: ERROR - wrong tag" << endl
;
4137 longjmp (env
, -149);
4139 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4140 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4143 int KeyTransRecipientInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
4145 bytesEncoded
= BEnc (b
);
4146 return !b
.WriteError();
4149 int KeyTransRecipientInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
4155 if ((val
= setjmp (env
)) == 0)
4157 BDec (b
, bytesDecoded
, env
);
4158 return !b
.ReadError();
4164 void KeyTransRecipientInfo::Print (ostream
&os
) const
4167 os
<< "{ -- SEQUENCE --" << endl
;
4168 indentG
+= stdIndentG
;
4171 Indent (os
, indentG
);
4179 Indent (os
, indentG
);
4185 Indent (os
, indentG
);
4191 if (NOT_NULL (keyEncryptionAlgorithm
))
4193 Indent (os
, indentG
);
4194 os
<< "keyEncryptionAlgorithm ";
4195 os
<< *keyEncryptionAlgorithm
;
4199 Indent (os
, indentG
);
4200 os
<< "keyEncryptionAlgorithm ";
4206 Indent (os
, indentG
);
4207 os
<< "encryptedKey ";
4212 indentG
-= stdIndentG
;
4213 Indent (os
, indentG
);
4216 } // KeyTransRecipientInfo::Print
4219 KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier()
4221 choiceId
= issuerAndSerialNumberCid
;
4223 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
4225 issuerAndSerialNumber
= NULL
; // incomplete initialization of mandatory element!
4229 KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier
&)
4231 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientIdentifier::KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &)" << endl
;
4235 KeyAgreeRecipientIdentifier::~KeyAgreeRecipientIdentifier()
4239 case issuerAndSerialNumberCid
:
4240 delete issuerAndSerialNumber
;
4246 } // end of destructor
4248 AsnType
*KeyAgreeRecipientIdentifier::Clone() const
4250 return new KeyAgreeRecipientIdentifier
;
4253 AsnType
*KeyAgreeRecipientIdentifier::Copy() const
4255 return new KeyAgreeRecipientIdentifier (*this);
4259 KeyAgreeRecipientIdentifier
&KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier
&that
)
4260 #else // SNACC_DEEP_COPY
4261 KeyAgreeRecipientIdentifier
&KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier
&)
4262 #endif // SNACC_DEEP_COPY
4269 case issuerAndSerialNumberCid
:
4270 delete issuerAndSerialNumber
;
4276 switch (choiceId
= that
.choiceId
)
4278 case issuerAndSerialNumberCid
:
4279 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
4280 *issuerAndSerialNumber
= *that
.issuerAndSerialNumber
;
4283 rKeyId
= new RecipientKeyIdentifier
;
4284 *rKeyId
= *that
.rKeyId
;
4290 #else // SNACC_DEEP_COPY
4291 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientIdentifier &KeyAgreeRecipientIdentifier::operator = (const KeyAgreeRecipientIdentifier &)" << endl
;
4293 // if your compiler complains here, check the -novolat option
4294 #endif // SNACC_DEEP_COPY
4298 KeyAgreeRecipientIdentifier::BEncContent (BUF_TYPE b
)
4303 case issuerAndSerialNumberCid
:
4305 l
= issuerAndSerialNumber
->BEncContent (b
);
4306 l
+= BEncConsLen (b
, l
);
4308 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4313 l
= rKeyId
->BEncContent (b
);
4314 l
+= BEncConsLen (b
, l
);
4316 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
4321 } // KeyAgreeRecipientIdentifier::BEncContent
4324 void KeyAgreeRecipientIdentifier::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4328 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
4329 choiceId
= issuerAndSerialNumberCid
;
4330 issuerAndSerialNumber
= new IssuerAndSerialNumber
;
4331 issuerAndSerialNumber
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
4334 case MAKE_TAG_ID (CNTX
, CONS
, 0):
4335 choiceId
= rKeyIdCid
;
4336 rKeyId
= new RecipientKeyIdentifier
;
4337 rKeyId
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
4341 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
4342 longjmp (env
, -150);
4345 } // KeyAgreeRecipientIdentifier::BDecContent
4348 AsnLen
KeyAgreeRecipientIdentifier::BEnc (BUF_TYPE b
)
4351 l
= BEncContent (b
);
4355 void KeyAgreeRecipientIdentifier::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4360 /* CHOICEs are a special case - grab identifying tag */
4361 /* this allows easier handling of nested CHOICEs */
4362 tag
= BDecTag (b
, bytesDecoded
, env
);
4363 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
4364 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
4367 int KeyAgreeRecipientIdentifier::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
4369 bytesEncoded
= BEnc (b
);
4370 return !b
.WriteError();
4373 int KeyAgreeRecipientIdentifier::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
4379 if ((val
= setjmp (env
)) == 0)
4381 BDec (b
, bytesDecoded
, env
);
4382 return !b
.ReadError();
4388 void KeyAgreeRecipientIdentifier::Print (ostream
&os
) const
4393 case issuerAndSerialNumberCid
:
4394 os
<< "issuerAndSerialNumber ";
4395 if (issuerAndSerialNumber
)
4396 os
<< *issuerAndSerialNumber
;
4398 os
<< "-- void3 --\n";
4406 os
<< "-- void3 --\n";
4411 } // KeyAgreeRecipientIdentifier::Print
4413 KEKRecipientInfo::KEKRecipientInfo()
4416 kekid
= new KEKIdentifier
;
4418 kekid
= NULL
; // incomplete initialization of mandatory element!
4421 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4423 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
4427 KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo
&)
4429 Asn1Error
<< "use of incompletely defined KEKRecipientInfo::KEKRecipientInfo (const KEKRecipientInfo &)" << endl
;
4433 KEKRecipientInfo::~KEKRecipientInfo()
4436 delete keyEncryptionAlgorithm
;
4439 AsnType
*KEKRecipientInfo::Clone() const
4441 return new KEKRecipientInfo
;
4444 AsnType
*KEKRecipientInfo::Copy() const
4446 return new KEKRecipientInfo (*this);
4450 KEKRecipientInfo
&KEKRecipientInfo::operator = (const KEKRecipientInfo
&that
)
4451 #else // SNACC_DEEP_COPY
4452 KEKRecipientInfo
&KEKRecipientInfo::operator = (const KEKRecipientInfo
&)
4453 #endif // SNACC_DEEP_COPY
4458 version
= that
.version
;
4462 kekid
= new KEKIdentifier
;
4463 *kekid
= *that
.kekid
;
4470 if (that
.keyEncryptionAlgorithm
)
4472 if (!keyEncryptionAlgorithm
)
4473 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4474 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
4478 delete keyEncryptionAlgorithm
;
4479 keyEncryptionAlgorithm
= NULL
;
4481 encryptedKey
= that
.encryptedKey
;
4485 #else // SNACC_DEEP_COPY
4486 Asn1Error
<< "use of incompletely defined KEKRecipientInfo &KEKRecipientInfo::operator = (const KEKRecipientInfo &)" << endl
;
4488 // if your compiler complains here, check the -novolat option
4489 #endif // SNACC_DEEP_COPY
4493 KEKRecipientInfo::BEncContent (BUF_TYPE b
)
4495 AsnLen totalLen
= 0;
4498 l
= encryptedKey
.BEncContent (b
);
4499 l
+= BEncDefLen (b
, l
);
4501 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
4505 l
= keyEncryptionAlgorithm
->BEncContent (b
);
4506 l
+= BEncConsLen (b
, l
);
4508 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4512 l
= kekid
->BEncContent (b
);
4513 l
+= BEncConsLen (b
, l
);
4515 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4518 l
= version
.BEncContent (b
);
4519 BEncDefLenTo127 (b
, l
);
4522 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
4526 } // KEKRecipientInfo::BEncContent
4529 void KEKRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4532 AsnLen seqBytesDecoded
= 0;
4534 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4536 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
4538 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4539 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4540 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4544 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4545 longjmp (env
, -151);
4548 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4550 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4551 kekid
= new KEKIdentifier
;
4552 kekid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4553 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4557 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4558 longjmp (env
, -152);
4561 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4563 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4564 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
4565 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4566 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4570 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4571 longjmp (env
, -153);
4574 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
4575 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
4577 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4578 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4582 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4583 longjmp (env
, -154);
4586 bytesDecoded
+= seqBytesDecoded
;
4587 if (elmtLen0
== INDEFINITE_LEN
)
4589 BDecEoc (b
, bytesDecoded
, env
);
4592 else if (seqBytesDecoded
!= elmtLen0
)
4594 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
4595 longjmp (env
, -155);
4599 } // KEKRecipientInfo::BDecContent
4601 AsnLen
KEKRecipientInfo::BEnc (BUF_TYPE b
)
4604 l
= BEncContent (b
);
4605 l
+= BEncConsLen (b
, l
);
4606 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4610 void KEKRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4615 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4617 Asn1Error
<< "KEKRecipientInfo::BDec: ERROR - wrong tag" << endl
;
4618 longjmp (env
, -156);
4620 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4621 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4624 int KEKRecipientInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
4626 bytesEncoded
= BEnc (b
);
4627 return !b
.WriteError();
4630 int KEKRecipientInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
4636 if ((val
= setjmp (env
)) == 0)
4638 BDec (b
, bytesDecoded
, env
);
4639 return !b
.ReadError();
4645 void KEKRecipientInfo::Print (ostream
&os
) const
4648 os
<< "{ -- SEQUENCE --" << endl
;
4649 indentG
+= stdIndentG
;
4652 Indent (os
, indentG
);
4658 if (NOT_NULL (kekid
))
4660 Indent (os
, indentG
);
4666 Indent (os
, indentG
);
4672 if (NOT_NULL (keyEncryptionAlgorithm
))
4674 Indent (os
, indentG
);
4675 os
<< "keyEncryptionAlgorithm ";
4676 os
<< *keyEncryptionAlgorithm
;
4680 Indent (os
, indentG
);
4681 os
<< "keyEncryptionAlgorithm ";
4687 Indent (os
, indentG
);
4688 os
<< "encryptedKey ";
4693 indentG
-= stdIndentG
;
4694 Indent (os
, indentG
);
4697 } // KEKRecipientInfo::Print
4700 ExtendedCertificate::ExtendedCertificate()
4703 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4705 extendedCertificateInfo
= NULL
; // incomplete initialization of mandatory element!
4708 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4710 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
4714 ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate
&)
4716 Asn1Error
<< "use of incompletely defined ExtendedCertificate::ExtendedCertificate (const ExtendedCertificate &)" << endl
;
4720 ExtendedCertificate::~ExtendedCertificate()
4722 delete extendedCertificateInfo
;
4723 delete signatureAlgorithm
;
4726 AsnType
*ExtendedCertificate::Clone() const
4728 return new ExtendedCertificate
;
4731 AsnType
*ExtendedCertificate::Copy() const
4733 return new ExtendedCertificate (*this);
4737 ExtendedCertificate
&ExtendedCertificate::operator = (const ExtendedCertificate
&that
)
4738 #else // SNACC_DEEP_COPY
4739 ExtendedCertificate
&ExtendedCertificate::operator = (const ExtendedCertificate
&)
4740 #endif // SNACC_DEEP_COPY
4745 if (that
.extendedCertificateInfo
)
4747 if (!extendedCertificateInfo
)
4748 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4749 *extendedCertificateInfo
= *that
.extendedCertificateInfo
;
4753 delete extendedCertificateInfo
;
4754 extendedCertificateInfo
= NULL
;
4756 if (that
.signatureAlgorithm
)
4758 if (!signatureAlgorithm
)
4759 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4760 *signatureAlgorithm
= *that
.signatureAlgorithm
;
4764 delete signatureAlgorithm
;
4765 signatureAlgorithm
= NULL
;
4767 signature
= that
.signature
;
4771 #else // SNACC_DEEP_COPY
4772 Asn1Error
<< "use of incompletely defined ExtendedCertificate &ExtendedCertificate::operator = (const ExtendedCertificate &)" << endl
;
4774 // if your compiler complains here, check the -novolat option
4775 #endif // SNACC_DEEP_COPY
4779 ExtendedCertificate::BEncContent (BUF_TYPE b
)
4781 AsnLen totalLen
= 0;
4784 l
= signature
.BEncContent (b
);
4785 l
+= BEncDefLen (b
, l
);
4787 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
4791 l
= signatureAlgorithm
->BEncContent (b
);
4792 l
+= BEncConsLen (b
, l
);
4794 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4798 l
= extendedCertificateInfo
->BEncContent (b
);
4799 l
+= BEncConsLen (b
, l
);
4801 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4805 } // ExtendedCertificate::BEncContent
4808 void ExtendedCertificate::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4811 AsnLen seqBytesDecoded
= 0;
4813 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4815 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4817 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4818 extendedCertificateInfo
= new ExtendedCertificateInfo
;
4819 extendedCertificateInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4820 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4824 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4825 longjmp (env
, -157);
4828 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
4830 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4831 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
4832 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4833 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
4837 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4838 longjmp (env
, -158);
4841 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
4842 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
4844 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
4845 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
4849 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
4850 longjmp (env
, -159);
4853 bytesDecoded
+= seqBytesDecoded
;
4854 if (elmtLen0
== INDEFINITE_LEN
)
4856 BDecEoc (b
, bytesDecoded
, env
);
4859 else if (seqBytesDecoded
!= elmtLen0
)
4861 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
4862 longjmp (env
, -160);
4866 } // ExtendedCertificate::BDecContent
4868 AsnLen
ExtendedCertificate::BEnc (BUF_TYPE b
)
4871 l
= BEncContent (b
);
4872 l
+= BEncConsLen (b
, l
);
4873 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
4877 void ExtendedCertificate::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4882 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
4884 Asn1Error
<< "ExtendedCertificate::BDec: ERROR - wrong tag" << endl
;
4885 longjmp (env
, -161);
4887 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4888 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4891 int ExtendedCertificate::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
4893 bytesEncoded
= BEnc (b
);
4894 return !b
.WriteError();
4897 int ExtendedCertificate::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
4903 if ((val
= setjmp (env
)) == 0)
4905 BDec (b
, bytesDecoded
, env
);
4906 return !b
.ReadError();
4912 void ExtendedCertificate::Print (ostream
&os
) const
4915 os
<< "{ -- SEQUENCE --" << endl
;
4916 indentG
+= stdIndentG
;
4918 if (NOT_NULL (extendedCertificateInfo
))
4920 Indent (os
, indentG
);
4921 os
<< "extendedCertificateInfo ";
4922 os
<< *extendedCertificateInfo
;
4926 Indent (os
, indentG
);
4927 os
<< "extendedCertificateInfo ";
4932 if (NOT_NULL (signatureAlgorithm
))
4934 Indent (os
, indentG
);
4935 os
<< "signatureAlgorithm ";
4936 os
<< *signatureAlgorithm
;
4940 Indent (os
, indentG
);
4941 os
<< "signatureAlgorithm ";
4947 Indent (os
, indentG
);
4953 indentG
-= stdIndentG
;
4954 Indent (os
, indentG
);
4957 } // ExtendedCertificate::Print
4960 AsnType
*SignerInfos::Clone() const
4962 return new SignerInfos
;
4965 AsnType
*SignerInfos::Copy() const
4967 return new SignerInfos (*this);
4970 AsnLen
SignerInfos::BEnc (BUF_TYPE b
)
4973 l
= BEncContent (b
);
4974 l
+= BEncConsLen (b
, l
);
4975 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
4979 void SignerInfos::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
4984 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
4986 Asn1Error
<< "SignerInfos::BDec: ERROR - wrong tag" << endl
;
4987 longjmp (env
, -162);
4989 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
4990 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
4993 SignerInfos::SignerInfos (const SignerInfos
&)
4995 Asn1Error
<< "use of incompletely defined SignerInfos::SignerInfos (const SignerInfos &)" << endl
;
4999 SignerInfos::~SignerInfos()
5002 for (; Curr() != NULL
; RemoveCurrFromList())
5004 } // end of destructor
5007 SignerInfos
&SignerInfos::operator = (const SignerInfos
&that
)
5008 #else // SNACC_DEEP_COPY
5009 SignerInfos
&SignerInfos::operator = (const SignerInfos
&)
5010 #endif // SNACC_DEEP_COPY
5016 for (; Curr(); RemoveCurrFromList())
5019 //that.SetCurrToFirst();
5020 //for (; that.Curr(); that.GoNext())
5021 // AppendCopy (*that.Curr());
5022 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
5023 AppendCopy (*run
->elmt
);
5027 #else // SNACC_DEEP_COPY
5028 Asn1Error
<< "use of incompletely defined SignerInfos &SignerInfos::operator = (const SignerInfos &)" << endl
;
5030 // if your compiler complains here, check the -novolat option
5031 #endif // SNACC_DEEP_COPY
5034 void SignerInfos::Print (ostream
&os
) const
5037 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
5038 indentG
+= stdIndentG
;
5040 //for (; Curr() != NULL; GoNext())
5041 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
5043 Indent (os
, indentG
);
5046 //if (Curr() != Last())
5051 indentG
-= stdIndentG
;
5052 Indent (os
, indentG
);
5060 void SignerInfos::SetCurrElmt (unsigned long int index
)
5062 unsigned long int i
;
5065 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
5067 } // SignerInfos::SetCurrElmt
5070 unsigned long int SignerInfos::GetCurrElmtIndex()
5072 unsigned long int i
;
5076 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
5085 } // SignerInfos::GetCurrElmtIndex
5088 // alloc new list elmt, put at end of list
5089 // and return the component type
5090 SignerInfo
*SignerInfos::Append()
5092 AsnListElmt
*newElmt
;
5093 newElmt
= new AsnListElmt
;
5094 newElmt
->elmt
= new SignerInfo
;
5095 newElmt
->next
= NULL
;
5098 newElmt
->prev
= NULL
;
5099 first
= last
= newElmt
;
5103 newElmt
->prev
= last
;
5104 last
->next
= newElmt
;
5108 return (curr
= newElmt
)->elmt
;
5109 } // SignerInfos::Append
5112 // alloc new list elmt, put at begining of list
5113 // and return the component type
5114 SignerInfo
*SignerInfos::Prepend()
5116 AsnListElmt
*newElmt
;
5117 newElmt
= new AsnListElmt
;
5118 newElmt
->elmt
= new SignerInfo
;
5119 newElmt
->prev
= NULL
;
5122 newElmt
->next
= NULL
;
5123 first
= last
= newElmt
;
5127 newElmt
->next
= first
;
5128 first
->prev
= newElmt
;
5132 return (curr
= newElmt
)->elmt
;
5133 } // SignerInfos::Prepend
5136 // alloc new list elmt, insert it before the
5137 // current element and return the component type
5138 // if the current element is null, the new element
5139 // is placed at the beginning of the list.
5140 SignerInfo
*SignerInfos::InsertBefore()
5142 AsnListElmt
*newElmt
;
5143 newElmt
= new AsnListElmt
;
5144 newElmt
->elmt
= new SignerInfo
;
5147 newElmt
->next
= first
;
5148 newElmt
->prev
= NULL
;
5155 newElmt
->next
= curr
;
5156 newElmt
->prev
= curr
->prev
;
5157 curr
->prev
= newElmt
;
5161 newElmt
->prev
->next
= newElmt
;
5164 return (curr
= newElmt
)->elmt
;
5165 } // SignerInfos::InsertBefore
5168 // alloc new list elmt, insert it after the
5169 // current element and return the component type
5170 // if the current element is null, the new element
5171 // is placed at the end of the list.
5172 SignerInfo
*SignerInfos::InsertAfter()
5174 AsnListElmt
*newElmt
;
5175 newElmt
= new AsnListElmt
;
5176 newElmt
->elmt
= new SignerInfo
;
5179 newElmt
->prev
= last
;
5180 newElmt
->next
= NULL
;
5187 newElmt
->prev
= curr
;
5188 newElmt
->next
= curr
->next
;
5189 curr
->next
= newElmt
;
5193 newElmt
->next
->prev
= newElmt
;
5196 return (curr
= newElmt
)->elmt
;
5197 } // SignerInfos::InsertAfter
5200 SignerInfos
&SignerInfos::AppendCopy (SignerInfo
&elmt
)
5202 AsnListElmt
*newElmt
;
5203 newElmt
= new AsnListElmt
;
5204 newElmt
->elmt
= new SignerInfo
;
5205 *newElmt
->elmt
= elmt
;
5206 newElmt
->next
= NULL
;
5209 newElmt
->prev
= NULL
;
5210 first
= last
= newElmt
;
5214 newElmt
->prev
= last
;
5215 last
->next
= newElmt
;
5223 SignerInfos
&SignerInfos::PrependCopy (SignerInfo
&elmt
)
5225 AsnListElmt
*newElmt
;
5226 newElmt
= new AsnListElmt
;
5227 newElmt
->elmt
= new SignerInfo
;
5228 *newElmt
->elmt
= elmt
;
5229 newElmt
->prev
= NULL
;
5232 newElmt
->next
= NULL
;
5233 first
= last
= newElmt
;
5237 newElmt
->next
= first
;
5238 first
->prev
= newElmt
;
5243 } // SignerInfos::PrependCopy
5246 // alloc new list elmt, insert it before the
5247 // current element, copy the given elmt into the new elmt
5248 // and return the component type.
5249 // if the current element is null, the new element
5250 // is placed at the beginning of the list.
5251 SignerInfos
&SignerInfos::InsertBeforeAndCopy (SignerInfo
&elmt
)
5253 AsnListElmt
*newElmt
;
5255 newElmt
= new AsnListElmt
;
5256 newElmt
->elmt
= new SignerInfo
;
5257 *newElmt
->elmt
= elmt
;
5261 newElmt
->next
= first
;
5262 newElmt
->prev
= NULL
;
5269 newElmt
->next
= curr
;
5270 newElmt
->prev
= curr
->prev
;
5271 curr
->prev
= newElmt
;
5275 newElmt
->prev
->next
= newElmt
;
5279 } // SignerInfos::InsertBeforeAndCopy
5282 // alloc new list elmt, insert it after the
5283 // current element, copy given elmt in to new elmt
5284 // and return the component type
5285 // if the current element is null, the new element
5286 // is placed at the end of the list.
5287 SignerInfos
&SignerInfos::InsertAfterAndCopy (SignerInfo
&elmt
)
5289 AsnListElmt
*newElmt
;
5291 newElmt
= new AsnListElmt
;
5292 newElmt
->elmt
= new SignerInfo
;
5293 *newElmt
->elmt
= elmt
;
5296 newElmt
->prev
= last
;
5297 newElmt
->next
= NULL
;
5304 newElmt
->prev
= curr
;
5305 newElmt
->next
= curr
->next
;
5306 curr
->next
= newElmt
;
5310 newElmt
->next
->prev
= newElmt
;
5314 } // SignerInfos::InsertAfterAndCopy
5317 // remove current element from list if current element is not NULL
5318 // The new current element will be the next element.
5319 // If the current element is the last element in the list
5320 // the second but last element will become the new current element.
5321 void SignerInfos::RemoveCurrFromList()
5323 AsnListElmt
*del_elmt
;
5331 first
= last
= curr
= NULL
;
5332 else if (curr
== first
)
5334 curr
= first
= first
->next
;
5337 else if (curr
== last
)
5339 curr
= last
= last
->prev
;
5344 curr
->prev
->next
= curr
->next
;
5345 curr
->next
->prev
= curr
->prev
;
5348 delete del_elmt
->elmt
;
5354 AsnLen
SignerInfos::BEncContent (BUF_TYPE b
)
5356 AsnListElmt
*currElmt
;
5358 AsnLen totalLen
= 0;
5361 CSM_Buffer
**tmpEnc
=NULL
;
5362 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
5363 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
5364 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
5367 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
5368 elmtLen
+= BEncConsLen (outputBuf
, elmtLen
);
5370 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, CONS
, SEQ_TAG_CODE
);
5371 ENCODE_BUF2(tmpEnc
[iii
]);
5373 vdasnacc_sortSetOf(tmpEnc
, icount
);
5374 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
5375 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
5376 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
5379 totalLen
+= elmtLen
;
5381 } // SignerInfos::BEncContent
5384 void SignerInfos::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
5385 AsnLen
&bytesDecoded
, ENV_TYPE env
)
5387 SignerInfo
*listElmt
;
5389 AsnLen listBytesDecoded
= 0;
5392 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
5394 tag1
= BDecTag (b
, listBytesDecoded
, env
);
5395 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
5397 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
5400 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
5402 Asn1Error
<< "Unexpected Tag" << endl
;
5403 longjmp (env
, -163);
5406 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
5407 listElmt
= Append();
5408 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
5411 bytesDecoded
+= listBytesDecoded
;
5412 } // SignerInfos::BDecContent
5415 RecipientEncryptedKey::RecipientEncryptedKey()
5418 rid
= new KeyAgreeRecipientIdentifier
;
5420 rid
= NULL
; // incomplete initialization of mandatory element!
5424 RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey
&)
5426 Asn1Error
<< "use of incompletely defined RecipientEncryptedKey::RecipientEncryptedKey (const RecipientEncryptedKey &)" << endl
;
5430 RecipientEncryptedKey::~RecipientEncryptedKey()
5435 AsnType
*RecipientEncryptedKey::Clone() const
5437 return new RecipientEncryptedKey
;
5440 AsnType
*RecipientEncryptedKey::Copy() const
5442 return new RecipientEncryptedKey (*this);
5446 RecipientEncryptedKey
&RecipientEncryptedKey::operator = (const RecipientEncryptedKey
&that
)
5447 #else // SNACC_DEEP_COPY
5448 RecipientEncryptedKey
&RecipientEncryptedKey::operator = (const RecipientEncryptedKey
&)
5449 #endif // SNACC_DEEP_COPY
5457 rid
= new KeyAgreeRecipientIdentifier
;
5465 encryptedKey
= that
.encryptedKey
;
5469 #else // SNACC_DEEP_COPY
5470 Asn1Error
<< "use of incompletely defined RecipientEncryptedKey &RecipientEncryptedKey::operator = (const RecipientEncryptedKey &)" << endl
;
5472 // if your compiler complains here, check the -novolat option
5473 #endif // SNACC_DEEP_COPY
5477 RecipientEncryptedKey::BEncContent (BUF_TYPE b
)
5479 AsnLen totalLen
= 0;
5482 l
= encryptedKey
.BEncContent (b
);
5483 l
+= BEncDefLen (b
, l
);
5485 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
5488 l
= rid
->BEncContent (b
);
5492 } // RecipientEncryptedKey::BEncContent
5495 void RecipientEncryptedKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5498 AsnLen seqBytesDecoded
= 0;
5500 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
5502 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
5503 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
5505 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
5506 rid
= new KeyAgreeRecipientIdentifier
;
5507 rid
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
5508 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
5512 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
5513 longjmp (env
, -164);
5516 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
5517 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
5519 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
5520 encryptedKey
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
5524 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
5525 longjmp (env
, -165);
5528 bytesDecoded
+= seqBytesDecoded
;
5529 if (elmtLen0
== INDEFINITE_LEN
)
5531 BDecEoc (b
, bytesDecoded
, env
);
5534 else if (seqBytesDecoded
!= elmtLen0
)
5536 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
5537 longjmp (env
, -166);
5541 } // RecipientEncryptedKey::BDecContent
5543 AsnLen
RecipientEncryptedKey::BEnc (BUF_TYPE b
)
5546 l
= BEncContent (b
);
5547 l
+= BEncConsLen (b
, l
);
5548 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
5552 void RecipientEncryptedKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5557 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
5559 Asn1Error
<< "RecipientEncryptedKey::BDec: ERROR - wrong tag" << endl
;
5560 longjmp (env
, -167);
5562 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
5563 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
5566 int RecipientEncryptedKey::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
5568 bytesEncoded
= BEnc (b
);
5569 return !b
.WriteError();
5572 int RecipientEncryptedKey::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
5578 if ((val
= setjmp (env
)) == 0)
5580 BDec (b
, bytesDecoded
, env
);
5581 return !b
.ReadError();
5587 void RecipientEncryptedKey::Print (ostream
&os
) const
5590 os
<< "{ -- SEQUENCE --" << endl
;
5591 indentG
+= stdIndentG
;
5595 Indent (os
, indentG
);
5601 Indent (os
, indentG
);
5608 Indent (os
, indentG
);
5609 os
<< "encryptedKey ";
5614 indentG
-= stdIndentG
;
5615 Indent (os
, indentG
);
5618 } // RecipientEncryptedKey::Print
5621 CertificateChoices::CertificateChoices()
5623 choiceId
= certificateCid
;
5625 certificate
= new Certificate
;
5627 certificate
= NULL
; // incomplete initialization of mandatory element!
5631 CertificateChoices::CertificateChoices (const CertificateChoices
&)
5633 Asn1Error
<< "use of incompletely defined CertificateChoices::CertificateChoices (const CertificateChoices &)" << endl
;
5637 CertificateChoices::~CertificateChoices()
5641 case certificateCid
:
5644 case extendedCertificateCid
:
5645 delete extendedCertificate
;
5651 } // end of destructor
5653 AsnType
*CertificateChoices::Clone() const
5655 return new CertificateChoices
;
5658 AsnType
*CertificateChoices::Copy() const
5660 return new CertificateChoices (*this);
5664 CertificateChoices
&CertificateChoices::operator = (const CertificateChoices
&that
)
5665 #else // SNACC_DEEP_COPY
5666 CertificateChoices
&CertificateChoices::operator = (const CertificateChoices
&)
5667 #endif // SNACC_DEEP_COPY
5674 case certificateCid
:
5677 case extendedCertificateCid
:
5678 delete extendedCertificate
;
5684 switch (choiceId
= that
.choiceId
)
5686 case certificateCid
:
5687 certificate
= new Certificate
;
5688 *certificate
= *that
.certificate
;
5690 case extendedCertificateCid
:
5691 extendedCertificate
= new ExtendedCertificate
;
5692 *extendedCertificate
= *that
.extendedCertificate
;
5695 attrCert
= new AttributeCertificate
;
5696 *attrCert
= *that
.attrCert
;
5702 #else // SNACC_DEEP_COPY
5703 Asn1Error
<< "use of incompletely defined CertificateChoices &CertificateChoices::operator = (const CertificateChoices &)" << endl
;
5705 // if your compiler complains here, check the -novolat option
5706 #endif // SNACC_DEEP_COPY
5710 CertificateChoices::BEncContent (BUF_TYPE b
)
5715 case certificateCid
:
5717 l
= certificate
->BEncContent (b
);
5718 l
+= BEncConsLen (b
, l
);
5720 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
5723 case extendedCertificateCid
:
5725 l
= extendedCertificate
->BEncContent (b
);
5726 l
+= BEncConsLen (b
, l
);
5728 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
5733 l
= attrCert
->BEncContent (b
);
5734 l
+= BEncConsLen (b
, l
);
5736 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
5741 } // CertificateChoices::BEncContent
5744 void CertificateChoices::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5748 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
5749 choiceId
= certificateCid
;
5750 certificate
= new Certificate
;
5751 certificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5754 case MAKE_TAG_ID (CNTX
, CONS
, 0):
5755 choiceId
= extendedCertificateCid
;
5756 extendedCertificate
= new ExtendedCertificate
;
5757 extendedCertificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5760 case MAKE_TAG_ID (CNTX
, CONS
, 1):
5761 choiceId
= attrCertCid
;
5762 attrCert
= new AttributeCertificate
;
5763 attrCert
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
5767 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
5768 longjmp (env
, -168);
5771 } // CertificateChoices::BDecContent
5774 AsnLen
CertificateChoices::BEnc (BUF_TYPE b
)
5777 l
= BEncContent (b
);
5781 void CertificateChoices::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5786 /* CHOICEs are a special case - grab identifying tag */
5787 /* this allows easier handling of nested CHOICEs */
5788 tag
= BDecTag (b
, bytesDecoded
, env
);
5789 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
5790 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
5793 int CertificateChoices::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
5795 bytesEncoded
= BEnc (b
);
5796 return !b
.WriteError();
5799 int CertificateChoices::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
5805 if ((val
= setjmp (env
)) == 0)
5807 BDec (b
, bytesDecoded
, env
);
5808 return !b
.ReadError();
5814 void CertificateChoices::Print (ostream
&os
) const
5819 case certificateCid
:
5820 os
<< "certificate ";
5824 os
<< "-- void3 --\n";
5827 case extendedCertificateCid
:
5828 os
<< "extendedCertificate ";
5829 if (extendedCertificate
)
5830 os
<< *extendedCertificate
;
5832 os
<< "-- void3 --\n";
5840 os
<< "-- void3 --\n";
5845 } // CertificateChoices::Print
5847 AsnType
*CertificateSet::Clone() const
5849 return new CertificateSet
;
5852 AsnType
*CertificateSet::Copy() const
5854 return new CertificateSet (*this);
5857 AsnLen
CertificateSet::BEnc (BUF_TYPE b
)
5860 l
= BEncContent (b
);
5861 l
+= BEncConsLen (b
, l
);
5862 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
5866 void CertificateSet::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
5871 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
5873 Asn1Error
<< "CertificateSet::BDec: ERROR - wrong tag" << endl
;
5874 longjmp (env
, -169);
5876 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
5877 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
5880 CertificateSet::CertificateSet (const CertificateSet
&)
5882 Asn1Error
<< "use of incompletely defined CertificateSet::CertificateSet (const CertificateSet &)" << endl
;
5886 CertificateSet::~CertificateSet()
5889 for (; Curr() != NULL
; RemoveCurrFromList())
5891 } // end of destructor
5894 CertificateSet
&CertificateSet::operator = (const CertificateSet
&that
)
5895 #else // SNACC_DEEP_COPY
5896 CertificateSet
&CertificateSet::operator = (const CertificateSet
&)
5897 #endif // SNACC_DEEP_COPY
5903 for (; Curr(); RemoveCurrFromList())
5906 //that.SetCurrToFirst();
5907 //for (; that.Curr(); that.GoNext())
5908 // AppendCopy (*that.Curr());
5909 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
5910 AppendCopy (*run
->elmt
);
5914 #else // SNACC_DEEP_COPY
5915 Asn1Error
<< "use of incompletely defined CertificateSet &CertificateSet::operator = (const CertificateSet &)" << endl
;
5917 // if your compiler complains here, check the -novolat option
5918 #endif // SNACC_DEEP_COPY
5921 void CertificateSet::Print (ostream
&os
) const
5924 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
5925 indentG
+= stdIndentG
;
5927 //for (; Curr() != NULL; GoNext())
5928 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
5930 Indent (os
, indentG
);
5933 //if (Curr() != Last())
5938 indentG
-= stdIndentG
;
5939 Indent (os
, indentG
);
5947 void CertificateSet::SetCurrElmt (unsigned long int index
)
5949 unsigned long int i
;
5952 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
5954 } // CertificateSet::SetCurrElmt
5957 unsigned long int CertificateSet::GetCurrElmtIndex()
5959 unsigned long int i
;
5963 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
5972 } // CertificateSet::GetCurrElmtIndex
5975 // alloc new list elmt, put at end of list
5976 // and return the component type
5977 CertificateChoices
*CertificateSet::Append()
5979 AsnListElmt
*newElmt
;
5980 newElmt
= new AsnListElmt
;
5981 newElmt
->elmt
= new CertificateChoices
;
5982 newElmt
->next
= NULL
;
5985 newElmt
->prev
= NULL
;
5986 first
= last
= newElmt
;
5990 newElmt
->prev
= last
;
5991 last
->next
= newElmt
;
5995 return (curr
= newElmt
)->elmt
;
5996 } // CertificateSet::Append
5999 // alloc new list elmt, put at begining of list
6000 // and return the component type
6001 CertificateChoices
*CertificateSet::Prepend()
6003 AsnListElmt
*newElmt
;
6004 newElmt
= new AsnListElmt
;
6005 newElmt
->elmt
= new CertificateChoices
;
6006 newElmt
->prev
= NULL
;
6009 newElmt
->next
= NULL
;
6010 first
= last
= newElmt
;
6014 newElmt
->next
= first
;
6015 first
->prev
= newElmt
;
6019 return (curr
= newElmt
)->elmt
;
6020 } // CertificateSet::Prepend
6023 // alloc new list elmt, insert it before the
6024 // current element and return the component type
6025 // if the current element is null, the new element
6026 // is placed at the beginning of the list.
6027 CertificateChoices
*CertificateSet::InsertBefore()
6029 AsnListElmt
*newElmt
;
6030 newElmt
= new AsnListElmt
;
6031 newElmt
->elmt
= new CertificateChoices
;
6034 newElmt
->next
= first
;
6035 newElmt
->prev
= NULL
;
6042 newElmt
->next
= curr
;
6043 newElmt
->prev
= curr
->prev
;
6044 curr
->prev
= newElmt
;
6048 newElmt
->prev
->next
= newElmt
;
6051 return (curr
= newElmt
)->elmt
;
6052 } // CertificateSet::InsertBefore
6055 // alloc new list elmt, insert it after the
6056 // current element and return the component type
6057 // if the current element is null, the new element
6058 // is placed at the end of the list.
6059 CertificateChoices
*CertificateSet::InsertAfter()
6061 AsnListElmt
*newElmt
;
6062 newElmt
= new AsnListElmt
;
6063 newElmt
->elmt
= new CertificateChoices
;
6066 newElmt
->prev
= last
;
6067 newElmt
->next
= NULL
;
6074 newElmt
->prev
= curr
;
6075 newElmt
->next
= curr
->next
;
6076 curr
->next
= newElmt
;
6080 newElmt
->next
->prev
= newElmt
;
6083 return (curr
= newElmt
)->elmt
;
6084 } // CertificateSet::InsertAfter
6087 CertificateSet
&CertificateSet::AppendCopy (CertificateChoices
&elmt
)
6089 AsnListElmt
*newElmt
;
6090 newElmt
= new AsnListElmt
;
6091 newElmt
->elmt
= new CertificateChoices
;
6092 *newElmt
->elmt
= elmt
;
6093 newElmt
->next
= NULL
;
6096 newElmt
->prev
= NULL
;
6097 first
= last
= newElmt
;
6101 newElmt
->prev
= last
;
6102 last
->next
= newElmt
;
6110 CertificateSet
&CertificateSet::PrependCopy (CertificateChoices
&elmt
)
6112 AsnListElmt
*newElmt
;
6113 newElmt
= new AsnListElmt
;
6114 newElmt
->elmt
= new CertificateChoices
;
6115 *newElmt
->elmt
= elmt
;
6116 newElmt
->prev
= NULL
;
6119 newElmt
->next
= NULL
;
6120 first
= last
= newElmt
;
6124 newElmt
->next
= first
;
6125 first
->prev
= newElmt
;
6130 } // CertificateSet::PrependCopy
6133 // alloc new list elmt, insert it before the
6134 // current element, copy the given elmt into the new elmt
6135 // and return the component type.
6136 // if the current element is null, the new element
6137 // is placed at the beginning of the list.
6138 CertificateSet
&CertificateSet::InsertBeforeAndCopy (CertificateChoices
&elmt
)
6140 AsnListElmt
*newElmt
;
6142 newElmt
= new AsnListElmt
;
6143 newElmt
->elmt
= new CertificateChoices
;
6144 *newElmt
->elmt
= elmt
;
6148 newElmt
->next
= first
;
6149 newElmt
->prev
= NULL
;
6156 newElmt
->next
= curr
;
6157 newElmt
->prev
= curr
->prev
;
6158 curr
->prev
= newElmt
;
6162 newElmt
->prev
->next
= newElmt
;
6166 } // CertificateSet::InsertBeforeAndCopy
6169 // alloc new list elmt, insert it after the
6170 // current element, copy given elmt in to new elmt
6171 // and return the component type
6172 // if the current element is null, the new element
6173 // is placed at the end of the list.
6174 CertificateSet
&CertificateSet::InsertAfterAndCopy (CertificateChoices
&elmt
)
6176 AsnListElmt
*newElmt
;
6178 newElmt
= new AsnListElmt
;
6179 newElmt
->elmt
= new CertificateChoices
;
6180 *newElmt
->elmt
= elmt
;
6183 newElmt
->prev
= last
;
6184 newElmt
->next
= NULL
;
6191 newElmt
->prev
= curr
;
6192 newElmt
->next
= curr
->next
;
6193 curr
->next
= newElmt
;
6197 newElmt
->next
->prev
= newElmt
;
6201 } // CertificateSet::InsertAfterAndCopy
6204 // remove current element from list if current element is not NULL
6205 // The new current element will be the next element.
6206 // If the current element is the last element in the list
6207 // the second but last element will become the new current element.
6208 void CertificateSet::RemoveCurrFromList()
6210 AsnListElmt
*del_elmt
;
6218 first
= last
= curr
= NULL
;
6219 else if (curr
== first
)
6221 curr
= first
= first
->next
;
6224 else if (curr
== last
)
6226 curr
= last
= last
->prev
;
6231 curr
->prev
->next
= curr
->next
;
6232 curr
->next
->prev
= curr
->prev
;
6235 delete del_elmt
->elmt
;
6241 AsnLen
CertificateSet::BEncContent (BUF_TYPE b
)
6243 AsnListElmt
*currElmt
;
6245 AsnLen totalLen
= 0;
6248 CSM_Buffer
**tmpEnc
=NULL
;
6249 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
6250 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
6251 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
6253 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
6254 ENCODE_BUF2(tmpEnc
[iii
]);
6256 vdasnacc_sortSetOf(tmpEnc
, icount
);
6257 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
6258 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
6259 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
6262 totalLen
+= elmtLen
;
6264 } // CertificateSet::BEncContent
6267 void CertificateSet::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
6268 AsnLen
&bytesDecoded
, ENV_TYPE env
)
6270 CertificateChoices
*listElmt
;
6272 AsnLen listBytesDecoded
= 0;
6275 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
6277 tag1
= BDecTag (b
, listBytesDecoded
, env
);
6278 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
6280 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
6283 if (!((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6284 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0))
6285 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1))))
6287 Asn1Error
<< "Unexpected Tag" << endl
;
6288 longjmp (env
, -170);
6291 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
6292 listElmt
= Append();
6293 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
6296 bytesDecoded
+= listBytesDecoded
;
6297 } // CertificateSet::BDecContent
6300 OriginatorInfo::OriginatorInfo()
6306 OriginatorInfo::OriginatorInfo (const OriginatorInfo
&)
6308 Asn1Error
<< "use of incompletely defined OriginatorInfo::OriginatorInfo (const OriginatorInfo &)" << endl
;
6312 OriginatorInfo::~OriginatorInfo()
6318 AsnType
*OriginatorInfo::Clone() const
6320 return new OriginatorInfo
;
6323 AsnType
*OriginatorInfo::Copy() const
6325 return new OriginatorInfo (*this);
6329 OriginatorInfo
&OriginatorInfo::operator = (const OriginatorInfo
&that
)
6330 #else // SNACC_DEEP_COPY
6331 OriginatorInfo
&OriginatorInfo::operator = (const OriginatorInfo
&)
6332 #endif // SNACC_DEEP_COPY
6340 certs
= new CertificateSet
;
6341 *certs
= *that
.certs
;
6351 crls
= new CertificateRevocationLists
;
6362 #else // SNACC_DEEP_COPY
6363 Asn1Error
<< "use of incompletely defined OriginatorInfo &OriginatorInfo::operator = (const OriginatorInfo &)" << endl
;
6365 // if your compiler complains here, check the -novolat option
6366 #endif // SNACC_DEEP_COPY
6370 OriginatorInfo::BEncContent (BUF_TYPE b
)
6372 AsnLen totalLen
= 0;
6375 if (NOT_NULL (crls
))
6378 l
= crls
->BEncContent (b
);
6379 l
+= BEncConsLen (b
, l
);
6381 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
6385 if (NOT_NULL (certs
))
6388 l
= certs
->BEncContent (b
);
6389 l
+= BEncConsLen (b
, l
);
6391 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
6396 } // OriginatorInfo::BEncContent
6399 void OriginatorInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6402 AsnLen seqBytesDecoded
= 0;
6408 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6410 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
6412 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
6413 bytesDecoded
+= seqBytesDecoded
;
6418 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
6420 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6421 certs
= new CertificateSet
;
6422 certs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6423 if (seqBytesDecoded
== elmtLen0
)
6425 bytesDecoded
+= seqBytesDecoded
;
6430 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
6432 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
6434 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
6435 bytesDecoded
+= seqBytesDecoded
;
6441 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
6443 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
6444 crls
= new CertificateRevocationLists
;
6445 crls
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
6448 bytesDecoded
+= seqBytesDecoded
;
6449 if (elmtLen0
== INDEFINITE_LEN
)
6451 BDecEoc (b
, bytesDecoded
, env
);
6454 else if (seqBytesDecoded
!= elmtLen0
)
6456 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
6457 longjmp (env
, -171);
6461 } // OriginatorInfo::BDecContent
6463 AsnLen
OriginatorInfo::BEnc (BUF_TYPE b
)
6466 l
= BEncContent (b
);
6467 l
+= BEncConsLen (b
, l
);
6468 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6472 void OriginatorInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6477 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6479 Asn1Error
<< "OriginatorInfo::BDec: ERROR - wrong tag" << endl
;
6480 longjmp (env
, -172);
6482 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
6483 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
6486 int OriginatorInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
6488 bytesEncoded
= BEnc (b
);
6489 return !b
.WriteError();
6492 int OriginatorInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
6498 if ((val
= setjmp (env
)) == 0)
6500 BDec (b
, bytesDecoded
, env
);
6501 return !b
.ReadError();
6507 void OriginatorInfo::Print (ostream
&os
) const
6510 int nonePrinted
= true;
6511 os
<< "{ -- SEQUENCE --" << endl
;
6512 indentG
+= stdIndentG
;
6514 if (NOT_NULL (certs
))
6516 nonePrinted
= false;
6517 Indent (os
, indentG
);
6523 Indent (os
, indentG
);
6529 if (NOT_NULL (crls
))
6533 nonePrinted
= false;
6534 Indent (os
, indentG
);
6540 Indent (os
, indentG
);
6547 indentG
-= stdIndentG
;
6548 Indent (os
, indentG
);
6551 } // OriginatorInfo::Print
6554 AsnType
*RecipientEncryptedKeys::Clone() const
6556 return new RecipientEncryptedKeys
;
6559 AsnType
*RecipientEncryptedKeys::Copy() const
6561 return new RecipientEncryptedKeys (*this);
6564 AsnLen
RecipientEncryptedKeys::BEnc (BUF_TYPE b
)
6567 l
= BEncContent (b
);
6568 l
+= BEncConsLen (b
, l
);
6569 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6573 void RecipientEncryptedKeys::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
6578 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
6580 Asn1Error
<< "RecipientEncryptedKeys::BDec: ERROR - wrong tag" << endl
;
6581 longjmp (env
, -173);
6583 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
6584 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
6587 RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys
&)
6589 Asn1Error
<< "use of incompletely defined RecipientEncryptedKeys::RecipientEncryptedKeys (const RecipientEncryptedKeys &)" << endl
;
6593 RecipientEncryptedKeys::~RecipientEncryptedKeys()
6596 for (; Curr() != NULL
; RemoveCurrFromList())
6598 } // end of destructor
6601 RecipientEncryptedKeys
&RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys
&that
)
6602 #else // SNACC_DEEP_COPY
6603 RecipientEncryptedKeys
&RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys
&)
6604 #endif // SNACC_DEEP_COPY
6610 for (; Curr(); RemoveCurrFromList())
6613 //that.SetCurrToFirst();
6614 //for (; that.Curr(); that.GoNext())
6615 // AppendCopy (*that.Curr());
6616 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
6617 AppendCopy (*run
->elmt
);
6621 #else // SNACC_DEEP_COPY
6622 Asn1Error
<< "use of incompletely defined RecipientEncryptedKeys &RecipientEncryptedKeys::operator = (const RecipientEncryptedKeys &)" << endl
;
6624 // if your compiler complains here, check the -novolat option
6625 #endif // SNACC_DEEP_COPY
6628 void RecipientEncryptedKeys::Print (ostream
&os
) const
6631 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
6632 indentG
+= stdIndentG
;
6634 //for (; Curr() != NULL; GoNext())
6635 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
6637 Indent (os
, indentG
);
6640 //if (Curr() != Last())
6645 indentG
-= stdIndentG
;
6646 Indent (os
, indentG
);
6654 void RecipientEncryptedKeys::SetCurrElmt (unsigned long int index
)
6656 unsigned long int i
;
6659 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
6661 } // RecipientEncryptedKeys::SetCurrElmt
6664 unsigned long int RecipientEncryptedKeys::GetCurrElmtIndex()
6666 unsigned long int i
;
6670 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
6679 } // RecipientEncryptedKeys::GetCurrElmtIndex
6682 // alloc new list elmt, put at end of list
6683 // and return the component type
6684 RecipientEncryptedKey
*RecipientEncryptedKeys::Append()
6686 AsnListElmt
*newElmt
;
6687 newElmt
= new AsnListElmt
;
6688 newElmt
->elmt
= new RecipientEncryptedKey
;
6689 newElmt
->next
= NULL
;
6692 newElmt
->prev
= NULL
;
6693 first
= last
= newElmt
;
6697 newElmt
->prev
= last
;
6698 last
->next
= newElmt
;
6702 return (curr
= newElmt
)->elmt
;
6703 } // RecipientEncryptedKeys::Append
6706 // alloc new list elmt, put at begining of list
6707 // and return the component type
6708 RecipientEncryptedKey
*RecipientEncryptedKeys::Prepend()
6710 AsnListElmt
*newElmt
;
6711 newElmt
= new AsnListElmt
;
6712 newElmt
->elmt
= new RecipientEncryptedKey
;
6713 newElmt
->prev
= NULL
;
6716 newElmt
->next
= NULL
;
6717 first
= last
= newElmt
;
6721 newElmt
->next
= first
;
6722 first
->prev
= newElmt
;
6726 return (curr
= newElmt
)->elmt
;
6727 } // RecipientEncryptedKeys::Prepend
6730 // alloc new list elmt, insert it before the
6731 // current element and return the component type
6732 // if the current element is null, the new element
6733 // is placed at the beginning of the list.
6734 RecipientEncryptedKey
*RecipientEncryptedKeys::InsertBefore()
6736 AsnListElmt
*newElmt
;
6737 newElmt
= new AsnListElmt
;
6738 newElmt
->elmt
= new RecipientEncryptedKey
;
6741 newElmt
->next
= first
;
6742 newElmt
->prev
= NULL
;
6749 newElmt
->next
= curr
;
6750 newElmt
->prev
= curr
->prev
;
6751 curr
->prev
= newElmt
;
6755 newElmt
->prev
->next
= newElmt
;
6758 return (curr
= newElmt
)->elmt
;
6759 } // RecipientEncryptedKeys::InsertBefore
6762 // alloc new list elmt, insert it after the
6763 // current element and return the component type
6764 // if the current element is null, the new element
6765 // is placed at the end of the list.
6766 RecipientEncryptedKey
*RecipientEncryptedKeys::InsertAfter()
6768 AsnListElmt
*newElmt
;
6769 newElmt
= new AsnListElmt
;
6770 newElmt
->elmt
= new RecipientEncryptedKey
;
6773 newElmt
->prev
= last
;
6774 newElmt
->next
= NULL
;
6781 newElmt
->prev
= curr
;
6782 newElmt
->next
= curr
->next
;
6783 curr
->next
= newElmt
;
6787 newElmt
->next
->prev
= newElmt
;
6790 return (curr
= newElmt
)->elmt
;
6791 } // RecipientEncryptedKeys::InsertAfter
6794 RecipientEncryptedKeys
&RecipientEncryptedKeys::AppendCopy (RecipientEncryptedKey
&elmt
)
6796 AsnListElmt
*newElmt
;
6797 newElmt
= new AsnListElmt
;
6798 newElmt
->elmt
= new RecipientEncryptedKey
;
6799 *newElmt
->elmt
= elmt
;
6800 newElmt
->next
= NULL
;
6803 newElmt
->prev
= NULL
;
6804 first
= last
= newElmt
;
6808 newElmt
->prev
= last
;
6809 last
->next
= newElmt
;
6817 RecipientEncryptedKeys
&RecipientEncryptedKeys::PrependCopy (RecipientEncryptedKey
&elmt
)
6819 AsnListElmt
*newElmt
;
6820 newElmt
= new AsnListElmt
;
6821 newElmt
->elmt
= new RecipientEncryptedKey
;
6822 *newElmt
->elmt
= elmt
;
6823 newElmt
->prev
= NULL
;
6826 newElmt
->next
= NULL
;
6827 first
= last
= newElmt
;
6831 newElmt
->next
= first
;
6832 first
->prev
= newElmt
;
6837 } // RecipientEncryptedKeys::PrependCopy
6840 // alloc new list elmt, insert it before the
6841 // current element, copy the given elmt into the new elmt
6842 // and return the component type.
6843 // if the current element is null, the new element
6844 // is placed at the beginning of the list.
6845 RecipientEncryptedKeys
&RecipientEncryptedKeys::InsertBeforeAndCopy (RecipientEncryptedKey
&elmt
)
6847 AsnListElmt
*newElmt
;
6849 newElmt
= new AsnListElmt
;
6850 newElmt
->elmt
= new RecipientEncryptedKey
;
6851 *newElmt
->elmt
= elmt
;
6855 newElmt
->next
= first
;
6856 newElmt
->prev
= NULL
;
6863 newElmt
->next
= curr
;
6864 newElmt
->prev
= curr
->prev
;
6865 curr
->prev
= newElmt
;
6869 newElmt
->prev
->next
= newElmt
;
6873 } // RecipientEncryptedKeys::InsertBeforeAndCopy
6876 // alloc new list elmt, insert it after the
6877 // current element, copy given elmt in to new elmt
6878 // and return the component type
6879 // if the current element is null, the new element
6880 // is placed at the end of the list.
6881 RecipientEncryptedKeys
&RecipientEncryptedKeys::InsertAfterAndCopy (RecipientEncryptedKey
&elmt
)
6883 AsnListElmt
*newElmt
;
6885 newElmt
= new AsnListElmt
;
6886 newElmt
->elmt
= new RecipientEncryptedKey
;
6887 *newElmt
->elmt
= elmt
;
6890 newElmt
->prev
= last
;
6891 newElmt
->next
= NULL
;
6898 newElmt
->prev
= curr
;
6899 newElmt
->next
= curr
->next
;
6900 curr
->next
= newElmt
;
6904 newElmt
->next
->prev
= newElmt
;
6908 } // RecipientEncryptedKeys::InsertAfterAndCopy
6911 // remove current element from list if current element is not NULL
6912 // The new current element will be the next element.
6913 // If the current element is the last element in the list
6914 // the second but last element will become the new current element.
6915 void RecipientEncryptedKeys::RemoveCurrFromList()
6917 AsnListElmt
*del_elmt
;
6925 first
= last
= curr
= NULL
;
6926 else if (curr
== first
)
6928 curr
= first
= first
->next
;
6931 else if (curr
== last
)
6933 curr
= last
= last
->prev
;
6938 curr
->prev
->next
= curr
->next
;
6939 curr
->next
->prev
= curr
->prev
;
6942 delete del_elmt
->elmt
;
6948 AsnLen
RecipientEncryptedKeys::BEncContent (BUF_TYPE b
)
6950 AsnListElmt
*currElmt
;
6952 AsnLen totalLen
= 0;
6953 for (currElmt
= last
; currElmt
!= NULL
; currElmt
= currElmt
->prev
)
6956 elmtLen
= currElmt
->elmt
->BEncContent (b
);
6957 elmtLen
+= BEncConsLen (b
, elmtLen
);
6959 elmtLen
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
6960 totalLen
+= elmtLen
;
6963 } // RecipientEncryptedKeys::BEncContent
6966 void RecipientEncryptedKeys::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
6967 AsnLen
&bytesDecoded
, ENV_TYPE env
)
6969 RecipientEncryptedKey
*listElmt
;
6971 AsnLen listBytesDecoded
= 0;
6974 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
6976 tag1
= BDecTag (b
, listBytesDecoded
, env
);
6977 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
6979 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
6982 if ((tag1
!= MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
6984 Asn1Error
<< "Unexpected Tag" << endl
;
6985 longjmp (env
, -174);
6988 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
6989 listElmt
= Append();
6990 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
6993 bytesDecoded
+= listBytesDecoded
;
6994 } // RecipientEncryptedKeys::BDecContent
6997 KeyAgreeRecipientInfo::KeyAgreeRecipientInfo()
7000 originator
= new OriginatorIdentifierOrKey
;
7002 originator
= NULL
; // incomplete initialization of mandatory element!
7006 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
7008 keyEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
7012 KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo
&)
7014 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientInfo::KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &)" << endl
;
7018 KeyAgreeRecipientInfo::~KeyAgreeRecipientInfo()
7022 delete keyEncryptionAlgorithm
;
7025 AsnType
*KeyAgreeRecipientInfo::Clone() const
7027 return new KeyAgreeRecipientInfo
;
7030 AsnType
*KeyAgreeRecipientInfo::Copy() const
7032 return new KeyAgreeRecipientInfo (*this);
7036 KeyAgreeRecipientInfo
&KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo
&that
)
7037 #else // SNACC_DEEP_COPY
7038 KeyAgreeRecipientInfo
&KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo
&)
7039 #endif // SNACC_DEEP_COPY
7044 version
= that
.version
;
7045 if (that
.originator
)
7048 originator
= new OriginatorIdentifierOrKey
;
7049 *originator
= *that
.originator
;
7059 ukm
= new UserKeyingMaterial
;
7067 if (that
.keyEncryptionAlgorithm
)
7069 if (!keyEncryptionAlgorithm
)
7070 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
7071 *keyEncryptionAlgorithm
= *that
.keyEncryptionAlgorithm
;
7075 delete keyEncryptionAlgorithm
;
7076 keyEncryptionAlgorithm
= NULL
;
7078 recipientEncryptedKeys
= that
.recipientEncryptedKeys
;
7082 #else // SNACC_DEEP_COPY
7083 Asn1Error
<< "use of incompletely defined KeyAgreeRecipientInfo &KeyAgreeRecipientInfo::operator = (const KeyAgreeRecipientInfo &)" << endl
;
7085 // if your compiler complains here, check the -novolat option
7086 #endif // SNACC_DEEP_COPY
7090 KeyAgreeRecipientInfo::BEncContent (BUF_TYPE b
)
7092 AsnLen totalLen
= 0;
7096 l
= recipientEncryptedKeys
.BEncContent (b
);
7097 l
+= BEncConsLen (b
, l
);
7099 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7103 l
= keyEncryptionAlgorithm
->BEncContent (b
);
7104 l
+= BEncConsLen (b
, l
);
7106 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7112 l
= ukm
->BEncContent (b
);
7113 l
+= BEncDefLen (b
, l
);
7115 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
7116 l
+= BEncConsLen (b
, l
);
7118 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
7123 l
= originator
->BEncContent (b
);
7124 l
+= BEncConsLen (b
, l
);
7126 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
7129 l
= version
.BEncContent (b
);
7130 BEncDefLenTo127 (b
, l
);
7133 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
7137 } // KeyAgreeRecipientInfo::BEncContent
7140 void KeyAgreeRecipientInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7143 AsnLen seqBytesDecoded
= 0;
7146 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7148 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
7150 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7151 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7152 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7156 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7157 longjmp (env
, -175);
7160 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
7162 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7163 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7164 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
7165 originator
= new OriginatorIdentifierOrKey
;
7166 originator
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
7167 if (elmtLen1
== INDEFINITE_LEN
)
7168 BDecEoc (b
, seqBytesDecoded
, env
);
7170 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7174 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7175 longjmp (env
, -176);
7178 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
7180 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7181 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7183 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
7184 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
7186 Asn1Error
<< "Unexpected Tag" << endl
;
7187 longjmp (env
, -177);
7190 elmtLen2
= BDecLen (b
, seqBytesDecoded
, env
);
7191 ukm
= new UserKeyingMaterial
;
7192 ukm
->BDecContent (b
, tag1
, elmtLen2
, seqBytesDecoded
, env
);
7193 if (elmtLen1
== INDEFINITE_LEN
)
7194 BDecEoc (b
, seqBytesDecoded
, env
);
7196 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7199 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
7201 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7202 keyEncryptionAlgorithm
= new KeyEncryptionAlgorithmIdentifier
;
7203 keyEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7204 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
7208 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7209 longjmp (env
, -178);
7212 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
7214 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
7215 recipientEncryptedKeys
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
7219 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
7220 longjmp (env
, -179);
7223 bytesDecoded
+= seqBytesDecoded
;
7224 if (elmtLen0
== INDEFINITE_LEN
)
7226 BDecEoc (b
, bytesDecoded
, env
);
7229 else if (seqBytesDecoded
!= elmtLen0
)
7231 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
7232 longjmp (env
, -180);
7236 } // KeyAgreeRecipientInfo::BDecContent
7238 AsnLen
KeyAgreeRecipientInfo::BEnc (BUF_TYPE b
)
7241 l
= BEncContent (b
);
7242 l
+= BEncConsLen (b
, l
);
7243 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7247 void KeyAgreeRecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7252 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
7254 Asn1Error
<< "KeyAgreeRecipientInfo::BDec: ERROR - wrong tag" << endl
;
7255 longjmp (env
, -181);
7257 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
7258 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
7261 int KeyAgreeRecipientInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
7263 bytesEncoded
= BEnc (b
);
7264 return !b
.WriteError();
7267 int KeyAgreeRecipientInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
7273 if ((val
= setjmp (env
)) == 0)
7275 BDec (b
, bytesDecoded
, env
);
7276 return !b
.ReadError();
7282 void KeyAgreeRecipientInfo::Print (ostream
&os
) const
7285 os
<< "{ -- SEQUENCE --" << endl
;
7286 indentG
+= stdIndentG
;
7289 Indent (os
, indentG
);
7295 if (NOT_NULL (originator
))
7297 Indent (os
, indentG
);
7298 os
<< "originator ";
7303 Indent (os
, indentG
);
7304 os
<< "originator ";
7311 Indent (os
, indentG
);
7317 Indent (os
, indentG
);
7323 if (NOT_NULL (keyEncryptionAlgorithm
))
7325 Indent (os
, indentG
);
7326 os
<< "keyEncryptionAlgorithm ";
7327 os
<< *keyEncryptionAlgorithm
;
7331 Indent (os
, indentG
);
7332 os
<< "keyEncryptionAlgorithm ";
7338 Indent (os
, indentG
);
7339 os
<< "recipientEncryptedKeys ";
7340 os
<< recipientEncryptedKeys
;
7344 indentG
-= stdIndentG
;
7345 Indent (os
, indentG
);
7348 } // KeyAgreeRecipientInfo::Print
7351 RecipientInfo::RecipientInfo()
7355 ktri
= new KeyTransRecipientInfo
;
7357 ktri
= NULL
; // incomplete initialization of mandatory element!
7361 RecipientInfo::RecipientInfo (const RecipientInfo
&)
7363 Asn1Error
<< "use of incompletely defined RecipientInfo::RecipientInfo (const RecipientInfo &)" << endl
;
7367 RecipientInfo::~RecipientInfo()
7381 } // end of destructor
7383 AsnType
*RecipientInfo::Clone() const
7385 return new RecipientInfo
;
7388 AsnType
*RecipientInfo::Copy() const
7390 return new RecipientInfo (*this);
7394 RecipientInfo
&RecipientInfo::operator = (const RecipientInfo
&that
)
7395 #else // SNACC_DEEP_COPY
7396 RecipientInfo
&RecipientInfo::operator = (const RecipientInfo
&)
7397 #endif // SNACC_DEEP_COPY
7414 switch (choiceId
= that
.choiceId
)
7417 ktri
= new KeyTransRecipientInfo
;
7421 kari
= new KeyAgreeRecipientInfo
;
7425 kekri
= new KEKRecipientInfo
;
7426 *kekri
= *that
.kekri
;
7432 #else // SNACC_DEEP_COPY
7433 Asn1Error
<< "use of incompletely defined RecipientInfo &RecipientInfo::operator = (const RecipientInfo &)" << endl
;
7435 // if your compiler complains here, check the -novolat option
7436 #endif // SNACC_DEEP_COPY
7440 RecipientInfo::BEncContent (BUF_TYPE b
)
7447 l
= ktri
->BEncContent (b
);
7448 l
+= BEncConsLen (b
, l
);
7450 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
7455 l
= kari
->BEncContent (b
);
7456 l
+= BEncConsLen (b
, l
);
7458 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
7463 l
= kekri
->BEncContent (b
);
7464 l
+= BEncConsLen (b
, l
);
7466 l
+= BEncTag1 (b
, CNTX
, CONS
, 2);
7471 } // RecipientInfo::BEncContent
7474 void RecipientInfo::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7478 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
7480 ktri
= new KeyTransRecipientInfo
;
7481 ktri
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7484 case MAKE_TAG_ID (CNTX
, CONS
, 1):
7486 kari
= new KeyAgreeRecipientInfo
;
7487 kari
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7490 case MAKE_TAG_ID (CNTX
, CONS
, 2):
7491 choiceId
= kekriCid
;
7492 kekri
= new KEKRecipientInfo
;
7493 kekri
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
7497 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
7498 longjmp (env
, -182);
7501 } // RecipientInfo::BDecContent
7504 AsnLen
RecipientInfo::BEnc (BUF_TYPE b
)
7507 l
= BEncContent (b
);
7511 void RecipientInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7516 /* CHOICEs are a special case - grab identifying tag */
7517 /* this allows easier handling of nested CHOICEs */
7518 tag
= BDecTag (b
, bytesDecoded
, env
);
7519 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
7520 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
7523 int RecipientInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
7525 bytesEncoded
= BEnc (b
);
7526 return !b
.WriteError();
7529 int RecipientInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
7535 if ((val
= setjmp (env
)) == 0)
7537 BDec (b
, bytesDecoded
, env
);
7538 return !b
.ReadError();
7544 void RecipientInfo::Print (ostream
&os
) const
7554 os
<< "-- void3 --\n";
7562 os
<< "-- void3 --\n";
7570 os
<< "-- void3 --\n";
7575 } // RecipientInfo::Print
7577 AsnType
*RecipientInfos::Clone() const
7579 return new RecipientInfos
;
7582 AsnType
*RecipientInfos::Copy() const
7584 return new RecipientInfos (*this);
7587 AsnLen
RecipientInfos::BEnc (BUF_TYPE b
)
7590 l
= BEncContent (b
);
7591 l
+= BEncConsLen (b
, l
);
7592 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
7596 void RecipientInfos::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
7601 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
7603 Asn1Error
<< "RecipientInfos::BDec: ERROR - wrong tag" << endl
;
7604 longjmp (env
, -183);
7606 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
7607 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
7610 RecipientInfos::RecipientInfos (const RecipientInfos
&)
7612 Asn1Error
<< "use of incompletely defined RecipientInfos::RecipientInfos (const RecipientInfos &)" << endl
;
7616 RecipientInfos::~RecipientInfos()
7619 for (; Curr() != NULL
; RemoveCurrFromList())
7621 } // end of destructor
7624 RecipientInfos
&RecipientInfos::operator = (const RecipientInfos
&that
)
7625 #else // SNACC_DEEP_COPY
7626 RecipientInfos
&RecipientInfos::operator = (const RecipientInfos
&)
7627 #endif // SNACC_DEEP_COPY
7633 for (; Curr(); RemoveCurrFromList())
7636 //that.SetCurrToFirst();
7637 //for (; that.Curr(); that.GoNext())
7638 // AppendCopy (*that.Curr());
7639 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
7640 AppendCopy (*run
->elmt
);
7644 #else // SNACC_DEEP_COPY
7645 Asn1Error
<< "use of incompletely defined RecipientInfos &RecipientInfos::operator = (const RecipientInfos &)" << endl
;
7647 // if your compiler complains here, check the -novolat option
7648 #endif // SNACC_DEEP_COPY
7651 void RecipientInfos::Print (ostream
&os
) const
7654 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
7655 indentG
+= stdIndentG
;
7657 //for (; Curr() != NULL; GoNext())
7658 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
7660 Indent (os
, indentG
);
7663 //if (Curr() != Last())
7668 indentG
-= stdIndentG
;
7669 Indent (os
, indentG
);
7677 void RecipientInfos::SetCurrElmt (unsigned long int index
)
7679 unsigned long int i
;
7682 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
7684 } // RecipientInfos::SetCurrElmt
7687 unsigned long int RecipientInfos::GetCurrElmtIndex()
7689 unsigned long int i
;
7693 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
7702 } // RecipientInfos::GetCurrElmtIndex
7705 // alloc new list elmt, put at end of list
7706 // and return the component type
7707 RecipientInfo
*RecipientInfos::Append()
7709 AsnListElmt
*newElmt
;
7710 newElmt
= new AsnListElmt
;
7711 newElmt
->elmt
= new RecipientInfo
;
7712 newElmt
->next
= NULL
;
7715 newElmt
->prev
= NULL
;
7716 first
= last
= newElmt
;
7720 newElmt
->prev
= last
;
7721 last
->next
= newElmt
;
7725 return (curr
= newElmt
)->elmt
;
7726 } // RecipientInfos::Append
7729 // alloc new list elmt, put at begining of list
7730 // and return the component type
7731 RecipientInfo
*RecipientInfos::Prepend()
7733 AsnListElmt
*newElmt
;
7734 newElmt
= new AsnListElmt
;
7735 newElmt
->elmt
= new RecipientInfo
;
7736 newElmt
->prev
= NULL
;
7739 newElmt
->next
= NULL
;
7740 first
= last
= newElmt
;
7744 newElmt
->next
= first
;
7745 first
->prev
= newElmt
;
7749 return (curr
= newElmt
)->elmt
;
7750 } // RecipientInfos::Prepend
7753 // alloc new list elmt, insert it before the
7754 // current element and return the component type
7755 // if the current element is null, the new element
7756 // is placed at the beginning of the list.
7757 RecipientInfo
*RecipientInfos::InsertBefore()
7759 AsnListElmt
*newElmt
;
7760 newElmt
= new AsnListElmt
;
7761 newElmt
->elmt
= new RecipientInfo
;
7764 newElmt
->next
= first
;
7765 newElmt
->prev
= NULL
;
7772 newElmt
->next
= curr
;
7773 newElmt
->prev
= curr
->prev
;
7774 curr
->prev
= newElmt
;
7778 newElmt
->prev
->next
= newElmt
;
7781 return (curr
= newElmt
)->elmt
;
7782 } // RecipientInfos::InsertBefore
7785 // alloc new list elmt, insert it after the
7786 // current element and return the component type
7787 // if the current element is null, the new element
7788 // is placed at the end of the list.
7789 RecipientInfo
*RecipientInfos::InsertAfter()
7791 AsnListElmt
*newElmt
;
7792 newElmt
= new AsnListElmt
;
7793 newElmt
->elmt
= new RecipientInfo
;
7796 newElmt
->prev
= last
;
7797 newElmt
->next
= NULL
;
7804 newElmt
->prev
= curr
;
7805 newElmt
->next
= curr
->next
;
7806 curr
->next
= newElmt
;
7810 newElmt
->next
->prev
= newElmt
;
7813 return (curr
= newElmt
)->elmt
;
7814 } // RecipientInfos::InsertAfter
7817 RecipientInfos
&RecipientInfos::AppendCopy (RecipientInfo
&elmt
)
7819 AsnListElmt
*newElmt
;
7820 newElmt
= new AsnListElmt
;
7821 newElmt
->elmt
= new RecipientInfo
;
7822 *newElmt
->elmt
= elmt
;
7823 newElmt
->next
= NULL
;
7826 newElmt
->prev
= NULL
;
7827 first
= last
= newElmt
;
7831 newElmt
->prev
= last
;
7832 last
->next
= newElmt
;
7840 RecipientInfos
&RecipientInfos::PrependCopy (RecipientInfo
&elmt
)
7842 AsnListElmt
*newElmt
;
7843 newElmt
= new AsnListElmt
;
7844 newElmt
->elmt
= new RecipientInfo
;
7845 *newElmt
->elmt
= elmt
;
7846 newElmt
->prev
= NULL
;
7849 newElmt
->next
= NULL
;
7850 first
= last
= newElmt
;
7854 newElmt
->next
= first
;
7855 first
->prev
= newElmt
;
7860 } // RecipientInfos::PrependCopy
7863 // alloc new list elmt, insert it before the
7864 // current element, copy the given elmt into the new elmt
7865 // and return the component type.
7866 // if the current element is null, the new element
7867 // is placed at the beginning of the list.
7868 RecipientInfos
&RecipientInfos::InsertBeforeAndCopy (RecipientInfo
&elmt
)
7870 AsnListElmt
*newElmt
;
7872 newElmt
= new AsnListElmt
;
7873 newElmt
->elmt
= new RecipientInfo
;
7874 *newElmt
->elmt
= elmt
;
7878 newElmt
->next
= first
;
7879 newElmt
->prev
= NULL
;
7886 newElmt
->next
= curr
;
7887 newElmt
->prev
= curr
->prev
;
7888 curr
->prev
= newElmt
;
7892 newElmt
->prev
->next
= newElmt
;
7896 } // RecipientInfos::InsertBeforeAndCopy
7899 // alloc new list elmt, insert it after the
7900 // current element, copy given elmt in to new elmt
7901 // and return the component type
7902 // if the current element is null, the new element
7903 // is placed at the end of the list.
7904 RecipientInfos
&RecipientInfos::InsertAfterAndCopy (RecipientInfo
&elmt
)
7906 AsnListElmt
*newElmt
;
7908 newElmt
= new AsnListElmt
;
7909 newElmt
->elmt
= new RecipientInfo
;
7910 *newElmt
->elmt
= elmt
;
7913 newElmt
->prev
= last
;
7914 newElmt
->next
= NULL
;
7921 newElmt
->prev
= curr
;
7922 newElmt
->next
= curr
->next
;
7923 curr
->next
= newElmt
;
7927 newElmt
->next
->prev
= newElmt
;
7931 } // RecipientInfos::InsertAfterAndCopy
7934 // remove current element from list if current element is not NULL
7935 // The new current element will be the next element.
7936 // If the current element is the last element in the list
7937 // the second but last element will become the new current element.
7938 void RecipientInfos::RemoveCurrFromList()
7940 AsnListElmt
*del_elmt
;
7948 first
= last
= curr
= NULL
;
7949 else if (curr
== first
)
7951 curr
= first
= first
->next
;
7954 else if (curr
== last
)
7956 curr
= last
= last
->prev
;
7961 curr
->prev
->next
= curr
->next
;
7962 curr
->next
->prev
= curr
->prev
;
7965 delete del_elmt
->elmt
;
7971 AsnLen
RecipientInfos::BEncContent (BUF_TYPE b
)
7973 AsnListElmt
*currElmt
;
7975 AsnLen totalLen
= 0;
7978 CSM_Buffer
**tmpEnc
=NULL
;
7979 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
7980 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
7981 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
7983 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
7984 ENCODE_BUF2(tmpEnc
[iii
]);
7986 vdasnacc_sortSetOf(tmpEnc
, icount
);
7987 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
7988 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
7989 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
7992 totalLen
+= elmtLen
;
7994 } // RecipientInfos::BEncContent
7997 void RecipientInfos::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
7998 AsnLen
&bytesDecoded
, ENV_TYPE env
)
8000 RecipientInfo
*listElmt
;
8002 AsnLen listBytesDecoded
= 0;
8005 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
8007 tag1
= BDecTag (b
, listBytesDecoded
, env
);
8008 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
8010 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
8013 if (!((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8014 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1))
8015 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 2))))
8017 Asn1Error
<< "Unexpected Tag" << endl
;
8018 longjmp (env
, -184);
8021 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
8022 listElmt
= Append();
8023 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
8026 bytesDecoded
+= listBytesDecoded
;
8027 } // RecipientInfos::BDecContent
8030 ContentInfo::ContentInfo()
8034 ContentInfo::ContentInfo (const ContentInfo
&)
8036 Asn1Error
<< "use of incompletely defined ContentInfo::ContentInfo (const ContentInfo &)" << endl
;
8040 ContentInfo::~ContentInfo()
8044 AsnType
*ContentInfo::Clone() const
8046 return new ContentInfo
;
8049 AsnType
*ContentInfo::Copy() const
8051 return new ContentInfo (*this);
8055 ContentInfo
&ContentInfo::operator = (const ContentInfo
&that
)
8056 #else // SNACC_DEEP_COPY
8057 ContentInfo
&ContentInfo::operator = (const ContentInfo
&)
8058 #endif // SNACC_DEEP_COPY
8063 contentType
= that
.contentType
;
8064 content
= that
.content
;
8068 #else // SNACC_DEEP_COPY
8069 Asn1Error
<< "use of incompletely defined ContentInfo &ContentInfo::operator = (const ContentInfo &)" << endl
;
8071 // if your compiler complains here, check the -novolat option
8072 #endif // SNACC_DEEP_COPY
8076 ContentInfo::BEncContent (BUF_TYPE b
)
8078 AsnLen totalLen
= 0;
8082 ENC_LOAD_ANYBUF(&content
, b
, l
);
8083 l
+= BEncConsLen (b
, l
);
8085 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
8088 l
= contentType
.BEncContent (b
);
8089 l
+= BEncDefLen (b
, l
);
8091 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
8095 } // ContentInfo::BEncContent
8098 void ContentInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8101 AsnLen seqBytesDecoded
= 0;
8103 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8105 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
8107 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8108 contentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8109 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8113 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8114 longjmp (env
, -185);
8117 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
8119 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8120 DEC_LOAD_ANYBUF(&content
, b
, seqBytesDecoded
, env
);
8121 if (elmtLen1
== INDEFINITE_LEN
)
8122 BDecEoc (b
, seqBytesDecoded
, env
);
8127 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8128 longjmp (env
, -186);
8131 bytesDecoded
+= seqBytesDecoded
;
8132 if (elmtLen0
== INDEFINITE_LEN
)
8134 BDecEoc (b
, bytesDecoded
, env
);
8137 else if (seqBytesDecoded
!= elmtLen0
)
8139 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8140 longjmp (env
, -187);
8144 } // ContentInfo::BDecContent
8146 AsnLen
ContentInfo::BEnc (BUF_TYPE b
)
8149 l
= BEncContent (b
);
8150 l
+= BEncConsLen (b
, l
);
8151 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8155 void ContentInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8160 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8162 Asn1Error
<< "ContentInfo::BDec: ERROR - wrong tag" << endl
;
8163 longjmp (env
, -188);
8165 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8166 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8169 int ContentInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
8171 bytesEncoded
= BEnc (b
);
8172 return !b
.WriteError();
8175 int ContentInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
8181 if ((val
= setjmp (env
)) == 0)
8183 BDec (b
, bytesDecoded
, env
);
8184 return !b
.ReadError();
8190 void ContentInfo::Print (ostream
&os
) const
8193 os
<< "{ -- SEQUENCE --" << endl
;
8194 indentG
+= stdIndentG
;
8197 Indent (os
, indentG
);
8198 os
<< "contentType ";
8204 Indent (os
, indentG
);
8210 indentG
-= stdIndentG
;
8211 Indent (os
, indentG
);
8214 } // ContentInfo::Print
8217 SignedData::SignedData()
8220 encapContentInfo
= new EncapsulatedContentInfo
;
8222 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
8224 certificates
= NULL
;
8228 SignedData::SignedData (const SignedData
&)
8230 Asn1Error
<< "use of incompletely defined SignedData::SignedData (const SignedData &)" << endl
;
8234 SignedData::~SignedData()
8236 delete encapContentInfo
;
8237 delete certificates
;
8241 AsnType
*SignedData::Clone() const
8243 return new SignedData
;
8246 AsnType
*SignedData::Copy() const
8248 return new SignedData (*this);
8252 SignedData
&SignedData::operator = (const SignedData
&that
)
8253 #else // SNACC_DEEP_COPY
8254 SignedData
&SignedData::operator = (const SignedData
&)
8255 #endif // SNACC_DEEP_COPY
8260 version
= that
.version
;
8261 digestAlgorithms
= that
.digestAlgorithms
;
8262 if (that
.encapContentInfo
)
8264 if (!encapContentInfo
)
8265 encapContentInfo
= new EncapsulatedContentInfo
;
8266 *encapContentInfo
= *that
.encapContentInfo
;
8270 delete encapContentInfo
;
8271 encapContentInfo
= NULL
;
8273 if (that
.certificates
)
8276 certificates
= new CertificateSet
;
8277 *certificates
= *that
.certificates
;
8281 delete certificates
;
8282 certificates
= NULL
;
8287 crls
= new CertificateRevocationLists
;
8295 signerInfos
= that
.signerInfos
;
8299 #else // SNACC_DEEP_COPY
8300 Asn1Error
<< "use of incompletely defined SignedData &SignedData::operator = (const SignedData &)" << endl
;
8302 // if your compiler complains here, check the -novolat option
8303 #endif // SNACC_DEEP_COPY
8307 SignedData::BEncContent (BUF_TYPE b
)
8309 AsnLen totalLen
= 0;
8313 l
= signerInfos
.BEncContent (b
);
8314 l
+= BEncConsLen (b
, l
);
8316 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
8319 if (NOT_NULL (crls
))
8322 l
= crls
->BEncContent (b
);
8323 l
+= BEncConsLen (b
, l
);
8325 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
8329 if (NOT_NULL (certificates
))
8332 l
= certificates
->BEncContent (b
);
8333 l
+= BEncConsLen (b
, l
);
8335 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
8340 l
= encapContentInfo
->BEncContent (b
);
8341 l
+= BEncConsLen (b
, l
);
8343 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8347 l
= digestAlgorithms
.BEncContent (b
);
8348 l
+= BEncConsLen (b
, l
);
8350 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
8353 l
= version
.BEncContent (b
);
8354 BEncDefLenTo127 (b
, l
);
8357 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
8361 } // SignedData::BEncContent
8364 void SignedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8367 AsnLen seqBytesDecoded
= 0;
8369 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8371 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
8373 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8374 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8375 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8379 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8380 longjmp (env
, -189);
8383 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
8385 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8386 digestAlgorithms
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8387 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8391 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8392 longjmp (env
, -190);
8395 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8397 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8398 encapContentInfo
= new EncapsulatedContentInfo
;
8399 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8400 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8404 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8405 longjmp (env
, -191);
8408 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
8410 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8411 certificates
= new CertificateSet
;
8412 certificates
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8413 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8416 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
8418 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8419 crls
= new CertificateRevocationLists
;
8420 crls
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8421 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8424 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
8426 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8427 signerInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8431 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8432 longjmp (env
, -192);
8435 bytesDecoded
+= seqBytesDecoded
;
8436 if (elmtLen0
== INDEFINITE_LEN
)
8438 BDecEoc (b
, bytesDecoded
, env
);
8441 else if (seqBytesDecoded
!= elmtLen0
)
8443 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8444 longjmp (env
, -193);
8448 } // SignedData::BDecContent
8450 AsnLen
SignedData::BEnc (BUF_TYPE b
)
8453 l
= BEncContent (b
);
8454 l
+= BEncConsLen (b
, l
);
8455 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8459 void SignedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8464 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8466 Asn1Error
<< "SignedData::BDec: ERROR - wrong tag" << endl
;
8467 longjmp (env
, -194);
8469 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8470 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8473 int SignedData::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
8475 bytesEncoded
= BEnc (b
);
8476 return !b
.WriteError();
8479 int SignedData::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
8485 if ((val
= setjmp (env
)) == 0)
8487 BDec (b
, bytesDecoded
, env
);
8488 return !b
.ReadError();
8494 void SignedData::Print (ostream
&os
) const
8497 os
<< "{ -- SEQUENCE --" << endl
;
8498 indentG
+= stdIndentG
;
8501 Indent (os
, indentG
);
8508 Indent (os
, indentG
);
8509 os
<< "digestAlgorithms ";
8510 os
<< digestAlgorithms
;
8514 if (NOT_NULL (encapContentInfo
))
8516 Indent (os
, indentG
);
8517 os
<< "encapContentInfo ";
8518 os
<< *encapContentInfo
;
8522 Indent (os
, indentG
);
8523 os
<< "encapContentInfo ";
8528 if (NOT_NULL (certificates
))
8530 Indent (os
, indentG
);
8531 os
<< "certificates ";
8532 os
<< *certificates
;
8536 Indent (os
, indentG
);
8537 os
<< "certificates ";
8542 if (NOT_NULL (crls
))
8544 Indent (os
, indentG
);
8550 Indent (os
, indentG
);
8557 Indent (os
, indentG
);
8558 os
<< "signerInfos ";
8563 indentG
-= stdIndentG
;
8564 Indent (os
, indentG
);
8567 } // SignedData::Print
8570 EnvelopedData::EnvelopedData()
8572 originatorInfo
= NULL
;
8574 encryptedContentInfo
= new EncryptedContentInfo
;
8576 encryptedContentInfo
= NULL
; // incomplete initialization of mandatory element!
8578 unprotectedAttrs
= NULL
;
8581 EnvelopedData::EnvelopedData (const EnvelopedData
&)
8583 Asn1Error
<< "use of incompletely defined EnvelopedData::EnvelopedData (const EnvelopedData &)" << endl
;
8587 EnvelopedData::~EnvelopedData()
8589 delete originatorInfo
;
8590 delete encryptedContentInfo
;
8591 delete unprotectedAttrs
;
8594 AsnType
*EnvelopedData::Clone() const
8596 return new EnvelopedData
;
8599 AsnType
*EnvelopedData::Copy() const
8601 return new EnvelopedData (*this);
8605 EnvelopedData
&EnvelopedData::operator = (const EnvelopedData
&that
)
8606 #else // SNACC_DEEP_COPY
8607 EnvelopedData
&EnvelopedData::operator = (const EnvelopedData
&)
8608 #endif // SNACC_DEEP_COPY
8613 version
= that
.version
;
8614 if (that
.originatorInfo
)
8616 if (!originatorInfo
)
8617 originatorInfo
= new OriginatorInfo
;
8618 *originatorInfo
= *that
.originatorInfo
;
8622 delete originatorInfo
;
8623 originatorInfo
= NULL
;
8625 recipientInfos
= that
.recipientInfos
;
8626 if (that
.encryptedContentInfo
)
8628 if (!encryptedContentInfo
)
8629 encryptedContentInfo
= new EncryptedContentInfo
;
8630 *encryptedContentInfo
= *that
.encryptedContentInfo
;
8634 delete encryptedContentInfo
;
8635 encryptedContentInfo
= NULL
;
8637 if (that
.unprotectedAttrs
)
8639 if (!unprotectedAttrs
)
8640 unprotectedAttrs
= new Attributes
;
8641 *unprotectedAttrs
= *that
.unprotectedAttrs
;
8645 delete unprotectedAttrs
;
8646 unprotectedAttrs
= NULL
;
8651 #else // SNACC_DEEP_COPY
8652 Asn1Error
<< "use of incompletely defined EnvelopedData &EnvelopedData::operator = (const EnvelopedData &)" << endl
;
8654 // if your compiler complains here, check the -novolat option
8655 #endif // SNACC_DEEP_COPY
8659 EnvelopedData::BEncContent (BUF_TYPE b
)
8661 AsnLen totalLen
= 0;
8664 if (NOT_NULL (unprotectedAttrs
))
8667 l
= unprotectedAttrs
->BEncContent (b
);
8668 l
+= BEncConsLen (b
, l
);
8670 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
8675 l
= encryptedContentInfo
->BEncContent (b
);
8676 l
+= BEncConsLen (b
, l
);
8678 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8682 l
= recipientInfos
.BEncContent (b
);
8683 l
+= BEncConsLen (b
, l
);
8685 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
8688 if (NOT_NULL (originatorInfo
))
8691 l
= originatorInfo
->BEncContent (b
);
8692 l
+= BEncConsLen (b
, l
);
8694 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
8698 l
= version
.BEncContent (b
);
8699 BEncDefLenTo127 (b
, l
);
8702 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
8706 } // EnvelopedData::BEncContent
8709 void EnvelopedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8712 AsnLen seqBytesDecoded
= 0;
8714 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8716 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
8718 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8719 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8720 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8724 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8725 longjmp (env
, -195);
8728 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
8730 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8731 originatorInfo
= new OriginatorInfo
;
8732 originatorInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8733 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8736 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
8738 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8739 recipientInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8740 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8744 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8745 longjmp (env
, -196);
8748 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
8750 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8751 encryptedContentInfo
= new EncryptedContentInfo
;
8752 encryptedContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8753 if (seqBytesDecoded
== elmtLen0
)
8755 bytesDecoded
+= seqBytesDecoded
;
8760 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
8762 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
8764 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
8765 bytesDecoded
+= seqBytesDecoded
;
8772 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
8773 longjmp (env
, -197);
8776 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
8778 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
8779 unprotectedAttrs
= new Attributes
;
8780 unprotectedAttrs
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
8783 bytesDecoded
+= seqBytesDecoded
;
8784 if (elmtLen0
== INDEFINITE_LEN
)
8786 BDecEoc (b
, bytesDecoded
, env
);
8789 else if (seqBytesDecoded
!= elmtLen0
)
8791 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
8792 longjmp (env
, -198);
8796 } // EnvelopedData::BDecContent
8798 AsnLen
EnvelopedData::BEnc (BUF_TYPE b
)
8801 l
= BEncContent (b
);
8802 l
+= BEncConsLen (b
, l
);
8803 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
8807 void EnvelopedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
8812 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
8814 Asn1Error
<< "EnvelopedData::BDec: ERROR - wrong tag" << endl
;
8815 longjmp (env
, -199);
8817 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
8818 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
8821 int EnvelopedData::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
8823 bytesEncoded
= BEnc (b
);
8824 return !b
.WriteError();
8827 int EnvelopedData::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
8833 if ((val
= setjmp (env
)) == 0)
8835 BDec (b
, bytesDecoded
, env
);
8836 return !b
.ReadError();
8842 void EnvelopedData::Print (ostream
&os
) const
8845 os
<< "{ -- SEQUENCE --" << endl
;
8846 indentG
+= stdIndentG
;
8849 Indent (os
, indentG
);
8855 if (NOT_NULL (originatorInfo
))
8857 Indent (os
, indentG
);
8858 os
<< "originatorInfo ";
8859 os
<< *originatorInfo
;
8863 Indent (os
, indentG
);
8864 os
<< "originatorInfo ";
8870 Indent (os
, indentG
);
8871 os
<< "recipientInfos ";
8872 os
<< recipientInfos
;
8876 if (NOT_NULL (encryptedContentInfo
))
8878 Indent (os
, indentG
);
8879 os
<< "encryptedContentInfo ";
8880 os
<< *encryptedContentInfo
;
8884 Indent (os
, indentG
);
8885 os
<< "encryptedContentInfo ";
8890 if (NOT_NULL (unprotectedAttrs
))
8893 Indent (os
, indentG
);
8894 os
<< "unprotectedAttrs ";
8895 os
<< *unprotectedAttrs
;
8899 Indent (os
, indentG
);
8900 os
<< "unprotectedAttrs ";
8906 indentG
-= stdIndentG
;
8907 Indent (os
, indentG
);
8910 } // EnvelopedData::Print
8913 DigestedData::DigestedData()
8916 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8918 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
8921 encapContentInfo
= new EncapsulatedContentInfo
;
8923 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
8927 DigestedData::DigestedData (const DigestedData
&)
8929 Asn1Error
<< "use of incompletely defined DigestedData::DigestedData (const DigestedData &)" << endl
;
8933 DigestedData::~DigestedData()
8935 delete digestAlgorithm
;
8936 delete encapContentInfo
;
8939 AsnType
*DigestedData::Clone() const
8941 return new DigestedData
;
8944 AsnType
*DigestedData::Copy() const
8946 return new DigestedData (*this);
8950 DigestedData
&DigestedData::operator = (const DigestedData
&that
)
8951 #else // SNACC_DEEP_COPY
8952 DigestedData
&DigestedData::operator = (const DigestedData
&)
8953 #endif // SNACC_DEEP_COPY
8958 version
= that
.version
;
8959 if (that
.digestAlgorithm
)
8961 if (!digestAlgorithm
)
8962 digestAlgorithm
= new DigestAlgorithmIdentifier
;
8963 *digestAlgorithm
= *that
.digestAlgorithm
;
8967 delete digestAlgorithm
;
8968 digestAlgorithm
= NULL
;
8970 if (that
.encapContentInfo
)
8972 if (!encapContentInfo
)
8973 encapContentInfo
= new EncapsulatedContentInfo
;
8974 *encapContentInfo
= *that
.encapContentInfo
;
8978 delete encapContentInfo
;
8979 encapContentInfo
= NULL
;
8981 digest
= that
.digest
;
8985 #else // SNACC_DEEP_COPY
8986 Asn1Error
<< "use of incompletely defined DigestedData &DigestedData::operator = (const DigestedData &)" << endl
;
8988 // if your compiler complains here, check the -novolat option
8989 #endif // SNACC_DEEP_COPY
8993 DigestedData::BEncContent (BUF_TYPE b
)
8995 AsnLen totalLen
= 0;
8998 l
= digest
.BEncContent (b
);
8999 l
+= BEncDefLen (b
, l
);
9001 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
9005 l
= encapContentInfo
->BEncContent (b
);
9006 l
+= BEncConsLen (b
, l
);
9008 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9012 l
= digestAlgorithm
->BEncContent (b
);
9013 l
+= BEncConsLen (b
, l
);
9015 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9018 l
= version
.BEncContent (b
);
9019 BEncDefLenTo127 (b
, l
);
9022 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
9026 } // DigestedData::BEncContent
9029 void DigestedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9032 AsnLen seqBytesDecoded
= 0;
9034 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9036 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
9038 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9039 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9040 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9044 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9045 longjmp (env
, -200);
9048 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9050 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9051 digestAlgorithm
= new DigestAlgorithmIdentifier
;
9052 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9053 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9057 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9058 longjmp (env
, -201);
9061 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9063 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9064 encapContentInfo
= new EncapsulatedContentInfo
;
9065 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9066 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9070 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9071 longjmp (env
, -202);
9074 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
9075 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
9077 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9078 digest
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9082 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9083 longjmp (env
, -203);
9086 bytesDecoded
+= seqBytesDecoded
;
9087 if (elmtLen0
== INDEFINITE_LEN
)
9089 BDecEoc (b
, bytesDecoded
, env
);
9092 else if (seqBytesDecoded
!= elmtLen0
)
9094 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
9095 longjmp (env
, -204);
9099 } // DigestedData::BDecContent
9101 AsnLen
DigestedData::BEnc (BUF_TYPE b
)
9104 l
= BEncContent (b
);
9105 l
+= BEncConsLen (b
, l
);
9106 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9110 void DigestedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9115 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
9117 Asn1Error
<< "DigestedData::BDec: ERROR - wrong tag" << endl
;
9118 longjmp (env
, -205);
9120 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9121 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9124 int DigestedData::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
9126 bytesEncoded
= BEnc (b
);
9127 return !b
.WriteError();
9130 int DigestedData::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
9136 if ((val
= setjmp (env
)) == 0)
9138 BDec (b
, bytesDecoded
, env
);
9139 return !b
.ReadError();
9145 void DigestedData::Print (ostream
&os
) const
9148 os
<< "{ -- SEQUENCE --" << endl
;
9149 indentG
+= stdIndentG
;
9152 Indent (os
, indentG
);
9158 if (NOT_NULL (digestAlgorithm
))
9160 Indent (os
, indentG
);
9161 os
<< "digestAlgorithm ";
9162 os
<< *digestAlgorithm
;
9166 Indent (os
, indentG
);
9167 os
<< "digestAlgorithm ";
9172 if (NOT_NULL (encapContentInfo
))
9174 Indent (os
, indentG
);
9175 os
<< "encapContentInfo ";
9176 os
<< *encapContentInfo
;
9180 Indent (os
, indentG
);
9181 os
<< "encapContentInfo ";
9187 Indent (os
, indentG
);
9193 indentG
-= stdIndentG
;
9194 Indent (os
, indentG
);
9197 } // DigestedData::Print
9200 EncryptedData::EncryptedData()
9203 encryptedContentInfo
= new EncryptedContentInfo
;
9205 encryptedContentInfo
= NULL
; // incomplete initialization of mandatory element!
9209 EncryptedData::EncryptedData (const EncryptedData
&)
9211 Asn1Error
<< "use of incompletely defined EncryptedData::EncryptedData (const EncryptedData &)" << endl
;
9215 EncryptedData::~EncryptedData()
9217 delete encryptedContentInfo
;
9220 AsnType
*EncryptedData::Clone() const
9222 return new EncryptedData
;
9225 AsnType
*EncryptedData::Copy() const
9227 return new EncryptedData (*this);
9231 EncryptedData
&EncryptedData::operator = (const EncryptedData
&that
)
9232 #else // SNACC_DEEP_COPY
9233 EncryptedData
&EncryptedData::operator = (const EncryptedData
&)
9234 #endif // SNACC_DEEP_COPY
9239 version
= that
.version
;
9240 if (that
.encryptedContentInfo
)
9242 if (!encryptedContentInfo
)
9243 encryptedContentInfo
= new EncryptedContentInfo
;
9244 *encryptedContentInfo
= *that
.encryptedContentInfo
;
9248 delete encryptedContentInfo
;
9249 encryptedContentInfo
= NULL
;
9254 #else // SNACC_DEEP_COPY
9255 Asn1Error
<< "use of incompletely defined EncryptedData &EncryptedData::operator = (const EncryptedData &)" << endl
;
9257 // if your compiler complains here, check the -novolat option
9258 #endif // SNACC_DEEP_COPY
9262 EncryptedData::BEncContent (BUF_TYPE b
)
9264 AsnLen totalLen
= 0;
9268 l
= encryptedContentInfo
->BEncContent (b
);
9269 l
+= BEncConsLen (b
, l
);
9271 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9274 l
= version
.BEncContent (b
);
9275 BEncDefLenTo127 (b
, l
);
9278 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
9282 } // EncryptedData::BEncContent
9285 void EncryptedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9288 AsnLen seqBytesDecoded
= 0;
9290 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9292 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
9294 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9295 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9296 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9300 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9301 longjmp (env
, -206);
9304 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9306 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9307 encryptedContentInfo
= new EncryptedContentInfo
;
9308 encryptedContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9312 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9313 longjmp (env
, -207);
9316 bytesDecoded
+= seqBytesDecoded
;
9317 if (elmtLen0
== INDEFINITE_LEN
)
9319 BDecEoc (b
, bytesDecoded
, env
);
9322 else if (seqBytesDecoded
!= elmtLen0
)
9324 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
9325 longjmp (env
, -208);
9329 } // EncryptedData::BDecContent
9331 AsnLen
EncryptedData::BEnc (BUF_TYPE b
)
9334 l
= BEncContent (b
);
9335 l
+= BEncConsLen (b
, l
);
9336 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9340 void EncryptedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9345 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
9347 Asn1Error
<< "EncryptedData::BDec: ERROR - wrong tag" << endl
;
9348 longjmp (env
, -209);
9350 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9351 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9354 int EncryptedData::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
9356 bytesEncoded
= BEnc (b
);
9357 return !b
.WriteError();
9360 int EncryptedData::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
9366 if ((val
= setjmp (env
)) == 0)
9368 BDec (b
, bytesDecoded
, env
);
9369 return !b
.ReadError();
9375 void EncryptedData::Print (ostream
&os
) const
9378 os
<< "{ -- SEQUENCE --" << endl
;
9379 indentG
+= stdIndentG
;
9382 Indent (os
, indentG
);
9388 if (NOT_NULL (encryptedContentInfo
))
9390 Indent (os
, indentG
);
9391 os
<< "encryptedContentInfo ";
9392 os
<< *encryptedContentInfo
;
9396 Indent (os
, indentG
);
9397 os
<< "encryptedContentInfo ";
9403 indentG
-= stdIndentG
;
9404 Indent (os
, indentG
);
9407 } // EncryptedData::Print
9410 AuthenticatedData::AuthenticatedData()
9412 originatorInfo
= NULL
;
9414 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
9416 macAlgorithm
= NULL
; // incomplete initialization of mandatory element!
9418 digestAlgorithm
= NULL
;
9420 encapContentInfo
= new EncapsulatedContentInfo
;
9422 encapContentInfo
= NULL
; // incomplete initialization of mandatory element!
9424 authenctiatedAttributes
= NULL
;
9425 unauthenticatedAttributes
= NULL
;
9428 AuthenticatedData::AuthenticatedData (const AuthenticatedData
&)
9430 Asn1Error
<< "use of incompletely defined AuthenticatedData::AuthenticatedData (const AuthenticatedData &)" << endl
;
9434 AuthenticatedData::~AuthenticatedData()
9436 delete originatorInfo
;
9437 delete macAlgorithm
;
9438 delete digestAlgorithm
;
9439 delete encapContentInfo
;
9440 delete authenctiatedAttributes
;
9441 delete unauthenticatedAttributes
;
9444 AsnType
*AuthenticatedData::Clone() const
9446 return new AuthenticatedData
;
9449 AsnType
*AuthenticatedData::Copy() const
9451 return new AuthenticatedData (*this);
9455 AuthenticatedData
&AuthenticatedData::operator = (const AuthenticatedData
&that
)
9456 #else // SNACC_DEEP_COPY
9457 AuthenticatedData
&AuthenticatedData::operator = (const AuthenticatedData
&)
9458 #endif // SNACC_DEEP_COPY
9463 version
= that
.version
;
9464 if (that
.originatorInfo
)
9466 if (!originatorInfo
)
9467 originatorInfo
= new OriginatorInfo
;
9468 *originatorInfo
= *that
.originatorInfo
;
9472 delete originatorInfo
;
9473 originatorInfo
= NULL
;
9475 recipientInfos
= that
.recipientInfos
;
9476 if (that
.macAlgorithm
)
9479 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
9480 *macAlgorithm
= *that
.macAlgorithm
;
9484 delete macAlgorithm
;
9485 macAlgorithm
= NULL
;
9487 if (that
.digestAlgorithm
)
9489 if (!digestAlgorithm
)
9490 digestAlgorithm
= new DigestAlgorithmIdentifier
;
9491 *digestAlgorithm
= *that
.digestAlgorithm
;
9495 delete digestAlgorithm
;
9496 digestAlgorithm
= NULL
;
9498 if (that
.encapContentInfo
)
9500 if (!encapContentInfo
)
9501 encapContentInfo
= new EncapsulatedContentInfo
;
9502 *encapContentInfo
= *that
.encapContentInfo
;
9506 delete encapContentInfo
;
9507 encapContentInfo
= NULL
;
9509 if (that
.authenctiatedAttributes
)
9511 if (!authenctiatedAttributes
)
9512 authenctiatedAttributes
= new Attributes
;
9513 *authenctiatedAttributes
= *that
.authenctiatedAttributes
;
9517 delete authenctiatedAttributes
;
9518 authenctiatedAttributes
= NULL
;
9521 if (that
.unauthenticatedAttributes
)
9523 if (!unauthenticatedAttributes
)
9524 unauthenticatedAttributes
= new Attributes
;
9525 *unauthenticatedAttributes
= *that
.unauthenticatedAttributes
;
9529 delete unauthenticatedAttributes
;
9530 unauthenticatedAttributes
= NULL
;
9535 #else // SNACC_DEEP_COPY
9536 Asn1Error
<< "use of incompletely defined AuthenticatedData &AuthenticatedData::operator = (const AuthenticatedData &)" << endl
;
9538 // if your compiler complains here, check the -novolat option
9539 #endif // SNACC_DEEP_COPY
9543 AuthenticatedData::BEncContent (BUF_TYPE b
)
9545 AsnLen totalLen
= 0;
9548 if (NOT_NULL (unauthenticatedAttributes
))
9551 l
= unauthenticatedAttributes
->BEncContent (b
);
9552 l
+= BEncConsLen (b
, l
);
9554 l
+= BEncTag1 (b
, CNTX
, CONS
, 3);
9558 l
= mac
.BEncContent (b
);
9559 l
+= BEncDefLen (b
, l
);
9561 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
9564 if (NOT_NULL (authenctiatedAttributes
))
9567 l
= authenctiatedAttributes
->BEncContent (b
);
9568 l
+= BEncConsLen (b
, l
);
9570 l
+= BEncTag1 (b
, CNTX
, CONS
, 2);
9575 l
= encapContentInfo
->BEncContent (b
);
9576 l
+= BEncConsLen (b
, l
);
9578 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9581 if (NOT_NULL (digestAlgorithm
))
9584 l
= digestAlgorithm
->BEncContent (b
);
9585 l
+= BEncConsLen (b
, l
);
9587 l
+= BEncTag1 (b
, CNTX
, CONS
, 1);
9592 l
= macAlgorithm
->BEncContent (b
);
9593 l
+= BEncConsLen (b
, l
);
9595 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9599 l
= recipientInfos
.BEncContent (b
);
9600 l
+= BEncConsLen (b
, l
);
9602 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
9605 if (NOT_NULL (originatorInfo
))
9608 l
= originatorInfo
->BEncContent (b
);
9609 l
+= BEncConsLen (b
, l
);
9611 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
9615 l
= version
.BEncContent (b
);
9616 BEncDefLenTo127 (b
, l
);
9619 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
9623 } // AuthenticatedData::BEncContent
9626 void AuthenticatedData::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9629 AsnLen seqBytesDecoded
= 0;
9631 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9633 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
9635 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9636 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9637 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9641 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9642 longjmp (env
, -210);
9645 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
9647 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9648 originatorInfo
= new OriginatorInfo
;
9649 originatorInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9650 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9653 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
)))
9655 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9656 recipientInfos
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9657 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9661 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9662 longjmp (env
, -211);
9665 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9667 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9668 macAlgorithm
= new MessageAuthenticationCodeAlgorithm
;
9669 macAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9670 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9674 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9675 longjmp (env
, -212);
9678 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 1)))
9680 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9681 digestAlgorithm
= new DigestAlgorithmIdentifier
;
9682 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9683 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9686 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
9688 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9689 encapContentInfo
= new EncapsulatedContentInfo
;
9690 encapContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9691 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9695 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9696 longjmp (env
, -213);
9699 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 2)))
9701 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9702 authenctiatedAttributes
= new Attributes
;
9703 authenctiatedAttributes
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9704 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9707 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
9708 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
9710 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9711 mac
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9712 if (seqBytesDecoded
== elmtLen0
)
9714 bytesDecoded
+= seqBytesDecoded
;
9719 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
9721 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
9723 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
9724 bytesDecoded
+= seqBytesDecoded
;
9731 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
9732 longjmp (env
, -214);
9735 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 3)))
9737 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
9738 unauthenticatedAttributes
= new Attributes
;
9739 unauthenticatedAttributes
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
9742 bytesDecoded
+= seqBytesDecoded
;
9743 if (elmtLen0
== INDEFINITE_LEN
)
9745 BDecEoc (b
, bytesDecoded
, env
);
9748 else if (seqBytesDecoded
!= elmtLen0
)
9750 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
9751 longjmp (env
, -215);
9755 } // AuthenticatedData::BDecContent
9757 AsnLen
AuthenticatedData::BEnc (BUF_TYPE b
)
9760 l
= BEncContent (b
);
9761 l
+= BEncConsLen (b
, l
);
9762 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
9766 void AuthenticatedData::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9771 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
9773 Asn1Error
<< "AuthenticatedData::BDec: ERROR - wrong tag" << endl
;
9774 longjmp (env
, -216);
9776 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9777 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9780 int AuthenticatedData::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
9782 bytesEncoded
= BEnc (b
);
9783 return !b
.WriteError();
9786 int AuthenticatedData::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
9792 if ((val
= setjmp (env
)) == 0)
9794 BDec (b
, bytesDecoded
, env
);
9795 return !b
.ReadError();
9801 void AuthenticatedData::Print (ostream
&os
) const
9804 os
<< "{ -- SEQUENCE --" << endl
;
9805 indentG
+= stdIndentG
;
9808 Indent (os
, indentG
);
9814 if (NOT_NULL (originatorInfo
))
9816 Indent (os
, indentG
);
9817 os
<< "originatorInfo ";
9818 os
<< *originatorInfo
;
9822 Indent (os
, indentG
);
9823 os
<< "originatorInfo ";
9829 Indent (os
, indentG
);
9830 os
<< "recipientInfos ";
9831 os
<< recipientInfos
;
9835 if (NOT_NULL (macAlgorithm
))
9837 Indent (os
, indentG
);
9838 os
<< "macAlgorithm ";
9839 os
<< *macAlgorithm
;
9843 Indent (os
, indentG
);
9844 os
<< "macAlgorithm ";
9849 if (NOT_NULL (digestAlgorithm
))
9851 Indent (os
, indentG
);
9852 os
<< "digestAlgorithm ";
9853 os
<< *digestAlgorithm
;
9857 Indent (os
, indentG
);
9858 os
<< "digestAlgorithm ";
9863 if (NOT_NULL (encapContentInfo
))
9865 Indent (os
, indentG
);
9866 os
<< "encapContentInfo ";
9867 os
<< *encapContentInfo
;
9871 Indent (os
, indentG
);
9872 os
<< "encapContentInfo ";
9877 if (NOT_NULL (authenctiatedAttributes
))
9879 Indent (os
, indentG
);
9880 os
<< "authenctiatedAttributes ";
9881 os
<< *authenctiatedAttributes
;
9885 Indent (os
, indentG
);
9886 os
<< "authenctiatedAttributes ";
9892 Indent (os
, indentG
);
9898 if (NOT_NULL (unauthenticatedAttributes
))
9901 Indent (os
, indentG
);
9902 os
<< "unauthenticatedAttributes ";
9903 os
<< *unauthenticatedAttributes
;
9907 Indent (os
, indentG
);
9908 os
<< "unauthenticatedAttributes ";
9914 indentG
-= stdIndentG
;
9915 Indent (os
, indentG
);
9918 } // AuthenticatedData::Print
9921 AsnType
*UserKeyingMaterials::Clone() const
9923 return new UserKeyingMaterials
;
9926 AsnType
*UserKeyingMaterials::Copy() const
9928 return new UserKeyingMaterials (*this);
9931 AsnLen
UserKeyingMaterials::BEnc (BUF_TYPE b
)
9934 l
= BEncContent (b
);
9935 l
+= BEncConsLen (b
, l
);
9936 l
+= BEncTag1 (b
, UNIV
, CONS
, SET_TAG_CODE
);
9940 void UserKeyingMaterials::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
9945 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SET_TAG_CODE
))
9947 Asn1Error
<< "UserKeyingMaterials::BDec: ERROR - wrong tag" << endl
;
9948 longjmp (env
, -217);
9950 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
9951 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
9954 UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials
&)
9956 Asn1Error
<< "use of incompletely defined UserKeyingMaterials::UserKeyingMaterials (const UserKeyingMaterials &)" << endl
;
9960 UserKeyingMaterials::~UserKeyingMaterials()
9963 for (; Curr() != NULL
; RemoveCurrFromList())
9965 } // end of destructor
9968 UserKeyingMaterials
&UserKeyingMaterials::operator = (const UserKeyingMaterials
&that
)
9969 #else // SNACC_DEEP_COPY
9970 UserKeyingMaterials
&UserKeyingMaterials::operator = (const UserKeyingMaterials
&)
9971 #endif // SNACC_DEEP_COPY
9977 for (; Curr(); RemoveCurrFromList())
9980 //that.SetCurrToFirst();
9981 //for (; that.Curr(); that.GoNext())
9982 // AppendCopy (*that.Curr());
9983 for (const AsnListElmt
*run
=that
.first
; run
; run
=run
->next
)
9984 AppendCopy (*run
->elmt
);
9988 #else // SNACC_DEEP_COPY
9989 Asn1Error
<< "use of incompletely defined UserKeyingMaterials &UserKeyingMaterials::operator = (const UserKeyingMaterials &)" << endl
;
9991 // if your compiler complains here, check the -novolat option
9992 #endif // SNACC_DEEP_COPY
9995 void UserKeyingMaterials::Print (ostream
&os
) const
9998 os
<< "{ -- SEQUENCE/SET OF -- " << endl
;
9999 indentG
+= stdIndentG
;
10000 //SetCurrToFirst();
10001 //for (; Curr() != NULL; GoNext())
10002 for (const AsnListElmt
*run
=first
; run
; run
=run
->next
)
10004 Indent (os
, indentG
);
10007 //if (Curr() != Last())
10012 indentG
-= stdIndentG
;
10013 Indent (os
, indentG
);
10015 #endif /* NDEBUG */
10021 void UserKeyingMaterials::SetCurrElmt (unsigned long int index
)
10023 unsigned long int i
;
10026 for (i
= 0; (i
< (count
-1)) && (i
< index
); i
++)
10028 } // UserKeyingMaterials::SetCurrElmt
10031 unsigned long int UserKeyingMaterials::GetCurrElmtIndex()
10033 unsigned long int i
;
10037 for (i
= 0, tmp
= first
; tmp
!= NULL
; i
++)
10046 } // UserKeyingMaterials::GetCurrElmtIndex
10049 // alloc new list elmt, put at end of list
10050 // and return the component type
10051 UserKeyingMaterial
*UserKeyingMaterials::Append()
10053 AsnListElmt
*newElmt
;
10054 newElmt
= new AsnListElmt
;
10055 newElmt
->elmt
= new UserKeyingMaterial
;
10056 newElmt
->next
= NULL
;
10059 newElmt
->prev
= NULL
;
10060 first
= last
= newElmt
;
10064 newElmt
->prev
= last
;
10065 last
->next
= newElmt
;
10069 return (curr
= newElmt
)->elmt
;
10070 } // UserKeyingMaterials::Append
10073 // alloc new list elmt, put at begining of list
10074 // and return the component type
10075 UserKeyingMaterial
*UserKeyingMaterials::Prepend()
10077 AsnListElmt
*newElmt
;
10078 newElmt
= new AsnListElmt
;
10079 newElmt
->elmt
= new UserKeyingMaterial
;
10080 newElmt
->prev
= NULL
;
10083 newElmt
->next
= NULL
;
10084 first
= last
= newElmt
;
10088 newElmt
->next
= first
;
10089 first
->prev
= newElmt
;
10093 return (curr
= newElmt
)->elmt
;
10094 } // UserKeyingMaterials::Prepend
10097 // alloc new list elmt, insert it before the
10098 // current element and return the component type
10099 // if the current element is null, the new element
10100 // is placed at the beginning of the list.
10101 UserKeyingMaterial
*UserKeyingMaterials::InsertBefore()
10103 AsnListElmt
*newElmt
;
10104 newElmt
= new AsnListElmt
;
10105 newElmt
->elmt
= new UserKeyingMaterial
;
10108 newElmt
->next
= first
;
10109 newElmt
->prev
= NULL
;
10116 newElmt
->next
= curr
;
10117 newElmt
->prev
= curr
->prev
;
10118 curr
->prev
= newElmt
;
10122 newElmt
->prev
->next
= newElmt
;
10125 return (curr
= newElmt
)->elmt
;
10126 } // UserKeyingMaterials::InsertBefore
10129 // alloc new list elmt, insert it after the
10130 // current element and return the component type
10131 // if the current element is null, the new element
10132 // is placed at the end of the list.
10133 UserKeyingMaterial
*UserKeyingMaterials::InsertAfter()
10135 AsnListElmt
*newElmt
;
10136 newElmt
= new AsnListElmt
;
10137 newElmt
->elmt
= new UserKeyingMaterial
;
10140 newElmt
->prev
= last
;
10141 newElmt
->next
= NULL
;
10148 newElmt
->prev
= curr
;
10149 newElmt
->next
= curr
->next
;
10150 curr
->next
= newElmt
;
10154 newElmt
->next
->prev
= newElmt
;
10157 return (curr
= newElmt
)->elmt
;
10158 } // UserKeyingMaterials::InsertAfter
10161 UserKeyingMaterials
&UserKeyingMaterials::AppendCopy (UserKeyingMaterial
&elmt
)
10163 AsnListElmt
*newElmt
;
10164 newElmt
= new AsnListElmt
;
10165 newElmt
->elmt
= new UserKeyingMaterial
;
10166 *newElmt
->elmt
= elmt
;
10167 newElmt
->next
= NULL
;
10170 newElmt
->prev
= NULL
;
10171 first
= last
= newElmt
;
10175 newElmt
->prev
= last
;
10176 last
->next
= newElmt
;
10184 UserKeyingMaterials
&UserKeyingMaterials::PrependCopy (UserKeyingMaterial
&elmt
)
10186 AsnListElmt
*newElmt
;
10187 newElmt
= new AsnListElmt
;
10188 newElmt
->elmt
= new UserKeyingMaterial
;
10189 *newElmt
->elmt
= elmt
;
10190 newElmt
->prev
= NULL
;
10193 newElmt
->next
= NULL
;
10194 first
= last
= newElmt
;
10198 newElmt
->next
= first
;
10199 first
->prev
= newElmt
;
10204 } // UserKeyingMaterials::PrependCopy
10207 // alloc new list elmt, insert it before the
10208 // current element, copy the given elmt into the new elmt
10209 // and return the component type.
10210 // if the current element is null, the new element
10211 // is placed at the beginning of the list.
10212 UserKeyingMaterials
&UserKeyingMaterials::InsertBeforeAndCopy (UserKeyingMaterial
&elmt
)
10214 AsnListElmt
*newElmt
;
10216 newElmt
= new AsnListElmt
;
10217 newElmt
->elmt
= new UserKeyingMaterial
;
10218 *newElmt
->elmt
= elmt
;
10222 newElmt
->next
= first
;
10223 newElmt
->prev
= NULL
;
10230 newElmt
->next
= curr
;
10231 newElmt
->prev
= curr
->prev
;
10232 curr
->prev
= newElmt
;
10236 newElmt
->prev
->next
= newElmt
;
10240 } // UserKeyingMaterials::InsertBeforeAndCopy
10243 // alloc new list elmt, insert it after the
10244 // current element, copy given elmt in to new elmt
10245 // and return the component type
10246 // if the current element is null, the new element
10247 // is placed at the end of the list.
10248 UserKeyingMaterials
&UserKeyingMaterials::InsertAfterAndCopy (UserKeyingMaterial
&elmt
)
10250 AsnListElmt
*newElmt
;
10252 newElmt
= new AsnListElmt
;
10253 newElmt
->elmt
= new UserKeyingMaterial
;
10254 *newElmt
->elmt
= elmt
;
10257 newElmt
->prev
= last
;
10258 newElmt
->next
= NULL
;
10265 newElmt
->prev
= curr
;
10266 newElmt
->next
= curr
->next
;
10267 curr
->next
= newElmt
;
10271 newElmt
->next
->prev
= newElmt
;
10275 } // UserKeyingMaterials::InsertAfterAndCopy
10278 // remove current element from list if current element is not NULL
10279 // The new current element will be the next element.
10280 // If the current element is the last element in the list
10281 // the second but last element will become the new current element.
10282 void UserKeyingMaterials::RemoveCurrFromList()
10284 AsnListElmt
*del_elmt
;
10292 first
= last
= curr
= NULL
;
10293 else if (curr
== first
)
10295 curr
= first
= first
->next
;
10296 first
->prev
= NULL
;
10298 else if (curr
== last
)
10300 curr
= last
= last
->prev
;
10305 curr
->prev
->next
= curr
->next
;
10306 curr
->next
->prev
= curr
->prev
;
10309 delete del_elmt
->elmt
;
10315 AsnLen
UserKeyingMaterials::BEncContent (BUF_TYPE b
)
10317 AsnListElmt
*currElmt
;
10319 AsnLen totalLen
= 0;
10322 CSM_Buffer
**tmpEnc
=NULL
;
10323 for (currElmt
= last
,icount
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
, icount
++);
10324 tmpEnc
= (CSM_Buffer
**) calloc(sizeof(CSM_Buffer
*), icount
);
10325 for (currElmt
= last
, iii
=0; currElmt
!= NULL
; currElmt
= currElmt
->prev
,iii
++,elmtLen
=0)
10327 ENCODE_BUF1(currElmt
->elmt
->BEncContent
, elmtLen
);
10328 elmtLen
+= BEncDefLen (outputBuf
, elmtLen
);
10330 elmtLen
+= BEncTag1 (outputBuf
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
10331 ENCODE_BUF2(tmpEnc
[iii
]);
10333 vdasnacc_sortSetOf(tmpEnc
, icount
);
10334 for (iii
=0,elmtLen
=0; iii
< icount
; elmtLen
+=tmpEnc
[iii
++]->Length())
10335 SM_WriteToAsnBuf(tmpEnc
[iii
], b
);
10336 for (iii
=0; iii
< icount
; iii
++) delete tmpEnc
[iii
];
10339 totalLen
+= elmtLen
;
10341 } // UserKeyingMaterials::BEncContent
10344 void UserKeyingMaterials::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
,
10345 AsnLen
&bytesDecoded
, ENV_TYPE env
)
10347 UserKeyingMaterial
*listElmt
;
10349 AsnLen listBytesDecoded
= 0;
10352 while ((listBytesDecoded
< elmtLen0
) || (elmtLen0
== INDEFINITE_LEN
))
10354 tag1
= BDecTag (b
, listBytesDecoded
, env
);
10355 if ((tag1
== EOC_TAG_ID
) && (elmtLen0
== INDEFINITE_LEN
))
10357 BDEC_2ND_EOC_OCTET (b
, listBytesDecoded
, env
);
10360 if ((tag1
!= MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
10361 && (tag1
!= MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
10363 Asn1Error
<< "Unexpected Tag" << endl
;
10364 longjmp (env
, -218);
10367 elmtLen1
= BDecLen (b
, listBytesDecoded
, env
);
10368 listElmt
= Append();
10369 listElmt
->BDecContent (b
, tag1
, elmtLen1
, listBytesDecoded
, env
);
10372 bytesDecoded
+= listBytesDecoded
;
10373 } // UserKeyingMaterials::BDecContent
10376 RC2CBCParameter::RC2CBCParameter()
10380 RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter
&)
10382 Asn1Error
<< "use of incompletely defined RC2CBCParameter::RC2CBCParameter (const RC2CBCParameter &)" << endl
;
10386 RC2CBCParameter::~RC2CBCParameter()
10390 AsnType
*RC2CBCParameter::Clone() const
10392 return new RC2CBCParameter
;
10395 AsnType
*RC2CBCParameter::Copy() const
10397 return new RC2CBCParameter (*this);
10400 #if SNACC_DEEP_COPY
10401 RC2CBCParameter
&RC2CBCParameter::operator = (const RC2CBCParameter
&that
)
10402 #else // SNACC_DEEP_COPY
10403 RC2CBCParameter
&RC2CBCParameter::operator = (const RC2CBCParameter
&)
10404 #endif // SNACC_DEEP_COPY
10406 #if SNACC_DEEP_COPY
10409 rc2ParameterVersion
= that
.rc2ParameterVersion
;
10414 #else // SNACC_DEEP_COPY
10415 Asn1Error
<< "use of incompletely defined RC2CBCParameter &RC2CBCParameter::operator = (const RC2CBCParameter &)" << endl
;
10417 // if your compiler complains here, check the -novolat option
10418 #endif // SNACC_DEEP_COPY
10422 RC2CBCParameter::BEncContent (BUF_TYPE b
)
10424 AsnLen totalLen
= 0;
10427 l
= iv
.BEncContent (b
);
10428 l
+= BEncDefLen (b
, l
);
10430 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
10433 l
= rc2ParameterVersion
.BEncContent (b
);
10434 BEncDefLenTo127 (b
, l
);
10437 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
10441 } // RC2CBCParameter::BEncContent
10444 void RC2CBCParameter::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10447 AsnLen seqBytesDecoded
= 0;
10449 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10451 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
10453 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10454 rc2ParameterVersion
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10455 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10459 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10460 longjmp (env
, -219);
10463 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
10464 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
10466 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10467 iv
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10471 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10472 longjmp (env
, -220);
10475 bytesDecoded
+= seqBytesDecoded
;
10476 if (elmtLen0
== INDEFINITE_LEN
)
10478 BDecEoc (b
, bytesDecoded
, env
);
10481 else if (seqBytesDecoded
!= elmtLen0
)
10483 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
10484 longjmp (env
, -221);
10488 } // RC2CBCParameter::BDecContent
10490 AsnLen
RC2CBCParameter::BEnc (BUF_TYPE b
)
10493 l
= BEncContent (b
);
10494 l
+= BEncConsLen (b
, l
);
10495 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10499 void RC2CBCParameter::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10504 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
10506 Asn1Error
<< "RC2CBCParameter::BDec: ERROR - wrong tag" << endl
;
10507 longjmp (env
, -222);
10509 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
10510 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
10513 int RC2CBCParameter::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
10515 bytesEncoded
= BEnc (b
);
10516 return !b
.WriteError();
10519 int RC2CBCParameter::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
10525 if ((val
= setjmp (env
)) == 0)
10527 BDec (b
, bytesDecoded
, env
);
10528 return !b
.ReadError();
10534 void RC2CBCParameter::Print (ostream
&os
) const
10537 os
<< "{ -- SEQUENCE --" << endl
;
10538 indentG
+= stdIndentG
;
10541 Indent (os
, indentG
);
10542 os
<< "rc2ParameterVersion ";
10543 os
<< rc2ParameterVersion
;
10548 Indent (os
, indentG
);
10554 indentG
-= stdIndentG
;
10555 Indent (os
, indentG
);
10557 #endif /* NDEBUG */
10558 } // RC2CBCParameter::Print
10561 ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate()
10563 choiceId
= certificateCid
;
10565 certificate
= new Certificate
;
10567 certificate
= NULL
; // incomplete initialization of mandatory element!
10571 ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate
&)
10573 Asn1Error
<< "use of incompletely defined ExtendedCertificateOrCertificate::ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &)" << endl
;
10577 ExtendedCertificateOrCertificate::~ExtendedCertificateOrCertificate()
10581 case certificateCid
:
10582 delete certificate
;
10584 case extendedCertificateCid
:
10585 delete extendedCertificate
;
10588 } // end of destructor
10590 AsnType
*ExtendedCertificateOrCertificate::Clone() const
10592 return new ExtendedCertificateOrCertificate
;
10595 AsnType
*ExtendedCertificateOrCertificate::Copy() const
10597 return new ExtendedCertificateOrCertificate (*this);
10600 #if SNACC_DEEP_COPY
10601 ExtendedCertificateOrCertificate
&ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate
&that
)
10602 #else // SNACC_DEEP_COPY
10603 ExtendedCertificateOrCertificate
&ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate
&)
10604 #endif // SNACC_DEEP_COPY
10606 #if SNACC_DEEP_COPY
10611 case certificateCid
:
10612 delete certificate
;
10614 case extendedCertificateCid
:
10615 delete extendedCertificate
;
10618 switch (choiceId
= that
.choiceId
)
10620 case certificateCid
:
10621 certificate
= new Certificate
;
10622 *certificate
= *that
.certificate
;
10624 case extendedCertificateCid
:
10625 extendedCertificate
= new ExtendedCertificate
;
10626 *extendedCertificate
= *that
.extendedCertificate
;
10632 #else // SNACC_DEEP_COPY
10633 Asn1Error
<< "use of incompletely defined ExtendedCertificateOrCertificate &ExtendedCertificateOrCertificate::operator = (const ExtendedCertificateOrCertificate &)" << endl
;
10635 // if your compiler complains here, check the -novolat option
10636 #endif // SNACC_DEEP_COPY
10640 ExtendedCertificateOrCertificate::BEncContent (BUF_TYPE b
)
10645 case certificateCid
:
10647 l
= certificate
->BEncContent (b
);
10648 l
+= BEncConsLen (b
, l
);
10650 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10653 case extendedCertificateCid
:
10655 l
= extendedCertificate
->BEncContent (b
);
10656 l
+= BEncConsLen (b
, l
);
10658 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
10663 } // ExtendedCertificateOrCertificate::BEncContent
10666 void ExtendedCertificateOrCertificate::BDecContent (BUF_TYPE b
, AsnTag tag
, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10670 case MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
):
10671 choiceId
= certificateCid
;
10672 certificate
= new Certificate
;
10673 certificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
10676 case MAKE_TAG_ID (CNTX
, CONS
, 0):
10677 choiceId
= extendedCertificateCid
;
10678 extendedCertificate
= new ExtendedCertificate
;
10679 extendedCertificate
->BDecContent (b
, tag
, elmtLen0
, bytesDecoded
, env
);
10683 Asn1Error
<< "ERROR - unexpected tag in CHOICE" << endl
;
10684 longjmp (env
, -223);
10687 } // ExtendedCertificateOrCertificate::BDecContent
10690 AsnLen
ExtendedCertificateOrCertificate::BEnc (BUF_TYPE b
)
10693 l
= BEncContent (b
);
10697 void ExtendedCertificateOrCertificate::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10702 /* CHOICEs are a special case - grab identifying tag */
10703 /* this allows easier handling of nested CHOICEs */
10704 tag
= BDecTag (b
, bytesDecoded
, env
);
10705 elmtLen
= BDecLen (b
, bytesDecoded
, env
);
10706 BDecContent (b
, tag
, elmtLen
, bytesDecoded
, env
);
10709 int ExtendedCertificateOrCertificate::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
10711 bytesEncoded
= BEnc (b
);
10712 return !b
.WriteError();
10715 int ExtendedCertificateOrCertificate::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
10721 if ((val
= setjmp (env
)) == 0)
10723 BDec (b
, bytesDecoded
, env
);
10724 return !b
.ReadError();
10730 void ExtendedCertificateOrCertificate::Print (ostream
&os
) const
10735 case certificateCid
:
10736 os
<< "certificate ";
10738 os
<< *certificate
;
10740 os
<< "-- void3 --\n";
10743 case extendedCertificateCid
:
10744 os
<< "extendedCertificate ";
10745 if (extendedCertificate
)
10746 os
<< *extendedCertificate
;
10748 os
<< "-- void3 --\n";
10752 #endif /* NDEBUG */
10753 } // ExtendedCertificateOrCertificate::Print
10755 DigestInfo::DigestInfo()
10758 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10760 digestAlgorithm
= NULL
; // incomplete initialization of mandatory element!
10764 DigestInfo::DigestInfo (const DigestInfo
&)
10766 Asn1Error
<< "use of incompletely defined DigestInfo::DigestInfo (const DigestInfo &)" << endl
;
10770 DigestInfo::~DigestInfo()
10772 delete digestAlgorithm
;
10775 AsnType
*DigestInfo::Clone() const
10777 return new DigestInfo
;
10780 AsnType
*DigestInfo::Copy() const
10782 return new DigestInfo (*this);
10785 #if SNACC_DEEP_COPY
10786 DigestInfo
&DigestInfo::operator = (const DigestInfo
&that
)
10787 #else // SNACC_DEEP_COPY
10788 DigestInfo
&DigestInfo::operator = (const DigestInfo
&)
10789 #endif // SNACC_DEEP_COPY
10791 #if SNACC_DEEP_COPY
10794 if (that
.digestAlgorithm
)
10796 if (!digestAlgorithm
)
10797 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10798 *digestAlgorithm
= *that
.digestAlgorithm
;
10802 delete digestAlgorithm
;
10803 digestAlgorithm
= NULL
;
10805 digest
= that
.digest
;
10809 #else // SNACC_DEEP_COPY
10810 Asn1Error
<< "use of incompletely defined DigestInfo &DigestInfo::operator = (const DigestInfo &)" << endl
;
10812 // if your compiler complains here, check the -novolat option
10813 #endif // SNACC_DEEP_COPY
10817 DigestInfo::BEncContent (BUF_TYPE b
)
10819 AsnLen totalLen
= 0;
10822 l
= digest
.BEncContent (b
);
10823 l
+= BEncDefLen (b
, l
);
10825 l
+= BEncTag1 (b
, UNIV
, PRIM
, OCTETSTRING_TAG_CODE
);
10829 l
= digestAlgorithm
->BEncContent (b
);
10830 l
+= BEncConsLen (b
, l
);
10832 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10836 } // DigestInfo::BEncContent
10839 void DigestInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10842 AsnLen seqBytesDecoded
= 0;
10844 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10846 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
10848 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10849 digestAlgorithm
= new DigestAlgorithmIdentifier
;
10850 digestAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10851 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
10855 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10856 longjmp (env
, -224);
10859 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OCTETSTRING_TAG_CODE
))
10860 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, OCTETSTRING_TAG_CODE
)))
10862 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
10863 digest
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
10867 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
10868 longjmp (env
, -225);
10871 bytesDecoded
+= seqBytesDecoded
;
10872 if (elmtLen0
== INDEFINITE_LEN
)
10874 BDecEoc (b
, bytesDecoded
, env
);
10877 else if (seqBytesDecoded
!= elmtLen0
)
10879 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
10880 longjmp (env
, -226);
10884 } // DigestInfo::BDecContent
10886 AsnLen
DigestInfo::BEnc (BUF_TYPE b
)
10889 l
= BEncContent (b
);
10890 l
+= BEncConsLen (b
, l
);
10891 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
10895 void DigestInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
10900 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
10902 Asn1Error
<< "DigestInfo::BDec: ERROR - wrong tag" << endl
;
10903 longjmp (env
, -227);
10905 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
10906 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
10909 int DigestInfo::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
10911 bytesEncoded
= BEnc (b
);
10912 return !b
.WriteError();
10915 int DigestInfo::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
10921 if ((val
= setjmp (env
)) == 0)
10923 BDec (b
, bytesDecoded
, env
);
10924 return !b
.ReadError();
10930 void DigestInfo::Print (ostream
&os
) const
10933 os
<< "{ -- SEQUENCE --" << endl
;
10934 indentG
+= stdIndentG
;
10936 if (NOT_NULL (digestAlgorithm
))
10938 Indent (os
, indentG
);
10939 os
<< "digestAlgorithm ";
10940 os
<< *digestAlgorithm
;
10944 Indent (os
, indentG
);
10945 os
<< "digestAlgorithm ";
10946 os
<< "-- void --";
10951 Indent (os
, indentG
);
10957 indentG
-= stdIndentG
;
10958 Indent (os
, indentG
);
10960 #endif /* NDEBUG */
10961 } // DigestInfo::Print