Skip to content

Commit

Permalink
Move a bunch of the crypt modules and pint.h into wsutil.
Browse files Browse the repository at this point in the history
This means wsutil now links against libcrypt.

Protect a bunch of the crypt header files from multiple inclusion.

svn path=/trunk/; revision=51100
  • Loading branch information
Jeff Morriss committed Aug 1, 2013
1 parent 6ae3372 commit 2df54da
Show file tree
Hide file tree
Showing 58 changed files with 259 additions and 193 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,6 @@ if(BUILD_editcap)
)
set(editcap_FILES
editcap.c
epan/crypt/md5.c
${WTAP_PLUGIN_SOURCES}
)
add_executable(editcap ${editcap_FILES})
Expand Down
1 change: 0 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ mergecap_SOURCES = \
# editcap specifics
editcap_SOURCES = \
editcap.c \
epan/crypt/md5.c \
$(WTAP_PLUGIN_SOURCES)

# reordercap specifics
Expand Down
6 changes: 4 additions & 2 deletions asn1/c1222/packet-c1222-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "config.h"

#include <glib.h>

#include <wsutil/eax.h>

#include <epan/conversation.h>
#include <epan/expert.h>
#include <epan/packet.h>
Expand All @@ -34,7 +37,6 @@
#include <epan/dissectors/packet-ber.h>
#include <epan/dissectors/packet-tcp.h>
#include <epan/uat.h>
#include <epan/crypt/eax.h>

#include <stdio.h>
#include <string.h>
Expand Down Expand Up @@ -485,7 +487,7 @@ parse_c1222_detailed(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int cm
*offset += 2;
*length -= 2;
tblsize -= 2;
}
}
proto_tree_add_item(tree, hf_c1222_write_data, tvb, *offset, tblsize, ENC_NA);
*offset += tblsize;
*length -= tblsize;
Expand Down
7 changes: 4 additions & 3 deletions asn1/cms/packet-cms-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include "config.h"

#include <glib.h>

#include <wsutil/sha1.h>
#include <wsutil/md5.h>

#include <epan/packet.h>
#include <epan/oids.h>
#include <epan/asn1.h>
Expand All @@ -41,9 +45,6 @@
#include "packet-x509sat.h"
#include "packet-pkcs12.h"

#include <epan/crypt/sha1.h>
#include <epan/crypt/md5.h>

#define PNAME "Cryptographic Message Syntax"
#define PSNAME "CMS"
#define PFNAME "cms"
Expand Down
2 changes: 1 addition & 1 deletion asn1/kerberos/packet-kerberos-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#include <nettle/des.h>
#include <nettle/cbc.h>
#endif
#include <epan/crypt/md5.h>
#include <wsutil/md5.h>
#include <sys/stat.h> /* For keyfile manipulation */
#endif

Expand Down
12 changes: 5 additions & 7 deletions asn1/snmp/packet-snmp-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@

#include <glib.h>

#include <wsutil/sha1.h>
#include <wsutil/md5.h>

#include <epan/packet.h>
#include <epan/strutil.h>
#include <epan/conversation.h>
Expand All @@ -65,18 +68,13 @@
#include <epan/asn1.h>
#include "packet-ipx.h"
#include "packet-hpext.h"

#include <epan/expert.h>
#include <epan/oids.h>

#include "packet-ber.h"

#include "packet-snmp.h"

#include <epan/crypt/sha1.h>
#include <epan/crypt/md5.h>
#include <epan/expert.h>
#include <epan/oids.h>


#ifdef HAVE_LIBGCRYPT
#include <wsutil/wsgcrypt.h>
#endif
Expand Down
4 changes: 3 additions & 1 deletion asn1/spnego/packet-spnego-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
#include "config.h"

#include <glib.h>

#include <wsutil/rc4.h>

#include <epan/packet.h>
#include <epan/asn1.h>
#include "packet-dcerpc.h"
#include "packet-gssapi.h"
#include "packet-kerberos.h"
#include <epan/crypt/rc4.h>
#include <epan/conversation.h>
#include <epan/wmem/wmem.h>
#include <epan/asn1.h>
Expand Down
2 changes: 1 addition & 1 deletion editcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
#include <wsutil/privileges.h>
#include <wsutil/report_err.h>
#include <wsutil/strnatcmp.h>
#include <wsutil/md5.h>

