]>
git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/pkcs1oids.cpp
23d1ba682eb94a71881ffb7845a7f3ef3d903788
1 // NOTE: this is a machine generated file--editing not recommended
3 // pkcs1oids.cpp - class member functions for ASN.1 module PKCS1-OIDS
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 RSAPublicKey::RSAPublicKey()
40 RSAPublicKey::RSAPublicKey (const RSAPublicKey
&)
42 Asn1Error
<< "use of incompletely defined RSAPublicKey::RSAPublicKey (const RSAPublicKey &)" << endl
;
46 RSAPublicKey::~RSAPublicKey()
50 AsnType
*RSAPublicKey::Clone() const
52 return new RSAPublicKey
;
55 AsnType
*RSAPublicKey::Copy() const
57 return new RSAPublicKey (*this);
61 RSAPublicKey
&RSAPublicKey::operator = (const RSAPublicKey
&that
)
62 #else // SNACC_DEEP_COPY
63 RSAPublicKey
&RSAPublicKey::operator = (const RSAPublicKey
&)
64 #endif // SNACC_DEEP_COPY
69 modulus
= that
.modulus
;
70 publicExponent
= that
.publicExponent
;
74 #else // SNACC_DEEP_COPY
75 Asn1Error
<< "use of incompletely defined RSAPublicKey &RSAPublicKey::operator = (const RSAPublicKey &)" << endl
;
77 // if your compiler complains here, check the -novolat option
78 #endif // SNACC_DEEP_COPY
82 RSAPublicKey::BEncContent (BUF_TYPE b
)
87 l
= publicExponent
.BEncContent (b
);
88 l
+= BEncDefLen (b
, l
);
90 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
93 l
= modulus
.BEncContent (b
);
94 l
+= BEncDefLen (b
, l
);
96 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
100 } // RSAPublicKey::BEncContent
103 void RSAPublicKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
106 AsnLen seqBytesDecoded
= 0;
108 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
110 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
111 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
113 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
114 modulus
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
115 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
119 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
120 SnaccExcep::throwMe(-100);
123 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
124 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
126 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
127 publicExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
131 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
132 SnaccExcep::throwMe(-101);
135 bytesDecoded
+= seqBytesDecoded
;
136 if (elmtLen0
== INDEFINITE_LEN
)
138 BDecEoc (b
, bytesDecoded
, env
);
141 else if (seqBytesDecoded
!= elmtLen0
)
143 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
144 SnaccExcep::throwMe(-102);
148 } // RSAPublicKey::BDecContent
150 AsnLen
RSAPublicKey::BEnc (BUF_TYPE b
)
154 l
+= BEncConsLen (b
, l
);
155 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
159 void RSAPublicKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
164 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
166 Asn1Error
<< "RSAPublicKey::BDec: ERROR - wrong tag" << endl
;
167 SnaccExcep::throwMe(-103);
169 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
170 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
173 void RSAPublicKey::Print (ostream
&os
) const
176 os
<< "{ -- SEQUENCE --" << endl
;
177 indentG
+= stdIndentG
;
180 Indent (os
, indentG
);
187 Indent (os
, indentG
);
188 os
<< "publicExponent ";
189 os
<< publicExponent
;
193 indentG
-= stdIndentG
;
194 Indent (os
, indentG
);
197 } // RSAPublicKey::Print
200 RSAPrivateKey::RSAPrivateKey()
204 RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey
&)
206 Asn1Error
<< "use of incompletely defined RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey &)" << endl
;
210 RSAPrivateKey::~RSAPrivateKey()
214 AsnType
*RSAPrivateKey::Clone() const
216 return new RSAPrivateKey
;
219 AsnType
*RSAPrivateKey::Copy() const
221 return new RSAPrivateKey (*this);
225 RSAPrivateKey
&RSAPrivateKey::operator = (const RSAPrivateKey
&that
)
226 #else // SNACC_DEEP_COPY
227 RSAPrivateKey
&RSAPrivateKey::operator = (const RSAPrivateKey
&)
228 #endif // SNACC_DEEP_COPY
233 version
= that
.version
;
234 modulus
= that
.modulus
;
235 publicExponent
= that
.publicExponent
;
236 privateExponent
= that
.privateExponent
;
237 prime1
= that
.prime1
;
238 prime2
= that
.prime2
;
239 exponent1
= that
.exponent1
;
240 exponent2
= that
.exponent2
;
241 coefficient
= that
.coefficient
;
245 #else // SNACC_DEEP_COPY
246 Asn1Error
<< "use of incompletely defined RSAPrivateKey &RSAPrivateKey::operator = (const RSAPrivateKey &)" << endl
;
248 // if your compiler complains here, check the -novolat option
249 #endif // SNACC_DEEP_COPY
253 RSAPrivateKey::BEncContent (BUF_TYPE b
)
258 l
= coefficient
.BEncContent (b
);
259 l
+= BEncDefLen (b
, l
);
261 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
264 l
= exponent2
.BEncContent (b
);
265 l
+= BEncDefLen (b
, l
);
267 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
270 l
= exponent1
.BEncContent (b
);
271 l
+= BEncDefLen (b
, l
);
273 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
276 l
= prime2
.BEncContent (b
);
277 l
+= BEncDefLen (b
, l
);
279 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
282 l
= prime1
.BEncContent (b
);
283 l
+= BEncDefLen (b
, l
);
285 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
288 l
= privateExponent
.BEncContent (b
);
289 l
+= BEncDefLen (b
, l
);
291 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
294 l
= publicExponent
.BEncContent (b
);
295 l
+= BEncDefLen (b
, l
);
297 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
300 l
= modulus
.BEncContent (b
);
301 l
+= BEncDefLen (b
, l
);
303 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
306 l
= version
.BEncContent (b
);
307 BEncDefLenTo127 (b
, l
);
310 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
314 } // RSAPrivateKey::BEncContent
317 void RSAPrivateKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
320 AsnLen seqBytesDecoded
= 0;
322 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
324 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
326 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
327 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
328 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
332 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
333 SnaccExcep::throwMe(-104);
336 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
337 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
339 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
340 modulus
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
341 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
345 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
346 SnaccExcep::throwMe(-105);
349 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
350 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
352 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
353 publicExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
354 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
358 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
359 SnaccExcep::throwMe(-106);
362 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
363 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
365 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
366 privateExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
367 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
371 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
372 SnaccExcep::throwMe(-107);
375 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
376 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
378 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
379 prime1
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
380 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
384 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
385 SnaccExcep::throwMe(-108);
388 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
389 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
391 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
392 prime2
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
393 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
397 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
398 SnaccExcep::throwMe(-109);
401 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
402 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
404 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
405 exponent1
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
406 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
410 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
411 SnaccExcep::throwMe(-110);
414 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
415 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
417 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
418 exponent2
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
419 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
423 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
424 SnaccExcep::throwMe(-111);
427 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
428 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
430 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
431 coefficient
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
435 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
436 SnaccExcep::throwMe(-112);
439 bytesDecoded
+= seqBytesDecoded
;
440 if (elmtLen0
== INDEFINITE_LEN
)
442 BDecEoc (b
, bytesDecoded
, env
);
445 else if (seqBytesDecoded
!= elmtLen0
)
447 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
448 SnaccExcep::throwMe(-113);
452 } // RSAPrivateKey::BDecContent
454 AsnLen
RSAPrivateKey::BEnc (BUF_TYPE b
)
458 l
+= BEncConsLen (b
, l
);
459 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
463 void RSAPrivateKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
468 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
470 Asn1Error
<< "RSAPrivateKey::BDec: ERROR - wrong tag" << endl
;
471 SnaccExcep::throwMe(-114);
473 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
474 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
477 void RSAPrivateKey::Print (ostream
&os
) const
480 os
<< "{ -- SEQUENCE --" << endl
;
481 indentG
+= stdIndentG
;
484 Indent (os
, indentG
);
491 Indent (os
, indentG
);
498 Indent (os
, indentG
);
499 os
<< "publicExponent ";
500 os
<< publicExponent
;
505 Indent (os
, indentG
);
506 os
<< "privateExponent ";
507 os
<< privateExponent
;
512 Indent (os
, indentG
);
519 Indent (os
, indentG
);
526 Indent (os
, indentG
);
533 Indent (os
, indentG
);
540 Indent (os
, indentG
);
541 os
<< "coefficient ";
546 indentG
-= stdIndentG
;
547 Indent (os
, indentG
);
550 } // RSAPrivateKey::Print