Move 3 ASN1 dissectors to 'clean' group; move 1 PIDL dissector to 'dirty' group.
[metze/wireshark/wip.git] / epan / dissectors / packet-pkcs12.c
1 /* Do not modify this file.                                                   */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
3 /* packet-pkcs12.c                                                            */
4 /* ../../tools/asn2wrs.py -b -p pkcs12 -c ./pkcs12.cnf -s ./packet-pkcs12-template -D . -O ../../epan/dissectors pkcs12.asn */
5
6 /* Input file: packet-pkcs12-template.c */
7
8 #line 1 "../../asn1/pkcs12/packet-pkcs12-template.c"
9 /* packet-pkcs12.c
10  * Routines for PKCS#12: Personal Information Exchange packet dissection
11  * Graeme Lunt 2006
12  *
13  * $Id$
14  *
15  * Wireshark - Network traffic analyzer
16  * By Gerald Combs <gerald@wireshark.org>
17  * Copyright 1998 Gerald Combs
18  *
19  * This program is free software; you can redistribute it and/or
20  * modify it under the terms of the GNU General Public License
21  * as published by the Free Software Foundation; either version 2
22  * of the License, or (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program; if not, write to the Free Software
31  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32  */
33
34 #include "config.h"
35
36 #include <glib.h>
37 #include <epan/packet.h>
38 #include <epan/oids.h>
39 #include <epan/asn1.h>
40 #include <epan/prefs.h>
41
42 #include "packet-ber.h"
43 #include "packet-pkcs12.h"
44 #include "packet-x509af.h"
45 #include "packet-x509if.h"
46 #include "packet-cms.h"
47
48 #ifdef HAVE_SYS_TYPES_H
49 #include <sys/types.h>
50 #endif
51
52 #ifdef HAVE_SYS_TIME_H
53 #include <sys/time.h>
54 #endif
55
56 #ifdef HAVE_LIBGCRYPT
57 #include <gcrypt.h>
58 #endif
59
60 #define PNAME  "PKCS#12: Personal Information Exchange"
61 #define PSNAME "PKCS12"
62 #define PFNAME "pkcs12"
63
64 #define PKCS12_PBE_ARCFOUR_SHA1_OID     "1.2.840.113549.1.12.1.1"
65 #define PKCS12_PBE_3DES_SHA1_OID        "1.2.840.113549.1.12.1.3"
66 #define PKCS12_PBE_RC2_40_SHA1_OID      "1.2.840.113549.1.12.1.6"
67
68 /* Initialize the protocol and registered fields */
69 static int proto_pkcs12 = -1;
70
71 static int hf_pkcs12_X509Certificate_PDU = -1;
72 static gint ett_decrypted_pbe = -1;
73
74 static const char *object_identifier_id = NULL;
75 static int iteration_count = 0;
76 static tvbuff_t *salt = NULL;
77 static const char *password = NULL;
78 static gboolean try_null_password = FALSE;
79
80 static void dissect_AuthenticatedSafe_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
81 static void dissect_SafeContents_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
82 static void dissect_PrivateKeyInfo_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
83
84
85 /*--- Included file: packet-pkcs12-hf.c ---*/
86 #line 1 "../../asn1/pkcs12/packet-pkcs12-hf.c"
87 static int hf_pkcs12_PFX_PDU = -1;                /* PFX */
88 static int hf_pkcs12_AuthenticatedSafe_PDU = -1;  /* AuthenticatedSafe */
89 static int hf_pkcs12_SafeContents_PDU = -1;       /* SafeContents */
90 static int hf_pkcs12_KeyBag_PDU = -1;             /* KeyBag */
91 static int hf_pkcs12_PKCS8ShroudedKeyBag_PDU = -1;  /* PKCS8ShroudedKeyBag */
92 static int hf_pkcs12_CertBag_PDU = -1;            /* CertBag */
93 static int hf_pkcs12_CRLBag_PDU = -1;             /* CRLBag */
94 static int hf_pkcs12_SecretBag_PDU = -1;          /* SecretBag */
95 static int hf_pkcs12_PrivateKeyInfo_PDU = -1;     /* PrivateKeyInfo */
96 static int hf_pkcs12_EncryptedPrivateKeyInfo_PDU = -1;  /* EncryptedPrivateKeyInfo */
97 static int hf_pkcs12_PBEParameter_PDU = -1;       /* PBEParameter */
98 static int hf_pkcs12_PBKDF2Params_PDU = -1;       /* PBKDF2Params */
99 static int hf_pkcs12_PBES2Params_PDU = -1;        /* PBES2Params */
100 static int hf_pkcs12_PBMAC1Params_PDU = -1;       /* PBMAC1Params */
101 static int hf_pkcs12_version = -1;                /* T_version */
102 static int hf_pkcs12_authSafe = -1;               /* ContentInfo */
103 static int hf_pkcs12_macData = -1;                /* MacData */
104 static int hf_pkcs12_mac = -1;                    /* DigestInfo */
105 static int hf_pkcs12_macSalt = -1;                /* OCTET_STRING */
106 static int hf_pkcs12_iterations = -1;             /* INTEGER */
107 static int hf_pkcs12_digestAlgorithm = -1;        /* DigestAlgorithmIdentifier */
108 static int hf_pkcs12_digest = -1;                 /* Digest */
109 static int hf_pkcs12_AuthenticatedSafe_item = -1;  /* ContentInfo */
110 static int hf_pkcs12_SafeContents_item = -1;      /* SafeBag */
111 static int hf_pkcs12_bagId = -1;                  /* T_bagId */
112 static int hf_pkcs12_bagValue = -1;               /* T_bagValue */
113 static int hf_pkcs12_bagAttributes = -1;          /* SET_OF_PKCS12Attribute */
114 static int hf_pkcs12_bagAttributes_item = -1;     /* PKCS12Attribute */
115 static int hf_pkcs12_certId = -1;                 /* T_certId */
116 static int hf_pkcs12_certValue = -1;              /* T_certValue */
117 static int hf_pkcs12_crlId = -1;                  /* T_crlId */
118 static int hf_pkcs12_crlValue = -1;               /* T_crlValue */
119 static int hf_pkcs12_secretTypeId = -1;           /* T_secretTypeId */
120 static int hf_pkcs12_secretValue = -1;            /* T_secretValue */
121 static int hf_pkcs12_attrId = -1;                 /* T_attrId */
122 static int hf_pkcs12_attrValues = -1;             /* T_attrValues */
123 static int hf_pkcs12_attrValues_item = -1;        /* T_attrValues_item */
124 static int hf_pkcs12_privateKeyVersion = -1;      /* Version */
125 static int hf_pkcs12_privateKeyAlgorithm = -1;    /* AlgorithmIdentifier */
126 static int hf_pkcs12_privateKey = -1;             /* PrivateKey */
127 static int hf_pkcs12_attributes = -1;             /* Attributes */
128 static int hf_pkcs12_Attributes_item = -1;        /* Attribute */
129 static int hf_pkcs12_encryptionAlgorithm = -1;    /* AlgorithmIdentifier */
130 static int hf_pkcs12_encryptedData = -1;          /* EncryptedData */
131 static int hf_pkcs12_salt = -1;                   /* OCTET_STRING */
132 static int hf_pkcs12_iterationCount = -1;         /* INTEGER */
133 static int hf_pkcs12_saltChoice = -1;             /* T_saltChoice */
134 static int hf_pkcs12_specified = -1;              /* OCTET_STRING */
135 static int hf_pkcs12_otherSource = -1;            /* AlgorithmIdentifier */
136 static int hf_pkcs12_keyLength = -1;              /* INTEGER_1_MAX */
137 static int hf_pkcs12_prf = -1;                    /* AlgorithmIdentifier */
138 static int hf_pkcs12_keyDerivationFunc = -1;      /* AlgorithmIdentifier */
139 static int hf_pkcs12_encryptionScheme = -1;       /* AlgorithmIdentifier */
140 static int hf_pkcs12_messageAuthScheme = -1;      /* AlgorithmIdentifier */
141
142 /*--- End of included file: packet-pkcs12-hf.c ---*/
143 #line 77 "../../asn1/pkcs12/packet-pkcs12-template.c"
144
145 /* Initialize the subtree pointers */
146
147 /*--- Included file: packet-pkcs12-ett.c ---*/
148 #line 1 "../../asn1/pkcs12/packet-pkcs12-ett.c"
149 static gint ett_pkcs12_PFX = -1;
150 static gint ett_pkcs12_MacData = -1;
151 static gint ett_pkcs12_DigestInfo = -1;
152 static gint ett_pkcs12_AuthenticatedSafe = -1;
153 static gint ett_pkcs12_SafeContents = -1;
154 static gint ett_pkcs12_SafeBag = -1;
155 static gint ett_pkcs12_SET_OF_PKCS12Attribute = -1;
156 static gint ett_pkcs12_CertBag = -1;
157 static gint ett_pkcs12_CRLBag = -1;
158 static gint ett_pkcs12_SecretBag = -1;
159 static gint ett_pkcs12_PKCS12Attribute = -1;
160 static gint ett_pkcs12_T_attrValues = -1;
161 static gint ett_pkcs12_PrivateKeyInfo = -1;
162 static gint ett_pkcs12_Attributes = -1;
163 static gint ett_pkcs12_EncryptedPrivateKeyInfo = -1;
164 static gint ett_pkcs12_PBEParameter = -1;
165 static gint ett_pkcs12_PBKDF2Params = -1;
166 static gint ett_pkcs12_T_saltChoice = -1;
167 static gint ett_pkcs12_PBES2Params = -1;
168 static gint ett_pkcs12_PBMAC1Params = -1;
169
170 /*--- End of included file: packet-pkcs12-ett.c ---*/
171 #line 80 "../../asn1/pkcs12/packet-pkcs12-template.c"
172
173 static void append_oid(proto_tree *tree, const char *oid)
174 {
175         const char *name = NULL;
176
177         name = oid_resolved_from_string(oid);
178         proto_item_append_text(tree, " (%s)", name ? name : oid);
179 }
180
181 #ifdef HAVE_LIBGCRYPT
182
183 static int
184 generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter,
185                        const char *pw, unsigned int req_keylen, char * keybuf)
186 {
187   int rc;
188   unsigned int i, j;
189   gcry_md_hd_t md;
190   gcry_mpi_t num_b1 = NULL;
191   size_t pwlen;
192   char hash[20], buf_b[64], buf_i[128], *p;
193   char *salt_p;
194   int salt_size;
195   size_t cur_keylen;
196   size_t n;
197   gcry_error_t  err;
198
199   cur_keylen = 0;
200
201   salt_size = tvb_length(salt_tvb);
202   salt_p = tvb_get_ephemeral_string(salt_tvb, 0, salt_size);
203
204   if (pw == NULL)
205     pwlen = 0;
206   else
207     pwlen = strlen (pw);
208
209   if (pwlen > 63 / 2)
210     {
211       return FALSE;
212     }
213
214   /* Store salt and password in BUF_I */
215   p = buf_i;
216   for (i = 0; i < 64; i++)
217     *p++ = salt_p[i % salt_size];
218   if (pw)
219     {
220       for (i = j = 0; i < 64; i += 2)
221         {
222           *p++ = 0;
223           *p++ = pw[j];
224           if (++j > pwlen)      /* Note, that we include the trailing zero */
225             j = 0;
226         }
227     }
228   else
229     memset (p, 0, 64);
230
231   for (;;){
232       err = gcry_md_open(&md, GCRY_MD_SHA1, 0);
233       if (gcry_err_code(err)) {
234                   return FALSE;
235           }
236       for (i = 0; i < 64; i++) {
237                   unsigned char lid = id & 0xFF;
238                   gcry_md_write (md, &lid, 1);
239           }
240
241           gcry_md_write(md, buf_i, pw ? 128 : 64);
242
243       gcry_md_final (md);
244       memcpy (hash, gcry_md_read (md, 0), 20);
245
246           gcry_md_close (md);
247
248           for (i = 1; i < iter; i++)
249                   gcry_md_hash_buffer (GCRY_MD_SHA1, hash, hash, 20);
250
251       for (i = 0; i < 20 && cur_keylen < req_keylen; i++)
252                   keybuf[cur_keylen++] = hash[i];
253
254           if (cur_keylen == req_keylen) {
255                   gcry_mpi_release (num_b1);
256                   return TRUE;          /* ready */
257           }
258
259       /* need more bytes. */
260       for (i = 0; i < 64; i++)
261                   buf_b[i] = hash[i % 20];
262
263           n = 64;
264
265           rc = gcry_mpi_scan (&num_b1, GCRYMPI_FMT_USG, buf_b, n, &n);
266
267           if (rc != 0) {
268                   return FALSE;
269           }
270
271           gcry_mpi_add_ui (num_b1, num_b1, 1);
272
273           for (i = 0; i < 128; i += 64) {
274                   gcry_mpi_t num_ij;
275
276                   n = 64;
277                   rc = gcry_mpi_scan (&num_ij, GCRYMPI_FMT_USG, buf_i + i, n, &n);
278
279                   if (rc != 0) {
280                           return FALSE;
281                   }
282
283                   gcry_mpi_add (num_ij, num_ij, num_b1);
284                   gcry_mpi_clear_highbit (num_ij, 64 * 8);
285
286                   n = 64;
287
288                   rc = gcry_mpi_print (GCRYMPI_FMT_USG, buf_i + i, n, &n, num_ij);
289                   if (rc != 0){
290                           return FALSE;
291                   }
292
293                   gcry_mpi_release (num_ij);
294           }
295   }
296 }
297
298 #endif
299
300 void PBE_reset_parameters(void)
301 {
302         iteration_count = 0;
303         salt = NULL;
304 }
305
306 int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted_tvb, asn1_ctx_t *actx, proto_item *item)
307 {
308 #ifdef HAVE_LIBGCRYPT
309         const char      *encryption_algorithm;
310         gcry_cipher_hd_t cipher;
311         gcry_error_t    err;
312         int             algo;
313         int             mode;
314         int             ivlen = 0;
315         int             keylen = 0;
316         int             datalen = 0;
317         char            *key = NULL;
318         char            *iv = NULL;
319         char            *clear_data = NULL;
320         tvbuff_t        *clear_tvb = NULL;
321         const gchar     *oidname;
322         GString         *name;
323         proto_tree      *tree;
324         char            byte;
325         gboolean        decrypt_ok = TRUE;
326
327         if(((password == NULL) || (*password == '\0')) && (try_null_password == FALSE)) {
328                 /* we are not configured to decrypt */
329                 return FALSE;
330         }
331
332         encryption_algorithm = x509af_get_last_algorithm_id();
333
334         /* these are the only encryption schemes we understand for now */
335         if(!strcmp(encryption_algorithm, PKCS12_PBE_3DES_SHA1_OID)) {
336                 ivlen = 8;
337                 keylen = 24;
338                 algo = GCRY_CIPHER_3DES;
339                 mode = GCRY_CIPHER_MODE_CBC;
340         } else if(!strcmp(encryption_algorithm, PKCS12_PBE_ARCFOUR_SHA1_OID)) {
341                 ivlen = 0;
342                 keylen = 16;
343                 algo = GCRY_CIPHER_ARCFOUR;
344                 mode = GCRY_CIPHER_MODE_NONE;
345         } else if(!strcmp(encryption_algorithm, PKCS12_PBE_RC2_40_SHA1_OID)) {
346                 ivlen = 8;
347                 keylen = 5;
348                 algo = GCRY_CIPHER_RFC2268_40;
349                 mode = GCRY_CIPHER_MODE_CBC;
350         } else {
351                 /* we don't know how to decrypt this */
352
353                 proto_item_append_text(item, " [Unsupported encryption algorithm]");
354                 return FALSE;
355         }
356
357         if((iteration_count == 0) || (salt == NULL)) {
358                 proto_item_append_text(item, " [Insufficient parameters]");
359                 return FALSE;
360         }
361
362         /* allocate buffers */
363         key = ep_alloc(keylen);
364
365         if(!generate_key_or_iv(1 /*LEY */, salt, iteration_count, password, keylen, key))
366                 return FALSE;
367
368         if(ivlen) {
369
370                 iv = ep_alloc(ivlen);
371
372                 if(!generate_key_or_iv(2 /* IV */, salt, iteration_count, password, ivlen, iv))
373                         return FALSE;
374         }
375
376         /* now try an internal function */
377         err = gcry_cipher_open(&cipher, algo, mode, 0);
378         if (gcry_err_code (err))
379                         return FALSE;
380
381         err = gcry_cipher_setkey (cipher, key, keylen);
382         if (gcry_err_code (err)) {
383                         gcry_cipher_close (cipher);
384                         return FALSE;
385         }
386
387         if(ivlen) {
388                   err = gcry_cipher_setiv (cipher, iv, ivlen);
389                   if (gcry_err_code (err)) {
390                           gcry_cipher_close (cipher);
391                           return FALSE;
392                   }
393         }
394
395         datalen = tvb_length(encrypted_tvb);
396         clear_data = g_malloc(datalen);
397
398         err = gcry_cipher_decrypt (cipher, clear_data, datalen, tvb_get_ephemeral_string(encrypted_tvb, 0, datalen), datalen);
399         if (gcry_err_code (err)) {
400
401                 proto_item_append_text(item, " [Failed to decrypt with password preference]");
402
403                 gcry_cipher_close (cipher);
404                 g_free(clear_data);
405                 return FALSE;
406         }
407
408         gcry_cipher_close (cipher);
409
410         /* We don't know if we have successfully decrypted the data or not so we:
411                 a) check the trailing bytes
412                 b) see if we start with a sequence or a set (is this too constraining?
413                 */
414
415         /* first the trailing bytes */
416         byte = clear_data[datalen-1];
417         if(byte <= 0x08) {
418                 int i;
419
420                 for(i = (int)byte; i > 0 ; i--) {
421                         if(clear_data[datalen - i] != byte) {
422                                 decrypt_ok = FALSE;
423                                 break;
424                         }
425                 }
426         } else {
427                 /* XXX: is this a failure? */
428         }
429
430         /* we assume the result is ASN.1 - check it is a SET or SEQUENCE */
431         byte = clear_data[0];
432         if((byte != 0x30) && (byte != 0x31)) { /* do we need more here? OCTET STRING? */
433                 decrypt_ok = FALSE;
434         }
435
436         if(!decrypt_ok) {
437                 g_free(clear_data);
438                 proto_item_append_text(item, " [Failed to decrypt with supplied password]");
439
440                 return FALSE;
441         }
442
443         proto_item_append_text(item, " [Decrypted successfully]");
444
445         tree = proto_item_add_subtree(item, ett_decrypted_pbe);
446
447         /* OK - so now clear_data contains the decrypted data */
448
449         clear_tvb = tvb_new_child_real_data(encrypted_tvb,(const guint8 *)clear_data, datalen, datalen);
450         tvb_set_free_cb(clear_tvb, g_free);
451
452         name = g_string_new("");
453         oidname = oid_resolved_from_string(object_identifier_id_param);
454         g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id_param);
455
456         /* add it as a new source */
457         add_new_data_source(actx->pinfo, clear_tvb, name->str);
458
459         g_string_free(name, TRUE);
460
461         /* now try and decode it */
462         call_ber_oid_callback(object_identifier_id_param, clear_tvb, 0, actx->pinfo, tree);
463
464         return TRUE;
465 #else
466         /* we cannot decrypt */
467         return FALSE;
468
469 #endif
470 }
471
472
473 /*--- Included file: packet-pkcs12-fn.c ---*/
474 #line 1 "../../asn1/pkcs12/packet-pkcs12-fn.c"
475
476 static const value_string pkcs12_T_version_vals[] = {
477   {   3, "v3" },
478   { 0, NULL }
479 };
480
481
482 static int
483 dissect_pkcs12_T_version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
484   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
485                                                 NULL);
486
487   return offset;
488 }
489
490
491 static const ber_sequence_t DigestInfo_sequence[] = {
492   { &hf_pkcs12_digestAlgorithm, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cms_DigestAlgorithmIdentifier },
493   { &hf_pkcs12_digest       , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_cms_Digest },
494   { NULL, 0, 0, 0, NULL }
495 };
496
497 static int
498 dissect_pkcs12_DigestInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
499   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
500                                    DigestInfo_sequence, hf_index, ett_pkcs12_DigestInfo);
501
502   return offset;
503 }
504
505
506
507 static int
508 dissect_pkcs12_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
509   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
510                                        (hf_index == hf_pkcs12_salt ? &salt : NULL));
511
512   return offset;
513 }
514
515
516
517 static int
518 dissect_pkcs12_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
519   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
520                                                 (hf_index == hf_pkcs12_iterationCount ? &iteration_count : NULL));
521
522   return offset;
523 }
524
525
526 static const ber_sequence_t MacData_sequence[] = {
527   { &hf_pkcs12_mac          , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkcs12_DigestInfo },
528   { &hf_pkcs12_macSalt      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs12_OCTET_STRING },
529   { &hf_pkcs12_iterations   , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkcs12_INTEGER },
530   { NULL, 0, 0, 0, NULL }
531 };
532
533 static int
534 dissect_pkcs12_MacData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
535   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
536                                    MacData_sequence, hf_index, ett_pkcs12_MacData);
537
538   return offset;
539 }
540
541
542 static const ber_sequence_t PFX_sequence[] = {
543   { &hf_pkcs12_version      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_version },
544   { &hf_pkcs12_authSafe     , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cms_ContentInfo },
545   { &hf_pkcs12_macData      , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkcs12_MacData },
546   { NULL, 0, 0, 0, NULL }
547 };
548
549 static int
550 dissect_pkcs12_PFX(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
551 #line 60 "../../asn1/pkcs12/pkcs12.cnf"
552         dissector_handle_t dissector_handle;
553
554         /* we change the CMS id-data dissector to dissect as AuthenticatedSafe
555            not sure why PKCS#12 couldn't have used its own content type OID for AuthenticatedSafe */
556         dissector_handle=create_dissector_handle(dissect_AuthenticatedSafe_OCTETSTRING_PDU, proto_pkcs12);
557         dissector_change_string("ber.oid", "1.2.840.113549.1.7.1", dissector_handle);
558
559           offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
560                                    PFX_sequence, hf_index, ett_pkcs12_PFX);
561
562
563         /* restore the original dissector */
564         dissector_reset_string("ber.oid", "1.2.840.113549.1.7.1");
565
566
567
568   return offset;
569 }
570
571
572 static const ber_sequence_t AuthenticatedSafe_sequence_of[1] = {
573   { &hf_pkcs12_AuthenticatedSafe_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cms_ContentInfo },
574 };
575
576 static int
577 dissect_pkcs12_AuthenticatedSafe(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
578 #line 73 "../../asn1/pkcs12/pkcs12.cnf"
579         dissector_handle_t dissector_handle;
580
581         /* we change the CMS id-data dissector to dissect as SafeContents */
582         dissector_handle=create_dissector_handle(dissect_SafeContents_OCTETSTRING_PDU, proto_pkcs12);
583         dissector_change_string("ber.oid", "1.2.840.113549.1.7.1", dissector_handle);
584
585           offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
586                                       AuthenticatedSafe_sequence_of, hf_index, ett_pkcs12_AuthenticatedSafe);
587
588
589         /* restore the original dissector */
590         dissector_reset_string("ber.oid", "1.2.840.113549.1.7.1");
591
592
593
594   return offset;
595 }
596
597
598
599 static int
600 dissect_pkcs12_T_bagId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
601   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &object_identifier_id);
602
603 #line 86 "../../asn1/pkcs12/pkcs12.cnf"
604   append_oid(tree, object_identifier_id);
605
606   return offset;
607 }
608
609
610
611 static int
612 dissect_pkcs12_T_bagValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
613 #line 110 "../../asn1/pkcs12/pkcs12.cnf"
614         if(object_identifier_id)
615                 offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree);
616
617
618
619   return offset;
620 }
621
622
623
624 static int
625 dissect_pkcs12_T_attrId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
626   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &object_identifier_id);
627
628 #line 106 "../../asn1/pkcs12/pkcs12.cnf"
629   append_oid(tree, object_identifier_id);
630
631   return offset;
632 }
633
634
635
636 static int
637 dissect_pkcs12_T_attrValues_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
638 #line 114 "../../asn1/pkcs12/pkcs12.cnf"
639         if(object_identifier_id)
640                 offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree);
641
642
643
644   return offset;
645 }
646
647
648 static const ber_sequence_t T_attrValues_set_of[1] = {
649   { &hf_pkcs12_attrValues_item, BER_CLASS_ANY, 0, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_attrValues_item },
650 };
651
652 static int
653 dissect_pkcs12_T_attrValues(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
654   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
655                                  T_attrValues_set_of, hf_index, ett_pkcs12_T_attrValues);
656
657   return offset;
658 }
659
660
661 static const ber_sequence_t PKCS12Attribute_sequence[] = {
662   { &hf_pkcs12_attrId       , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_attrId },
663   { &hf_pkcs12_attrValues   , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_attrValues },
664   { NULL, 0, 0, 0, NULL }
665 };
666
667 static int
668 dissect_pkcs12_PKCS12Attribute(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
669   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
670                                    PKCS12Attribute_sequence, hf_index, ett_pkcs12_PKCS12Attribute);
671
672   return offset;
673 }
674
675
676 static const ber_sequence_t SET_OF_PKCS12Attribute_set_of[1] = {
677   { &hf_pkcs12_bagAttributes_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkcs12_PKCS12Attribute },
678 };
679
680 static int
681 dissect_pkcs12_SET_OF_PKCS12Attribute(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
682   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
683                                  SET_OF_PKCS12Attribute_set_of, hf_index, ett_pkcs12_SET_OF_PKCS12Attribute);
684
685   return offset;
686 }
687
688
689 static const ber_sequence_t SafeBag_sequence[] = {
690   { &hf_pkcs12_bagId        , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_bagId },
691   { &hf_pkcs12_bagValue     , BER_CLASS_CON, 0, 0, dissect_pkcs12_T_bagValue },
692   { &hf_pkcs12_bagAttributes, BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkcs12_SET_OF_PKCS12Attribute },
693   { NULL, 0, 0, 0, NULL }
694 };
695
696 static int
697 dissect_pkcs12_SafeBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
698   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
699                                    SafeBag_sequence, hf_index, ett_pkcs12_SafeBag);
700
701   return offset;
702 }
703
704
705 static const ber_sequence_t SafeContents_sequence_of[1] = {
706   { &hf_pkcs12_SafeContents_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_pkcs12_SafeBag },
707 };
708
709 static int
710 dissect_pkcs12_SafeContents(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
711   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
712                                       SafeContents_sequence_of, hf_index, ett_pkcs12_SafeContents);
713
714   return offset;
715 }
716
717
718 static const value_string pkcs12_Version_vals[] = {
719   {   0, "v1" },
720   { 0, NULL }
721 };
722
723
724 static int
725 dissect_pkcs12_Version(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
726   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
727                                                 NULL);
728
729   return offset;
730 }
731
732
733
734 static int
735 dissect_pkcs12_PrivateKey(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
736   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
737                                        NULL);
738
739   return offset;
740 }
741
742
743 static const ber_sequence_t Attributes_set_of[1] = {
744   { &hf_pkcs12_Attributes_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509if_Attribute },
745 };
746
747 static int
748 dissect_pkcs12_Attributes(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
749   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
750                                  Attributes_set_of, hf_index, ett_pkcs12_Attributes);
751
752   return offset;
753 }
754
755
756 static const ber_sequence_t PrivateKeyInfo_sequence[] = {
757   { &hf_pkcs12_privateKeyVersion, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkcs12_Version },
758   { &hf_pkcs12_privateKeyAlgorithm, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
759   { &hf_pkcs12_privateKey   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs12_PrivateKey },
760   { &hf_pkcs12_attributes   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_pkcs12_Attributes },
761   { NULL, 0, 0, 0, NULL }
762 };
763
764 static int
765 dissect_pkcs12_PrivateKeyInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
766   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
767                                    PrivateKeyInfo_sequence, hf_index, ett_pkcs12_PrivateKeyInfo);
768
769   return offset;
770 }
771
772
773
774 static int
775 dissect_pkcs12_KeyBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
776   offset = dissect_pkcs12_PrivateKeyInfo(implicit_tag, tvb, offset, actx, tree, hf_index);
777
778   return offset;
779 }
780
781
782
783 static int
784 dissect_pkcs12_EncryptedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
785 #line 141 "../../asn1/pkcs12/pkcs12.cnf"
786         tvbuff_t *encrypted_tvb;
787         dissector_handle_t dissector_handle;
788         
789
790   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
791                                        &encrypted_tvb);
792
793 #line 147 "../../asn1/pkcs12/pkcs12.cnf"
794
795         
796
797         dissector_handle=create_dissector_handle(dissect_PrivateKeyInfo_PDU, proto_pkcs12);
798         dissector_change_string("ber.oid", object_identifier_id, dissector_handle);
799         
800         PBE_decrypt_data(object_identifier_id, encrypted_tvb, actx, actx->created_item);
801         
802         /* restore the original dissector */
803         dissector_reset_string("ber.oid", object_identifier_id);
804         
805
806   return offset;
807 }
808
809
810 static const ber_sequence_t EncryptedPrivateKeyInfo_sequence[] = {
811   { &hf_pkcs12_encryptionAlgorithm, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
812   { &hf_pkcs12_encryptedData, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs12_EncryptedData },
813   { NULL, 0, 0, 0, NULL }
814 };
815
816 static int
817 dissect_pkcs12_EncryptedPrivateKeyInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
818   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
819                                    EncryptedPrivateKeyInfo_sequence, hf_index, ett_pkcs12_EncryptedPrivateKeyInfo);
820
821   return offset;
822 }
823
824
825
826 static int
827 dissect_pkcs12_PKCS8ShroudedKeyBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
828   offset = dissect_pkcs12_EncryptedPrivateKeyInfo(implicit_tag, tvb, offset, actx, tree, hf_index);
829
830   return offset;
831 }
832
833
834
835 static int
836 dissect_pkcs12_T_certId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
837   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &object_identifier_id);
838
839 #line 91 "../../asn1/pkcs12/pkcs12.cnf"
840   append_oid(tree, object_identifier_id);
841
842   return offset;
843 }
844
845
846
847 static int
848 dissect_pkcs12_T_certValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
849 #line 118 "../../asn1/pkcs12/pkcs12.cnf"
850         if(object_identifier_id)
851                 offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree);
852
853
854
855   return offset;
856 }
857
858
859 static const ber_sequence_t CertBag_sequence[] = {
860   { &hf_pkcs12_certId       , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_certId },
861   { &hf_pkcs12_certValue    , BER_CLASS_CON, 0, 0, dissect_pkcs12_T_certValue },
862   { NULL, 0, 0, 0, NULL }
863 };
864
865 static int
866 dissect_pkcs12_CertBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
867   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
868                                    CertBag_sequence, hf_index, ett_pkcs12_CertBag);
869
870   return offset;
871 }
872
873
874
875 static int
876 dissect_pkcs12_T_crlId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
877   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &object_identifier_id);
878
879 #line 96 "../../asn1/pkcs12/pkcs12.cnf"
880   append_oid(tree, object_identifier_id);
881
882   return offset;
883 }
884
885
886
887 static int
888 dissect_pkcs12_T_crlValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
889 #line 122 "../../asn1/pkcs12/pkcs12.cnf"
890         if(object_identifier_id)
891                 offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree);
892
893
894
895   return offset;
896 }
897
898
899 static const ber_sequence_t CRLBag_sequence[] = {
900   { &hf_pkcs12_crlId        , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_crlId },
901   { &hf_pkcs12_crlValue     , BER_CLASS_CON, 0, 0, dissect_pkcs12_T_crlValue },
902   { NULL, 0, 0, 0, NULL }
903 };
904
905 static int
906 dissect_pkcs12_CRLBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
907   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
908                                    CRLBag_sequence, hf_index, ett_pkcs12_CRLBag);
909
910   return offset;
911 }
912
913
914
915 static int
916 dissect_pkcs12_T_secretTypeId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
917   offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &object_identifier_id);
918
919 #line 101 "../../asn1/pkcs12/pkcs12.cnf"
920   append_oid(tree, object_identifier_id);
921
922   return offset;
923 }
924
925
926
927 static int
928 dissect_pkcs12_T_secretValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
929 #line 126 "../../asn1/pkcs12/pkcs12.cnf"
930         if(object_identifier_id)
931                 offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree);
932                 
933
934
935   return offset;
936 }
937
938
939 static const ber_sequence_t SecretBag_sequence[] = {
940   { &hf_pkcs12_secretTypeId , BER_CLASS_UNI, BER_UNI_TAG_OID, BER_FLAGS_NOOWNTAG, dissect_pkcs12_T_secretTypeId },
941   { &hf_pkcs12_secretValue  , BER_CLASS_CON, 0, 0, dissect_pkcs12_T_secretValue },
942   { NULL, 0, 0, 0, NULL }
943 };
944
945 static int
946 dissect_pkcs12_SecretBag(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
947   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
948                                    SecretBag_sequence, hf_index, ett_pkcs12_SecretBag);
949
950   return offset;
951 }
952
953
954 static const ber_sequence_t PBEParameter_sequence[] = {
955   { &hf_pkcs12_salt         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs12_OCTET_STRING },
956   { &hf_pkcs12_iterationCount, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkcs12_INTEGER },
957   { NULL, 0, 0, 0, NULL }
958 };
959
960 static int
961 dissect_pkcs12_PBEParameter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
962 #line 130 "../../asn1/pkcs12/pkcs12.cnf"
963         /* initialise the encryption parameters */
964         PBE_reset_parameters();
965
966
967   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
968                                    PBEParameter_sequence, hf_index, ett_pkcs12_PBEParameter);
969
970   return offset;
971 }
972
973
974 static const value_string pkcs12_T_saltChoice_vals[] = {
975   {   0, "specified" },
976   {   1, "otherSource" },
977   { 0, NULL }
978 };
979
980 static const ber_choice_t T_saltChoice_choice[] = {
981   {   0, &hf_pkcs12_specified    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_pkcs12_OCTET_STRING },
982   {   1, &hf_pkcs12_otherSource  , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
983   { 0, NULL, 0, 0, 0, NULL }
984 };
985
986 static int
987 dissect_pkcs12_T_saltChoice(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
988   offset = dissect_ber_choice(actx, tree, tvb, offset,
989                                  T_saltChoice_choice, hf_index, ett_pkcs12_T_saltChoice,
990                                  NULL);
991
992   return offset;
993 }
994
995
996
997 static int
998 dissect_pkcs12_INTEGER_1_MAX(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
999   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1000                                                 NULL);
1001
1002   return offset;
1003 }
1004
1005
1006 static const ber_sequence_t PBKDF2Params_sequence[] = {
1007   { &hf_pkcs12_saltChoice   , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_pkcs12_T_saltChoice },
1008   { &hf_pkcs12_iterationCount, BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_pkcs12_INTEGER },
1009   { &hf_pkcs12_keyLength    , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_pkcs12_INTEGER_1_MAX },
1010   { &hf_pkcs12_prf          , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
1011   { NULL, 0, 0, 0, NULL }
1012 };
1013
1014 static int
1015 dissect_pkcs12_PBKDF2Params(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1016   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1017                                    PBKDF2Params_sequence, hf_index, ett_pkcs12_PBKDF2Params);
1018
1019   return offset;
1020 }
1021
1022
1023 static const ber_sequence_t PBES2Params_sequence[] = {
1024   { &hf_pkcs12_keyDerivationFunc, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
1025   { &hf_pkcs12_encryptionScheme, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
1026   { NULL, 0, 0, 0, NULL }
1027 };
1028
1029 static int
1030 dissect_pkcs12_PBES2Params(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1031   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1032                                    PBES2Params_sequence, hf_index, ett_pkcs12_PBES2Params);
1033
1034   return offset;
1035 }
1036
1037
1038 static const ber_sequence_t PBMAC1Params_sequence[] = {
1039   { &hf_pkcs12_keyDerivationFunc, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
1040   { &hf_pkcs12_messageAuthScheme, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_x509af_AlgorithmIdentifier },
1041   { NULL, 0, 0, 0, NULL }
1042 };
1043
1044 static int
1045 dissect_pkcs12_PBMAC1Params(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1046   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1047                                    PBMAC1Params_sequence, hf_index, ett_pkcs12_PBMAC1Params);
1048
1049   return offset;
1050 }
1051
1052 /*--- PDUs ---*/
1053
1054 static void dissect_PFX_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1055   asn1_ctx_t asn1_ctx;
1056   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1057   dissect_pkcs12_PFX(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PFX_PDU);
1058 }
1059 static void dissect_AuthenticatedSafe_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1060   asn1_ctx_t asn1_ctx;
1061   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1062   dissect_pkcs12_AuthenticatedSafe(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_AuthenticatedSafe_PDU);
1063 }
1064 static void dissect_SafeContents_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1065   asn1_ctx_t asn1_ctx;
1066   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1067   dissect_pkcs12_SafeContents(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_SafeContents_PDU);
1068 }
1069 static void dissect_KeyBag_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1070   asn1_ctx_t asn1_ctx;
1071   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1072   dissect_pkcs12_KeyBag(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_KeyBag_PDU);
1073 }
1074 static void dissect_PKCS8ShroudedKeyBag_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1075   asn1_ctx_t asn1_ctx;
1076   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1077   dissect_pkcs12_PKCS8ShroudedKeyBag(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PKCS8ShroudedKeyBag_PDU);
1078 }
1079 static void dissect_CertBag_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1080   asn1_ctx_t asn1_ctx;
1081   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1082   dissect_pkcs12_CertBag(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_CertBag_PDU);
1083 }
1084 static void dissect_CRLBag_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1085   asn1_ctx_t asn1_ctx;
1086   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1087   dissect_pkcs12_CRLBag(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_CRLBag_PDU);
1088 }
1089 static void dissect_SecretBag_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1090   asn1_ctx_t asn1_ctx;
1091   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1092   dissect_pkcs12_SecretBag(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_SecretBag_PDU);
1093 }
1094 static void dissect_PrivateKeyInfo_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1095   asn1_ctx_t asn1_ctx;
1096   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1097   dissect_pkcs12_PrivateKeyInfo(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PrivateKeyInfo_PDU);
1098 }
1099 static void dissect_EncryptedPrivateKeyInfo_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1100   asn1_ctx_t asn1_ctx;
1101   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1102   dissect_pkcs12_EncryptedPrivateKeyInfo(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_EncryptedPrivateKeyInfo_PDU);
1103 }
1104 static void dissect_PBEParameter_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1105   asn1_ctx_t asn1_ctx;
1106   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1107   dissect_pkcs12_PBEParameter(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PBEParameter_PDU);
1108 }
1109 static void dissect_PBKDF2Params_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1110   asn1_ctx_t asn1_ctx;
1111   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1112   dissect_pkcs12_PBKDF2Params(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PBKDF2Params_PDU);
1113 }
1114 static void dissect_PBES2Params_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1115   asn1_ctx_t asn1_ctx;
1116   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1117   dissect_pkcs12_PBES2Params(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PBES2Params_PDU);
1118 }
1119 static void dissect_PBMAC1Params_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
1120   asn1_ctx_t asn1_ctx;
1121   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1122   dissect_pkcs12_PBMAC1Params(FALSE, tvb, 0, &asn1_ctx, tree, hf_pkcs12_PBMAC1Params_PDU);
1123 }
1124
1125
1126 /*--- End of included file: packet-pkcs12-fn.c ---*/
1127 #line 381 "../../asn1/pkcs12/packet-pkcs12-template.c"
1128
1129 static int strip_octet_string(tvbuff_t *tvb)
1130 {
1131   gint8 ber_class;
1132   gboolean pc, ind;
1133   gint32 tag;
1134   guint32 len;
1135   int offset = 0;
1136
1137   /* PKCS#7 encodes the content as OCTET STRING, whereas CMS is just any ANY */
1138   /* if we use CMS (rather than PKCS#7) - which we are - we need to strip the OCTET STRING tag */
1139   /* before proceeding */
1140
1141   offset = get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
1142   offset = get_ber_length(tvb, offset, &len, &ind);
1143
1144   if((ber_class == BER_CLASS_UNI) && (tag == BER_UNI_TAG_OCTETSTRING))
1145     return offset;
1146
1147   return 0;
1148
1149 }
1150
1151 static void dissect_AuthenticatedSafe_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
1152   int offset = 0;
1153   asn1_ctx_t asn1_ctx;
1154   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1155
1156   if((offset = strip_octet_string(tvb)) > 0)
1157     dissect_pkcs12_AuthenticatedSafe(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs12_AuthenticatedSafe_PDU);
1158   else
1159         proto_tree_add_text(tree, tvb, 0, 1, "BER Error: OCTET STRING expected");
1160 }
1161
1162 static void dissect_SafeContents_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1163 {
1164   int offset = 0;
1165   asn1_ctx_t asn1_ctx;
1166   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1167
1168   offset = strip_octet_string(tvb);
1169
1170   dissect_pkcs12_SafeContents(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs12_SafeContents_PDU);
1171 }
1172
1173 static void dissect_X509Certificate_OCTETSTRING_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1174 {
1175   int offset = 0;
1176   asn1_ctx_t asn1_ctx;
1177   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1178
1179   if((offset = strip_octet_string(tvb)) > 0)
1180         dissect_x509af_Certificate(FALSE, tvb, offset, &asn1_ctx, tree, hf_pkcs12_X509Certificate_PDU);
1181   else
1182         proto_tree_add_text(tree, tvb, 0, 1, "BER Error: OCTET STRING expected");
1183 }
1184
1185 /*--- proto_register_pkcs12 ----------------------------------------------*/
1186 void proto_register_pkcs12(void) {
1187
1188   /* List of fields */
1189   static hf_register_info hf[] = {
1190         { &hf_pkcs12_X509Certificate_PDU,
1191       { "X509Certificate", "pkcs12.X509Certificate",
1192         FT_NONE, BASE_NONE, NULL, 0,
1193         "pkcs12.X509Certificate", HFILL }},
1194
1195 /*--- Included file: packet-pkcs12-hfarr.c ---*/
1196 #line 1 "../../asn1/pkcs12/packet-pkcs12-hfarr.c"
1197     { &hf_pkcs12_PFX_PDU,
1198       { "PFX", "pkcs12.PFX",
1199         FT_NONE, BASE_NONE, NULL, 0,
1200         NULL, HFILL }},
1201     { &hf_pkcs12_AuthenticatedSafe_PDU,
1202       { "AuthenticatedSafe", "pkcs12.AuthenticatedSafe",
1203         FT_UINT32, BASE_DEC, NULL, 0,
1204         NULL, HFILL }},
1205     { &hf_pkcs12_SafeContents_PDU,
1206       { "SafeContents", "pkcs12.SafeContents",
1207         FT_UINT32, BASE_DEC, NULL, 0,
1208         NULL, HFILL }},
1209     { &hf_pkcs12_KeyBag_PDU,
1210       { "KeyBag", "pkcs12.KeyBag",
1211         FT_NONE, BASE_NONE, NULL, 0,
1212         NULL, HFILL }},
1213     { &hf_pkcs12_PKCS8ShroudedKeyBag_PDU,
1214       { "PKCS8ShroudedKeyBag", "pkcs12.PKCS8ShroudedKeyBag",
1215         FT_NONE, BASE_NONE, NULL, 0,
1216         NULL, HFILL }},
1217     { &hf_pkcs12_CertBag_PDU,
1218       { "CertBag", "pkcs12.CertBag",
1219         FT_NONE, BASE_NONE, NULL, 0,
1220         NULL, HFILL }},
1221     { &hf_pkcs12_CRLBag_PDU,
1222       { "CRLBag", "pkcs12.CRLBag",
1223         FT_NONE, BASE_NONE, NULL, 0,
1224         NULL, HFILL }},
1225     { &hf_pkcs12_SecretBag_PDU,
1226       { "SecretBag", "pkcs12.SecretBag",
1227         FT_NONE, BASE_NONE, NULL, 0,
1228         NULL, HFILL }},
1229     { &hf_pkcs12_PrivateKeyInfo_PDU,
1230       { "PrivateKeyInfo", "pkcs12.PrivateKeyInfo",
1231         FT_NONE, BASE_NONE, NULL, 0,
1232         NULL, HFILL }},
1233     { &hf_pkcs12_EncryptedPrivateKeyInfo_PDU,
1234       { "EncryptedPrivateKeyInfo", "pkcs12.EncryptedPrivateKeyInfo",
1235         FT_NONE, BASE_NONE, NULL, 0,
1236         NULL, HFILL }},
1237     { &hf_pkcs12_PBEParameter_PDU,
1238       { "PBEParameter", "pkcs12.PBEParameter",
1239         FT_NONE, BASE_NONE, NULL, 0,
1240         NULL, HFILL }},
1241     { &hf_pkcs12_PBKDF2Params_PDU,
1242       { "PBKDF2Params", "pkcs12.PBKDF2Params",
1243         FT_NONE, BASE_NONE, NULL, 0,
1244         NULL, HFILL }},
1245     { &hf_pkcs12_PBES2Params_PDU,
1246       { "PBES2Params", "pkcs12.PBES2Params",
1247         FT_NONE, BASE_NONE, NULL, 0,
1248         NULL, HFILL }},
1249     { &hf_pkcs12_PBMAC1Params_PDU,
1250       { "PBMAC1Params", "pkcs12.PBMAC1Params",
1251         FT_NONE, BASE_NONE, NULL, 0,
1252         NULL, HFILL }},
1253     { &hf_pkcs12_version,
1254       { "version", "pkcs12.version",
1255         FT_UINT32, BASE_DEC, VALS(pkcs12_T_version_vals), 0,
1256         NULL, HFILL }},
1257     { &hf_pkcs12_authSafe,
1258       { "authSafe", "pkcs12.authSafe",
1259         FT_NONE, BASE_NONE, NULL, 0,
1260         "ContentInfo", HFILL }},
1261     { &hf_pkcs12_macData,
1262       { "macData", "pkcs12.macData",
1263         FT_NONE, BASE_NONE, NULL, 0,
1264         NULL, HFILL }},
1265     { &hf_pkcs12_mac,
1266       { "mac", "pkcs12.mac",
1267         FT_NONE, BASE_NONE, NULL, 0,
1268         "DigestInfo", HFILL }},
1269     { &hf_pkcs12_macSalt,
1270       { "macSalt", "pkcs12.macSalt",
1271         FT_BYTES, BASE_NONE, NULL, 0,
1272         "OCTET_STRING", HFILL }},
1273     { &hf_pkcs12_iterations,
1274       { "iterations", "pkcs12.iterations",
1275         FT_INT32, BASE_DEC, NULL, 0,
1276         "INTEGER", HFILL }},
1277     { &hf_pkcs12_digestAlgorithm,
1278       { "digestAlgorithm", "pkcs12.digestAlgorithm",
1279         FT_NONE, BASE_NONE, NULL, 0,
1280         "DigestAlgorithmIdentifier", HFILL }},
1281     { &hf_pkcs12_digest,
1282       { "digest", "pkcs12.digest",
1283         FT_BYTES, BASE_NONE, NULL, 0,
1284         NULL, HFILL }},
1285     { &hf_pkcs12_AuthenticatedSafe_item,
1286       { "ContentInfo", "pkcs12.ContentInfo",
1287         FT_NONE, BASE_NONE, NULL, 0,
1288         NULL, HFILL }},
1289     { &hf_pkcs12_SafeContents_item,
1290       { "SafeBag", "pkcs12.SafeBag",
1291         FT_NONE, BASE_NONE, NULL, 0,
1292         NULL, HFILL }},
1293     { &hf_pkcs12_bagId,
1294       { "bagId", "pkcs12.bagId",
1295         FT_OID, BASE_NONE, NULL, 0,
1296         NULL, HFILL }},
1297     { &hf_pkcs12_bagValue,
1298       { "bagValue", "pkcs12.bagValue",
1299         FT_NONE, BASE_NONE, NULL, 0,
1300         NULL, HFILL }},
1301     { &hf_pkcs12_bagAttributes,
1302       { "bagAttributes", "pkcs12.bagAttributes",
1303         FT_UINT32, BASE_DEC, NULL, 0,
1304         "SET_OF_PKCS12Attribute", HFILL }},
1305     { &hf_pkcs12_bagAttributes_item,
1306       { "PKCS12Attribute", "pkcs12.PKCS12Attribute",
1307         FT_NONE, BASE_NONE, NULL, 0,
1308         NULL, HFILL }},
1309     { &hf_pkcs12_certId,
1310       { "certId", "pkcs12.certId",
1311         FT_OID, BASE_NONE, NULL, 0,
1312         NULL, HFILL }},
1313     { &hf_pkcs12_certValue,
1314       { "certValue", "pkcs12.certValue",
1315         FT_NONE, BASE_NONE, NULL, 0,
1316         NULL, HFILL }},
1317     { &hf_pkcs12_crlId,
1318       { "crlId", "pkcs12.crlId",
1319         FT_OID, BASE_NONE, NULL, 0,
1320         NULL, HFILL }},
1321     { &hf_pkcs12_crlValue,
1322       { "crlValue", "pkcs12.crlValue",
1323         FT_NONE, BASE_NONE, NULL, 0,
1324         NULL, HFILL }},
1325     { &hf_pkcs12_secretTypeId,
1326       { "secretTypeId", "pkcs12.secretTypeId",
1327         FT_OID, BASE_NONE, NULL, 0,
1328         NULL, HFILL }},
1329     { &hf_pkcs12_secretValue,
1330       { "secretValue", "pkcs12.secretValue",
1331         FT_NONE, BASE_NONE, NULL, 0,
1332         NULL, HFILL }},
1333     { &hf_pkcs12_attrId,
1334       { "attrId", "pkcs12.attrId",
1335         FT_OID, BASE_NONE, NULL, 0,
1336         NULL, HFILL }},
1337     { &hf_pkcs12_attrValues,
1338       { "attrValues", "pkcs12.attrValues",
1339         FT_UINT32, BASE_DEC, NULL, 0,
1340         NULL, HFILL }},
1341     { &hf_pkcs12_attrValues_item,
1342       { "attrValues item", "pkcs12.attrValues_item",
1343         FT_NONE, BASE_NONE, NULL, 0,
1344         NULL, HFILL }},
1345     { &hf_pkcs12_privateKeyVersion,
1346       { "version", "pkcs12.version",
1347         FT_UINT32, BASE_DEC, VALS(pkcs12_Version_vals), 0,
1348         NULL, HFILL }},
1349     { &hf_pkcs12_privateKeyAlgorithm,
1350       { "privateKeyAlgorithm", "pkcs12.privateKeyAlgorithm",
1351         FT_NONE, BASE_NONE, NULL, 0,
1352         "AlgorithmIdentifier", HFILL }},
1353     { &hf_pkcs12_privateKey,
1354       { "privateKey", "pkcs12.privateKey",
1355         FT_BYTES, BASE_NONE, NULL, 0,
1356         NULL, HFILL }},
1357     { &hf_pkcs12_attributes,
1358       { "attributes", "pkcs12.attributes",
1359         FT_UINT32, BASE_DEC, NULL, 0,
1360         NULL, HFILL }},
1361     { &hf_pkcs12_Attributes_item,
1362       { "Attribute", "pkcs12.Attribute",
1363         FT_NONE, BASE_NONE, NULL, 0,
1364         NULL, HFILL }},
1365     { &hf_pkcs12_encryptionAlgorithm,
1366       { "encryptionAlgorithm", "pkcs12.encryptionAlgorithm",
1367         FT_NONE, BASE_NONE, NULL, 0,
1368         "AlgorithmIdentifier", HFILL }},
1369     { &hf_pkcs12_encryptedData,
1370       { "encryptedData", "pkcs12.encryptedData",
1371         FT_BYTES, BASE_NONE, NULL, 0,
1372         NULL, HFILL }},
1373     { &hf_pkcs12_salt,
1374       { "salt", "pkcs12.salt",
1375         FT_BYTES, BASE_NONE, NULL, 0,
1376         "OCTET_STRING", HFILL }},
1377     { &hf_pkcs12_iterationCount,
1378       { "iterationCount", "pkcs12.iterationCount",
1379         FT_INT32, BASE_DEC, NULL, 0,
1380         "INTEGER", HFILL }},
1381     { &hf_pkcs12_saltChoice,
1382       { "salt", "pkcs12.salt",
1383         FT_UINT32, BASE_DEC, VALS(pkcs12_T_saltChoice_vals), 0,
1384         "T_saltChoice", HFILL }},
1385     { &hf_pkcs12_specified,
1386       { "specified", "pkcs12.specified",
1387         FT_BYTES, BASE_NONE, NULL, 0,
1388         "OCTET_STRING", HFILL }},
1389     { &hf_pkcs12_otherSource,
1390       { "otherSource", "pkcs12.otherSource",
1391         FT_NONE, BASE_NONE, NULL, 0,
1392         "AlgorithmIdentifier", HFILL }},
1393     { &hf_pkcs12_keyLength,
1394       { "keyLength", "pkcs12.keyLength",
1395         FT_UINT32, BASE_DEC, NULL, 0,
1396         "INTEGER_1_MAX", HFILL }},
1397     { &hf_pkcs12_prf,
1398       { "prf", "pkcs12.prf",
1399         FT_NONE, BASE_NONE, NULL, 0,
1400         "AlgorithmIdentifier", HFILL }},
1401     { &hf_pkcs12_keyDerivationFunc,
1402       { "keyDerivationFunc", "pkcs12.keyDerivationFunc",
1403         FT_NONE, BASE_NONE, NULL, 0,
1404         "AlgorithmIdentifier", HFILL }},
1405     { &hf_pkcs12_encryptionScheme,
1406       { "encryptionScheme", "pkcs12.encryptionScheme",
1407         FT_NONE, BASE_NONE, NULL, 0,
1408         "AlgorithmIdentifier", HFILL }},
1409     { &hf_pkcs12_messageAuthScheme,
1410       { "messageAuthScheme", "pkcs12.messageAuthScheme",
1411         FT_NONE, BASE_NONE, NULL, 0,
1412         "AlgorithmIdentifier", HFILL }},
1413
1414 /*--- End of included file: packet-pkcs12-hfarr.c ---*/
1415 #line 448 "../../asn1/pkcs12/packet-pkcs12-template.c"
1416   };
1417
1418   /* List of subtrees */
1419   static gint *ett[] = {
1420           &ett_decrypted_pbe,
1421
1422 /*--- Included file: packet-pkcs12-ettarr.c ---*/
1423 #line 1 "../../asn1/pkcs12/packet-pkcs12-ettarr.c"
1424     &ett_pkcs12_PFX,
1425     &ett_pkcs12_MacData,
1426     &ett_pkcs12_DigestInfo,
1427     &ett_pkcs12_AuthenticatedSafe,
1428     &ett_pkcs12_SafeContents,
1429     &ett_pkcs12_SafeBag,
1430     &ett_pkcs12_SET_OF_PKCS12Attribute,
1431     &ett_pkcs12_CertBag,
1432     &ett_pkcs12_CRLBag,
1433     &ett_pkcs12_SecretBag,
1434     &ett_pkcs12_PKCS12Attribute,
1435     &ett_pkcs12_T_attrValues,
1436     &ett_pkcs12_PrivateKeyInfo,
1437     &ett_pkcs12_Attributes,
1438     &ett_pkcs12_EncryptedPrivateKeyInfo,
1439     &ett_pkcs12_PBEParameter,
1440     &ett_pkcs12_PBKDF2Params,
1441     &ett_pkcs12_T_saltChoice,
1442     &ett_pkcs12_PBES2Params,
1443     &ett_pkcs12_PBMAC1Params,
1444
1445 /*--- End of included file: packet-pkcs12-ettarr.c ---*/
1446 #line 454 "../../asn1/pkcs12/packet-pkcs12-template.c"
1447   };
1448   module_t *pkcs12_module;
1449
1450   /* Register protocol */
1451   proto_pkcs12 = proto_register_protocol(PNAME, PSNAME, PFNAME);
1452
1453   /* Register fields and subtrees */
1454   proto_register_field_array(proto_pkcs12, hf, array_length(hf));
1455   proto_register_subtree_array(ett, array_length(ett));
1456
1457   /* Register preferences */
1458   pkcs12_module = prefs_register_protocol(proto_pkcs12, NULL);
1459
1460   prefs_register_string_preference(pkcs12_module, "password",
1461         "Password to decrypt the file with",
1462         "The password to used to decrypt the encrypted elements within"
1463         " the PKCS#12 file", &password);
1464
1465   prefs_register_bool_preference(pkcs12_module, "try_null_password",
1466         "Try to decrypt with a empty password",
1467         "Whether to try and decrypt the encrypted data within the"
1468         " PKCS#12 with a NULL password", &try_null_password);
1469
1470   register_ber_syntax_dissector("PKCS#12", proto_pkcs12, dissect_PFX_PDU);
1471   register_ber_oid_syntax(".p12", NULL, "PKCS#12");
1472   register_ber_oid_syntax(".pfx", NULL, "PKCS#12");
1473 }
1474
1475
1476 /*--- proto_reg_handoff_pkcs12 -------------------------------------------*/
1477 void proto_reg_handoff_pkcs12(void) {
1478
1479 /*--- Included file: packet-pkcs12-dis-tab.c ---*/
1480 #line 1 "../../asn1/pkcs12/packet-pkcs12-dis-tab.c"
1481   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.1", dissect_KeyBag_PDU, proto_pkcs12, "keyBag");
1482   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.2", dissect_PKCS8ShroudedKeyBag_PDU, proto_pkcs12, "pkcs8ShroudedKeyBag");
1483   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.3", dissect_CertBag_PDU, proto_pkcs12, "certBag");
1484   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.4", dissect_SecretBag_PDU, proto_pkcs12, "secretBag");
1485   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.5", dissect_CRLBag_PDU, proto_pkcs12, "crlBag");
1486   register_ber_oid_dissector("1.2.840.113549.1.12.10.1.6", dissect_SafeContents_PDU, proto_pkcs12, "safeContentsBag");
1487   register_ber_oid_dissector("2.16.840.1.113730.3.1.216", dissect_PFX_PDU, proto_pkcs12, "pkcs-9-at-PKCS12");
1488   register_ber_oid_dissector("1.2.840.113549.1.9.25.2", dissect_EncryptedPrivateKeyInfo_PDU, proto_pkcs12, "pkcs-9-at-encryptedPrivateKeyInfo");
1489   register_ber_oid_dissector("1.2.840.113549.1.12.1.1", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd128BitRC4");
1490   register_ber_oid_dissector("1.2.840.113549.1.12.1.2", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd40BitRC4");
1491   register_ber_oid_dissector("1.2.840.113549.1.12.1.3", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd3-KeyTripleDES-CBC");
1492   register_ber_oid_dissector("1.2.840.113549.1.12.1.4", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd2-KeyTripleDES-CBC");
1493   register_ber_oid_dissector("1.2.840.113549.1.12.1.5", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd128BitRC2-CBC");
1494   register_ber_oid_dissector("1.2.840.113549.1.12.1.6", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHAAnd128BitRC2-CBC");
1495   register_ber_oid_dissector("1.2.840.113549.1.5.1", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithMD2AndDES-CBC");
1496   register_ber_oid_dissector("1.2.840.113549.1.5.3", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithMD5AndDES-CBC");
1497   register_ber_oid_dissector("1.2.840.113549.1.5.4", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithMD2AndRC2-CBC");
1498   register_ber_oid_dissector("1.2.840.113549.1.5.6", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithMD5AndRC2-CBC");
1499   register_ber_oid_dissector("1.2.840.113549.1.5.10", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHA1AndDES-CBC");
1500   register_ber_oid_dissector("1.2.840.113549.1.5.11", dissect_PBEParameter_PDU, proto_pkcs12, "pbeWithSHA1AndRC2-CBC");
1501   register_ber_oid_dissector("1.2.840.113549.1.5.12", dissect_PBKDF2Params_PDU, proto_pkcs12, "id-PBKDF2");
1502   register_ber_oid_dissector("1.2.840.113549.1.5.13", dissect_PBES2Params_PDU, proto_pkcs12, "id-PBES2");
1503   register_ber_oid_dissector("1.2.840.113549.1.5.14", dissect_PBMAC1Params_PDU, proto_pkcs12, "id-PBMAC1");
1504
1505
1506 /*--- End of included file: packet-pkcs12-dis-tab.c ---*/
1507 #line 486 "../../asn1/pkcs12/packet-pkcs12-template.c"
1508
1509         register_ber_oid_dissector("1.2.840.113549.1.9.22.1", dissect_X509Certificate_OCTETSTRING_PDU, proto_pkcs12, "x509Certificate");
1510
1511 }
1512