/*
* The symbols declared in the below are exported from libwireshark,
Expand All @@ -87,7 +88,6 @@
*/
#define WS_BUILD_DLL
#define RESET_SYMBOL_EXPORT /* wsutil/wsgetopt.h set export behavior above. */
#include "epan/crypt/md5.h"
#include "epan/plugins.h"
#include "epan/filesystem.h"
#undef WS_BUILD_DLL
Expand Down
7 changes: 0 additions & 7 deletions epan/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ set(CRYPT_FILES
crypt/airpdcap_debug.c
crypt/airpdcap_rijndael.c
crypt/airpdcap_tkip.c
crypt/aes.c
crypt/des.c
crypt/eax.c
crypt/md4.c
crypt/md5.c
crypt/rc4.c
crypt/sha1.c
)

set(DFILTER_FILES
Expand Down
1 change: 0 additions & 1 deletion epan/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ LIBWIRESHARK_INCLUDES = \
packet.h \
packet_info.h \
params.h \
pint.h \
plugins.h \
ppptypes.h \
print.h \
Expand Down
30 changes: 15 additions & 15 deletions epan/address_to_str.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#include "to_str.h"
#include "value_string.h"
#include "addr_resolv.h"
#include "pint.h"
#include "wsutil/pint.h"
#include "atalk-utils.h"
#include "sna-utils.h"
#include "osi-utils.h"
Expand Down Expand Up @@ -195,19 +195,19 @@ ip6_to_str_buf_len(const guchar* src, char *buf, size_t buf_len)
best.base = -1;

/* Is this address an encapsulated IPv4? */
/* XXX,
/* XXX,
* Orginal code dated 1996 uses ::/96 as a valid IPv4-compatible addresses
* but since Feb 2006 ::/96 is deprecated one.
* Quoting wikipedia [0]:
* > The 96-bit zero-value prefix ::/96, originally known as IPv4-compatible
* > addresses, was mentioned in 1995[35] but first described in 1998.[41]
* > This class of addresses was used to represent IPv4 addresses within
* > an IPv6 transition technology. Such an IPv6 address has its first
* > (most significant) 96 bits set to zero, while its last 32 bits are the
* > IPv4 address that is represented.
* > In February 2006 the Internet Engineering Task Force (IETF) has deprecated
* > the use of IPv4-compatible addresses.[1] The only remaining use of this address
* > format is to represent an IPv4 address in a table or database with fixed size
* > The 96-bit zero-value prefix ::/96, originally known as IPv4-compatible
* > addresses, was mentioned in 1995[35] but first described in 1998.[41]
* > This class of addresses was used to represent IPv4 addresses within
* > an IPv6 transition technology. Such an IPv6 address has its first
* > (most significant) 96 bits set to zero, while its last 32 bits are the
* > IPv4 address that is represented.
* > In February 2006 the Internet Engineering Task Force (IETF) has deprecated
* > the use of IPv4-compatible addresses.[1] The only remaining use of this address
* > format is to represent an IPv4 address in a table or database with fixed size
* > members that must also be able to store an IPv6 address.
*
* If needed it can be fixed by changing next line:
Expand Down Expand Up @@ -334,7 +334,7 @@ eui64_to_str(const guint64 ad) {
/* Copy and convert the address to network byte order. */
*(guint64 *)(void *)(p_eui64) = pntoh64(&(ad));

g_snprintf(buf, EUI64_STR_LEN, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
g_snprintf(buf, EUI64_STR_LEN, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x:%.2x",
p_eui64[0], p_eui64[1], p_eui64[2], p_eui64[3],
p_eui64[4], p_eui64[5], p_eui64[6], p_eui64[7] );
return buf;
Expand Down Expand Up @@ -389,12 +389,12 @@ ib_addr_to_str_buf( const address *addr, gchar *buf, int buf_len){
#define PREAMBLE_STR_LEN ((int)(sizeof("GID: ") - 1))
g_snprintf(buf,buf_len,"GID: ");
if (buf_len < PREAMBLE_STR_LEN ||
inet_ntop(AF_INET6, addr->data, buf + PREAMBLE_STR_LEN,
inet_ntop(AF_INET6, addr->data, buf + PREAMBLE_STR_LEN,
buf_len - PREAMBLE_STR_LEN) == NULL ) /* Returns NULL if no space and does not touch buf */
g_snprintf ( buf, buf_len, BUF_TOO_SMALL_ERR ); /* Let the unexpected value alert user */
} else { /* this is a LID (16 bits) */
guint16 lid_number;

memcpy((void *)&lid_number, addr->data, sizeof lid_number);
g_snprintf(buf,buf_len,"LID: %u",lid_number);
}
Expand Down Expand Up @@ -622,7 +622,7 @@ address_to_str_buf(const address *addr, gchar *buf, int buf_len)
g_snprintf(buf, buf_len, "Broadcast");
else
g_snprintf(buf, buf_len, "0x%04x", ieee_802_15_4_short_addr);
break;
break;
default:
g_assert_not_reached();
}
Expand Down
2 changes: 1 addition & 1 deletion epan/column-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "atalk-utils.h"
#include "to_str.h"
#include "packet_info.h"
#include "pint.h"
#include "wsutil/pint.h"
#include "addr_resolv.h"
#include "ipv6-utils.h"
#include "osi-utils.h"
Expand Down
1 change: 0 additions & 1 deletion epan/crypt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ endif

AM_CPPFLAGS = \
-I$(top_srcdir)
$(LIBGCRYPT_CFLAGS)

noinst_LTLIBRARIES = libairpdcap.la

Expand Down
14 changes: 0 additions & 14 deletions epan/crypt/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,20 @@
include Custom.common

LIBAIRPDCAP_SRC = \
aes.c \
airpdcap.c \
airpdcap_ccmp.c \
airpdcap_debug.c \
airpdcap_rijndael.c \
airpdcap_tkip.c \
des.c \
eax.c \
md4.c \
md5.c \
rc4.c \
sha1.c \
$(CUSTOM_CRYPTO_SRC)

LIBAIRPDCAP_INCLUDES = \
aes.h \
airpdcap_debug.h \
airpdcap_interop.h \
airpdcap_int.h \
airpdcap_rijndael.h \
airpdcap_system.h \
airpdcap_user.h \
airpdcap_ws.h \
des.h \
kasumi.h \
md4.h \
md5.h \
rc4.h \
sha1.h \
eax.h \
wep-wpadefs.h
14 changes: 8 additions & 6 deletions epan/crypt/airpdcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@

#include "config.h"

#include <epan/tvbuff.h>
#include <glib.h>

#include <wsutil/crc32.h>
#include <wsutil/rc4.h>
#include <wsutil/sha1.h>
#include <wsutil/md5.h>
#include <wsutil/pint.h>

#include <epan/tvbuff.h>
#include <epan/strutil.h>
#include <epan/emem.h>
#include <epan/pint.h>
#include <epan/crypt/rc4.h>
#include <epan/crypt/airpdcap_rijndael.h>

#include "airpdcap_system.h"
#include "airpdcap_int.h"

#include "sha1.h"
#include "md5.h"

#include "airpdcap_debug.h"

#include "wep-wpadefs.h"
Expand Down
2 changes: 1 addition & 1 deletion epan/crypt/airpdcap_ccmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

#include "airpdcap_debug.h"
#include <glib.h>
#include "aes.h"
#include <wsutil/aes.h>

/****************************************************************************/
/* Internal definitions */
Expand Down
2 changes: 1 addition & 1 deletion epan/crypt/airpdcap_rijndael.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

#include "airpdcap_debug.h"
#include <glib.h>
#include "aes.h"
#include <wsutil/aes.h>

/* Based on RFC 3394 and NIST AES Key Wrap Specification pseudo-code.
Expand Down
2 changes: 1 addition & 1 deletion epan/crypt/airpdcap_tkip.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/******************************************************************************/
/* File includes */
/* */
#include <epan/pint.h>
#include <wsutil/pint.h>
#include <wsutil/crc32.h>
#include "airpdcap_system.h"
#include "airpdcap_int.h"
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-3com-njack.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ dissect_tlvs(tvbuff_t *tvb, proto_tree *njack_tree, guint32 offset)
}

#if 0
#include <epan/crypt/md5.h>
#include <wsutil/md5.h>

static gboolean
verify_password(tvbuff_t *tvb, const char *password)
Expand Down
Loading

0 comments on commit 2df54da

Please sign in to comment.