wsgcrypt.h checks internally if we HAVE_LIBGCRYPT
[metze/wireshark/wip.git] / asn1 / pkcs12 / packet-pkcs12-template.c
index db10a0e1bb79c1e914312694c6aeb4a4c9329c7e..bcdd6202a084f0a9b0c644f4eafd7a13e35dfe29 100644 (file)
 
 #include "config.h"
 
-#include <glib.h>
 #include <epan/packet.h>
 #include <epan/expert.h>
 #include <epan/oids.h>
 #include <epan/asn1.h>
 #include <epan/prefs.h>
-#include <epan/wmem/wmem.h>
 
 #include "packet-ber.h"
 #include "packet-pkcs12.h"
 #include "packet-x509if.h"
 #include "packet-cms.h"
 
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-
-#ifdef HAVE_LIBGCRYPT
 #include <wsutil/wsgcrypt.h>
-#endif
 
 #define PNAME  "PKCS#12: Personal Information Exchange"
 #define PSNAME "PKCS12"
@@ -64,6 +56,7 @@ void proto_reg_handoff_pkcs12(void);
 static int proto_pkcs12 = -1;
 
 static int hf_pkcs12_X509Certificate_PDU = -1;
+static int hf_pkcs12_AuthenticatedSafe_PDU = -1;  /* AuthenticatedSafe */
 static gint ett_decrypted_pbe = -1;
 
 static expert_field ei_pkcs12_octet_string_expected = EI_INIT;
@@ -88,7 +81,7 @@ static void append_oid(proto_tree *tree, const char *oid)
 {
        const char *name = NULL;
 
-       name = oid_resolved_from_string(oid);
+       name = oid_resolved_from_string(wmem_packet_scope(), oid);
        proto_item_append_text(tree, " (%s)", name ? name : oid);
 }
 
@@ -118,7 +111,7 @@ generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter,
   if (pw == NULL)
     pwlen = 0;
   else
-    pwlen = strlen (pw);
+    pwlen = strlen(pw);
 
   if (pwlen > 63 / 2)
     {
@@ -224,7 +217,7 @@ void PBE_reset_parameters(void)
        salt = NULL;
 }
 
-int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted_tvb, asn1_ctx_t *actx, proto_item *item)
+int PBE_decrypt_data(const char *object_identifier_id_param _U_, tvbuff_t *encrypted_tvb _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
 {
 #ifdef HAVE_LIBGCRYPT
        const char      *encryption_algorithm;
@@ -371,7 +364,7 @@ int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted
        tvb_set_free_cb(clear_tvb, g_free);
 
        name = g_string_new("");
-       oidname = oid_resolved_from_string(object_identifier_id_param);
+       oidname = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id_param);
        g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id_param);
 
        /* add it as a new source */
@@ -457,6 +450,11 @@ void proto_register_pkcs12(void) {
       { "X509Certificate", "pkcs12.X509Certificate",
         FT_NONE, BASE_NONE, NULL, 0,
         "pkcs12.X509Certificate", HFILL }},
+    { &hf_pkcs12_AuthenticatedSafe_PDU,
+      { "AuthenticatedSafe", "pkcs12.AuthenticatedSafe",
+        FT_UINT32, BASE_DEC, NULL, 0,
+        NULL, HFILL }},
+
 #include "packet-pkcs12-hfarr.c"
   };