]>
git.saurik.com Git - apple/security.git/blob - SecurityASN1/c++/pkcs1oids.cpp
12eb16152cb1ab3db1cfdda31a92c54d86994f5c
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 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 RSAPublicKey::RSAPublicKey()
39 RSAPublicKey::RSAPublicKey (const RSAPublicKey
&)
41 Asn1Error
<< "use of incompletely defined RSAPublicKey::RSAPublicKey (const RSAPublicKey &)" << endl
;
45 RSAPublicKey::~RSAPublicKey()
49 AsnType
*RSAPublicKey::Clone() const
51 return new RSAPublicKey
;
54 AsnType
*RSAPublicKey::Copy() const
56 return new RSAPublicKey (*this);
60 RSAPublicKey
&RSAPublicKey::operator = (const RSAPublicKey
&that
)
61 #else // SNACC_DEEP_COPY
62 RSAPublicKey
&RSAPublicKey::operator = (const RSAPublicKey
&)
63 #endif // SNACC_DEEP_COPY
68 modulus
= that
.modulus
;
69 publicExponent
= that
.publicExponent
;
73 #else // SNACC_DEEP_COPY
74 Asn1Error
<< "use of incompletely defined RSAPublicKey &RSAPublicKey::operator = (const RSAPublicKey &)" << endl
;
76 // if your compiler complains here, check the -novolat option
77 #endif // SNACC_DEEP_COPY
81 RSAPublicKey::BEncContent (BUF_TYPE b
)
86 l
= publicExponent
.BEncContent (b
);
87 l
+= BEncDefLen (b
, l
);
89 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
92 l
= modulus
.BEncContent (b
);
93 l
+= BEncDefLen (b
, l
);
95 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
99 } // RSAPublicKey::BEncContent
102 void RSAPublicKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
105 AsnLen seqBytesDecoded
= 0;
107 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
109 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
110 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
112 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
113 modulus
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
114 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
118 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
122 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
123 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
125 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
126 publicExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
130 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
134 bytesDecoded
+= seqBytesDecoded
;
135 if (elmtLen0
== INDEFINITE_LEN
)
137 BDecEoc (b
, bytesDecoded
, env
);
140 else if (seqBytesDecoded
!= elmtLen0
)
142 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
147 } // RSAPublicKey::BDecContent
149 AsnLen
RSAPublicKey::BEnc (BUF_TYPE b
)
153 l
+= BEncConsLen (b
, l
);
154 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
158 void RSAPublicKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
163 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
165 Asn1Error
<< "RSAPublicKey::BDec: ERROR - wrong tag" << endl
;
168 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
169 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
172 int RSAPublicKey::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
174 bytesEncoded
= BEnc (b
);
175 return !b
.WriteError();
178 int RSAPublicKey::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
184 if ((val
= setjmp (env
)) == 0)
186 BDec (b
, bytesDecoded
, env
);
187 return !b
.ReadError();
193 void RSAPublicKey::Print (ostream
&os
) const
196 os
<< "{ -- SEQUENCE --" << endl
;
197 indentG
+= stdIndentG
;
200 Indent (os
, indentG
);
207 Indent (os
, indentG
);
208 os
<< "publicExponent ";
209 os
<< publicExponent
;
213 indentG
-= stdIndentG
;
214 Indent (os
, indentG
);
217 } // RSAPublicKey::Print
220 RSAPrivateKey::RSAPrivateKey()
224 RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey
&)
226 Asn1Error
<< "use of incompletely defined RSAPrivateKey::RSAPrivateKey (const RSAPrivateKey &)" << endl
;
230 RSAPrivateKey::~RSAPrivateKey()
234 AsnType
*RSAPrivateKey::Clone() const
236 return new RSAPrivateKey
;
239 AsnType
*RSAPrivateKey::Copy() const
241 return new RSAPrivateKey (*this);
245 RSAPrivateKey
&RSAPrivateKey::operator = (const RSAPrivateKey
&that
)
246 #else // SNACC_DEEP_COPY
247 RSAPrivateKey
&RSAPrivateKey::operator = (const RSAPrivateKey
&)
248 #endif // SNACC_DEEP_COPY
253 version
= that
.version
;
254 modulus
= that
.modulus
;
255 publicExponent
= that
.publicExponent
;
256 privateExponent
= that
.privateExponent
;
257 prime1
= that
.prime1
;
258 prime2
= that
.prime2
;
259 exponent1
= that
.exponent1
;
260 exponent2
= that
.exponent2
;
261 coefficient
= that
.coefficient
;
265 #else // SNACC_DEEP_COPY
266 Asn1Error
<< "use of incompletely defined RSAPrivateKey &RSAPrivateKey::operator = (const RSAPrivateKey &)" << endl
;
268 // if your compiler complains here, check the -novolat option
269 #endif // SNACC_DEEP_COPY
273 RSAPrivateKey::BEncContent (BUF_TYPE b
)
278 l
= coefficient
.BEncContent (b
);
279 l
+= BEncDefLen (b
, l
);
281 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
284 l
= exponent2
.BEncContent (b
);
285 l
+= BEncDefLen (b
, l
);
287 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
290 l
= exponent1
.BEncContent (b
);
291 l
+= BEncDefLen (b
, l
);
293 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
296 l
= prime2
.BEncContent (b
);
297 l
+= BEncDefLen (b
, l
);
299 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
302 l
= prime1
.BEncContent (b
);
303 l
+= BEncDefLen (b
, l
);
305 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
308 l
= privateExponent
.BEncContent (b
);
309 l
+= BEncDefLen (b
, l
);
311 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
314 l
= publicExponent
.BEncContent (b
);
315 l
+= BEncDefLen (b
, l
);
317 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
320 l
= modulus
.BEncContent (b
);
321 l
+= BEncDefLen (b
, l
);
323 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
326 l
= version
.BEncContent (b
);
327 BEncDefLenTo127 (b
, l
);
330 l
+= BEncTag1 (b
, UNIV
, PRIM
, INTEGER_TAG_CODE
);
334 } // RSAPrivateKey::BEncContent
337 void RSAPrivateKey::BDecContent (BUF_TYPE b
, AsnTag
/*tag0*/, AsnLen elmtLen0
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
340 AsnLen seqBytesDecoded
= 0;
342 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
344 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
)))
346 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
347 version
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
348 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
352 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
356 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
357 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
359 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
360 modulus
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
361 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
365 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
369 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
370 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
372 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
373 publicExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
374 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
378 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
382 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
383 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
385 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
386 privateExponent
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
387 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
391 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
395 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
396 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
398 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
399 prime1
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
400 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
404 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
408 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
409 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
411 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
412 prime2
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
413 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
417 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
421 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
422 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
424 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
425 exponent1
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
426 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
430 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
434 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
435 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
437 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
438 exponent2
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
439 tag1
= BDecTag (b
, seqBytesDecoded
, env
);
443 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
447 if ((tag1
== MAKE_TAG_ID (UNIV
, PRIM
, INTEGER_TAG_CODE
))
448 || (tag1
== MAKE_TAG_ID (UNIV
, CONS
, INTEGER_TAG_CODE
)))
450 elmtLen1
= BDecLen (b
, seqBytesDecoded
, env
);
451 coefficient
.BDecContent (b
, tag1
, elmtLen1
, seqBytesDecoded
, env
);
455 Asn1Error
<< "ERROR - SEQUENCE is missing non-optional elmt." << endl
;
459 bytesDecoded
+= seqBytesDecoded
;
460 if (elmtLen0
== INDEFINITE_LEN
)
462 BDecEoc (b
, bytesDecoded
, env
);
465 else if (seqBytesDecoded
!= elmtLen0
)
467 Asn1Error
<< "ERROR - Length discrepancy on sequence." << endl
;
472 } // RSAPrivateKey::BDecContent
474 AsnLen
RSAPrivateKey::BEnc (BUF_TYPE b
)
478 l
+= BEncConsLen (b
, l
);
479 l
+= BEncTag1 (b
, UNIV
, CONS
, SEQ_TAG_CODE
);
483 void RSAPrivateKey::BDec (BUF_TYPE b
, AsnLen
&bytesDecoded
, ENV_TYPE env
)
488 if ((tag
= BDecTag (b
, bytesDecoded
, env
)) != MAKE_TAG_ID (UNIV
, CONS
, SEQ_TAG_CODE
))
490 Asn1Error
<< "RSAPrivateKey::BDec: ERROR - wrong tag" << endl
;
493 elmtLen1
= BDecLen (b
, bytesDecoded
, env
);
494 BDecContent (b
, tag
, elmtLen1
, bytesDecoded
, env
);
497 int RSAPrivateKey::BEncPdu (BUF_TYPE b
, AsnLen
&bytesEncoded
)
499 bytesEncoded
= BEnc (b
);
500 return !b
.WriteError();
503 int RSAPrivateKey::BDecPdu (BUF_TYPE b
, AsnLen
&bytesDecoded
)
509 if ((val
= setjmp (env
)) == 0)
511 BDec (b
, bytesDecoded
, env
);
512 return !b
.ReadError();
518 void RSAPrivateKey::Print (ostream
&os
) const
521 os
<< "{ -- SEQUENCE --" << endl
;
522 indentG
+= stdIndentG
;
525 Indent (os
, indentG
);
532 Indent (os
, indentG
);
539 Indent (os
, indentG
);
540 os
<< "publicExponent ";
541 os
<< publicExponent
;
546 Indent (os
, indentG
);
547 os
<< "privateExponent ";
548 os
<< privateExponent
;
553 Indent (os
, indentG
);
560 Indent (os
, indentG
);
567 Indent (os
, indentG
);
574 Indent (os
, indentG
);
581 Indent (os
, indentG
);
582 os
<< "coefficient ";
587 indentG
-= stdIndentG
;
588 Indent (os
, indentG
);
591 } // RSAPrivateKey::Print