1 // NOTE: this is a machine generated file--editing not recommended
3 // pkcs7.cpp - class member functions for ASN.1 module PKCS7
5 // This file was generated by snacc on Mon Apr 22 22:34:19 2002
6 // UBC snacc written by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
11 #include "sm_vdatypes.h"
12 #include "sm_x501ud.h"
13 #include "sm_x411ub.h"
14 #include "sm_x411mtsas.h"
15 #include "sm_x501if.h"
16 #include "sm_x520sa.h"
17 #include "sm_x509cmn.h"
18 #include "sm_x509af.h"
19 #include "sm_x509ce.h"
20 #include "pkcs1oids.h"
21 #include "pkcs9oids.h"
26 #include "appleoids.h"
29 //------------------------------------------------------------------------------
33 //------------------------------------------------------------------------------
34 // class member definitions:
36 EncryptedContentInfo1::EncryptedContentInfo1()
39 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier1
;
41 contentEncryptionAlgorithm
= NULL
; // incomplete initialization of mandatory element!
43 encryptedContent
= NULL
;
46 EncryptedContentInfo1::EncryptedContentInfo1 (const EncryptedContentInfo1
&)
48 Asn1Error
<< "use of incompletely defined EncryptedContentInfo1::EncryptedContentInfo1 (const EncryptedContentInfo1 &)" << endl
;
52 EncryptedContentInfo1::~EncryptedContentInfo1()
54 delete contentEncryptionAlgorithm
;
55 delete encryptedContent
;
58 AsnType
*EncryptedContentInfo1::Clone() const
60 return new EncryptedContentInfo1
;
63 AsnType
*EncryptedContentInfo1::Copy() const
65 return new EncryptedContentInfo1 (*this);
69 EncryptedContentInfo1
&EncryptedContentInfo1::operator = (const EncryptedContentInfo1
&that
)
70 #else // SNACC_DEEP_COPY
71 EncryptedContentInfo1
&EncryptedContentInfo1::operator = (const EncryptedContentInfo1
&)
72 #endif // SNACC_DEEP_COPY
77 contentType
= that
.contentType
;
78 if (that
.contentEncryptionAlgorithm
)
80 if (!contentEncryptionAlgorithm
)
81 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier1
;
82 *contentEncryptionAlgorithm
= *that
.contentEncryptionAlgorithm
;
86 delete contentEncryptionAlgorithm
;
87 contentEncryptionAlgorithm
= NULL
;
89 if (that
.encryptedContent
)
91 if (!encryptedContent
)
92 encryptedContent
= new EncryptedContent1
;
93 *encryptedContent
= *that
.encryptedContent
;
97 delete encryptedContent
;
98 encryptedContent
= NULL
;
103 #else // SNACC_DEEP_COPY
104 Asn1Error
<< "use of incompletely defined EncryptedContentInfo1 &EncryptedContentInfo1::operator = (const EncryptedContentInfo1 &)" << endl
;
106 // if your compiler complains here, check the -novolat option
107 #endif // SNACC_DEEP_COPY
111 EncryptedContentInfo1::BEncContent (BUF_TYPE b
)
116 if (NOT_NULL (encryptedContent
))
118 l
= encryptedContent
->BEncContent (b
);
119 l
+= BEncDefLen (b
, l
);
121 l
+= BEncTag1 (b
, CNTX
, PRIM
, 0);
126 l
= contentEncryptionAlgorithm
->BEncContent (b
);
127 l
+= BEncConsLen (b
, l
);
129 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
132 l
= contentType
.BEncContent (b
);
133 l
+= BEncDefLen (b
, l
);
135 l
+= BEncTag1 (b
, UNIV
, PRIM
, OID_TAG_CODE
);
139 } // EncryptedContentInfo1::BEncContent
142 void EncryptedContentInfo1::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
145 AsnLen seqBytesDecoded
= 0;
147 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
149 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, OID_TAG_CODE
)))
151 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
152 contentType
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
153 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
157 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
158 SnaccExcep::throwMe(-100);
161 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
163 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
164 contentEncryptionAlgorithm
= new ContentEncryptionAlgorithmIdentifier1
;
165 contentEncryptionAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
166 if (seqBytesDecoded
== elmtLen0
)
168 bytesDecoded
+= seqBytesDecoded
;
173 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
175 if ((elmtLen0
== INDEFINITE_LEN
) && (tag1
== EOC_TAG_ID
))
177 BDEC_2ND_EOC_OCTET (b
, seqBytesDecoded
, env
)
178 bytesDecoded
+= seqBytesDecoded
;
185 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
186 SnaccExcep::throwMe(-101);
189 if ((tag1
== MAKE_TAG_ID (CNTX
, PRIM
, 0))
190 || (tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
192 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
193 encryptedContent
= new EncryptedContent1
;
194 encryptedContent
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
197 bytesDecoded
+= seqBytesDecoded
;
198 if (elmtLen0
== INDEFINITE_LEN
)
200 BDecEoc (b
, bytesDecoded
, env
);
203 else if (seqBytesDecoded
!= elmtLen0
)
205 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
206 SnaccExcep::throwMe(-102);
210 } // EncryptedContentInfo1::BDecContent
212 AsnLen
EncryptedContentInfo1::BEnc (BUF_TYPE b
)
216 l
+= BEncConsLen (b
, l
);
217 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
221 void EncryptedContentInfo1::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
226 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
228 Asn1Error
<< "EncryptedContentInfo1::BDec: ERROR - wrong tag" << endl
;
229 SnaccExcep::throwMe(-103);
231 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
232 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
235 void EncryptedContentInfo1::Print (ostream
&os
) const
238 os
<< "{ -- SEQUENCE --" << endl
;
239 indentG
+= stdIndentG
;
242 Indent (os
, indentG
);
243 os
<< "contentType ";
248 if (NOT_NULL (contentEncryptionAlgorithm
))
250 Indent (os
, indentG
);
251 os
<< "contentEncryptionAlgorithm ";
252 os
<< *contentEncryptionAlgorithm
;
256 Indent (os
, indentG
);
257 os
<< "contentEncryptionAlgorithm ";
262 if (NOT_NULL (encryptedContent
))
265 Indent (os
, indentG
);
266 os
<< "encryptedContent ";
267 os
<< *encryptedContent
;
271 Indent (os
, indentG
);
272 os
<< "encryptedContent ";
278 indentG
-= stdIndentG
;
279 Indent (os
, indentG
);
282 } // EncryptedContentInfo1::Print
285 EncryptedData1::EncryptedData1()
288 encryptedContentInfo
= new EncryptedContentInfo1
;
290 encryptedContentInfo
= NULL
; // incomplete initialization of mandatory element!
294 EncryptedData1::EncryptedData1 (const EncryptedData1
&)
296 Asn1Error
<< "use of incompletely defined EncryptedData1::EncryptedData1 (const EncryptedData1 &)" << endl
;
300 EncryptedData1::~EncryptedData1()
302 delete encryptedContentInfo
;
305 AsnType
*EncryptedData1::Clone() const
307 return new EncryptedData1
;
310 AsnType
*EncryptedData1::Copy() const
312 return new EncryptedData1 (*this);
316 EncryptedData1
&EncryptedData1::operator = (const EncryptedData1
&that
)
317 #else // SNACC_DEEP_COPY
318 EncryptedData1
&EncryptedData1::operator = (const EncryptedData1
&)
319 #endif // SNACC_DEEP_COPY
324 version
= that
.version
;
325 if (that
.encryptedContentInfo
)
327 if (!encryptedContentInfo
)
328 encryptedContentInfo
= new EncryptedContentInfo1
;
329 *encryptedContentInfo
= *that
.encryptedContentInfo
;
333 delete encryptedContentInfo
;
334 encryptedContentInfo
= NULL
;
339 #else // SNACC_DEEP_COPY
340 Asn1Error
<< "use of incompletely defined EncryptedData1 &EncryptedData1::operator = (const EncryptedData1 &)" << endl
;
342 // if your compiler complains here, check the -novolat option
343 #endif // SNACC_DEEP_COPY
347 EncryptedData1::BEncContent (BUF_TYPE b
)
353 l
= encryptedContentInfo
->BEncContent (b
);
354 l
+= BEncConsLen (b
, l
);
356 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
359 l
= version
.BEncContent (b
);
360 BEncDefLenTo127 (b
, l
);
363 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
367 } // EncryptedData1::BEncContent
370 void EncryptedData1::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
373 AsnLen seqBytesDecoded
= 0;
375 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
377 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
379 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
380 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
381 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
385 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
386 SnaccExcep::throwMe(-104);
389 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
391 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
392 encryptedContentInfo
= new EncryptedContentInfo1
;
393 encryptedContentInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
397 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
398 SnaccExcep::throwMe(-105);
401 bytesDecoded
+= seqBytesDecoded
;
402 if (elmtLen0
== INDEFINITE_LEN
)
404 BDecEoc (b
, bytesDecoded
, env
);
407 else if (seqBytesDecoded
!= elmtLen0
)
409 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
410 SnaccExcep::throwMe(-106);
414 } // EncryptedData1::BDecContent
416 AsnLen
EncryptedData1::BEnc (BUF_TYPE b
)
420 l
+= BEncConsLen (b
, l
);
421 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
425 void EncryptedData1::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
430 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
432 Asn1Error
<< "EncryptedData1::BDec: ERROR - wrong tag" << endl
;
433 SnaccExcep::throwMe(-107);
435 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
436 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
439 void EncryptedData1::Print (ostream
&os
) const
442 os
<< "{ -- SEQUENCE --" << endl
;
443 indentG
+= stdIndentG
;
446 Indent (os
, indentG
);
452 if (NOT_NULL (encryptedContentInfo
))
454 Indent (os
, indentG
);
455 os
<< "encryptedContentInfo ";
456 os
<< *encryptedContentInfo
;
460 Indent (os
, indentG
);
461 os
<< "encryptedContentInfo ";
467 indentG
-= stdIndentG
;
468 Indent (os
, indentG
);
471 } // EncryptedData1::Print