563e62dc0bdadbd90a9af8bc02ac30378c9affc6
[obnox/wireshark/wip.git] / epan / dissectors / packet-cms.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Ethereal dissector compiler    */
3 /* ./packet-cms.c                                                             */
4 /* ../../tools/asn2eth.py -X -b -e -p cms -c cms.cnf -s packet-cms-template CryptographicMessageSyntax.asn */
5
6 /* Input file: packet-cms-template.c */
7
8 /* packet-cms.c
9  * Routines for RFC2630 Cryptographic Message Syntax packet dissection
10  *   Ronnie Sahlberg 2004
11  *
12  * $Id$
13  *
14  * Ethereal - Network traffic analyzer
15  * By Gerald Combs <gerald@ethereal.com>
16  * Copyright 1998 Gerald Combs
17  *
18  * This program is free software; you can redistribute it and/or
19  * modify it under the terms of the GNU General Public License
20  * as published by the Free Software Foundation; either version 2
21  * of the License, or (at your option) any later version.
22  *
23  * This program is distributed in the hope that it will be useful,
24  * but WITHOUT ANY WARRANTY; without even the implied warranty of
25  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26  * GNU General Public License for more details.
27  *
28  * You should have received a copy of the GNU General Public License
29  * along with this program; if not, write to the Free Software
30  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
31  */
32
33 #ifdef HAVE_CONFIG_H
34 # include "config.h"
35 #endif
36
37 #include <glib.h>
38 #include <epan/packet.h>
39 #include <epan/conversation.h>
40
41 #include <stdio.h>
42 #include <string.h>
43
44 #include "packet-ber.h"
45 #include "packet-cms.h"
46 #include "packet-x509af.h"
47 #include "packet-x509if.h"
48
49 #include <epan/sha1.h>
50 #include <epan/crypt-md5.h>
51
52 #define PNAME  "Cryptographic Message Syntax"
53 #define PSNAME "CMS"
54 #define PFNAME "cms"
55
56 /* Initialize the protocol and registered fields */
57 int proto_cms = -1;
58 static int hf_cms_ci_contentType = -1;
59
60 /*--- Included file: packet-cms-hf.c ---*/
61
62 static int hf_cms_ContentInfo_PDU = -1;           /* ContentInfo */
63 static int hf_cms_ContentType_PDU = -1;           /* ContentType */
64 static int hf_cms_SignedData_PDU = -1;            /* SignedData */
65 static int hf_cms_EnvelopedData_PDU = -1;         /* EnvelopedData */
66 static int hf_cms_DigestedData_PDU = -1;          /* DigestedData */
67 static int hf_cms_EncryptedData_PDU = -1;         /* EncryptedData */
68 static int hf_cms_AuthenticatedData_PDU = -1;     /* AuthenticatedData */
69 static int hf_cms_MessageDigest_PDU = -1;         /* MessageDigest */
70 static int hf_cms_SigningTime_PDU = -1;           /* SigningTime */
71 static int hf_cms_Countersignature_PDU = -1;      /* Countersignature */
72 static int hf_cms_contentType = -1;               /* T_contentType */
73 static int hf_cms_content = -1;                   /* T_content */
74 static int hf_cms_version = -1;                   /* CMSVersion */
75 static int hf_cms_digestAlgorithms = -1;          /* DigestAlgorithmIdentifiers */
76 static int hf_cms_encapContentInfo = -1;          /* EncapsulatedContentInfo */
77 static int hf_cms_certificates = -1;              /* CertificateSet */
78 static int hf_cms_crls = -1;                      /* CertificateRevocationLists */
79 static int hf_cms_signerInfos = -1;               /* SignerInfos */
80 static int hf_cms_DigestAlgorithmIdentifiers_item = -1;  /* DigestAlgorithmIdentifier */
81 static int hf_cms_SignerInfos_item = -1;          /* SignerInfo */
82 static int hf_cms_eContentType = -1;              /* T_eContentType */
83 static int hf_cms_eContent = -1;                  /* T_eContent */
84 static int hf_cms_sid = -1;                       /* SignerIdentifier */
85 static int hf_cms_digestAlgorithm = -1;           /* DigestAlgorithmIdentifier */
86 static int hf_cms_signedAttrs = -1;               /* SignedAttributes */
87 static int hf_cms_signatureAlgorithm = -1;        /* SignatureAlgorithmIdentifier */
88 static int hf_cms_signatureValue = -1;            /* SignatureValue */
89 static int hf_cms_unsignedAttrs = -1;             /* UnsignedAttributes */
90 static int hf_cms_issuerAndSerialNumber = -1;     /* IssuerAndSerialNumber */
91 static int hf_cms_subjectKeyIdentifier = -1;      /* SubjectKeyIdentifier */
92 static int hf_cms_SignedAttributes_item = -1;     /* Attribute */
93 static int hf_cms_UnsignedAttributes_item = -1;   /* Attribute */
94 static int hf_cms_attrType = -1;                  /* T_attrType */
95 static int hf_cms_attrValues = -1;                /* SET_OF_AttributeValue */
96 static int hf_cms_attrValues_item = -1;           /* AttributeValue */
97 static int hf_cms_originatorInfo = -1;            /* OriginatorInfo */
98 static int hf_cms_recipientInfos = -1;            /* RecipientInfos */
99 static int hf_cms_encryptedContentInfo = -1;      /* EncryptedContentInfo */
100 static int hf_cms_unprotectedAttrs = -1;          /* UnprotectedAttributes */
101 static int hf_cms_certs = -1;                     /* CertificateSet */
102 static int hf_cms_RecipientInfos_item = -1;       /* RecipientInfo */
103 static int hf_cms_encryptedContentType = -1;      /* ContentType */
104 static int hf_cms_contentEncryptionAlgorithm = -1;  /* ContentEncryptionAlgorithmIdentifier */
105 static int hf_cms_encryptedContent = -1;          /* EncryptedContent */
106 static int hf_cms_UnprotectedAttributes_item = -1;  /* Attribute */
107 static int hf_cms_ktri = -1;                      /* KeyTransRecipientInfo */
108 static int hf_cms_kari = -1;                      /* KeyAgreeRecipientInfo */
109 static int hf_cms_kekri = -1;                     /* KEKRecipientInfo */
110 static int hf_cms_rid = -1;                       /* RecipientIdentifier */
111 static int hf_cms_keyEncryptionAlgorithm = -1;    /* KeyEncryptionAlgorithmIdentifier */
112 static int hf_cms_encryptedKey = -1;              /* EncryptedKey */
113 static int hf_cms_originator = -1;                /* OriginatorIdentifierOrKey */
114 static int hf_cms_ukm = -1;                       /* UserKeyingMaterial */
115 static int hf_cms_recipientEncryptedKeys = -1;    /* RecipientEncryptedKeys */
116 static int hf_cms_originatorKey = -1;             /* OriginatorPublicKey */
117 static int hf_cms_algorithm = -1;                 /* AlgorithmIdentifier */
118 static int hf_cms_publicKey = -1;                 /* BIT_STRING */
119 static int hf_cms_RecipientEncryptedKeys_item = -1;  /* RecipientEncryptedKey */
120 static int hf_cms_rekRid = -1;                    /* KeyAgreeRecipientIdentifier */
121 static int hf_cms_rKeyId = -1;                    /* RecipientKeyIdentifier */
122 static int hf_cms_date = -1;                      /* GeneralizedTime */
123 static int hf_cms_other = -1;                     /* OtherKeyAttribute */
124 static int hf_cms_kekid = -1;                     /* KEKIdentifier */
125 static int hf_cms_keyIdentifier = -1;             /* OCTET_STRING */
126 static int hf_cms_digest = -1;                    /* Digest */
127 static int hf_cms_macAlgorithm = -1;              /* MessageAuthenticationCodeAlgorithm */
128 static int hf_cms_authenticatedAttributes = -1;   /* AuthAttributes */
129 static int hf_cms_mac = -1;                       /* MessageAuthenticationCode */
130 static int hf_cms_unauthenticatedAttributes = -1;  /* UnauthAttributes */
131 static int hf_cms_AuthAttributes_item = -1;       /* Attribute */
132 static int hf_cms_UnauthAttributes_item = -1;     /* Attribute */
133 static int hf_cms_CertificateRevocationLists_item = -1;  /* CertificateList */
134 static int hf_cms_certificate = -1;               /* Certificate */
135 static int hf_cms_extendedCertificate = -1;       /* ExtendedCertificate */
136 static int hf_cms_attrCert = -1;                  /* AttributeCertificate */
137 static int hf_cms_CertificateSet_item = -1;       /* CertificateChoices */
138 static int hf_cms_issuer = -1;                    /* Name */
139 static int hf_cms_serialNumber = -1;              /* CertificateSerialNumber */
140 static int hf_cms_keyAttrId = -1;                 /* T_keyAttrId */
141 static int hf_cms_keyAttr = -1;                   /* T_keyAttr */
142 static int hf_cms_utcTime = -1;                   /* UTCTime */
143 static int hf_cms_generalTime = -1;               /* GeneralizedTime */
144 static int hf_cms_extendedCertificateInfo = -1;   /* ExtendedCertificateInfo */
145 static int hf_cms_signature = -1;                 /* Signature */
146 static int hf_cms_attributes = -1;                /* UnauthAttributes */
147
148 /*--- End of included file: packet-cms-hf.c ---*/
149
150
151 /* Initialize the subtree pointers */
152
153 /*--- Included file: packet-cms-ett.c ---*/
154
155 static gint ett_cms_ContentInfo = -1;
156 static gint ett_cms_SignedData = -1;
157 static gint ett_cms_DigestAlgorithmIdentifiers = -1;
158 static gint ett_cms_SignerInfos = -1;
159 static gint ett_cms_EncapsulatedContentInfo = -1;
160 static gint ett_cms_SignerInfo = -1;
161 static gint ett_cms_SignerIdentifier = -1;
162 static gint ett_cms_SignedAttributes = -1;
163 static gint ett_cms_UnsignedAttributes = -1;
164 static gint ett_cms_Attribute = -1;
165 static gint ett_cms_SET_OF_AttributeValue = -1;
166 static gint ett_cms_EnvelopedData = -1;
167 static gint ett_cms_OriginatorInfo = -1;
168 static gint ett_cms_RecipientInfos = -1;
169 static gint ett_cms_EncryptedContentInfo = -1;
170 static gint ett_cms_UnprotectedAttributes = -1;
171 static gint ett_cms_RecipientInfo = -1;
172 static gint ett_cms_KeyTransRecipientInfo = -1;
173 static gint ett_cms_RecipientIdentifier = -1;
174 static gint ett_cms_KeyAgreeRecipientInfo = -1;
175 static gint ett_cms_OriginatorIdentifierOrKey = -1;
176 static gint ett_cms_OriginatorPublicKey = -1;
177 static gint ett_cms_RecipientEncryptedKeys = -1;
178 static gint ett_cms_RecipientEncryptedKey = -1;
179 static gint ett_cms_KeyAgreeRecipientIdentifier = -1;
180 static gint ett_cms_RecipientKeyIdentifier = -1;
181 static gint ett_cms_KEKRecipientInfo = -1;
182 static gint ett_cms_KEKIdentifier = -1;
183 static gint ett_cms_DigestedData = -1;
184 static gint ett_cms_EncryptedData = -1;
185 static gint ett_cms_AuthenticatedData = -1;
186 static gint ett_cms_AuthAttributes = -1;
187 static gint ett_cms_UnauthAttributes = -1;
188 static gint ett_cms_CertificateRevocationLists = -1;
189 static gint ett_cms_CertificateChoices = -1;
190 static gint ett_cms_CertificateSet = -1;
191 static gint ett_cms_IssuerAndSerialNumber = -1;
192 static gint ett_cms_OtherKeyAttribute = -1;
193 static gint ett_cms_Time = -1;
194 static gint ett_cms_ExtendedCertificate = -1;
195 static gint ett_cms_ExtendedCertificateInfo = -1;
196
197 /*--- End of included file: packet-cms-ett.c ---*/
198
199
200 static int dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) ; /* XXX kill a compiler warning until asn2eth stops generating these silly wrappers */
201
202
203 static const char *object_identifier_id;
204 static tvbuff_t *content_tvb = NULL;
205
206 static proto_tree *top_tree=NULL;
207
208 #define HASH_SHA1 "1.3.14.3.2.26"
209 #define SHA1_BUFFER_SIZE  20
210
211 #define HASH_MD5 "1.2.840.113549.2.5"
212 #define MD5_BUFFER_SIZE  16
213
214
215 /* SHA-2 variants */
216 #define HASH_SHA224 "2.16.840.1.101.3.4.2.4"
217 #define SHA224_BUFFER_SIZE  32 /* actually 28 */
218 #define HASH_SHA256 "2.16.840.1.101.3.4.2.1"
219 #define SHA256_BUFFER_SIZE  32
220
221 unsigned char digest_buf[MAX(SHA1_BUFFER_SIZE, MD5_BUFFER_SIZE)];
222
223 static void
224 cms_verify_msg_digest(proto_item *pi, tvbuff_t *content, const char *alg, tvbuff_t *tvb, int offset)
225 {
226   sha1_context sha1_ctx;
227   md5_state_t md5_ctx;
228   int i= 0, buffer_size = 0;
229
230   /* we only support two algorithms at the moment  - if we do add SHA2
231      we should add a registration process to use a registration process */
232
233   if(strcmp(alg, HASH_SHA1) == 0) {
234
235     sha1_starts(&sha1_ctx);
236
237     sha1_update(&sha1_ctx, tvb_get_ptr(content, 0, tvb_length(content)), 
238                 tvb_length(content));
239
240     sha1_finish(&sha1_ctx, digest_buf);
241
242     buffer_size = SHA1_BUFFER_SIZE;
243
244   } else if(strcmp(alg, HASH_MD5) == 0) {
245
246     md5_init(&md5_ctx);
247
248     md5_append(&md5_ctx, tvb_get_ptr(content, 0, tvb_length(content)), 
249                tvb_length(content));
250     
251     md5_finish(&md5_ctx, digest_buf);
252
253     buffer_size = MD5_BUFFER_SIZE;
254   }
255
256   if(buffer_size) {
257     /* compare our computed hash with what we have received */  
258
259     if(tvb_bytes_exist(tvb, offset, buffer_size) &&
260        (memcmp(tvb_get_ptr(tvb, offset, buffer_size), digest_buf, buffer_size) != 0)) { 
261       proto_item_append_text(pi, " [incorrect, should be ");
262       for(i = 0; i < buffer_size; i++)
263         proto_item_append_text(pi, "%02X", digest_buf[i]);
264
265       proto_item_append_text(pi, "]");
266     }
267     else
268       proto_item_append_text(pi, " [correct]");
269   } else {
270     proto_item_append_text(pi, " [unable to verify]");
271   }
272
273 }
274
275
276 /*--- Included file: packet-cms-fn.c ---*/
277
278 /*--- Fields for imported types ---*/
279
280 static int dissect_algorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
281   return dissect_x509af_AlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_algorithm);
282 }
283 static int dissect_CertificateRevocationLists_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
284   return dissect_x509af_CertificateList(FALSE, tvb, offset, pinfo, tree, hf_cms_CertificateRevocationLists_item);
285 }
286 static int dissect_certificate(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
287   return dissect_x509af_Certificate(FALSE, tvb, offset, pinfo, tree, hf_cms_certificate);
288 }
289 static int dissect_attrCert_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
290   return dissect_x509af_AttributeCertificate(TRUE, tvb, offset, pinfo, tree, hf_cms_attrCert);
291 }
292 static int dissect_issuer(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
293   return dissect_x509if_Name(FALSE, tvb, offset, pinfo, tree, hf_cms_issuer);
294 }
295 static int dissect_serialNumber(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
296   return dissect_x509af_CertificateSerialNumber(FALSE, tvb, offset, pinfo, tree, hf_cms_serialNumber);
297 }
298
299
300
301 int
302 dissect_cms_ContentType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
303   offset = dissect_ber_object_identifier(implicit_tag, pinfo, tree, tvb, offset, hf_index, NULL);
304
305   return offset;
306 }
307 static int dissect_encryptedContentType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
308   return dissect_cms_ContentType(FALSE, tvb, offset, pinfo, tree, hf_cms_encryptedContentType);
309 }
310
311
312
313 static int
314 dissect_cms_T_contentType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
315   offset = dissect_ber_object_identifier_str(FALSE, pinfo, tree, tvb, offset,
316                                          hf_cms_ci_contentType, &object_identifier_id);
317
318
319   return offset;
320 }
321 static int dissect_contentType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
322   return dissect_cms_T_contentType(FALSE, tvb, offset, pinfo, tree, hf_cms_contentType);
323 }
324
325
326
327 static int
328 dissect_cms_T_content(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
329   offset=call_ber_oid_callback(object_identifier_id, tvb, offset, pinfo, tree);
330
331
332   return offset;
333 }
334 static int dissect_content(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
335   return dissect_cms_T_content(FALSE, tvb, offset, pinfo, tree, hf_cms_content);
336 }
337
338
339 static const ber_sequence_t ContentInfo_sequence[] = {
340   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_contentType },
341   { BER_CLASS_CON, 0, 0, dissect_content },
342   { 0, 0, 0, NULL }
343 };
344
345 int
346 dissect_cms_ContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
347   top_tree = tree;
348     offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
349                                    ContentInfo_sequence, hf_index, ett_cms_ContentInfo);
350
351   content_tvb = NULL;
352   top_tree = NULL;
353
354
355   return offset;
356 }
357
358
359 static const value_string cms_CMSVersion_vals[] = {
360   {   0, "v0" },
361   {   1, "v1" },
362   {   2, "v2" },
363   {   3, "v3" },
364   {   4, "v4" },
365   { 0, NULL }
366 };
367
368
369 static int
370 dissect_cms_CMSVersion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
371   offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
372                                   NULL);
373
374   return offset;
375 }
376 static int dissect_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
377   return dissect_cms_CMSVersion(FALSE, tvb, offset, pinfo, tree, hf_cms_version);
378 }
379
380
381
382 static int
383 dissect_cms_DigestAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
384   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
385
386   return offset;
387 }
388 static int dissect_DigestAlgorithmIdentifiers_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
389   return dissect_cms_DigestAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_DigestAlgorithmIdentifiers_item);
390 }
391 static int dissect_digestAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
392   return dissect_cms_DigestAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_digestAlgorithm);
393 }
394 static int dissect_digestAlgorithm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
395   return dissect_cms_DigestAlgorithmIdentifier(TRUE, tvb, offset, pinfo, tree, hf_cms_digestAlgorithm);
396 }
397
398
399 static const ber_sequence_t DigestAlgorithmIdentifiers_set_of[1] = {
400   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_DigestAlgorithmIdentifiers_item },
401 };
402
403 int
404 dissect_cms_DigestAlgorithmIdentifiers(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
405   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
406                                  DigestAlgorithmIdentifiers_set_of, hf_index, ett_cms_DigestAlgorithmIdentifiers);
407
408   return offset;
409 }
410 static int dissect_digestAlgorithms(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
411   return dissect_cms_DigestAlgorithmIdentifiers(FALSE, tvb, offset, pinfo, tree, hf_cms_digestAlgorithms);
412 }
413
414
415
416 static int
417 dissect_cms_T_eContentType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
418   offset = dissect_ber_object_identifier_str(FALSE, pinfo, tree, tvb, offset,
419                                          hf_cms_ci_contentType, &object_identifier_id);
420
421
422   return offset;
423 }
424 static int dissect_eContentType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
425   return dissect_cms_T_eContentType(FALSE, tvb, offset, pinfo, tree, hf_cms_eContentType);
426 }
427
428
429
430 static int
431 dissect_cms_T_eContent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
432   gint8 class;
433   gboolean pc, ind;
434   gint32 tag;
435   guint32 len;
436   int pdu_offset = offset;
437   int content_offset;
438
439   /* XXX Do we care about printing out the octet string? */
440   offset = dissect_cms_OCTET_STRING(FALSE, tvb, offset, pinfo, NULL, hf_cms_eContent);
441
442   pdu_offset = get_ber_identifier(tvb, pdu_offset, &class, &pc, &tag);
443   content_offset = pdu_offset = get_ber_length(tree, tvb, pdu_offset, &len, &ind);
444   pdu_offset = call_ber_oid_callback(object_identifier_id, tvb, pdu_offset, pinfo, top_tree ? top_tree : tree);
445   
446   content_tvb = tvb_new_subset(tvb, content_offset, len, -1);
447
448
449   return offset;
450 }
451 static int dissect_eContent(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
452   return dissect_cms_T_eContent(FALSE, tvb, offset, pinfo, tree, hf_cms_eContent);
453 }
454
455
456 static const ber_sequence_t EncapsulatedContentInfo_sequence[] = {
457   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_eContentType },
458   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL, dissect_eContent },
459   { 0, 0, 0, NULL }
460 };
461
462 int
463 dissect_cms_EncapsulatedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
464   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
465                                    EncapsulatedContentInfo_sequence, hf_index, ett_cms_EncapsulatedContentInfo);
466
467   return offset;
468 }
469 static int dissect_encapContentInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
470   return dissect_cms_EncapsulatedContentInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_encapContentInfo);
471 }
472
473
474
475 static int
476 dissect_cms_T_attrType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
477   char *name = NULL;
478
479     offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_cms_attrType, &object_identifier_id);
480
481
482   if(object_identifier_id) {
483     name = get_ber_oid_name(object_identifier_id);
484     proto_item_append_text(tree, " (%s)", name ? name : object_identifier_id); 
485   }
486
487
488   return offset;
489 }
490 static int dissect_attrType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
491   return dissect_cms_T_attrType(FALSE, tvb, offset, pinfo, tree, hf_cms_attrType);
492 }
493
494
495
496 static int
497 dissect_cms_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
498
499   offset=call_ber_oid_callback(object_identifier_id, tvb, offset, pinfo, tree);
500
501
502   return offset;
503 }
504 static int dissect_attrValues_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
505   return dissect_cms_AttributeValue(FALSE, tvb, offset, pinfo, tree, hf_cms_attrValues_item);
506 }
507
508
509 static const ber_sequence_t SET_OF_AttributeValue_set_of[1] = {
510   { BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_attrValues_item },
511 };
512
513 static int
514 dissect_cms_SET_OF_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
515   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
516                                  SET_OF_AttributeValue_set_of, hf_index, ett_cms_SET_OF_AttributeValue);
517
518   return offset;
519 }
520 static int dissect_attrValues(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
521   return dissect_cms_SET_OF_AttributeValue(FALSE, tvb, offset, pinfo, tree, hf_cms_attrValues);
522 }
523
524
525 static const ber_sequence_t Attribute_sequence[] = {
526   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_attrType },
527   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_attrValues },
528   { 0, 0, 0, NULL }
529 };
530
531 static int
532 dissect_cms_Attribute(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
533   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
534                                    Attribute_sequence, hf_index, ett_cms_Attribute);
535
536   return offset;
537 }
538 static int dissect_SignedAttributes_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
539   return dissect_cms_Attribute(FALSE, tvb, offset, pinfo, tree, hf_cms_SignedAttributes_item);
540 }
541 static int dissect_UnsignedAttributes_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
542   return dissect_cms_Attribute(FALSE, tvb, offset, pinfo, tree, hf_cms_UnsignedAttributes_item);
543 }
544 static int dissect_UnprotectedAttributes_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
545   return dissect_cms_Attribute(FALSE, tvb, offset, pinfo, tree, hf_cms_UnprotectedAttributes_item);
546 }
547 static int dissect_AuthAttributes_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
548   return dissect_cms_Attribute(FALSE, tvb, offset, pinfo, tree, hf_cms_AuthAttributes_item);
549 }
550 static int dissect_UnauthAttributes_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
551   return dissect_cms_Attribute(FALSE, tvb, offset, pinfo, tree, hf_cms_UnauthAttributes_item);
552 }
553
554
555 static const ber_sequence_t UnauthAttributes_set_of[1] = {
556   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_UnauthAttributes_item },
557 };
558
559 static int
560 dissect_cms_UnauthAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
561   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
562                                  UnauthAttributes_set_of, hf_index, ett_cms_UnauthAttributes);
563
564   return offset;
565 }
566 static int dissect_unauthenticatedAttributes_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
567   return dissect_cms_UnauthAttributes(TRUE, tvb, offset, pinfo, tree, hf_cms_unauthenticatedAttributes);
568 }
569 static int dissect_attributes(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
570   return dissect_cms_UnauthAttributes(FALSE, tvb, offset, pinfo, tree, hf_cms_attributes);
571 }
572
573
574 static const ber_sequence_t ExtendedCertificateInfo_sequence[] = {
575   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
576   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_certificate },
577   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_attributes },
578   { 0, 0, 0, NULL }
579 };
580
581 static int
582 dissect_cms_ExtendedCertificateInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
583   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
584                                    ExtendedCertificateInfo_sequence, hf_index, ett_cms_ExtendedCertificateInfo);
585
586   return offset;
587 }
588 static int dissect_extendedCertificateInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
589   return dissect_cms_ExtendedCertificateInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_extendedCertificateInfo);
590 }
591
592
593
594 static int
595 dissect_cms_SignatureAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
596   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
597
598   return offset;
599 }
600 static int dissect_signatureAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
601   return dissect_cms_SignatureAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_signatureAlgorithm);
602 }
603
604
605
606 static int
607 dissect_cms_Signature(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
608   offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset,
609                                     NULL, hf_index, -1,
610                                     NULL);
611
612   return offset;
613 }
614 static int dissect_signature(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
615   return dissect_cms_Signature(FALSE, tvb, offset, pinfo, tree, hf_cms_signature);
616 }
617
618
619 static const ber_sequence_t ExtendedCertificate_sequence[] = {
620   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_extendedCertificateInfo },
621   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_signatureAlgorithm },
622   { BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_NOOWNTAG, dissect_signature },
623   { 0, 0, 0, NULL }
624 };
625
626 static int
627 dissect_cms_ExtendedCertificate(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
628   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
629                                    ExtendedCertificate_sequence, hf_index, ett_cms_ExtendedCertificate);
630
631   return offset;
632 }
633 static int dissect_extendedCertificate_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
634   return dissect_cms_ExtendedCertificate(TRUE, tvb, offset, pinfo, tree, hf_cms_extendedCertificate);
635 }
636
637
638 static const value_string cms_CertificateChoices_vals[] = {
639   {   0, "certificate" },
640   {   1, "extendedCertificate" },
641   {   2, "attrCert" },
642   { 0, NULL }
643 };
644
645 static const ber_choice_t CertificateChoices_choice[] = {
646   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_certificate },
647   {   1, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_extendedCertificate_impl },
648   {   2, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_attrCert_impl },
649   { 0, 0, 0, 0, NULL }
650 };
651
652 static int
653 dissect_cms_CertificateChoices(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
654   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
655                                  CertificateChoices_choice, hf_index, ett_cms_CertificateChoices,
656                                  NULL);
657
658   return offset;
659 }
660 static int dissect_CertificateSet_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
661   return dissect_cms_CertificateChoices(FALSE, tvb, offset, pinfo, tree, hf_cms_CertificateSet_item);
662 }
663
664
665 static const ber_sequence_t CertificateSet_set_of[1] = {
666   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_CertificateSet_item },
667 };
668
669 static int
670 dissect_cms_CertificateSet(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
671   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
672                                  CertificateSet_set_of, hf_index, ett_cms_CertificateSet);
673
674   return offset;
675 }
676 static int dissect_certificates_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
677   return dissect_cms_CertificateSet(TRUE, tvb, offset, pinfo, tree, hf_cms_certificates);
678 }
679 static int dissect_certs_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
680   return dissect_cms_CertificateSet(TRUE, tvb, offset, pinfo, tree, hf_cms_certs);
681 }
682
683
684 static const ber_sequence_t CertificateRevocationLists_set_of[1] = {
685   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_CertificateRevocationLists_item },
686 };
687
688 static int
689 dissect_cms_CertificateRevocationLists(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
690   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
691                                  CertificateRevocationLists_set_of, hf_index, ett_cms_CertificateRevocationLists);
692
693   return offset;
694 }
695 static int dissect_crls_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
696   return dissect_cms_CertificateRevocationLists(TRUE, tvb, offset, pinfo, tree, hf_cms_crls);
697 }
698
699
700 static const ber_sequence_t IssuerAndSerialNumber_sequence[] = {
701   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG, dissect_issuer },
702   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_serialNumber },
703   { 0, 0, 0, NULL }
704 };
705
706 int
707 dissect_cms_IssuerAndSerialNumber(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
708   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
709                                    IssuerAndSerialNumber_sequence, hf_index, ett_cms_IssuerAndSerialNumber);
710
711   return offset;
712 }
713 static int dissect_issuerAndSerialNumber(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
714   return dissect_cms_IssuerAndSerialNumber(FALSE, tvb, offset, pinfo, tree, hf_cms_issuerAndSerialNumber);
715 }
716
717
718
719 static int
720 dissect_cms_SubjectKeyIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
721   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
722                                        NULL);
723
724   return offset;
725 }
726 static int dissect_subjectKeyIdentifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
727   return dissect_cms_SubjectKeyIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_subjectKeyIdentifier);
728 }
729 static int dissect_subjectKeyIdentifier_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
730   return dissect_cms_SubjectKeyIdentifier(TRUE, tvb, offset, pinfo, tree, hf_cms_subjectKeyIdentifier);
731 }
732
733
734 const value_string cms_SignerIdentifier_vals[] = {
735   {   0, "issuerAndSerialNumber" },
736   {   1, "subjectKeyIdentifier" },
737   { 0, NULL }
738 };
739
740 static const ber_choice_t SignerIdentifier_choice[] = {
741   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_issuerAndSerialNumber },
742   {   1, BER_CLASS_CON, 0, 0, dissect_subjectKeyIdentifier_impl },
743   { 0, 0, 0, 0, NULL }
744 };
745
746 int
747 dissect_cms_SignerIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
748   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
749                                  SignerIdentifier_choice, hf_index, ett_cms_SignerIdentifier,
750                                  NULL);
751
752   return offset;
753 }
754 static int dissect_sid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
755   return dissect_cms_SignerIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_sid);
756 }
757
758
759 static const ber_sequence_t SignedAttributes_set_of[1] = {
760   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_SignedAttributes_item },
761 };
762
763 int
764 dissect_cms_SignedAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
765   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
766                                  SignedAttributes_set_of, hf_index, ett_cms_SignedAttributes);
767
768   return offset;
769 }
770 static int dissect_signedAttrs_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
771   return dissect_cms_SignedAttributes(TRUE, tvb, offset, pinfo, tree, hf_cms_signedAttrs);
772 }
773
774
775
776 int
777 dissect_cms_SignatureValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
778   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
779                                        NULL);
780
781   return offset;
782 }
783 static int dissect_signatureValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
784   return dissect_cms_SignatureValue(FALSE, tvb, offset, pinfo, tree, hf_cms_signatureValue);
785 }
786
787
788 static const ber_sequence_t UnsignedAttributes_set_of[1] = {
789   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_UnsignedAttributes_item },
790 };
791
792 int
793 dissect_cms_UnsignedAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
794   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
795                                  UnsignedAttributes_set_of, hf_index, ett_cms_UnsignedAttributes);
796
797   return offset;
798 }
799 static int dissect_unsignedAttrs_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
800   return dissect_cms_UnsignedAttributes(TRUE, tvb, offset, pinfo, tree, hf_cms_unsignedAttrs);
801 }
802
803
804 static const ber_sequence_t SignerInfo_sequence[] = {
805   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
806   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_sid },
807   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_digestAlgorithm },
808   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_signedAttrs_impl },
809   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_signatureAlgorithm },
810   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_signatureValue },
811   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_unsignedAttrs_impl },
812   { 0, 0, 0, NULL }
813 };
814
815 int
816 dissect_cms_SignerInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
817   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
818                                    SignerInfo_sequence, hf_index, ett_cms_SignerInfo);
819
820   return offset;
821 }
822 static int dissect_SignerInfos_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
823   return dissect_cms_SignerInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_SignerInfos_item);
824 }
825
826
827 static const ber_sequence_t SignerInfos_set_of[1] = {
828   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_SignerInfos_item },
829 };
830
831 int
832 dissect_cms_SignerInfos(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
833   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
834                                  SignerInfos_set_of, hf_index, ett_cms_SignerInfos);
835
836   return offset;
837 }
838 static int dissect_signerInfos(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
839   return dissect_cms_SignerInfos(FALSE, tvb, offset, pinfo, tree, hf_cms_signerInfos);
840 }
841
842
843 static const ber_sequence_t SignedData_sequence[] = {
844   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
845   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_digestAlgorithms },
846   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_encapContentInfo },
847   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_certificates_impl },
848   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_crls_impl },
849   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_signerInfos },
850   { 0, 0, 0, NULL }
851 };
852
853 int
854 dissect_cms_SignedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
855   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
856                                    SignedData_sequence, hf_index, ett_cms_SignedData);
857
858   return offset;
859 }
860
861
862 static const ber_sequence_t OriginatorInfo_sequence[] = {
863   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_certs_impl },
864   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_crls_impl },
865   { 0, 0, 0, NULL }
866 };
867
868 static int
869 dissect_cms_OriginatorInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
870   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
871                                    OriginatorInfo_sequence, hf_index, ett_cms_OriginatorInfo);
872
873   return offset;
874 }
875 static int dissect_originatorInfo_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
876   return dissect_cms_OriginatorInfo(TRUE, tvb, offset, pinfo, tree, hf_cms_originatorInfo);
877 }
878
879
880 static const value_string cms_RecipientIdentifier_vals[] = {
881   {   0, "issuerAndSerialNumber" },
882   {   1, "subjectKeyIdentifier" },
883   { 0, NULL }
884 };
885
886 static const ber_choice_t RecipientIdentifier_choice[] = {
887   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_issuerAndSerialNumber },
888   {   1, BER_CLASS_CON, 0, 0, dissect_subjectKeyIdentifier_impl },
889   { 0, 0, 0, 0, NULL }
890 };
891
892 static int
893 dissect_cms_RecipientIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
894   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
895                                  RecipientIdentifier_choice, hf_index, ett_cms_RecipientIdentifier,
896                                  NULL);
897
898   return offset;
899 }
900 static int dissect_rid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
901   return dissect_cms_RecipientIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_rid);
902 }
903
904
905
906 static int
907 dissect_cms_KeyEncryptionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
908   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
909
910   return offset;
911 }
912 static int dissect_keyEncryptionAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
913   return dissect_cms_KeyEncryptionAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_keyEncryptionAlgorithm);
914 }
915
916
917
918 static int
919 dissect_cms_EncryptedKey(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
920   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
921                                        NULL);
922
923   return offset;
924 }
925 static int dissect_encryptedKey(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
926   return dissect_cms_EncryptedKey(FALSE, tvb, offset, pinfo, tree, hf_cms_encryptedKey);
927 }
928
929
930 static const ber_sequence_t KeyTransRecipientInfo_sequence[] = {
931   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
932   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_rid },
933   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_keyEncryptionAlgorithm },
934   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_encryptedKey },
935   { 0, 0, 0, NULL }
936 };
937
938 static int
939 dissect_cms_KeyTransRecipientInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
940   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
941                                    KeyTransRecipientInfo_sequence, hf_index, ett_cms_KeyTransRecipientInfo);
942
943   return offset;
944 }
945 static int dissect_ktri(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
946   return dissect_cms_KeyTransRecipientInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_ktri);
947 }
948
949
950
951 static int
952 dissect_cms_BIT_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
953   offset = dissect_ber_bitstring(implicit_tag, pinfo, tree, tvb, offset,
954                                     NULL, hf_index, -1,
955                                     NULL);
956
957   return offset;
958 }
959 static int dissect_publicKey(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
960   return dissect_cms_BIT_STRING(FALSE, tvb, offset, pinfo, tree, hf_cms_publicKey);
961 }
962
963
964 static const ber_sequence_t OriginatorPublicKey_sequence[] = {
965   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_algorithm },
966   { BER_CLASS_UNI, BER_UNI_TAG_BITSTRING, BER_FLAGS_NOOWNTAG, dissect_publicKey },
967   { 0, 0, 0, NULL }
968 };
969
970 static int
971 dissect_cms_OriginatorPublicKey(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
972   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
973                                    OriginatorPublicKey_sequence, hf_index, ett_cms_OriginatorPublicKey);
974
975   return offset;
976 }
977 static int dissect_originatorKey_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
978   return dissect_cms_OriginatorPublicKey(TRUE, tvb, offset, pinfo, tree, hf_cms_originatorKey);
979 }
980
981
982 static const value_string cms_OriginatorIdentifierOrKey_vals[] = {
983   {   0, "issuerAndSerialNumber" },
984   {   1, "subjectKeyIdentifier" },
985   {   2, "originatorKey" },
986   { 0, NULL }
987 };
988
989 static const ber_choice_t OriginatorIdentifierOrKey_choice[] = {
990   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_issuerAndSerialNumber },
991   {   1, BER_CLASS_CON, 0, 0, dissect_subjectKeyIdentifier_impl },
992   {   2, BER_CLASS_CON, 1, 0, dissect_originatorKey_impl },
993   { 0, 0, 0, 0, NULL }
994 };
995
996 static int
997 dissect_cms_OriginatorIdentifierOrKey(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
998   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
999                                  OriginatorIdentifierOrKey_choice, hf_index, ett_cms_OriginatorIdentifierOrKey,
1000                                  NULL);
1001
1002   return offset;
1003 }
1004 static int dissect_originator(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1005   return dissect_cms_OriginatorIdentifierOrKey(FALSE, tvb, offset, pinfo, tree, hf_cms_originator);
1006 }
1007
1008
1009
1010 static int
1011 dissect_cms_UserKeyingMaterial(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1012   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1013                                        NULL);
1014
1015   return offset;
1016 }
1017 static int dissect_ukm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1018   return dissect_cms_UserKeyingMaterial(FALSE, tvb, offset, pinfo, tree, hf_cms_ukm);
1019 }
1020
1021
1022
1023 static int
1024 dissect_cms_GeneralizedTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1025   offset = dissect_ber_GeneralizedTime(implicit_tag, pinfo, tree, tvb, offset, hf_index);
1026
1027   return offset;
1028 }
1029 static int dissect_date(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1030   return dissect_cms_GeneralizedTime(FALSE, tvb, offset, pinfo, tree, hf_cms_date);
1031 }
1032 static int dissect_generalTime(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1033   return dissect_cms_GeneralizedTime(FALSE, tvb, offset, pinfo, tree, hf_cms_generalTime);
1034 }
1035
1036
1037
1038 static int
1039 dissect_cms_T_keyAttrId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1040   offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_cms_ci_contentType, &object_identifier_id);
1041
1042   return offset;
1043 }
1044 static int dissect_keyAttrId(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1045   return dissect_cms_T_keyAttrId(FALSE, tvb, offset, pinfo, tree, hf_cms_keyAttrId);
1046 }
1047
1048
1049
1050 static int
1051 dissect_cms_T_keyAttr(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1052   offset=call_ber_oid_callback(object_identifier_id, tvb, offset, pinfo, tree);
1053
1054
1055
1056   return offset;
1057 }
1058 static int dissect_keyAttr(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1059   return dissect_cms_T_keyAttr(FALSE, tvb, offset, pinfo, tree, hf_cms_keyAttr);
1060 }
1061
1062
1063 static const ber_sequence_t OtherKeyAttribute_sequence[] = {
1064   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_keyAttrId },
1065   { BER_CLASS_ANY, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_keyAttr },
1066   { 0, 0, 0, NULL }
1067 };
1068
1069 static int
1070 dissect_cms_OtherKeyAttribute(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1071   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1072                                    OtherKeyAttribute_sequence, hf_index, ett_cms_OtherKeyAttribute);
1073
1074   return offset;
1075 }
1076 static int dissect_other(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1077   return dissect_cms_OtherKeyAttribute(FALSE, tvb, offset, pinfo, tree, hf_cms_other);
1078 }
1079
1080
1081 static const ber_sequence_t RecipientKeyIdentifier_sequence[] = {
1082   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_subjectKeyIdentifier },
1083   { BER_CLASS_UNI, BER_UNI_TAG_GeneralizedTime, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_date },
1084   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_other },
1085   { 0, 0, 0, NULL }
1086 };
1087
1088 static int
1089 dissect_cms_RecipientKeyIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1090   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1091                                    RecipientKeyIdentifier_sequence, hf_index, ett_cms_RecipientKeyIdentifier);
1092
1093   return offset;
1094 }
1095 static int dissect_rKeyId_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1096   return dissect_cms_RecipientKeyIdentifier(TRUE, tvb, offset, pinfo, tree, hf_cms_rKeyId);
1097 }
1098
1099
1100 static const value_string cms_KeyAgreeRecipientIdentifier_vals[] = {
1101   {   0, "issuerAndSerialNumber" },
1102   {   1, "rKeyId" },
1103   { 0, NULL }
1104 };
1105
1106 static const ber_choice_t KeyAgreeRecipientIdentifier_choice[] = {
1107   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_issuerAndSerialNumber },
1108   {   1, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_rKeyId_impl },
1109   { 0, 0, 0, 0, NULL }
1110 };
1111
1112 static int
1113 dissect_cms_KeyAgreeRecipientIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1114   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1115                                  KeyAgreeRecipientIdentifier_choice, hf_index, ett_cms_KeyAgreeRecipientIdentifier,
1116                                  NULL);
1117
1118   return offset;
1119 }
1120 static int dissect_rekRid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1121   return dissect_cms_KeyAgreeRecipientIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_rekRid);
1122 }
1123
1124
1125 static const ber_sequence_t RecipientEncryptedKey_sequence[] = {
1126   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_rekRid },
1127   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_encryptedKey },
1128   { 0, 0, 0, NULL }
1129 };
1130
1131 static int
1132 dissect_cms_RecipientEncryptedKey(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1133   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1134                                    RecipientEncryptedKey_sequence, hf_index, ett_cms_RecipientEncryptedKey);
1135
1136   return offset;
1137 }
1138 static int dissect_RecipientEncryptedKeys_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1139   return dissect_cms_RecipientEncryptedKey(FALSE, tvb, offset, pinfo, tree, hf_cms_RecipientEncryptedKeys_item);
1140 }
1141
1142
1143 static const ber_sequence_t RecipientEncryptedKeys_sequence_of[1] = {
1144   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_RecipientEncryptedKeys_item },
1145 };
1146
1147 static int
1148 dissect_cms_RecipientEncryptedKeys(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1149   offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1150                                       RecipientEncryptedKeys_sequence_of, hf_index, ett_cms_RecipientEncryptedKeys);
1151
1152   return offset;
1153 }
1154 static int dissect_recipientEncryptedKeys(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1155   return dissect_cms_RecipientEncryptedKeys(FALSE, tvb, offset, pinfo, tree, hf_cms_recipientEncryptedKeys);
1156 }
1157
1158
1159 static const ber_sequence_t KeyAgreeRecipientInfo_sequence[] = {
1160   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1161   { BER_CLASS_CON, 0, BER_FLAGS_NOTCHKTAG, dissect_originator },
1162   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL, dissect_ukm },
1163   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_keyEncryptionAlgorithm },
1164   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_recipientEncryptedKeys },
1165   { 0, 0, 0, NULL }
1166 };
1167
1168 static int
1169 dissect_cms_KeyAgreeRecipientInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1170   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1171                                    KeyAgreeRecipientInfo_sequence, hf_index, ett_cms_KeyAgreeRecipientInfo);
1172
1173   return offset;
1174 }
1175 static int dissect_kari_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1176   return dissect_cms_KeyAgreeRecipientInfo(TRUE, tvb, offset, pinfo, tree, hf_cms_kari);
1177 }
1178
1179
1180
1181 static int
1182 dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1183   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1184                                        NULL);
1185
1186   return offset;
1187 }
1188 static int dissect_keyIdentifier(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1189   return dissect_cms_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_cms_keyIdentifier);
1190 }
1191
1192
1193 static const ber_sequence_t KEKIdentifier_sequence[] = {
1194   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_keyIdentifier },
1195   { BER_CLASS_UNI, BER_UNI_TAG_GeneralizedTime, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_date },
1196   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_other },
1197   { 0, 0, 0, NULL }
1198 };
1199
1200 static int
1201 dissect_cms_KEKIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1202   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1203                                    KEKIdentifier_sequence, hf_index, ett_cms_KEKIdentifier);
1204
1205   return offset;
1206 }
1207 static int dissect_kekid(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1208   return dissect_cms_KEKIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_kekid);
1209 }
1210
1211
1212 static const ber_sequence_t KEKRecipientInfo_sequence[] = {
1213   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1214   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_kekid },
1215   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_keyEncryptionAlgorithm },
1216   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_encryptedKey },
1217   { 0, 0, 0, NULL }
1218 };
1219
1220 static int
1221 dissect_cms_KEKRecipientInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1222   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1223                                    KEKRecipientInfo_sequence, hf_index, ett_cms_KEKRecipientInfo);
1224
1225   return offset;
1226 }
1227 static int dissect_kekri_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1228   return dissect_cms_KEKRecipientInfo(TRUE, tvb, offset, pinfo, tree, hf_cms_kekri);
1229 }
1230
1231
1232 static const value_string cms_RecipientInfo_vals[] = {
1233   {   0, "ktri" },
1234   {   1, "kari" },
1235   {   2, "kekri" },
1236   { 0, NULL }
1237 };
1238
1239 static const ber_choice_t RecipientInfo_choice[] = {
1240   {   0, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ktri },
1241   {   1, BER_CLASS_CON, 1, 0, dissect_kari_impl },
1242   {   2, BER_CLASS_CON, 2, 0, dissect_kekri_impl },
1243   { 0, 0, 0, 0, NULL }
1244 };
1245
1246 static int
1247 dissect_cms_RecipientInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1248   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1249                                  RecipientInfo_choice, hf_index, ett_cms_RecipientInfo,
1250                                  NULL);
1251
1252   return offset;
1253 }
1254 static int dissect_RecipientInfos_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1255   return dissect_cms_RecipientInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_RecipientInfos_item);
1256 }
1257
1258
1259 static const ber_sequence_t RecipientInfos_set_of[1] = {
1260   { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_RecipientInfos_item },
1261 };
1262
1263 static int
1264 dissect_cms_RecipientInfos(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1265   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
1266                                  RecipientInfos_set_of, hf_index, ett_cms_RecipientInfos);
1267
1268   return offset;
1269 }
1270 static int dissect_recipientInfos(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1271   return dissect_cms_RecipientInfos(FALSE, tvb, offset, pinfo, tree, hf_cms_recipientInfos);
1272 }
1273
1274
1275
1276 static int
1277 dissect_cms_ContentEncryptionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1278   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1279
1280   return offset;
1281 }
1282 static int dissect_contentEncryptionAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1283   return dissect_cms_ContentEncryptionAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cms_contentEncryptionAlgorithm);
1284 }
1285
1286
1287
1288 static int
1289 dissect_cms_EncryptedContent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1290   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1291                                        NULL);
1292
1293   return offset;
1294 }
1295 static int dissect_encryptedContent_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1296   return dissect_cms_EncryptedContent(TRUE, tvb, offset, pinfo, tree, hf_cms_encryptedContent);
1297 }
1298
1299
1300 static const ber_sequence_t EncryptedContentInfo_sequence[] = {
1301   { BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_encryptedContentType },
1302   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_contentEncryptionAlgorithm },
1303   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_encryptedContent_impl },
1304   { 0, 0, 0, NULL }
1305 };
1306
1307 static int
1308 dissect_cms_EncryptedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1309   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1310                                    EncryptedContentInfo_sequence, hf_index, ett_cms_EncryptedContentInfo);
1311
1312   return offset;
1313 }
1314 static int dissect_encryptedContentInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1315   return dissect_cms_EncryptedContentInfo(FALSE, tvb, offset, pinfo, tree, hf_cms_encryptedContentInfo);
1316 }
1317
1318
1319 static const ber_sequence_t UnprotectedAttributes_set_of[1] = {
1320   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_UnprotectedAttributes_item },
1321 };
1322
1323 static int
1324 dissect_cms_UnprotectedAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1325   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
1326                                  UnprotectedAttributes_set_of, hf_index, ett_cms_UnprotectedAttributes);
1327
1328   return offset;
1329 }
1330 static int dissect_unprotectedAttrs_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1331   return dissect_cms_UnprotectedAttributes(TRUE, tvb, offset, pinfo, tree, hf_cms_unprotectedAttrs);
1332 }
1333
1334
1335 static const ber_sequence_t EnvelopedData_sequence[] = {
1336   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1337   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_originatorInfo_impl },
1338   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_recipientInfos },
1339   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_encryptedContentInfo },
1340   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_unprotectedAttrs_impl },
1341   { 0, 0, 0, NULL }
1342 };
1343
1344 int
1345 dissect_cms_EnvelopedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1346   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1347                                    EnvelopedData_sequence, hf_index, ett_cms_EnvelopedData);
1348
1349   return offset;
1350 }
1351
1352
1353
1354 static int
1355 dissect_cms_Digest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1356   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1357                                        NULL);
1358
1359   return offset;
1360 }
1361 static int dissect_digest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1362   return dissect_cms_Digest(FALSE, tvb, offset, pinfo, tree, hf_cms_digest);
1363 }
1364
1365
1366 static const ber_sequence_t DigestedData_sequence[] = {
1367   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1368   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_digestAlgorithm },
1369   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_encapContentInfo },
1370   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_digest },
1371   { 0, 0, 0, NULL }
1372 };
1373
1374 static int
1375 dissect_cms_DigestedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1376   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1377                                    DigestedData_sequence, hf_index, ett_cms_DigestedData);
1378
1379   return offset;
1380 }
1381
1382
1383 static const ber_sequence_t EncryptedData_sequence[] = {
1384   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1385   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_encryptedContentInfo },
1386   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_unprotectedAttrs_impl },
1387   { 0, 0, 0, NULL }
1388 };
1389
1390 static int
1391 dissect_cms_EncryptedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1392   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1393                                    EncryptedData_sequence, hf_index, ett_cms_EncryptedData);
1394
1395   return offset;
1396 }
1397
1398
1399
1400 static int
1401 dissect_cms_MessageAuthenticationCodeAlgorithm(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1402   offset = dissect_x509af_AlgorithmIdentifier(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1403
1404   return offset;
1405 }
1406 static int dissect_macAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1407   return dissect_cms_MessageAuthenticationCodeAlgorithm(FALSE, tvb, offset, pinfo, tree, hf_cms_macAlgorithm);
1408 }
1409
1410
1411 static const ber_sequence_t AuthAttributes_set_of[1] = {
1412   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_AuthAttributes_item },
1413 };
1414
1415 static int
1416 dissect_cms_AuthAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1417   offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
1418                                  AuthAttributes_set_of, hf_index, ett_cms_AuthAttributes);
1419
1420   return offset;
1421 }
1422 static int dissect_authenticatedAttributes_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1423   return dissect_cms_AuthAttributes(TRUE, tvb, offset, pinfo, tree, hf_cms_authenticatedAttributes);
1424 }
1425
1426
1427
1428 static int
1429 dissect_cms_MessageAuthenticationCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1430   offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1431                                        NULL);
1432
1433   return offset;
1434 }
1435 static int dissect_mac(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1436   return dissect_cms_MessageAuthenticationCode(FALSE, tvb, offset, pinfo, tree, hf_cms_mac);
1437 }
1438
1439
1440 static const ber_sequence_t AuthenticatedData_sequence[] = {
1441   { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
1442   { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_originatorInfo_impl },
1443   { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_recipientInfos },
1444   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_macAlgorithm },
1445   { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_digestAlgorithm_impl },
1446   { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_encapContentInfo },
1447   { BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_authenticatedAttributes_impl },
1448   { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_mac },
1449   { BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_unauthenticatedAttributes_impl },
1450   { 0, 0, 0, NULL }
1451 };
1452
1453 static int
1454 dissect_cms_AuthenticatedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1455   offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1456                                    AuthenticatedData_sequence, hf_index, ett_cms_AuthenticatedData);
1457
1458   return offset;
1459 }
1460
1461
1462
1463 static int
1464 dissect_cms_MessageDigest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1465   proto_item *pi;
1466   int old_offset = offset;
1467
1468     offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1469                                        NULL);
1470
1471  
1472   pi = get_ber_last_created_item();
1473
1474   /* move past TLV */
1475   old_offset = get_ber_identifier(tvb, old_offset, NULL, NULL, NULL);
1476   old_offset = get_ber_length(tree, tvb, old_offset, NULL, NULL);
1477
1478   if(content_tvb) 
1479     cms_verify_msg_digest(pi, content_tvb, x509af_get_last_algorithm_id(), tvb, old_offset);
1480
1481
1482   return offset;
1483 }
1484
1485
1486
1487 static int
1488 dissect_cms_UTCTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1489   offset = dissect_ber_restricted_string(implicit_tag, BER_UNI_TAG_UTCTime,
1490                                             pinfo, tree, tvb, offset, hf_index,
1491                                             NULL);
1492
1493   return offset;
1494 }
1495 static int dissect_utcTime(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1496   return dissect_cms_UTCTime(FALSE, tvb, offset, pinfo, tree, hf_cms_utcTime);
1497 }
1498
1499
1500 static const value_string cms_Time_vals[] = {
1501   {   0, "utcTime" },
1502   {   1, "generalTime" },
1503   { 0, NULL }
1504 };
1505
1506 static const ber_choice_t Time_choice[] = {
1507   {   0, BER_CLASS_UNI, BER_UNI_TAG_UTCTime, BER_FLAGS_NOOWNTAG, dissect_utcTime },
1508   {   1, BER_CLASS_UNI, BER_UNI_TAG_GeneralizedTime, BER_FLAGS_NOOWNTAG, dissect_generalTime },
1509   { 0, 0, 0, 0, NULL }
1510 };
1511
1512 static int
1513 dissect_cms_Time(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1514   offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1515                                  Time_choice, hf_index, ett_cms_Time,
1516                                  NULL);
1517
1518   return offset;
1519 }
1520
1521
1522
1523 static int
1524 dissect_cms_SigningTime(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1525   offset = dissect_cms_Time(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1526
1527   return offset;
1528 }
1529
1530
1531
1532 int
1533 dissect_cms_Countersignature(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1534   offset = dissect_cms_SignerInfo(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1535
1536   return offset;
1537 }
1538
1539 /*--- PDUs ---*/
1540
1541 static void dissect_ContentInfo_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1542   dissect_cms_ContentInfo(FALSE, tvb, 0, pinfo, tree, hf_cms_ContentInfo_PDU);
1543 }
1544 static void dissect_ContentType_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1545   dissect_cms_ContentType(FALSE, tvb, 0, pinfo, tree, hf_cms_ContentType_PDU);
1546 }
1547 static void dissect_SignedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1548   dissect_cms_SignedData(FALSE, tvb, 0, pinfo, tree, hf_cms_SignedData_PDU);
1549 }
1550 static void dissect_EnvelopedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1551   dissect_cms_EnvelopedData(FALSE, tvb, 0, pinfo, tree, hf_cms_EnvelopedData_PDU);
1552 }
1553 static void dissect_DigestedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1554   dissect_cms_DigestedData(FALSE, tvb, 0, pinfo, tree, hf_cms_DigestedData_PDU);
1555 }
1556 static void dissect_EncryptedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1557   dissect_cms_EncryptedData(FALSE, tvb, 0, pinfo, tree, hf_cms_EncryptedData_PDU);
1558 }
1559 static void dissect_AuthenticatedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1560   dissect_cms_AuthenticatedData(FALSE, tvb, 0, pinfo, tree, hf_cms_AuthenticatedData_PDU);
1561 }
1562 static void dissect_MessageDigest_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1563   dissect_cms_MessageDigest(FALSE, tvb, 0, pinfo, tree, hf_cms_MessageDigest_PDU);
1564 }
1565 static void dissect_SigningTime_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1566   dissect_cms_SigningTime(FALSE, tvb, 0, pinfo, tree, hf_cms_SigningTime_PDU);
1567 }
1568 static void dissect_Countersignature_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1569   dissect_cms_Countersignature(FALSE, tvb, 0, pinfo, tree, hf_cms_Countersignature_PDU);
1570 }
1571
1572
1573 /*--- End of included file: packet-cms-fn.c ---*/
1574
1575
1576 /*--- proto_register_cms ----------------------------------------------*/
1577 void proto_register_cms(void) {
1578
1579   /* List of fields */
1580   static hf_register_info hf[] = {
1581     { &hf_cms_ci_contentType,
1582       { "contentType", "cms.contentInfo.contentType",
1583         FT_STRING, BASE_NONE, NULL, 0,
1584         "ContentType", HFILL }},
1585
1586 /*--- Included file: packet-cms-hfarr.c ---*/
1587
1588     { &hf_cms_ContentInfo_PDU,
1589       { "ContentInfo", "cms.ContentInfo",
1590         FT_NONE, BASE_NONE, NULL, 0,
1591         "ContentInfo", HFILL }},
1592     { &hf_cms_ContentType_PDU,
1593       { "ContentType", "cms.ContentType",
1594         FT_STRING, BASE_NONE, NULL, 0,
1595         "ContentType", HFILL }},
1596     { &hf_cms_SignedData_PDU,
1597       { "SignedData", "cms.SignedData",
1598         FT_NONE, BASE_NONE, NULL, 0,
1599         "SignedData", HFILL }},
1600     { &hf_cms_EnvelopedData_PDU,
1601       { "EnvelopedData", "cms.EnvelopedData",
1602         FT_NONE, BASE_NONE, NULL, 0,
1603         "EnvelopedData", HFILL }},
1604     { &hf_cms_DigestedData_PDU,
1605       { "DigestedData", "cms.DigestedData",
1606         FT_NONE, BASE_NONE, NULL, 0,
1607         "DigestedData", HFILL }},
1608     { &hf_cms_EncryptedData_PDU,
1609       { "EncryptedData", "cms.EncryptedData",
1610         FT_NONE, BASE_NONE, NULL, 0,
1611         "EncryptedData", HFILL }},
1612     { &hf_cms_AuthenticatedData_PDU,
1613       { "AuthenticatedData", "cms.AuthenticatedData",
1614         FT_NONE, BASE_NONE, NULL, 0,
1615         "AuthenticatedData", HFILL }},
1616     { &hf_cms_MessageDigest_PDU,
1617       { "MessageDigest", "cms.MessageDigest",
1618         FT_BYTES, BASE_HEX, NULL, 0,
1619         "MessageDigest", HFILL }},
1620     { &hf_cms_SigningTime_PDU,
1621       { "SigningTime", "cms.SigningTime",
1622         FT_UINT32, BASE_DEC, VALS(x509af_Time_vals), 0,
1623         "SigningTime", HFILL }},
1624     { &hf_cms_Countersignature_PDU,
1625       { "Countersignature", "cms.Countersignature",
1626         FT_NONE, BASE_NONE, NULL, 0,
1627         "Countersignature", HFILL }},
1628     { &hf_cms_contentType,
1629       { "contentType", "cms.contentType",
1630         FT_STRING, BASE_NONE, NULL, 0,
1631         "ContentInfo/contentType", HFILL }},
1632     { &hf_cms_content,
1633       { "content", "cms.content",
1634         FT_NONE, BASE_NONE, NULL, 0,
1635         "ContentInfo/content", HFILL }},
1636     { &hf_cms_version,
1637       { "version", "cms.version",
1638         FT_INT32, BASE_DEC, VALS(cms_CMSVersion_vals), 0,
1639         "", HFILL }},
1640     { &hf_cms_digestAlgorithms,
1641       { "digestAlgorithms", "cms.digestAlgorithms",
1642         FT_UINT32, BASE_DEC, NULL, 0,
1643         "SignedData/digestAlgorithms", HFILL }},
1644     { &hf_cms_encapContentInfo,
1645       { "encapContentInfo", "cms.encapContentInfo",
1646         FT_NONE, BASE_NONE, NULL, 0,
1647         "", HFILL }},
1648     { &hf_cms_certificates,
1649       { "certificates", "cms.certificates",
1650         FT_UINT32, BASE_DEC, NULL, 0,
1651         "SignedData/certificates", HFILL }},
1652     { &hf_cms_crls,
1653       { "crls", "cms.crls",
1654         FT_UINT32, BASE_DEC, NULL, 0,
1655         "", HFILL }},
1656     { &hf_cms_signerInfos,
1657       { "signerInfos", "cms.signerInfos",
1658         FT_UINT32, BASE_DEC, NULL, 0,
1659         "SignedData/signerInfos", HFILL }},
1660     { &hf_cms_DigestAlgorithmIdentifiers_item,
1661       { "Item", "cms.DigestAlgorithmIdentifiers_item",
1662         FT_NONE, BASE_NONE, NULL, 0,
1663         "DigestAlgorithmIdentifiers/_item", HFILL }},
1664     { &hf_cms_SignerInfos_item,
1665       { "Item", "cms.SignerInfos_item",
1666         FT_NONE, BASE_NONE, NULL, 0,
1667         "SignerInfos/_item", HFILL }},
1668     { &hf_cms_eContentType,
1669       { "eContentType", "cms.eContentType",
1670         FT_STRING, BASE_NONE, NULL, 0,
1671         "EncapsulatedContentInfo/eContentType", HFILL }},
1672     { &hf_cms_eContent,
1673       { "eContent", "cms.eContent",
1674         FT_BYTES, BASE_HEX, NULL, 0,
1675         "EncapsulatedContentInfo/eContent", HFILL }},
1676     { &hf_cms_sid,
1677       { "sid", "cms.sid",
1678         FT_UINT32, BASE_DEC, VALS(cms_SignerIdentifier_vals), 0,
1679         "SignerInfo/sid", HFILL }},
1680     { &hf_cms_digestAlgorithm,
1681       { "digestAlgorithm", "cms.digestAlgorithm",
1682         FT_NONE, BASE_NONE, NULL, 0,
1683         "", HFILL }},
1684     { &hf_cms_signedAttrs,
1685       { "signedAttrs", "cms.signedAttrs",
1686         FT_UINT32, BASE_DEC, NULL, 0,
1687         "SignerInfo/signedAttrs", HFILL }},
1688     { &hf_cms_signatureAlgorithm,
1689       { "signatureAlgorithm", "cms.signatureAlgorithm",
1690         FT_NONE, BASE_NONE, NULL, 0,
1691         "", HFILL }},
1692     { &hf_cms_signatureValue,
1693       { "signature", "cms.signature",
1694         FT_BYTES, BASE_HEX, NULL, 0,
1695         "SignerInfo/signature", HFILL }},
1696     { &hf_cms_unsignedAttrs,
1697       { "unsignedAttrs", "cms.unsignedAttrs",
1698         FT_UINT32, BASE_DEC, NULL, 0,
1699         "SignerInfo/unsignedAttrs", HFILL }},
1700     { &hf_cms_issuerAndSerialNumber,
1701       { "issuerAndSerialNumber", "cms.issuerAndSerialNumber",
1702         FT_NONE, BASE_NONE, NULL, 0,
1703         "", HFILL }},
1704     { &hf_cms_subjectKeyIdentifier,
1705       { "subjectKeyIdentifier", "cms.subjectKeyIdentifier",
1706         FT_BYTES, BASE_HEX, NULL, 0,
1707         "", HFILL }},
1708     { &hf_cms_SignedAttributes_item,
1709       { "Item", "cms.SignedAttributes_item",
1710         FT_NONE, BASE_NONE, NULL, 0,
1711         "SignedAttributes/_item", HFILL }},
1712     { &hf_cms_UnsignedAttributes_item,
1713       { "Item", "cms.UnsignedAttributes_item",
1714         FT_NONE, BASE_NONE, NULL, 0,
1715         "UnsignedAttributes/_item", HFILL }},
1716     { &hf_cms_attrType,
1717       { "attrType", "cms.attrType",
1718         FT_STRING, BASE_NONE, NULL, 0,
1719         "Attribute/attrType", HFILL }},
1720     { &hf_cms_attrValues,
1721       { "attrValues", "cms.attrValues",
1722         FT_UINT32, BASE_DEC, NULL, 0,
1723         "Attribute/attrValues", HFILL }},
1724     { &hf_cms_attrValues_item,
1725       { "Item", "cms.attrValues_item",
1726         FT_NONE, BASE_NONE, NULL, 0,
1727         "Attribute/attrValues/_item", HFILL }},
1728     { &hf_cms_originatorInfo,
1729       { "originatorInfo", "cms.originatorInfo",
1730         FT_NONE, BASE_NONE, NULL, 0,
1731         "", HFILL }},
1732     { &hf_cms_recipientInfos,
1733       { "recipientInfos", "cms.recipientInfos",
1734         FT_UINT32, BASE_DEC, NULL, 0,
1735         "", HFILL }},
1736     { &hf_cms_encryptedContentInfo,
1737       { "encryptedContentInfo", "cms.encryptedContentInfo",
1738         FT_NONE, BASE_NONE, NULL, 0,
1739         "", HFILL }},
1740     { &hf_cms_unprotectedAttrs,
1741       { "unprotectedAttrs", "cms.unprotectedAttrs",
1742         FT_UINT32, BASE_DEC, NULL, 0,
1743         "", HFILL }},
1744     { &hf_cms_certs,
1745       { "certs", "cms.certs",
1746         FT_UINT32, BASE_DEC, NULL, 0,
1747         "OriginatorInfo/certs", HFILL }},
1748     { &hf_cms_RecipientInfos_item,
1749       { "Item", "cms.RecipientInfos_item",
1750         FT_UINT32, BASE_DEC, VALS(cms_RecipientInfo_vals), 0,
1751         "RecipientInfos/_item", HFILL }},
1752     { &hf_cms_encryptedContentType,
1753       { "contentType", "cms.contentType",
1754         FT_STRING, BASE_NONE, NULL, 0,
1755         "EncryptedContentInfo/contentType", HFILL }},
1756     { &hf_cms_contentEncryptionAlgorithm,
1757       { "contentEncryptionAlgorithm", "cms.contentEncryptionAlgorithm",
1758         FT_NONE, BASE_NONE, NULL, 0,
1759         "EncryptedContentInfo/contentEncryptionAlgorithm", HFILL }},
1760     { &hf_cms_encryptedContent,
1761       { "encryptedContent", "cms.encryptedContent",
1762         FT_BYTES, BASE_HEX, NULL, 0,
1763         "EncryptedContentInfo/encryptedContent", HFILL }},
1764     { &hf_cms_UnprotectedAttributes_item,
1765       { "Item", "cms.UnprotectedAttributes_item",
1766         FT_NONE, BASE_NONE, NULL, 0,
1767         "UnprotectedAttributes/_item", HFILL }},
1768     { &hf_cms_ktri,
1769       { "ktri", "cms.ktri",
1770         FT_NONE, BASE_NONE, NULL, 0,
1771         "RecipientInfo/ktri", HFILL }},
1772     { &hf_cms_kari,
1773       { "kari", "cms.kari",
1774         FT_NONE, BASE_NONE, NULL, 0,
1775         "RecipientInfo/kari", HFILL }},
1776     { &hf_cms_kekri,
1777       { "kekri", "cms.kekri",
1778         FT_NONE, BASE_NONE, NULL, 0,
1779         "RecipientInfo/kekri", HFILL }},
1780     { &hf_cms_rid,
1781       { "rid", "cms.rid",
1782         FT_UINT32, BASE_DEC, VALS(cms_RecipientIdentifier_vals), 0,
1783         "KeyTransRecipientInfo/rid", HFILL }},
1784     { &hf_cms_keyEncryptionAlgorithm,
1785       { "keyEncryptionAlgorithm", "cms.keyEncryptionAlgorithm",
1786         FT_NONE, BASE_NONE, NULL, 0,
1787         "", HFILL }},
1788     { &hf_cms_encryptedKey,
1789       { "encryptedKey", "cms.encryptedKey",
1790         FT_BYTES, BASE_HEX, NULL, 0,
1791         "", HFILL }},
1792     { &hf_cms_originator,
1793       { "originator", "cms.originator",
1794         FT_UINT32, BASE_DEC, VALS(cms_OriginatorIdentifierOrKey_vals), 0,
1795         "KeyAgreeRecipientInfo/originator", HFILL }},
1796     { &hf_cms_ukm,
1797       { "ukm", "cms.ukm",
1798         FT_BYTES, BASE_HEX, NULL, 0,
1799         "KeyAgreeRecipientInfo/ukm", HFILL }},
1800     { &hf_cms_recipientEncryptedKeys,
1801       { "recipientEncryptedKeys", "cms.recipientEncryptedKeys",
1802         FT_UINT32, BASE_DEC, NULL, 0,
1803         "KeyAgreeRecipientInfo/recipientEncryptedKeys", HFILL }},
1804     { &hf_cms_originatorKey,
1805       { "originatorKey", "cms.originatorKey",
1806         FT_NONE, BASE_NONE, NULL, 0,
1807         "OriginatorIdentifierOrKey/originatorKey", HFILL }},
1808     { &hf_cms_algorithm,
1809       { "algorithm", "cms.algorithm",
1810         FT_NONE, BASE_NONE, NULL, 0,
1811         "OriginatorPublicKey/algorithm", HFILL }},
1812     { &hf_cms_publicKey,
1813       { "publicKey", "cms.publicKey",
1814         FT_BYTES, BASE_HEX, NULL, 0,
1815         "OriginatorPublicKey/publicKey", HFILL }},
1816     { &hf_cms_RecipientEncryptedKeys_item,
1817       { "Item", "cms.RecipientEncryptedKeys_item",
1818         FT_NONE, BASE_NONE, NULL, 0,
1819         "RecipientEncryptedKeys/_item", HFILL }},
1820     { &hf_cms_rekRid,
1821       { "rid", "cms.rid",
1822         FT_UINT32, BASE_DEC, VALS(cms_KeyAgreeRecipientIdentifier_vals), 0,
1823         "RecipientEncryptedKey/rid", HFILL }},
1824     { &hf_cms_rKeyId,
1825       { "rKeyId", "cms.rKeyId",
1826         FT_NONE, BASE_NONE, NULL, 0,
1827         "KeyAgreeRecipientIdentifier/rKeyId", HFILL }},
1828     { &hf_cms_date,
1829       { "date", "cms.date",
1830         FT_STRING, BASE_NONE, NULL, 0,
1831         "", HFILL }},
1832     { &hf_cms_other,
1833       { "other", "cms.other",
1834         FT_NONE, BASE_NONE, NULL, 0,
1835         "", HFILL }},
1836     { &hf_cms_kekid,
1837       { "kekid", "cms.kekid",
1838         FT_NONE, BASE_NONE, NULL, 0,
1839         "KEKRecipientInfo/kekid", HFILL }},
1840     { &hf_cms_keyIdentifier,
1841       { "keyIdentifier", "cms.keyIdentifier",
1842         FT_BYTES, BASE_HEX, NULL, 0,
1843         "KEKIdentifier/keyIdentifier", HFILL }},
1844     { &hf_cms_digest,
1845       { "digest", "cms.digest",
1846         FT_BYTES, BASE_HEX, NULL, 0,
1847         "DigestedData/digest", HFILL }},
1848     { &hf_cms_macAlgorithm,
1849       { "macAlgorithm", "cms.macAlgorithm",
1850         FT_NONE, BASE_NONE, NULL, 0,
1851         "AuthenticatedData/macAlgorithm", HFILL }},
1852     { &hf_cms_authenticatedAttributes,
1853       { "authenticatedAttributes", "cms.authenticatedAttributes",
1854         FT_UINT32, BASE_DEC, NULL, 0,
1855         "AuthenticatedData/authenticatedAttributes", HFILL }},
1856     { &hf_cms_mac,
1857       { "mac", "cms.mac",
1858         FT_BYTES, BASE_HEX, NULL, 0,
1859         "AuthenticatedData/mac", HFILL }},
1860     { &hf_cms_unauthenticatedAttributes,
1861       { "unauthenticatedAttributes", "cms.unauthenticatedAttributes",
1862         FT_UINT32, BASE_DEC, NULL, 0,
1863         "AuthenticatedData/unauthenticatedAttributes", HFILL }},
1864     { &hf_cms_AuthAttributes_item,
1865       { "Item", "cms.AuthAttributes_item",
1866         FT_NONE, BASE_NONE, NULL, 0,
1867         "AuthAttributes/_item", HFILL }},
1868     { &hf_cms_UnauthAttributes_item,
1869       { "Item", "cms.UnauthAttributes_item",
1870         FT_NONE, BASE_NONE, NULL, 0,
1871         "UnauthAttributes/_item", HFILL }},
1872     { &hf_cms_CertificateRevocationLists_item,
1873       { "Item", "cms.CertificateRevocationLists_item",
1874         FT_NONE, BASE_NONE, NULL, 0,
1875         "CertificateRevocationLists/_item", HFILL }},
1876     { &hf_cms_certificate,
1877       { "certificate", "cms.certificate",
1878         FT_NONE, BASE_NONE, NULL, 0,
1879         "", HFILL }},
1880     { &hf_cms_extendedCertificate,
1881       { "extendedCertificate", "cms.extendedCertificate",
1882         FT_NONE, BASE_NONE, NULL, 0,
1883         "CertificateChoices/extendedCertificate", HFILL }},
1884     { &hf_cms_attrCert,
1885       { "attrCert", "cms.attrCert",
1886         FT_NONE, BASE_NONE, NULL, 0,
1887         "CertificateChoices/attrCert", HFILL }},
1888     { &hf_cms_CertificateSet_item,
1889       { "Item", "cms.CertificateSet_item",
1890         FT_UINT32, BASE_DEC, VALS(cms_CertificateChoices_vals), 0,
1891         "CertificateSet/_item", HFILL }},
1892     { &hf_cms_issuer,
1893       { "issuer", "cms.issuer",
1894         FT_UINT32, BASE_DEC, VALS(x509if_Name_vals), 0,
1895         "IssuerAndSerialNumber/issuer", HFILL }},
1896     { &hf_cms_serialNumber,
1897       { "serialNumber", "cms.serialNumber",
1898         FT_INT32, BASE_DEC, NULL, 0,
1899         "IssuerAndSerialNumber/serialNumber", HFILL }},
1900     { &hf_cms_keyAttrId,
1901       { "keyAttrId", "cms.keyAttrId",
1902         FT_STRING, BASE_NONE, NULL, 0,
1903         "OtherKeyAttribute/keyAttrId", HFILL }},
1904     { &hf_cms_keyAttr,
1905       { "keyAttr", "cms.keyAttr",
1906         FT_NONE, BASE_NONE, NULL, 0,
1907         "OtherKeyAttribute/keyAttr", HFILL }},
1908     { &hf_cms_utcTime,
1909       { "utcTime", "cms.utcTime",
1910         FT_STRING, BASE_NONE, NULL, 0,
1911         "Time/utcTime", HFILL }},
1912     { &hf_cms_generalTime,
1913       { "generalTime", "cms.generalTime",
1914         FT_STRING, BASE_NONE, NULL, 0,
1915         "Time/generalTime", HFILL }},
1916     { &hf_cms_extendedCertificateInfo,
1917       { "extendedCertificateInfo", "cms.extendedCertificateInfo",
1918         FT_NONE, BASE_NONE, NULL, 0,
1919         "ExtendedCertificate/extendedCertificateInfo", HFILL }},
1920     { &hf_cms_signature,
1921       { "signature", "cms.signature",
1922         FT_BYTES, BASE_HEX, NULL, 0,
1923         "ExtendedCertificate/signature", HFILL }},
1924     { &hf_cms_attributes,
1925       { "attributes", "cms.attributes",
1926         FT_UINT32, BASE_DEC, NULL, 0,
1927         "ExtendedCertificateInfo/attributes", HFILL }},
1928
1929 /*--- End of included file: packet-cms-hfarr.c ---*/
1930
1931   };
1932
1933   /* List of subtrees */
1934   static gint *ett[] = {
1935
1936 /*--- Included file: packet-cms-ettarr.c ---*/
1937
1938     &ett_cms_ContentInfo,
1939     &ett_cms_SignedData,
1940     &ett_cms_DigestAlgorithmIdentifiers,
1941     &ett_cms_SignerInfos,
1942     &ett_cms_EncapsulatedContentInfo,
1943     &ett_cms_SignerInfo,
1944     &ett_cms_SignerIdentifier,
1945     &ett_cms_SignedAttributes,
1946     &ett_cms_UnsignedAttributes,
1947     &ett_cms_Attribute,
1948     &ett_cms_SET_OF_AttributeValue,
1949     &ett_cms_EnvelopedData,
1950     &ett_cms_OriginatorInfo,
1951     &ett_cms_RecipientInfos,
1952     &ett_cms_EncryptedContentInfo,
1953     &ett_cms_UnprotectedAttributes,
1954     &ett_cms_RecipientInfo,
1955     &ett_cms_KeyTransRecipientInfo,
1956     &ett_cms_RecipientIdentifier,
1957     &ett_cms_KeyAgreeRecipientInfo,
1958     &ett_cms_OriginatorIdentifierOrKey,
1959     &ett_cms_OriginatorPublicKey,
1960     &ett_cms_RecipientEncryptedKeys,
1961     &ett_cms_RecipientEncryptedKey,
1962     &ett_cms_KeyAgreeRecipientIdentifier,
1963     &ett_cms_RecipientKeyIdentifier,
1964     &ett_cms_KEKRecipientInfo,
1965     &ett_cms_KEKIdentifier,
1966     &ett_cms_DigestedData,
1967     &ett_cms_EncryptedData,
1968     &ett_cms_AuthenticatedData,
1969     &ett_cms_AuthAttributes,
1970     &ett_cms_UnauthAttributes,
1971     &ett_cms_CertificateRevocationLists,
1972     &ett_cms_CertificateChoices,
1973     &ett_cms_CertificateSet,
1974     &ett_cms_IssuerAndSerialNumber,
1975     &ett_cms_OtherKeyAttribute,
1976     &ett_cms_Time,
1977     &ett_cms_ExtendedCertificate,
1978     &ett_cms_ExtendedCertificateInfo,
1979
1980 /*--- End of included file: packet-cms-ettarr.c ---*/
1981
1982   };
1983
1984   /* Register protocol */
1985   proto_cms = proto_register_protocol(PNAME, PSNAME, PFNAME);
1986
1987   /* Register fields and subtrees */
1988   proto_register_field_array(proto_cms, hf, array_length(hf));
1989   proto_register_subtree_array(ett, array_length(ett));
1990
1991 }
1992
1993
1994 /*--- proto_reg_handoff_cms -------------------------------------------*/
1995 void proto_reg_handoff_cms(void) {
1996
1997 /*--- Included file: packet-cms-dis-tab.c ---*/
1998
1999   register_ber_oid_dissector("1.2.840.113549.1.9.16.1.6", dissect_ContentInfo_PDU, proto_cms, "id-ct-contentInfo");
2000   register_ber_oid_dissector("1.2.840.113549.1.7.2", dissect_SignedData_PDU, proto_cms, "id-signedData");
2001   register_ber_oid_dissector("1.2.840.113549.1.7.3", dissect_EnvelopedData_PDU, proto_cms, "id-envelopedData");
2002   register_ber_oid_dissector("1.2.840.113549.1.7.5", dissect_DigestedData_PDU, proto_cms, "id-digestedData");
2003   register_ber_oid_dissector("1.2.840.113549.1.7.6", dissect_EncryptedData_PDU, proto_cms, "id-encryptedData");
2004   register_ber_oid_dissector("1.2.840.113549.1.9.16.1.2", dissect_AuthenticatedData_PDU, proto_cms, "id-ct-authenticatedData");
2005   register_ber_oid_dissector("1.2.840.113549.1.9.3", dissect_ContentType_PDU, proto_cms, "id-contentType");
2006   register_ber_oid_dissector("1.2.840.113549.1.9.4", dissect_MessageDigest_PDU, proto_cms, "id-messageDigest");
2007   register_ber_oid_dissector("1.2.840.113549.1.9.5", dissect_SigningTime_PDU, proto_cms, "id-signingTime");
2008   register_ber_oid_dissector("1.2.840.113549.1.9.6", dissect_Countersignature_PDU, proto_cms, "id-counterSignature");
2009
2010
2011 /*--- End of included file: packet-cms-dis-tab.c ---*/
2012
2013 }
2014