]> git.saurik.com Git - apple/security.git/blob - SecurityASN1/inc/sm_cms.h
Security-28.tar.gz
[apple/security.git] / SecurityASN1 / inc / sm_cms.h
1 // NOTE: this is a machine generated file--editing not recommended
2 //
3 // sm_cms.h - class definitions for ASN.1 module CryptographicMessageSyntax
4 //
5 // This file was generated by snacc on Wed Jun 27 16:40:55 2001
6 // UBC snacc by Mike Sample
7 // A couple of enhancements made by IBM European Networking Center
8
9 #ifndef _sm_cms_h_
10 #define _sm_cms_h_
11
12
13 //------------------------------------------------------------------------------
14 // class declarations:
15
16 class CMSVersion;
17 class OriginatorPublicKey;
18 class CertificateRevocationLists;
19 class IssuerAndSerialNumber;
20 class OtherKeyAttribute;
21 class DigestAlgorithmIdentifiers;
22 class EncapsulatedContentInfo;
23 class SignerIdentifier;
24 class EncryptedContentInfo;
25 class RecipientIdentifier;
26 class OriginatorIdentifierOrKey;
27 class RecipientKeyIdentifier;
28 class KEKIdentifier;
29 class ExtendedCertificateInfo;
30 class SignerInfo;
31 class KeyTransRecipientInfo;
32 class KeyAgreeRecipientIdentifier;
33 class KEKRecipientInfo;
34 class ExtendedCertificate;
35 class SignerInfos;
36 class RecipientEncryptedKey;
37 class CertificateChoices;
38 class CertificateSet;
39 class OriginatorInfo;
40 class RecipientEncryptedKeys;
41 class KeyAgreeRecipientInfo;
42 class RecipientInfo;
43 class RecipientInfos;
44 class ContentInfo;
45 class SignedData;
46 class EnvelopedData;
47 class DigestedData;
48 class EncryptedData;
49 class AuthenticatedData;
50 class UserKeyingMaterials;
51 class RC2CBCParameter;
52 class ExtendedCertificateOrCertificate;
53 class DigestInfo;
54
55 //------------------------------------------------------------------------------
56 // class definitions:
57
58 typedef enum CryptographicMessageSyntaxAnyId
59 {
60
61 } CryptographicMessageSyntaxAnyId;
62
63
64 /* OBJECT IDENTIFIER */
65 typedef AsnOid ContentType;
66
67 /* OCTET STRING */
68 typedef AsnOcts SignatureValue;
69
70 /* OCTET STRING */
71 typedef AsnOcts EncryptedContent;
72
73 /* OCTET STRING */
74 typedef AsnOcts EncryptedKey;
75
76 /* OCTET STRING */
77 typedef AsnOcts Digest;
78
79 /* OCTET STRING */
80 typedef AsnOcts MessageAuthenticationCode;
81
82 /* INTEGER { v0 (0), v1 (1), v2 (2), v3 (3), v4 (4) } */
83 class CMSVersion: public AsnInt
84 {
85 public:
86 CMSVersion(): AsnInt() {}
87 CMSVersion (int i): AsnInt (i) {}
88 enum
89 {
90 v0 = 0,
91 v1 = 1,
92 v2 = 2,
93 v3 = 3,
94 v4 = 4
95 };
96 };
97
98
99 /* OCTET STRING */
100 typedef AsnOcts UserKeyingMaterial;
101
102 /* OCTET STRING */
103 typedef AsnOcts MessageDigest;
104
105 /* INTEGER */
106 typedef AsnInt RC2ParameterVersion;
107
108 /* OCTET STRING */
109 typedef AsnOcts IV;
110
111 /* BIT STRING */
112 typedef AsnBits Signature;
113
114 class OriginatorPublicKey: public AsnType
115 {
116 public:
117 AlgorithmIdentifier *algorithm;
118 AsnBits publicKey;
119
120 OriginatorPublicKey();
121 OriginatorPublicKey (const OriginatorPublicKey &);
122 virtual ~OriginatorPublicKey();
123 virtual AsnType *Clone() const;
124
125 virtual AsnType *Copy() const;
126
127 OriginatorPublicKey &operator = (const OriginatorPublicKey &);
128 AsnLen BEncContent (BUF_TYPE b);
129 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
130
131 AsnLen BEnc (BUF_TYPE b);
132 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
133 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
134 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
135
136 void Print (ostream &os) const;
137 };
138
139
140 /* AlgorithmIdentifier */
141 typedef AlgorithmIdentifier DigestAlgorithmIdentifier;
142
143 /* AlgorithmIdentifier */
144 typedef AlgorithmIdentifier SignatureAlgorithmIdentifier;
145
146 /* AlgorithmIdentifier */
147 typedef AlgorithmIdentifier KeyEncryptionAlgorithmIdentifier;
148
149 /* AlgorithmIdentifier */
150 typedef AlgorithmIdentifier ContentEncryptionAlgorithmIdentifier;
151
152 /* AlgorithmIdentifier */
153 typedef AlgorithmIdentifier MessageAuthenticationCodeAlgorithm;
154
155 class CertificateRevocationLists: public AsnType
156 {
157 protected:
158 unsigned long int count;
159 struct AsnListElmt
160 {
161 AsnListElmt *next;
162 AsnListElmt *prev;
163 CertificateList *elmt;
164 } *first, *curr, *last;
165
166 public:
167 CertificateRevocationLists() { count = 0; first = curr = last = NULL; }
168 CertificateRevocationLists (const CertificateRevocationLists &);
169 virtual ~CertificateRevocationLists();
170 virtual AsnType *Clone() const;
171
172 virtual AsnType *Copy() const;
173
174 CertificateRevocationLists &operator = (const CertificateRevocationLists &);
175 void SetCurrElmt (unsigned long int index);
176 unsigned long int GetCurrElmtIndex();
177 void SetCurrToFirst() { curr = first; }
178 void SetCurrToLast() { curr = last; }
179 // reading member fcns
180 int Count() const { return count; }
181 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
182 CertificateList *First() const { return count > 0 ? first->elmt : NULL; }
183 CertificateList *Last() const { return count > 0 ? last->elmt : NULL; }
184 CertificateList *Curr() const { return curr ? curr->elmt : NULL; }
185 CertificateList *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
186 CertificateList *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
187
188 // routines that move the curr elmt
189 CertificateList *GoNext() { if (curr) curr = curr->next; return Curr(); }
190 CertificateList *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
191
192 // write & alloc fcns - returns new elmt
193 CertificateList *Append(); // add elmt to end of list
194 CertificateList *Prepend(); // add elmt to beginning of list
195 CertificateList *InsertBefore(); //insert elmt before current elmt
196 CertificateList *InsertAfter(); //insert elmt after current elmt
197
198 // write & alloc & copy - returns list after copying elmt
199 CertificateRevocationLists &AppendCopy (CertificateList &elmt); // add elmt to end of list
200 CertificateRevocationLists &PrependCopy (CertificateList &elmt); // add elmt to beginning of list
201 CertificateRevocationLists &InsertBeforeAndCopy (CertificateList &elmt); //insert elmt before current elmt
202 CertificateRevocationLists &InsertAfterAndCopy (CertificateList &elmt); //insert elmt after current elmt
203
204 // removing the current elmt from the list
205 void RemoveCurrFromList();
206
207 // encode and decode routines
208 AsnLen BEnc (BUF_TYPE b);
209 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
210 AsnLen BEncContent (BUF_TYPE b);
211 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
212
213 PDU_MEMBER_MACROS
214 void Print (ostream &os) const;
215 };
216
217
218 class IssuerAndSerialNumber: public AsnType
219 {
220 public:
221 Name *issuer;
222 CertificateSerialNumber serialNumber;
223
224 IssuerAndSerialNumber();
225 IssuerAndSerialNumber (const IssuerAndSerialNumber &);
226 virtual ~IssuerAndSerialNumber();
227 virtual AsnType *Clone() const;
228
229 virtual AsnType *Copy() const;
230
231 IssuerAndSerialNumber &operator = (const IssuerAndSerialNumber &);
232 AsnLen BEncContent (BUF_TYPE b);
233 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
234
235 AsnLen BEnc (BUF_TYPE b);
236 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
237 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
238 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
239
240 void Print (ostream &os) const;
241 };
242
243
244 class OtherKeyAttribute: public AsnType
245 {
246 public:
247 AsnOid keyAttrId;
248 AsnAny *keyAttr;
249
250 OtherKeyAttribute();
251 OtherKeyAttribute (const OtherKeyAttribute &);
252 virtual ~OtherKeyAttribute();
253 virtual AsnType *Clone() const;
254
255 virtual AsnType *Copy() const;
256
257 OtherKeyAttribute &operator = (const OtherKeyAttribute &);
258 AsnLen BEncContent (BUF_TYPE b);
259 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
260
261 AsnLen BEnc (BUF_TYPE b);
262 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
263 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
264 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
265
266 void Print (ostream &os) const;
267 };
268
269
270 class DigestAlgorithmIdentifiers: public AsnType
271 {
272 protected:
273 unsigned long int count;
274 struct AsnListElmt
275 {
276 AsnListElmt *next;
277 AsnListElmt *prev;
278 DigestAlgorithmIdentifier *elmt;
279 } *first, *curr, *last;
280
281 public:
282 DigestAlgorithmIdentifiers() { count = 0; first = curr = last = NULL; }
283 DigestAlgorithmIdentifiers (const DigestAlgorithmIdentifiers &);
284 virtual ~DigestAlgorithmIdentifiers();
285 virtual AsnType *Clone() const;
286
287 virtual AsnType *Copy() const;
288
289 DigestAlgorithmIdentifiers &operator = (const DigestAlgorithmIdentifiers &);
290 void SetCurrElmt (unsigned long int index);
291 unsigned long int GetCurrElmtIndex();
292 void SetCurrToFirst() { curr = first; }
293 void SetCurrToLast() { curr = last; }
294 // reading member fcns
295 int Count() const { return count; }
296 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
297 DigestAlgorithmIdentifier *First() const { return count > 0 ? first->elmt : NULL; }
298 DigestAlgorithmIdentifier *Last() const { return count > 0 ? last->elmt : NULL; }
299 DigestAlgorithmIdentifier *Curr() const { return curr ? curr->elmt : NULL; }
300 DigestAlgorithmIdentifier *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
301 DigestAlgorithmIdentifier *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
302
303 // routines that move the curr elmt
304 DigestAlgorithmIdentifier *GoNext() { if (curr) curr = curr->next; return Curr(); }
305 DigestAlgorithmIdentifier *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
306
307 // write & alloc fcns - returns new elmt
308 DigestAlgorithmIdentifier *Append(); // add elmt to end of list
309 DigestAlgorithmIdentifier *Prepend(); // add elmt to beginning of list
310 DigestAlgorithmIdentifier *InsertBefore(); //insert elmt before current elmt
311 DigestAlgorithmIdentifier *InsertAfter(); //insert elmt after current elmt
312
313 // write & alloc & copy - returns list after copying elmt
314 DigestAlgorithmIdentifiers &AppendCopy (DigestAlgorithmIdentifier &elmt); // add elmt to end of list
315 DigestAlgorithmIdentifiers &PrependCopy (DigestAlgorithmIdentifier &elmt); // add elmt to beginning of list
316 DigestAlgorithmIdentifiers &InsertBeforeAndCopy (DigestAlgorithmIdentifier &elmt); //insert elmt before current elmt
317 DigestAlgorithmIdentifiers &InsertAfterAndCopy (DigestAlgorithmIdentifier &elmt); //insert elmt after current elmt
318
319 // removing the current elmt from the list
320 void RemoveCurrFromList();
321
322 // encode and decode routines
323 AsnLen BEnc (BUF_TYPE b);
324 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
325 AsnLen BEncContent (BUF_TYPE b);
326 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
327
328 PDU_MEMBER_MACROS
329 void Print (ostream &os) const;
330 };
331
332
333 class EncapsulatedContentInfo: public AsnType
334 {
335 public:
336 ContentType eContentType;
337 AsnOcts *eContent;
338
339 EncapsulatedContentInfo();
340 EncapsulatedContentInfo (const EncapsulatedContentInfo &);
341 virtual ~EncapsulatedContentInfo();
342 virtual AsnType *Clone() const;
343
344 virtual AsnType *Copy() const;
345
346 EncapsulatedContentInfo &operator = (const EncapsulatedContentInfo &);
347 AsnLen BEncContent (BUF_TYPE b);
348 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
349
350 AsnLen BEnc (BUF_TYPE b);
351 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
352 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
353 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
354
355 void Print (ostream &os) const;
356 };
357
358
359 class SignerIdentifier: public AsnType
360 {
361 public:
362 enum ChoiceIdEnum
363 {
364 issuerAndSerialNumberCid = 0,
365 subjectKeyIdentifierCid = 1
366 };
367
368 enum ChoiceIdEnum choiceId;
369 union
370 {
371 IssuerAndSerialNumber *issuerAndSerialNumber;
372 KeyIdentifier *subjectKeyIdentifier;
373 };
374
375
376 SignerIdentifier();
377 SignerIdentifier (const SignerIdentifier &);
378 virtual ~SignerIdentifier();
379
380 virtual AsnType *Clone() const;
381
382 virtual AsnType *Copy() const;
383
384 SignerIdentifier &operator = (const SignerIdentifier &);
385 AsnLen BEncContent (BUF_TYPE b);
386 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
387 AsnLen BEnc (BUF_TYPE b);
388 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
389 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
390 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
391
392 void Print (ostream &os) const;
393 };
394
395
396 class EncryptedContentInfo: public AsnType
397 {
398 public:
399 ContentType contentType;
400 ContentEncryptionAlgorithmIdentifier *contentEncryptionAlgorithm;
401 EncryptedContent *encryptedContent;
402
403 EncryptedContentInfo();
404 EncryptedContentInfo (const EncryptedContentInfo &);
405 virtual ~EncryptedContentInfo();
406 virtual AsnType *Clone() const;
407
408 virtual AsnType *Copy() const;
409
410 EncryptedContentInfo &operator = (const EncryptedContentInfo &);
411 AsnLen BEncContent (BUF_TYPE b);
412 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
413
414 AsnLen BEnc (BUF_TYPE b);
415 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
416 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
417 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
418
419 void Print (ostream &os) const;
420 };
421
422
423 class RecipientIdentifier: public AsnType
424 {
425 public:
426 enum ChoiceIdEnum
427 {
428 issuerAndSerialNumberCid = 0,
429 subjectKeyIdentifierCid = 1
430 };
431
432 enum ChoiceIdEnum choiceId;
433 union
434 {
435 IssuerAndSerialNumber *issuerAndSerialNumber;
436 KeyIdentifier *subjectKeyIdentifier;
437 };
438
439
440 RecipientIdentifier();
441 RecipientIdentifier (const RecipientIdentifier &);
442 virtual ~RecipientIdentifier();
443
444 virtual AsnType *Clone() const;
445
446 virtual AsnType *Copy() const;
447
448 RecipientIdentifier &operator = (const RecipientIdentifier &);
449 AsnLen BEncContent (BUF_TYPE b);
450 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
451 AsnLen BEnc (BUF_TYPE b);
452 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
453 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
454 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
455
456 void Print (ostream &os) const;
457 };
458
459
460 class OriginatorIdentifierOrKey: public AsnType
461 {
462 public:
463 enum ChoiceIdEnum
464 {
465 issuerAndSerialNumberCid = 0,
466 subjectKeyIdentifierCid = 1,
467 originatorKeyCid = 2
468 };
469
470 enum ChoiceIdEnum choiceId;
471 union
472 {
473 IssuerAndSerialNumber *issuerAndSerialNumber;
474 KeyIdentifier *subjectKeyIdentifier;
475 OriginatorPublicKey *originatorKey;
476 };
477
478
479 OriginatorIdentifierOrKey();
480 OriginatorIdentifierOrKey (const OriginatorIdentifierOrKey &);
481 virtual ~OriginatorIdentifierOrKey();
482
483 virtual AsnType *Clone() const;
484
485 virtual AsnType *Copy() const;
486
487 OriginatorIdentifierOrKey &operator = (const OriginatorIdentifierOrKey &);
488 AsnLen BEncContent (BUF_TYPE b);
489 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
490 AsnLen BEnc (BUF_TYPE b);
491 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
492 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
493 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
494
495 void Print (ostream &os) const;
496 };
497
498
499 class RecipientKeyIdentifier: public AsnType
500 {
501 public:
502 KeyIdentifier subjectKeyIdentifier;
503 GeneralizedTime *date;
504 OtherKeyAttribute *other;
505
506 RecipientKeyIdentifier();
507 RecipientKeyIdentifier (const RecipientKeyIdentifier &);
508 virtual ~RecipientKeyIdentifier();
509 virtual AsnType *Clone() const;
510
511 virtual AsnType *Copy() const;
512
513 RecipientKeyIdentifier &operator = (const RecipientKeyIdentifier &);
514 AsnLen BEncContent (BUF_TYPE b);
515 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
516
517 AsnLen BEnc (BUF_TYPE b);
518 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
519 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
520 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
521
522 void Print (ostream &os) const;
523 };
524
525
526 class KEKIdentifier: public AsnType
527 {
528 public:
529 AsnOcts keyIdentifier;
530 GeneralizedTime *date;
531 OtherKeyAttribute *other;
532
533 KEKIdentifier();
534 KEKIdentifier (const KEKIdentifier &);
535 virtual ~KEKIdentifier();
536 virtual AsnType *Clone() const;
537
538 virtual AsnType *Copy() const;
539
540 KEKIdentifier &operator = (const KEKIdentifier &);
541 AsnLen BEncContent (BUF_TYPE b);
542 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
543
544 AsnLen BEnc (BUF_TYPE b);
545 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
546 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
547 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
548
549 void Print (ostream &os) const;
550 };
551
552
553 class ExtendedCertificateInfo: public AsnType
554 {
555 public:
556 CMSVersion version;
557 Certificate *certificate;
558 Attributes attributes;
559
560 ExtendedCertificateInfo();
561 ExtendedCertificateInfo (const ExtendedCertificateInfo &);
562 virtual ~ExtendedCertificateInfo();
563 virtual AsnType *Clone() const;
564
565 virtual AsnType *Copy() const;
566
567 ExtendedCertificateInfo &operator = (const ExtendedCertificateInfo &);
568 AsnLen BEncContent (BUF_TYPE b);
569 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
570
571 AsnLen BEnc (BUF_TYPE b);
572 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
573 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
574 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
575
576 void Print (ostream &os) const;
577 };
578
579
580 class SignerInfo: public AsnType
581 {
582 public:
583 CMSVersion version;
584 SignerIdentifier *sid;
585 DigestAlgorithmIdentifier *digestAlgorithm;
586 Attributes *signedAttrs;
587 SignatureAlgorithmIdentifier *signatureAlgorithm;
588 SignatureValue signature;
589 Attributes *unsignedAttrs;
590
591 SignerInfo();
592 SignerInfo (const SignerInfo &);
593 virtual ~SignerInfo();
594 virtual AsnType *Clone() const;
595
596 virtual AsnType *Copy() const;
597
598 SignerInfo &operator = (const SignerInfo &);
599 AsnLen BEncContent (BUF_TYPE b);
600 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
601
602 AsnLen BEnc (BUF_TYPE b);
603 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
604 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
605 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
606
607 void Print (ostream &os) const;
608 };
609
610
611 class KeyTransRecipientInfo: public AsnType
612 {
613 public:
614 CMSVersion version;
615 RecipientIdentifier *rid;
616 KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm;
617 EncryptedKey encryptedKey;
618
619 KeyTransRecipientInfo();
620 KeyTransRecipientInfo (const KeyTransRecipientInfo &);
621 virtual ~KeyTransRecipientInfo();
622 virtual AsnType *Clone() const;
623
624 virtual AsnType *Copy() const;
625
626 KeyTransRecipientInfo &operator = (const KeyTransRecipientInfo &);
627 AsnLen BEncContent (BUF_TYPE b);
628 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
629
630 AsnLen BEnc (BUF_TYPE b);
631 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
632 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
633 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
634
635 void Print (ostream &os) const;
636 };
637
638
639 class KeyAgreeRecipientIdentifier: public AsnType
640 {
641 public:
642 enum ChoiceIdEnum
643 {
644 issuerAndSerialNumberCid = 0,
645 rKeyIdCid = 1
646 };
647
648 enum ChoiceIdEnum choiceId;
649 union
650 {
651 IssuerAndSerialNumber *issuerAndSerialNumber;
652 RecipientKeyIdentifier *rKeyId;
653 };
654
655
656 KeyAgreeRecipientIdentifier();
657 KeyAgreeRecipientIdentifier (const KeyAgreeRecipientIdentifier &);
658 virtual ~KeyAgreeRecipientIdentifier();
659
660 virtual AsnType *Clone() const;
661
662 virtual AsnType *Copy() const;
663
664 KeyAgreeRecipientIdentifier &operator = (const KeyAgreeRecipientIdentifier &);
665 AsnLen BEncContent (BUF_TYPE b);
666 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
667 AsnLen BEnc (BUF_TYPE b);
668 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
669 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
670 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
671
672 void Print (ostream &os) const;
673 };
674
675
676 class KEKRecipientInfo: public AsnType
677 {
678 public:
679 CMSVersion version;
680 KEKIdentifier *kekid;
681 KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm;
682 EncryptedKey encryptedKey;
683
684 KEKRecipientInfo();
685 KEKRecipientInfo (const KEKRecipientInfo &);
686 virtual ~KEKRecipientInfo();
687 virtual AsnType *Clone() const;
688
689 virtual AsnType *Copy() const;
690
691 KEKRecipientInfo &operator = (const KEKRecipientInfo &);
692 AsnLen BEncContent (BUF_TYPE b);
693 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
694
695 AsnLen BEnc (BUF_TYPE b);
696 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
697 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
698 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
699
700 void Print (ostream &os) const;
701 };
702
703
704 class ExtendedCertificate: public AsnType
705 {
706 public:
707 ExtendedCertificateInfo *extendedCertificateInfo;
708 SignatureAlgorithmIdentifier *signatureAlgorithm;
709 Signature signature;
710
711 ExtendedCertificate();
712 ExtendedCertificate (const ExtendedCertificate &);
713 virtual ~ExtendedCertificate();
714 virtual AsnType *Clone() const;
715
716 virtual AsnType *Copy() const;
717
718 ExtendedCertificate &operator = (const ExtendedCertificate &);
719 AsnLen BEncContent (BUF_TYPE b);
720 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
721
722 AsnLen BEnc (BUF_TYPE b);
723 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
724 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
725 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
726
727 void Print (ostream &os) const;
728 };
729
730
731 class SignerInfos: public AsnType
732 {
733 protected:
734 unsigned long int count;
735 struct AsnListElmt
736 {
737 AsnListElmt *next;
738 AsnListElmt *prev;
739 SignerInfo *elmt;
740 } *first, *curr, *last;
741
742 public:
743 SignerInfos() { count = 0; first = curr = last = NULL; }
744 SignerInfos (const SignerInfos &);
745 virtual ~SignerInfos();
746 virtual AsnType *Clone() const;
747
748 virtual AsnType *Copy() const;
749
750 SignerInfos &operator = (const SignerInfos &);
751 void SetCurrElmt (unsigned long int index);
752 unsigned long int GetCurrElmtIndex();
753 void SetCurrToFirst() { curr = first; }
754 void SetCurrToLast() { curr = last; }
755 // reading member fcns
756 int Count() const { return count; }
757 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
758 SignerInfo *First() const { return count > 0 ? first->elmt : NULL; }
759 SignerInfo *Last() const { return count > 0 ? last->elmt : NULL; }
760 SignerInfo *Curr() const { return curr ? curr->elmt : NULL; }
761 SignerInfo *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
762 SignerInfo *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
763
764 // routines that move the curr elmt
765 SignerInfo *GoNext() { if (curr) curr = curr->next; return Curr(); }
766 SignerInfo *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
767
768 // write & alloc fcns - returns new elmt
769 SignerInfo *Append(); // add elmt to end of list
770 SignerInfo *Prepend(); // add elmt to beginning of list
771 SignerInfo *InsertBefore(); //insert elmt before current elmt
772 SignerInfo *InsertAfter(); //insert elmt after current elmt
773
774 // write & alloc & copy - returns list after copying elmt
775 SignerInfos &AppendCopy (SignerInfo &elmt); // add elmt to end of list
776 SignerInfos &PrependCopy (SignerInfo &elmt); // add elmt to beginning of list
777 SignerInfos &InsertBeforeAndCopy (SignerInfo &elmt); //insert elmt before current elmt
778 SignerInfos &InsertAfterAndCopy (SignerInfo &elmt); //insert elmt after current elmt
779
780 // removing the current elmt from the list
781 void RemoveCurrFromList();
782
783 // encode and decode routines
784 AsnLen BEnc (BUF_TYPE b);
785 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
786 AsnLen BEncContent (BUF_TYPE b);
787 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
788
789 PDU_MEMBER_MACROS
790 void Print (ostream &os) const;
791 };
792
793
794 class RecipientEncryptedKey: public AsnType
795 {
796 public:
797 KeyAgreeRecipientIdentifier *rid;
798 EncryptedKey encryptedKey;
799
800 RecipientEncryptedKey();
801 RecipientEncryptedKey (const RecipientEncryptedKey &);
802 virtual ~RecipientEncryptedKey();
803 virtual AsnType *Clone() const;
804
805 virtual AsnType *Copy() const;
806
807 RecipientEncryptedKey &operator = (const RecipientEncryptedKey &);
808 AsnLen BEncContent (BUF_TYPE b);
809 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
810
811 AsnLen BEnc (BUF_TYPE b);
812 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
813 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
814 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
815
816 void Print (ostream &os) const;
817 };
818
819
820 class CertificateChoices: public AsnType
821 {
822 public:
823 enum ChoiceIdEnum
824 {
825 certificateCid = 0,
826 extendedCertificateCid = 1,
827 attrCertCid = 2
828 };
829
830 enum ChoiceIdEnum choiceId;
831 union
832 {
833 Certificate *certificate;
834 ExtendedCertificate *extendedCertificate;
835 AttributeCertificate *attrCert;
836 };
837
838
839 CertificateChoices();
840 CertificateChoices (const CertificateChoices &);
841 virtual ~CertificateChoices();
842
843 virtual AsnType *Clone() const;
844
845 virtual AsnType *Copy() const;
846
847 CertificateChoices &operator = (const CertificateChoices &);
848 AsnLen BEncContent (BUF_TYPE b);
849 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
850 AsnLen BEnc (BUF_TYPE b);
851 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
852 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
853 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
854
855 void Print (ostream &os) const;
856 };
857
858
859 class CertificateSet: public AsnType
860 {
861 protected:
862 unsigned long int count;
863 struct AsnListElmt
864 {
865 AsnListElmt *next;
866 AsnListElmt *prev;
867 CertificateChoices *elmt;
868 } *first, *curr, *last;
869
870 public:
871 CertificateSet() { count = 0; first = curr = last = NULL; }
872 CertificateSet (const CertificateSet &);
873 virtual ~CertificateSet();
874 virtual AsnType *Clone() const;
875
876 virtual AsnType *Copy() const;
877
878 CertificateSet &operator = (const CertificateSet &);
879 void SetCurrElmt (unsigned long int index);
880 unsigned long int GetCurrElmtIndex();
881 void SetCurrToFirst() { curr = first; }
882 void SetCurrToLast() { curr = last; }
883 // reading member fcns
884 int Count() const { return count; }
885 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
886 CertificateChoices *First() const { return count > 0 ? first->elmt : NULL; }
887 CertificateChoices *Last() const { return count > 0 ? last->elmt : NULL; }
888 CertificateChoices *Curr() const { return curr ? curr->elmt : NULL; }
889 CertificateChoices *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
890 CertificateChoices *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
891
892 // routines that move the curr elmt
893 CertificateChoices *GoNext() { if (curr) curr = curr->next; return Curr(); }
894 CertificateChoices *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
895
896 // write & alloc fcns - returns new elmt
897 CertificateChoices *Append(); // add elmt to end of list
898 CertificateChoices *Prepend(); // add elmt to beginning of list
899 CertificateChoices *InsertBefore(); //insert elmt before current elmt
900 CertificateChoices *InsertAfter(); //insert elmt after current elmt
901
902 // write & alloc & copy - returns list after copying elmt
903 CertificateSet &AppendCopy (CertificateChoices &elmt); // add elmt to end of list
904 CertificateSet &PrependCopy (CertificateChoices &elmt); // add elmt to beginning of list
905 CertificateSet &InsertBeforeAndCopy (CertificateChoices &elmt); //insert elmt before current elmt
906 CertificateSet &InsertAfterAndCopy (CertificateChoices &elmt); //insert elmt after current elmt
907
908 // removing the current elmt from the list
909 void RemoveCurrFromList();
910
911 // encode and decode routines
912 AsnLen BEnc (BUF_TYPE b);
913 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
914 AsnLen BEncContent (BUF_TYPE b);
915 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
916
917 PDU_MEMBER_MACROS
918 void Print (ostream &os) const;
919 };
920
921
922 class OriginatorInfo: public AsnType
923 {
924 public:
925 CertificateSet *certs;
926 CertificateRevocationLists *crls;
927
928 OriginatorInfo();
929 OriginatorInfo (const OriginatorInfo &);
930 virtual ~OriginatorInfo();
931 virtual AsnType *Clone() const;
932
933 virtual AsnType *Copy() const;
934
935 OriginatorInfo &operator = (const OriginatorInfo &);
936 AsnLen BEncContent (BUF_TYPE b);
937 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
938
939 AsnLen BEnc (BUF_TYPE b);
940 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
941 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
942 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
943
944 void Print (ostream &os) const;
945 };
946
947
948 class RecipientEncryptedKeys: public AsnType
949 {
950 protected:
951 unsigned long int count;
952 struct AsnListElmt
953 {
954 AsnListElmt *next;
955 AsnListElmt *prev;
956 RecipientEncryptedKey *elmt;
957 } *first, *curr, *last;
958
959 public:
960 RecipientEncryptedKeys() { count = 0; first = curr = last = NULL; }
961 RecipientEncryptedKeys (const RecipientEncryptedKeys &);
962 virtual ~RecipientEncryptedKeys();
963 virtual AsnType *Clone() const;
964
965 virtual AsnType *Copy() const;
966
967 RecipientEncryptedKeys &operator = (const RecipientEncryptedKeys &);
968 void SetCurrElmt (unsigned long int index);
969 unsigned long int GetCurrElmtIndex();
970 void SetCurrToFirst() { curr = first; }
971 void SetCurrToLast() { curr = last; }
972 // reading member fcns
973 int Count() const { return count; }
974 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
975 RecipientEncryptedKey *First() const { return count > 0 ? first->elmt : NULL; }
976 RecipientEncryptedKey *Last() const { return count > 0 ? last->elmt : NULL; }
977 RecipientEncryptedKey *Curr() const { return curr ? curr->elmt : NULL; }
978 RecipientEncryptedKey *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
979 RecipientEncryptedKey *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
980
981 // routines that move the curr elmt
982 RecipientEncryptedKey *GoNext() { if (curr) curr = curr->next; return Curr(); }
983 RecipientEncryptedKey *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
984
985 // write & alloc fcns - returns new elmt
986 RecipientEncryptedKey *Append(); // add elmt to end of list
987 RecipientEncryptedKey *Prepend(); // add elmt to beginning of list
988 RecipientEncryptedKey *InsertBefore(); //insert elmt before current elmt
989 RecipientEncryptedKey *InsertAfter(); //insert elmt after current elmt
990
991 // write & alloc & copy - returns list after copying elmt
992 RecipientEncryptedKeys &AppendCopy (RecipientEncryptedKey &elmt); // add elmt to end of list
993 RecipientEncryptedKeys &PrependCopy (RecipientEncryptedKey &elmt); // add elmt to beginning of list
994 RecipientEncryptedKeys &InsertBeforeAndCopy (RecipientEncryptedKey &elmt); //insert elmt before current elmt
995 RecipientEncryptedKeys &InsertAfterAndCopy (RecipientEncryptedKey &elmt); //insert elmt after current elmt
996
997 // removing the current elmt from the list
998 void RemoveCurrFromList();
999
1000 // encode and decode routines
1001 AsnLen BEnc (BUF_TYPE b);
1002 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1003 AsnLen BEncContent (BUF_TYPE b);
1004 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1005
1006 PDU_MEMBER_MACROS
1007 void Print (ostream &os) const;
1008 };
1009
1010
1011 class KeyAgreeRecipientInfo: public AsnType
1012 {
1013 public:
1014 CMSVersion version;
1015 OriginatorIdentifierOrKey *originator;
1016 UserKeyingMaterial *ukm;
1017 KeyEncryptionAlgorithmIdentifier *keyEncryptionAlgorithm;
1018 RecipientEncryptedKeys recipientEncryptedKeys;
1019
1020 KeyAgreeRecipientInfo();
1021 KeyAgreeRecipientInfo (const KeyAgreeRecipientInfo &);
1022 virtual ~KeyAgreeRecipientInfo();
1023 virtual AsnType *Clone() const;
1024
1025 virtual AsnType *Copy() const;
1026
1027 KeyAgreeRecipientInfo &operator = (const KeyAgreeRecipientInfo &);
1028 AsnLen BEncContent (BUF_TYPE b);
1029 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1030
1031 AsnLen BEnc (BUF_TYPE b);
1032 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1033 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1034 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1035
1036 void Print (ostream &os) const;
1037 };
1038
1039
1040 class RecipientInfo: public AsnType
1041 {
1042 public:
1043 enum ChoiceIdEnum
1044 {
1045 ktriCid = 0,
1046 kariCid = 1,
1047 kekriCid = 2
1048 };
1049
1050 enum ChoiceIdEnum choiceId;
1051 union
1052 {
1053 KeyTransRecipientInfo *ktri;
1054 KeyAgreeRecipientInfo *kari;
1055 KEKRecipientInfo *kekri;
1056 };
1057
1058
1059 RecipientInfo();
1060 RecipientInfo (const RecipientInfo &);
1061 virtual ~RecipientInfo();
1062
1063 virtual AsnType *Clone() const;
1064
1065 virtual AsnType *Copy() const;
1066
1067 RecipientInfo &operator = (const RecipientInfo &);
1068 AsnLen BEncContent (BUF_TYPE b);
1069 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1070 AsnLen BEnc (BUF_TYPE b);
1071 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1072 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1073 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1074
1075 void Print (ostream &os) const;
1076 };
1077
1078
1079 class RecipientInfos: public AsnType
1080 {
1081 protected:
1082 unsigned long int count;
1083 struct AsnListElmt
1084 {
1085 AsnListElmt *next;
1086 AsnListElmt *prev;
1087 RecipientInfo *elmt;
1088 } *first, *curr, *last;
1089
1090 public:
1091 RecipientInfos() { count = 0; first = curr = last = NULL; }
1092 RecipientInfos (const RecipientInfos &);
1093 virtual ~RecipientInfos();
1094 virtual AsnType *Clone() const;
1095
1096 virtual AsnType *Copy() const;
1097
1098 RecipientInfos &operator = (const RecipientInfos &);
1099 void SetCurrElmt (unsigned long int index);
1100 unsigned long int GetCurrElmtIndex();
1101 void SetCurrToFirst() { curr = first; }
1102 void SetCurrToLast() { curr = last; }
1103 // reading member fcns
1104 int Count() const { return count; }
1105 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
1106 RecipientInfo *First() const { return count > 0 ? first->elmt : NULL; }
1107 RecipientInfo *Last() const { return count > 0 ? last->elmt : NULL; }
1108 RecipientInfo *Curr() const { return curr ? curr->elmt : NULL; }
1109 RecipientInfo *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
1110 RecipientInfo *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
1111
1112 // routines that move the curr elmt
1113 RecipientInfo *GoNext() { if (curr) curr = curr->next; return Curr(); }
1114 RecipientInfo *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
1115
1116 // write & alloc fcns - returns new elmt
1117 RecipientInfo *Append(); // add elmt to end of list
1118 RecipientInfo *Prepend(); // add elmt to beginning of list
1119 RecipientInfo *InsertBefore(); //insert elmt before current elmt
1120 RecipientInfo *InsertAfter(); //insert elmt after current elmt
1121
1122 // write & alloc & copy - returns list after copying elmt
1123 RecipientInfos &AppendCopy (RecipientInfo &elmt); // add elmt to end of list
1124 RecipientInfos &PrependCopy (RecipientInfo &elmt); // add elmt to beginning of list
1125 RecipientInfos &InsertBeforeAndCopy (RecipientInfo &elmt); //insert elmt before current elmt
1126 RecipientInfos &InsertAfterAndCopy (RecipientInfo &elmt); //insert elmt after current elmt
1127
1128 // removing the current elmt from the list
1129 void RemoveCurrFromList();
1130
1131 // encode and decode routines
1132 AsnLen BEnc (BUF_TYPE b);
1133 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1134 AsnLen BEncContent (BUF_TYPE b);
1135 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1136
1137 PDU_MEMBER_MACROS
1138 void Print (ostream &os) const;
1139 };
1140
1141
1142 class ContentInfo: public AsnType
1143 {
1144 public:
1145 ContentType contentType;
1146 AsnAny content;
1147
1148 ContentInfo();
1149 ContentInfo (const ContentInfo &);
1150 virtual ~ContentInfo();
1151 virtual AsnType *Clone() const;
1152
1153 virtual AsnType *Copy() const;
1154
1155 ContentInfo &operator = (const ContentInfo &);
1156 AsnLen BEncContent (BUF_TYPE b);
1157 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1158
1159 AsnLen BEnc (BUF_TYPE b);
1160 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1161 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1162 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1163
1164 void Print (ostream &os) const;
1165 };
1166
1167
1168 class SignedData: public AsnType
1169 {
1170 public:
1171 CMSVersion version;
1172 DigestAlgorithmIdentifiers digestAlgorithms;
1173 EncapsulatedContentInfo *encapContentInfo;
1174 CertificateSet *certificates;
1175 CertificateRevocationLists *crls;
1176 SignerInfos signerInfos;
1177
1178 SignedData();
1179 SignedData (const SignedData &);
1180 virtual ~SignedData();
1181 virtual AsnType *Clone() const;
1182
1183 virtual AsnType *Copy() const;
1184
1185 SignedData &operator = (const SignedData &);
1186 AsnLen BEncContent (BUF_TYPE b);
1187 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1188
1189 AsnLen BEnc (BUF_TYPE b);
1190 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1191 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1192 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1193
1194 void Print (ostream &os) const;
1195 };
1196
1197
1198 class EnvelopedData: public AsnType
1199 {
1200 public:
1201 CMSVersion version;
1202 OriginatorInfo *originatorInfo;
1203 RecipientInfos recipientInfos;
1204 EncryptedContentInfo *encryptedContentInfo;
1205 Attributes *unprotectedAttrs;
1206
1207 EnvelopedData();
1208 EnvelopedData (const EnvelopedData &);
1209 virtual ~EnvelopedData();
1210 virtual AsnType *Clone() const;
1211
1212 virtual AsnType *Copy() const;
1213
1214 EnvelopedData &operator = (const EnvelopedData &);
1215 AsnLen BEncContent (BUF_TYPE b);
1216 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1217
1218 AsnLen BEnc (BUF_TYPE b);
1219 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1220 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1221 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1222
1223 void Print (ostream &os) const;
1224 };
1225
1226
1227 class DigestedData: public AsnType
1228 {
1229 public:
1230 CMSVersion version;
1231 DigestAlgorithmIdentifier *digestAlgorithm;
1232 EncapsulatedContentInfo *encapContentInfo;
1233 Digest digest;
1234
1235 DigestedData();
1236 DigestedData (const DigestedData &);
1237 virtual ~DigestedData();
1238 virtual AsnType *Clone() const;
1239
1240 virtual AsnType *Copy() const;
1241
1242 DigestedData &operator = (const DigestedData &);
1243 AsnLen BEncContent (BUF_TYPE b);
1244 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1245
1246 AsnLen BEnc (BUF_TYPE b);
1247 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1248 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1249 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1250
1251 void Print (ostream &os) const;
1252 };
1253
1254
1255 class EncryptedData: public AsnType
1256 {
1257 public:
1258 CMSVersion version;
1259 EncryptedContentInfo *encryptedContentInfo;
1260
1261 EncryptedData();
1262 EncryptedData (const EncryptedData &);
1263 virtual ~EncryptedData();
1264 virtual AsnType *Clone() const;
1265
1266 virtual AsnType *Copy() const;
1267
1268 EncryptedData &operator = (const EncryptedData &);
1269 AsnLen BEncContent (BUF_TYPE b);
1270 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1271
1272 AsnLen BEnc (BUF_TYPE b);
1273 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1274 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1275 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1276
1277 void Print (ostream &os) const;
1278 };
1279
1280
1281 class AuthenticatedData: public AsnType
1282 {
1283 public:
1284 CMSVersion version;
1285 OriginatorInfo *originatorInfo;
1286 RecipientInfos recipientInfos;
1287 MessageAuthenticationCodeAlgorithm *macAlgorithm;
1288 DigestAlgorithmIdentifier *digestAlgorithm;
1289 EncapsulatedContentInfo *encapContentInfo;
1290 Attributes *authenctiatedAttributes;
1291 MessageAuthenticationCode mac;
1292 Attributes *unauthenticatedAttributes;
1293
1294 AuthenticatedData();
1295 AuthenticatedData (const AuthenticatedData &);
1296 virtual ~AuthenticatedData();
1297 virtual AsnType *Clone() const;
1298
1299 virtual AsnType *Copy() const;
1300
1301 AuthenticatedData &operator = (const AuthenticatedData &);
1302 AsnLen BEncContent (BUF_TYPE b);
1303 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1304
1305 AsnLen BEnc (BUF_TYPE b);
1306 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1307 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1308 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1309
1310 void Print (ostream &os) const;
1311 };
1312
1313
1314 class UserKeyingMaterials: public AsnType
1315 {
1316 protected:
1317 unsigned long int count;
1318 struct AsnListElmt
1319 {
1320 AsnListElmt *next;
1321 AsnListElmt *prev;
1322 UserKeyingMaterial *elmt;
1323 } *first, *curr, *last;
1324
1325 public:
1326 UserKeyingMaterials() { count = 0; first = curr = last = NULL; }
1327 UserKeyingMaterials (const UserKeyingMaterials &);
1328 virtual ~UserKeyingMaterials();
1329 virtual AsnType *Clone() const;
1330
1331 virtual AsnType *Copy() const;
1332
1333 UserKeyingMaterials &operator = (const UserKeyingMaterials &);
1334 void SetCurrElmt (unsigned long int index);
1335 unsigned long int GetCurrElmtIndex();
1336 void SetCurrToFirst() { curr = first; }
1337 void SetCurrToLast() { curr = last; }
1338 // reading member fcns
1339 int Count() const { return count; }
1340 // NOTE: if your compiler complains about these NULLs, its definition of NULL is broken (and you better change it there!)
1341 UserKeyingMaterial *First() const { return count > 0 ? first->elmt : NULL; }
1342 UserKeyingMaterial *Last() const { return count > 0 ? last->elmt : NULL; }
1343 UserKeyingMaterial *Curr() const { return curr ? curr->elmt : NULL; }
1344 UserKeyingMaterial *Next() const { return curr && curr->next ? curr->next->elmt : NULL; }
1345 UserKeyingMaterial *Prev() const { return curr && curr->prev ? curr->prev->elmt : NULL; }
1346
1347 // routines that move the curr elmt
1348 UserKeyingMaterial *GoNext() { if (curr) curr = curr->next; return Curr(); }
1349 UserKeyingMaterial *GoPrev() { if (curr) curr = curr->prev; return Curr(); }
1350
1351 // write & alloc fcns - returns new elmt
1352 UserKeyingMaterial *Append(); // add elmt to end of list
1353 UserKeyingMaterial *Prepend(); // add elmt to beginning of list
1354 UserKeyingMaterial *InsertBefore(); //insert elmt before current elmt
1355 UserKeyingMaterial *InsertAfter(); //insert elmt after current elmt
1356
1357 // write & alloc & copy - returns list after copying elmt
1358 UserKeyingMaterials &AppendCopy (UserKeyingMaterial &elmt); // add elmt to end of list
1359 UserKeyingMaterials &PrependCopy (UserKeyingMaterial &elmt); // add elmt to beginning of list
1360 UserKeyingMaterials &InsertBeforeAndCopy (UserKeyingMaterial &elmt); //insert elmt before current elmt
1361 UserKeyingMaterials &InsertAfterAndCopy (UserKeyingMaterial &elmt); //insert elmt after current elmt
1362
1363 // removing the current elmt from the list
1364 void RemoveCurrFromList();
1365
1366 // encode and decode routines
1367 AsnLen BEnc (BUF_TYPE b);
1368 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1369 AsnLen BEncContent (BUF_TYPE b);
1370 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1371
1372 PDU_MEMBER_MACROS
1373 void Print (ostream &os) const;
1374 };
1375
1376
1377 /* Time */
1378 typedef Time SigningTime;
1379
1380 /* SignerInfo */
1381 typedef SignerInfo Countersignature;
1382
1383 /* AlgorithmIdentifier */
1384 typedef AlgorithmIdentifier KeyWrapAlgorithm;
1385
1386 /* RC2ParameterVersion */
1387 typedef RC2ParameterVersion RC2wrapParameter;
1388
1389 /* IV */
1390 typedef IV CBCParameter;
1391
1392 class RC2CBCParameter: public AsnType
1393 {
1394 public:
1395 AsnInt rc2ParameterVersion;
1396 AsnOcts iv;
1397
1398 RC2CBCParameter();
1399 RC2CBCParameter (const RC2CBCParameter &);
1400 virtual ~RC2CBCParameter();
1401 virtual AsnType *Clone() const;
1402
1403 virtual AsnType *Copy() const;
1404
1405 RC2CBCParameter &operator = (const RC2CBCParameter &);
1406 AsnLen BEncContent (BUF_TYPE b);
1407 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1408
1409 AsnLen BEnc (BUF_TYPE b);
1410 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1411 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1412 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1413
1414 void Print (ostream &os) const;
1415 };
1416
1417
1418 class ExtendedCertificateOrCertificate: public AsnType
1419 {
1420 public:
1421 enum ChoiceIdEnum
1422 {
1423 certificateCid = 0,
1424 extendedCertificateCid = 1
1425 };
1426
1427 enum ChoiceIdEnum choiceId;
1428 union
1429 {
1430 Certificate *certificate;
1431 ExtendedCertificate *extendedCertificate;
1432 };
1433
1434
1435 ExtendedCertificateOrCertificate();
1436 ExtendedCertificateOrCertificate (const ExtendedCertificateOrCertificate &);
1437 virtual ~ExtendedCertificateOrCertificate();
1438
1439 virtual AsnType *Clone() const;
1440
1441 virtual AsnType *Copy() const;
1442
1443 ExtendedCertificateOrCertificate &operator = (const ExtendedCertificateOrCertificate &);
1444 AsnLen BEncContent (BUF_TYPE b);
1445 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1446 AsnLen BEnc (BUF_TYPE b);
1447 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1448 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1449 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1450
1451 void Print (ostream &os) const;
1452 };
1453
1454
1455 class DigestInfo: public AsnType
1456 {
1457 public:
1458 DigestAlgorithmIdentifier *digestAlgorithm;
1459 Digest digest;
1460
1461 DigestInfo();
1462 DigestInfo (const DigestInfo &);
1463 virtual ~DigestInfo();
1464 virtual AsnType *Clone() const;
1465
1466 virtual AsnType *Copy() const;
1467
1468 DigestInfo &operator = (const DigestInfo &);
1469 AsnLen BEncContent (BUF_TYPE b);
1470 void BDecContent (BUF_TYPE b, AsnTag tag, AsnLen elmtLen, AsnLen &bytesDecoded, ENV_TYPE env);
1471
1472 AsnLen BEnc (BUF_TYPE b);
1473 void BDec (BUF_TYPE b, AsnLen &bytesDecoded, ENV_TYPE env);
1474 int BEncPdu (BUF_TYPE b, AsnLen &bytesEncoded);
1475 int BDecPdu (BUF_TYPE b, AsnLen &bytesDecoded);
1476
1477 void Print (ostream &os) const;
1478 };
1479
1480
1481 //------------------------------------------------------------------------------
1482 // externs for value defs
1483
1484 #define sha_1_arc 1, 3, 14, 3, 2, 26
1485 #define sha_1 AsnOid(sha_1_arc)
1486 #define id_dsa_with_sha1_arc 1, 2, 840, 10040, 4, 3
1487 #define id_dsa_with_sha1 AsnOid(id_dsa_with_sha1_arc)
1488 #define dh_public_number_arc 1, 2, 840, 10046, 2, 1
1489 #define dh_public_number AsnOid(dh_public_number_arc)
1490 #define id_alg_ESDH_arc 1, 2, 840, 113549, 1, 9, 16, 3, 5
1491 #define id_alg_ESDH AsnOid(id_alg_ESDH_arc)
1492 #define id_alg_CMS3DESwrap_arc 1, 2, 840, 113549, 1, 9, 16, 3, 6
1493 #define id_alg_CMS3DESwrap AsnOid(id_alg_CMS3DESwrap_arc)
1494 #define id_alg_CMSRC2wrap_arc 1, 2, 840, 113549, 1, 9, 16, 3, 7
1495 #define id_alg_CMSRC2wrap AsnOid(id_alg_CMSRC2wrap_arc)
1496 #define des_ede3_cbc_arc 1, 2, 840, 113549, 3, 7
1497 #define des_ede3_cbc AsnOid(des_ede3_cbc_arc)
1498 #define rc2_cbc_arc 1, 2, 840, 113549, 3, 2
1499 #define rc2_cbc AsnOid(rc2_cbc_arc)
1500 #define hMAC_SHA1_arc 1, 3, 6, 1, 5, 5, 8, 1, 2
1501 #define hMAC_SHA1 AsnOid(hMAC_SHA1_arc)
1502 #define rc2_ecb_arc 1, 2, 840, 113549, 3, 3
1503 #define rc2_ecb AsnOid(rc2_ecb_arc)
1504 #define rc4_arc 1, 2, 840, 113549, 3, 4
1505 #define rc4 AsnOid(rc4_arc)
1506 #define rc4WithMAC_arc 1, 2, 840, 113549, 3, 5
1507 #define rc4WithMAC AsnOid(rc4WithMAC_arc)
1508 #define desx_CBC_arc 1, 2, 840, 113549, 3, 6
1509 #define desx_CBC AsnOid(desx_CBC_arc)
1510 #define rc5CBC_arc 1, 2, 840, 113549, 3, 8
1511 #define rc5CBC AsnOid(rc5CBC_arc)
1512 #define rc5_CBCPad_arc 1, 2, 840, 113549, 3, 9
1513 #define rc5_CBCPad AsnOid(rc5_CBCPad_arc)
1514 #define desCDMF_arc 1, 2, 840, 113549, 3, 10
1515 #define desCDMF AsnOid(desCDMF_arc)
1516 #define dsa_bsafe_arc 1, 3, 14, 3, 2, 12
1517 #define dsa_bsafe AsnOid(dsa_bsafe_arc)
1518 #define id_data_arc 1, 2, 840, 113549, 1, 7, 1
1519 #define id_data AsnOid(id_data_arc)
1520 #define id_signedData_arc 1, 2, 840, 113549, 1, 7, 2
1521 #define id_signedData AsnOid(id_signedData_arc)
1522 #define id_envelopedData_arc 1, 2, 840, 113549, 1, 7, 3
1523 #define id_envelopedData AsnOid(id_envelopedData_arc)
1524 #define id_digestedData_arc 1, 2, 840, 113549, 1, 7, 5
1525 #define id_digestedData AsnOid(id_digestedData_arc)
1526 #define id_encryptedData_arc 1, 2, 840, 113549, 1, 7, 6
1527 #define id_encryptedData AsnOid(id_encryptedData_arc)
1528 #define id_ct_authData_arc 1, 2, 840, 113549, 1, 9, 16, 1, 2
1529 #define id_ct_authData AsnOid(id_ct_authData_arc)
1530 #define id_contentType_arc 1, 2, 840, 113549, 1, 9, 3
1531 #define id_contentType AsnOid(id_contentType_arc)
1532 #define id_messageDigest_arc 1, 2, 840, 113549, 1, 9, 4
1533 #define id_messageDigest AsnOid(id_messageDigest_arc)
1534 #define id_signingTime_arc 1, 2, 840, 113549, 1, 9, 5
1535 #define id_signingTime AsnOid(id_signingTime_arc)
1536 #define id_countersignature_arc 1, 2, 840, 113549, 1, 9, 6
1537 #define id_countersignature AsnOid(id_countersignature_arc)
1538 #define id_macValue_arc 1, 2, 840, 113549, 1, 9, 16, 2, 8
1539 #define id_macValue AsnOid(id_macValue_arc)
1540 #define id_dsa_arc 1, 2, 840, 10040, 4, 1
1541 #define id_dsa AsnOid(id_dsa_arc)
1542 //------------------------------------------------------------------------------
1543
1544 #endif /* conditional include of sm_cms.h */