1 // NOTE: this is a machine generated file--editing not recommended
3 // pkcs10.cpp - class member functions for ASN.1 module PKCS5
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 CertificationRequestInfo::CertificationRequestInfo()
41 subject
= NULL
; // incomplete initialization of mandatory element!
44 subjectPublicKeyInfo
= new SubjectPublicKeyInfo
;
46 subjectPublicKeyInfo
= NULL
; // incomplete initialization of mandatory element!
50 CertificationRequestInfo::CertificationRequestInfo (const CertificationRequestInfo
&)
52 Asn1Error
<< "use of incompletely defined CertificationRequestInfo::CertificationRequestInfo (const CertificationRequestInfo &)" << endl
;
56 CertificationRequestInfo::~CertificationRequestInfo()
59 delete subjectPublicKeyInfo
;
62 AsnType
*CertificationRequestInfo::Clone() const
64 return new CertificationRequestInfo
;
67 AsnType
*CertificationRequestInfo::Copy() const
69 return new CertificationRequestInfo (*this);
73 CertificationRequestInfo
&CertificationRequestInfo::operator = (const CertificationRequestInfo
&that
)
74 #else // SNACC_DEEP_COPY
75 CertificationRequestInfo
&CertificationRequestInfo::operator = (const CertificationRequestInfo
&)
76 #endif // SNACC_DEEP_COPY
81 version
= that
.version
;
86 *subject
= *that
.subject
;
93 if (that
.subjectPublicKeyInfo
)
95 if (!subjectPublicKeyInfo
)
96 subjectPublicKeyInfo
= new SubjectPublicKeyInfo
;
97 *subjectPublicKeyInfo
= *that
.subjectPublicKeyInfo
;
101 delete subjectPublicKeyInfo
;
102 subjectPublicKeyInfo
= NULL
;
104 attributes
= that
.attributes
;
108 #else // SNACC_DEEP_COPY
109 Asn1Error
<< "use of incompletely defined CertificationRequestInfo &CertificationRequestInfo::operator = (const CertificationRequestInfo &)" << endl
;
111 // if your compiler complains here, check the -novolat option
112 #endif // SNACC_DEEP_COPY
116 CertificationRequestInfo::BEncContent (BUF_TYPE b
)
122 l
= attributes
.BEncContent (b
);
123 l
+= BEncConsLen (b
, l
);
125 l
+= BEncTag1 (b
, CNTX
, CONS
, 0);
129 l
= subjectPublicKeyInfo
->BEncContent (b
);
130 l
+= BEncConsLen (b
, l
);
132 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
135 l
= subject
->BEncContent (b
);
138 l
= version
.BEncContent (b
);
139 BEncDefLenTo127 (b
, l
);
142 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
146 } // CertificationRequestInfo::BEncContent
149 void CertificationRequestInfo::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
152 AsnLen seqBytesDecoded
= 0;
154 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
156 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
158 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
159 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
160 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
164 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
165 SnaccExcep::throwMe(-100);
168 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
170 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
172 subject
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
173 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
177 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
178 SnaccExcep::throwMe(-101);
181 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
183 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
184 subjectPublicKeyInfo
= new SubjectPublicKeyInfo
;
185 subjectPublicKeyInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
186 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
190 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
191 SnaccExcep::throwMe(-102);
194 if ((tag1
== MAKE_TAG_ID (CNTX
, CONS
, 0)))
196 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
197 attributes
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
201 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
202 SnaccExcep::throwMe(-103);
205 bytesDecoded
+= seqBytesDecoded
;
206 if (elmtLen0
== INDEFINITE_LEN
)
208 BDecEoc (b
, bytesDecoded
, env
);
211 else if (seqBytesDecoded
!= elmtLen0
)
213 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
214 SnaccExcep::throwMe(-104);
218 } // CertificationRequestInfo::BDecContent
220 AsnLen
CertificationRequestInfo::BEnc (BUF_TYPE b
)
224 l
+= BEncConsLen (b
, l
);
225 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
229 void CertificationRequestInfo::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
234 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
236 Asn1Error
<< "CertificationRequestInfo::BDec: ERROR - wrong tag" << endl
;
237 SnaccExcep::throwMe(-105);
239 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
240 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
243 void CertificationRequestInfo::Print (ostream
&os
) const
246 os
<< "{ -- SEQUENCE --" << endl
;
247 indentG
+= stdIndentG
;
250 Indent (os
, indentG
);
256 if (NOT_NULL (subject
))
258 Indent (os
, indentG
);
264 Indent (os
, indentG
);
270 if (NOT_NULL (subjectPublicKeyInfo
))
272 Indent (os
, indentG
);
273 os
<< "subjectPublicKeyInfo ";
274 os
<< *subjectPublicKeyInfo
;
278 Indent (os
, indentG
);
279 os
<< "subjectPublicKeyInfo ";
285 Indent (os
, indentG
);
291 indentG
-= stdIndentG
;
292 Indent (os
, indentG
);
295 } // CertificationRequestInfo::Print
298 CertificationRequest::CertificationRequest()
301 certificationRequestInfo
= new CertificationRequestInfo
;
303 certificationRequestInfo
= NULL
; // incomplete initialization of mandatory element!
306 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
308 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
312 CertificationRequest::CertificationRequest (const CertificationRequest
&)
314 Asn1Error
<< "use of incompletely defined CertificationRequest::CertificationRequest (const CertificationRequest &)" << endl
;
318 CertificationRequest::~CertificationRequest()
320 delete certificationRequestInfo
;
321 delete signatureAlgorithm
;
324 AsnType
*CertificationRequest::Clone() const
326 return new CertificationRequest
;
329 AsnType
*CertificationRequest::Copy() const
331 return new CertificationRequest (*this);
335 CertificationRequest
&CertificationRequest::operator = (const CertificationRequest
&that
)
336 #else // SNACC_DEEP_COPY
337 CertificationRequest
&CertificationRequest::operator = (const CertificationRequest
&)
338 #endif // SNACC_DEEP_COPY
343 if (that
.certificationRequestInfo
)
345 if (!certificationRequestInfo
)
346 certificationRequestInfo
= new CertificationRequestInfo
;
347 *certificationRequestInfo
= *that
.certificationRequestInfo
;
351 delete certificationRequestInfo
;
352 certificationRequestInfo
= NULL
;
354 if (that
.signatureAlgorithm
)
356 if (!signatureAlgorithm
)
357 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
358 *signatureAlgorithm
= *that
.signatureAlgorithm
;
362 delete signatureAlgorithm
;
363 signatureAlgorithm
= NULL
;
365 signature
= that
.signature
;
369 #else // SNACC_DEEP_COPY
370 Asn1Error
<< "use of incompletely defined CertificationRequest &CertificationRequest::operator = (const CertificationRequest &)" << endl
;
372 // if your compiler complains here, check the -novolat option
373 #endif // SNACC_DEEP_COPY
377 CertificationRequest::BEncContent (BUF_TYPE b
)
382 l
= signature
.BEncContent (b
);
383 l
+= BEncDefLen (b
, l
);
385 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
389 l
= signatureAlgorithm
->BEncContent (b
);
390 l
+= BEncConsLen (b
, l
);
392 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
396 l
= certificationRequestInfo
->BEncContent (b
);
397 l
+= BEncConsLen (b
, l
);
399 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
403 } // CertificationRequest::BEncContent
406 void CertificationRequest::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
409 AsnLen seqBytesDecoded
= 0;
411 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
413 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
415 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
416 certificationRequestInfo
= new CertificationRequestInfo
;
417 certificationRequestInfo
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
418 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
422 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
423 SnaccExcep::throwMe(-106);
426 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
428 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
429 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
430 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
431 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
435 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
436 SnaccExcep::throwMe(-107);
439 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
440 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
442 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
443 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
447 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
448 SnaccExcep::throwMe(-108);
451 bytesDecoded
+= seqBytesDecoded
;
452 if (elmtLen0
== INDEFINITE_LEN
)
454 BDecEoc (b
, bytesDecoded
, env
);
457 else if (seqBytesDecoded
!= elmtLen0
)
459 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
460 SnaccExcep::throwMe(-109);
464 } // CertificationRequest::BDecContent
466 AsnLen
CertificationRequest::BEnc (BUF_TYPE b
)
470 l
+= BEncConsLen (b
, l
);
471 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
475 void CertificationRequest::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
480 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
482 Asn1Error
<< "CertificationRequest::BDec: ERROR - wrong tag" << endl
;
483 SnaccExcep::throwMe(-110);
485 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
486 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
489 void CertificationRequest::Print (ostream
&os
) const
492 os
<< "{ -- SEQUENCE --" << endl
;
493 indentG
+= stdIndentG
;
495 if (NOT_NULL (certificationRequestInfo
))
497 Indent (os
, indentG
);
498 os
<< "certificationRequestInfo ";
499 os
<< *certificationRequestInfo
;
503 Indent (os
, indentG
);
504 os
<< "certificationRequestInfo ";
509 if (NOT_NULL (signatureAlgorithm
))
511 Indent (os
, indentG
);
512 os
<< "signatureAlgorithm ";
513 os
<< *signatureAlgorithm
;
517 Indent (os
, indentG
);
518 os
<< "signatureAlgorithm ";
524 Indent (os
, indentG
);
530 indentG
-= stdIndentG
;
531 Indent (os
, indentG
);
534 } // CertificationRequest::Print
537 CertificationRequestSigned::CertificationRequestSigned()
540 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
542 signatureAlgorithm
= NULL
; // incomplete initialization of mandatory element!
546 CertificationRequestSigned::CertificationRequestSigned (const CertificationRequestSigned
&)
548 Asn1Error
<< "use of incompletely defined CertificationRequestSigned::CertificationRequestSigned (const CertificationRequestSigned &)" << endl
;
552 CertificationRequestSigned::~CertificationRequestSigned()
554 delete signatureAlgorithm
;
557 AsnType
*CertificationRequestSigned::Clone() const
559 return new CertificationRequestSigned
;
562 AsnType
*CertificationRequestSigned::Copy() const
564 return new CertificationRequestSigned (*this);
568 CertificationRequestSigned
&CertificationRequestSigned::operator = (const CertificationRequestSigned
&that
)
569 #else // SNACC_DEEP_COPY
570 CertificationRequestSigned
&CertificationRequestSigned::operator = (const CertificationRequestSigned
&)
571 #endif // SNACC_DEEP_COPY
576 certificationRequestInfo
= that
.certificationRequestInfo
;
577 if (that
.signatureAlgorithm
)
579 if (!signatureAlgorithm
)
580 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
581 *signatureAlgorithm
= *that
.signatureAlgorithm
;
585 delete signatureAlgorithm
;
586 signatureAlgorithm
= NULL
;
588 signature
= that
.signature
;
592 #else // SNACC_DEEP_COPY
593 Asn1Error
<< "use of incompletely defined CertificationRequestSigned &CertificationRequestSigned::operator = (const CertificationRequestSigned &)" << endl
;
595 // if your compiler complains here, check the -novolat option
596 #endif // SNACC_DEEP_COPY
600 CertificationRequestSigned::BEncContent (BUF_TYPE b
)
605 l
= signature
.BEncContent (b
);
606 l
+= BEncDefLen (b
, l
);
608 l
+= BEncTag1 (b
, UNIV
, PRIM
, BITSTRING_TAG_CODE
);
612 l
= signatureAlgorithm
->BEncContent (b
);
613 l
+= BEncConsLen (b
, l
);
615 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
618 ENC_LOAD_ANYBUF(&certificationRequestInfo
, b
, l
);
622 } // CertificationRequestSigned::BEncContent
625 void CertificationRequestSigned::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
628 AsnLen seqBytesDecoded
= 0;
631 DEC_LOAD_ANYBUF(&certificationRequestInfo
, b
, seqBytesDecoded
, env
);
632 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
635 if ((tag1
== MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
)))
637 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
638 signatureAlgorithm
= new SignatureAlgorithmIdentifier
;
639 signatureAlgorithm
->BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
640 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
644 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
645 SnaccExcep::throwMe(-111);
648 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, BITSTRING_TAG_CODE
))
649 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, BITSTRING_TAG_CODE
)))
651 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
652 signature
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
656 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
657 SnaccExcep::throwMe(-112);
660 bytesDecoded
+= seqBytesDecoded
;
661 if (elmtLen0
== INDEFINITE_LEN
)
663 BDecEoc (b
, bytesDecoded
, env
);
666 else if (seqBytesDecoded
!= elmtLen0
)
668 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
669 SnaccExcep::throwMe(-113);
673 } // CertificationRequestSigned::BDecContent
675 AsnLen
CertificationRequestSigned::BEnc (BUF_TYPE b
)
679 l
+= BEncConsLen (b
, l
);
680 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
684 void CertificationRequestSigned::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
689 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
691 Asn1Error
<< "CertificationRequestSigned::BDec: ERROR - wrong tag" << endl
;
692 SnaccExcep::throwMe(-114);
694 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
695 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
698 void CertificationRequestSigned::Print (ostream
&os
) const
701 os
<< "{ -- SEQUENCE --" << endl
;
702 indentG
+= stdIndentG
;
705 Indent (os
, indentG
);
706 os
<< "certificationRequestInfo ";
707 os
<< certificationRequestInfo
;
711 if (NOT_NULL (signatureAlgorithm
))
713 Indent (os
, indentG
);
714 os
<< "signatureAlgorithm ";
715 os
<< *signatureAlgorithm
;
719 Indent (os
, indentG
);
720 os
<< "signatureAlgorithm ";
726 Indent (os
, indentG
);
732 indentG
-= stdIndentG
;
733 Indent (os
, indentG
);
736 } // CertificationRequestSigned::Print