-Wmissing-prototypes
[metze/wireshark/wip.git] / asn1 / pkcs12 / packet-pkcs12-template.c
index 2be750a8f58b2fd0de5d6f6a6a30cb5d60fcfa78..016021324840fd190c8a32c478499eedfa4c0dbb 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
+#include "config.h"
 
 #include <glib.h>
 #include <epan/packet.h>
@@ -48,7 +46,7 @@
 #endif
 
 #ifdef HAVE_LIBGCRYPT
-#include <gcrypt.h>
+#include <wsutil/wsgcrypt.h>
 #endif
 
 #define PNAME  "PKCS#12: Personal Information Exchange"
@@ -59,6 +57,9 @@
 #define PKCS12_PBE_3DES_SHA1_OID       "1.2.840.113549.1.12.1.3"
 #define PKCS12_PBE_RC2_40_SHA1_OID     "1.2.840.113549.1.12.1.6"
 
+void proto_register_pkcs12(void);
+void proto_reg_handoff_pkcs12(void);
+
 /* Initialize the protocol and registered fields */
 static int proto_pkcs12 = -1;
 
@@ -100,7 +101,7 @@ generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter,
   gcry_mpi_t num_b1 = NULL;
   size_t pwlen;
   char hash[20], buf_b[64], buf_i[128], *p;
-  char *salt;
+  char *salt_p;
   int salt_size;
   size_t cur_keylen;
   size_t n;
@@ -109,7 +110,7 @@ generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter,
   cur_keylen = 0;
 
   salt_size = tvb_length(salt_tvb);
-  salt = tvb_get_ephemeral_string(salt_tvb, 0, salt_size);
+  salt_p = tvb_get_ephemeral_string(salt_tvb, 0, salt_size);
 
   if (pw == NULL)
     pwlen = 0;
@@ -124,7 +125,7 @@ generate_key_or_iv(unsigned int id, tvbuff_t *salt_tvb, unsigned int iter,
   /* Store salt and password in BUF_I */
   p = buf_i;
   for (i = 0; i < 64; i++)
-    *p++ = salt[i % salt_size];
+    *p++ = salt_p[i % salt_size];
   if (pw)
     {
       for (i = j = 0; i < 64; i += 2)
@@ -213,7 +214,7 @@ void PBE_reset_parameters(void)
        salt = NULL;
 }
 
-int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_tvb _U_, asn1_ctx_t *actx _U_, proto_item *item _U_)
+int PBE_decrypt_data(const char *object_identifier_id_param, tvbuff_t *encrypted_tvb, asn1_ctx_t *actx, proto_item *item)
 {
 #ifdef HAVE_LIBGCRYPT
        const char      *encryption_algorithm;
@@ -270,14 +271,14 @@ int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_t
        }
 
        /* allocate buffers */
-       key = ep_alloc(keylen);
+       key = (char *)ep_alloc(keylen);
 
        if(!generate_key_or_iv(1 /*LEY */, salt, iteration_count, password, keylen, key))
                return FALSE;
 
        if(ivlen) {
 
-               iv = ep_alloc(ivlen);
+               iv = (char *)ep_alloc(ivlen);
 
                if(!generate_key_or_iv(2 /* IV */, salt, iteration_count, password, ivlen, iv))
                        return FALSE;
@@ -303,7 +304,7 @@ int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_t
        }
 
        datalen = tvb_length(encrypted_tvb);
-       clear_data = g_malloc(datalen);
+       clear_data = (char *)g_malloc(datalen);
 
        err = gcry_cipher_decrypt (cipher, clear_data, datalen, tvb_get_ephemeral_string(encrypted_tvb, 0, datalen), datalen);
        if (gcry_err_code (err)) {
@@ -360,8 +361,8 @@ int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_t
        tvb_set_free_cb(clear_tvb, g_free);
 
        name = g_string_new("");
-       oidname = oid_resolved_from_string(object_identifier_id);
-       g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id);
+       oidname = oid_resolved_from_string(object_identifier_id_param);
+       g_string_printf(name, "Decrypted %s", oidname ? oidname : object_identifier_id_param);
 
        /* add it as a new source */
        add_new_data_source(actx->pinfo, clear_tvb, name->str);
@@ -369,7 +370,7 @@ int PBE_decrypt_data(const char *object_identifier_id _U_, tvbuff_t *encrypted_t
        g_string_free(name, TRUE);
 
        /* now try and decode it */
-       call_ber_oid_callback(object_identifier_id, clear_tvb, 0, actx->pinfo, tree);
+       call_ber_oid_callback(object_identifier_id_param, clear_tvb, 0, actx->pinfo, tree);
 
        return TRUE;
 #else