diff options
58 files changed, 259 insertions, 193 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 50ade08fb7..bbd4c78a68 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -998,7 +998,6 @@ if(BUILD_editcap) ) set(editcap_FILES editcap.c - epan/crypt/md5.c ${WTAP_PLUGIN_SOURCES} ) add_executable(editcap ${editcap_FILES}) diff --git a/Makefile.common b/Makefile.common index b4dab9ae88..5e2f255071 100644 --- a/Makefile.common +++ b/Makefile.common @@ -148,7 +148,6 @@ mergecap_SOURCES = \ # editcap specifics editcap_SOURCES = \ editcap.c \ - epan/crypt/md5.c \ $(WTAP_PLUGIN_SOURCES) # reordercap specifics diff --git a/asn1/c1222/packet-c1222-template.c b/asn1/c1222/packet-c1222-template.c index 8633a21afd..d63c23d3e8 100644 --- a/asn1/c1222/packet-c1222-template.c +++ b/asn1/c1222/packet-c1222-template.c @@ -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> @@ -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> @@ -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; diff --git a/asn1/cms/packet-cms-template.c b/asn1/cms/packet-cms-template.c index 01efb52f86..e4e93d12ea 100644 --- a/asn1/cms/packet-cms-template.c +++ b/asn1/cms/packet-cms-template.c @@ -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> @@ -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" diff --git a/asn1/kerberos/packet-kerberos-template.c b/asn1/kerberos/packet-kerberos-template.c index 69a9d88148..cd47ab9b15 100644 --- a/asn1/kerberos/packet-kerberos-template.c +++ b/asn1/kerberos/packet-kerberos-template.c @@ -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 diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index 1653f8a4ec..db18fb28b6 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -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> @@ -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 diff --git a/asn1/spnego/packet-spnego-template.c b/asn1/spnego/packet-spnego-template.c index 4239c1e156..7960a71da7 100644 --- a/asn1/spnego/packet-spnego-template.c +++ b/asn1/spnego/packet-spnego-template.c @@ -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> @@ -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, @@ -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 diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index 4c5eba8e93..a9bc586821 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -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 diff --git a/epan/Makefile.common b/epan/Makefile.common index b587dc57ec..26b0d37557 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -222,7 +222,6 @@ LIBWIRESHARK_INCLUDES = \ packet.h \ packet_info.h \ params.h \ - pint.h \ plugins.h \ ppptypes.h \ print.h \ diff --git a/epan/address_to_str.c b/epan/address_to_str.c index 984e7aba7d..e8fe3509c6 100644 --- a/epan/address_to_str.c +++ b/epan/address_to_str.c @@ -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" @@ -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: @@ -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; @@ -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); } @@ -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(); } diff --git a/epan/column-utils.c b/epan/column-utils.c index 6546944bf8..ef0e75e682 100644 --- a/epan/column-utils.c +++ b/epan/column-utils.c @@ -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" diff --git a/epan/crypt/Makefile.am b/epan/crypt/Makefile.am index dc1a5734e1..82bb91e06b 100644 --- a/epan/crypt/Makefile.am +++ b/epan/crypt/Makefile.am @@ -29,7 +29,6 @@ endif AM_CPPFLAGS = \ -I$(top_srcdir) - $(LIBGCRYPT_CFLAGS) noinst_LTLIBRARIES = libairpdcap.la diff --git a/epan/crypt/Makefile.common b/epan/crypt/Makefile.common index e55a5254cc..8b4bda7939 100644 --- a/epan/crypt/Makefile.common +++ b/epan/crypt/Makefile.common @@ -26,22 +26,14 @@ 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 \ @@ -49,11 +41,5 @@ LIBAIRPDCAP_INCLUDES = \ 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 diff --git a/epan/crypt/airpdcap.c b/epan/crypt/airpdcap.c index d79f80b35d..6201386e42 100644 --- a/epan/crypt/airpdcap.c +++ b/epan/crypt/airpdcap.c @@ -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" diff --git a/epan/crypt/airpdcap_ccmp.c b/epan/crypt/airpdcap_ccmp.c index b1bafbe769..afd23aa8a1 100644 --- a/epan/crypt/airpdcap_ccmp.c +++ b/epan/crypt/airpdcap_ccmp.c @@ -48,7 +48,7 @@ #include "airpdcap_debug.h" #include <glib.h> -#include "aes.h" +#include <wsutil/aes.h> /****************************************************************************/ /* Internal definitions */ diff --git a/epan/crypt/airpdcap_rijndael.c b/epan/crypt/airpdcap_rijndael.c index 7732418adc..1f70c45e06 100644 --- a/epan/crypt/airpdcap_rijndael.c +++ b/epan/crypt/airpdcap_rijndael.c @@ -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. diff --git a/epan/crypt/airpdcap_tkip.c b/epan/crypt/airpdcap_tkip.c index 9920485968..0f0aaa781b 100644 --- a/epan/crypt/airpdcap_tkip.c +++ b/epan/crypt/airpdcap_tkip.c @@ -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" diff --git a/epan/dissectors/packet-3com-njack.c b/epan/dissectors/packet-3com-njack.c index 9cc06bbb97..3525ca08c6 100644 --- a/epan/dissectors/packet-3com-njack.c +++ b/epan/dissectors/packet-3com-njack.c @@ -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) diff --git a/epan/dissectors/packet-c1222.c b/epan/dissectors/packet-c1222.c index 98d5e4022d..1b31d86f36 100644 --- a/epan/dissectors/packet-c1222.c +++ b/epan/dissectors/packet-c1222.c @@ -34,6 +34,9 @@ #include "config.h" #include <glib.h> + +#include <wsutil/eax.h> + #include <epan/conversation.h> #include <epan/expert.h> #include <epan/packet.h> @@ -42,7 +45,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> @@ -123,7 +125,7 @@ static int hf_c1222_c1221_auth_request = -1; /* OCTET_STRING_SIZE_1_255 */ static int hf_c1222_c1221_auth_response = -1; /* OCTET_STRING_SIZE_CONSTR002 */ /*--- End of included file: packet-c1222-hf.c ---*/ -#line 91 "../../asn1/c1222/packet-c1222-template.c" +#line 93 "../../asn1/c1222/packet-c1222-template.c" /* These are the EPSEM pieces */ /* first, the flag components */ static int hf_c1222_epsem_flags = -1; @@ -228,7 +230,7 @@ static gint ett_c1222_Calling_authentication_value_c1222_U = -1; static gint ett_c1222_Calling_authentication_value_c1221_U = -1; /*--- End of included file: packet-c1222-ett.c ---*/ -#line 184 "../../asn1/c1222/packet-c1222-template.c" +#line 186 "../../asn1/c1222/packet-c1222-template.c" static expert_field ei_c1222_command_truncated = EI_INIT; static expert_field ei_c1222_bad_checksum = EI_INIT; @@ -533,7 +535,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; @@ -1448,7 +1450,7 @@ dissect_c1222_User_information(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int proto_item *tf = NULL; proto_tree *epsem_tree = NULL; FILL_START; - + /* get Tag and Length */ offset = dissect_ber_identifier(actx->pinfo, tree, tvb, offset, &end_device_class, &pc, &tag); offset = dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, &ind); @@ -1511,7 +1513,7 @@ static void dissect_MESSAGE_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto /*--- End of included file: packet-c1222-fn.c ---*/ -#line 1017 "../../asn1/c1222/packet-c1222-template.c" +#line 1019 "../../asn1/c1222/packet-c1222-template.c" /** * Dissects a a full (reassembled) C12.22 message. @@ -1890,7 +1892,7 @@ void proto_register_c1222(void) { "OCTET_STRING_SIZE_CONSTR002", HFILL }}, /*--- End of included file: packet-c1222-hfarr.c ---*/ -#line 1299 "../../asn1/c1222/packet-c1222-template.c" +#line 1301 "../../asn1/c1222/packet-c1222-template.c" }; /* List of subtrees */ @@ -1912,7 +1914,7 @@ void proto_register_c1222(void) { &ett_c1222_Calling_authentication_value_c1221_U, /*--- End of included file: packet-c1222-ettarr.c ---*/ -#line 1309 "../../asn1/c1222/packet-c1222-template.c" +#line 1311 "../../asn1/c1222/packet-c1222-template.c" }; static ei_register_info ei[] = { diff --git a/epan/dissectors/packet-cms.c b/epan/dissectors/packet-cms.c index f960e03655..769ae7d228 100644 --- a/epan/dissectors/packet-cms.c +++ b/epan/dissectors/packet-cms.c @@ -35,6 +35,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> @@ -49,9 +53,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" @@ -187,7 +188,7 @@ static int hf_cms_issuerUniqueID = -1; /* UniqueIdentifier */ static int hf_cms_extensions = -1; /* Extensions */ /*--- End of included file: packet-cms-hf.c ---*/ -#line 55 "../../asn1/cms/packet-cms-template.c" +#line 56 "../../asn1/cms/packet-cms-template.c" /* Initialize the subtree pointers */ @@ -249,7 +250,7 @@ static gint ett_cms_T_subject = -1; static gint ett_cms_SEQUENCE_OF_Attribute = -1; /*--- End of included file: packet-cms-ett.c ---*/ -#line 58 "../../asn1/cms/packet-cms-template.c" +#line 59 "../../asn1/cms/packet-cms-template.c" static int dissect_cms_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) ; /* XXX kill a compiler warning until asn2wrs stops generating these silly wrappers */ @@ -1518,7 +1519,7 @@ dissect_cms_MessageDigest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offs offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL); - + pi = actx->created_item; /* move past TLV */ @@ -1823,7 +1824,7 @@ static void dissect_RC2CBCParameters_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _ /*--- End of included file: packet-cms-fn.c ---*/ -#line 136 "../../asn1/cms/packet-cms-template.c" +#line 137 "../../asn1/cms/packet-cms-template.c" /*--- proto_register_cms ----------------------------------------------*/ void proto_register_cms(void) { @@ -2331,7 +2332,7 @@ void proto_register_cms(void) { NULL, HFILL }}, /*--- End of included file: packet-cms-hfarr.c ---*/ -#line 147 "../../asn1/cms/packet-cms-template.c" +#line 148 "../../asn1/cms/packet-cms-template.c" }; /* List of subtrees */ @@ -2395,7 +2396,7 @@ void proto_register_cms(void) { &ett_cms_SEQUENCE_OF_Attribute, /*--- End of included file: packet-cms-ettarr.c ---*/ -#line 152 "../../asn1/cms/packet-cms-template.c" +#line 153 "../../asn1/cms/packet-cms-template.c" }; /* Register protocol */ @@ -2441,7 +2442,7 @@ void proto_reg_handoff_cms(void) { /*--- End of included file: packet-cms-dis-tab.c ---*/ -#line 174 "../../asn1/cms/packet-cms-template.c" +#line 175 "../../asn1/cms/packet-cms-template.c" oid_add_from_string("id-data","1.2.840.113549.1.7.1"); oid_add_from_string("id-alg-des-ede3-cbc","1.2.840.113549.3.7"); diff --git a/epan/dissectors/packet-data.c b/epan/dissectors/packet-data.c index 3b32ec1580..ba3388fd20 100644 --- a/epan/dissectors/packet-data.c +++ b/epan/dissectors/packet-data.c @@ -25,9 +25,12 @@ #include "config.h" +#include <glib.h> + +#include <wsutil/md5.h> + #include <epan/packet.h> #include <epan/prefs.h> -#include <epan/crypt/md5.h> #include "packet-data.h" /* proto_data cannot be static because it's referenced in the diff --git a/epan/dissectors/packet-dcerpc-netlogon.c b/epan/dissectors/packet-dcerpc-netlogon.c index 66b223d895..2a33402978 100644 --- a/epan/dissectors/packet-dcerpc-netlogon.c +++ b/epan/dissectors/packet-dcerpc-netlogon.c @@ -29,6 +29,12 @@ #include <glib.h> #include <string.h> + +#include <wsutil/rc4.h> +#include <wsutil/md4.h> +#include <wsutil/md5.h> +#include <wsutil/des.h> + #include <epan/packet.h> /* for dissect_mscldap_string */ #include "packet-ldap.h" @@ -42,10 +48,6 @@ #include <epan/asn1.h> #include "packet-kerberos.h" /* for decoding */ -#include <epan/crypt/rc4.h> -#include <epan/crypt/md4.h> -#include <epan/crypt/md5.h> -#include <epan/crypt/des.h> extern const char *gbl_nt_password; #ifdef DEBUG_NETLOGON diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c index 0eccdba794..42f0694fd6 100644 --- a/epan/dissectors/packet-frame.c +++ b/epan/dissectors/packet-frame.c @@ -30,13 +30,15 @@ #endif #include <glib.h> + +#include <wsutil/md5.h> + #include <epan/packet.h> #include <epan/show_exception.h> #include <epan/timestamp.h> #include <epan/prefs.h> #include <epan/tap.h> #include <epan/expert.h> -#include <epan/crypt/md5.h> #include "packet-frame.h" @@ -80,7 +82,7 @@ static int hf_frame_pack_preamble_error = -1; static int hf_frame_pack_symbol_error = -1; static int hf_frame_wtap_encap = -1; static int hf_comments_text = -1; -static int hf_frame_num_p_prot_data = -1; +static int hf_frame_num_p_prot_data = -1; static gint ett_frame = -1; static gint ett_flags = -1; @@ -765,13 +767,13 @@ proto_register_frame(void) FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL }}, }; - + static hf_register_info hf_encap = { &hf_frame_wtap_encap, { "Encapsulation type", "frame.encap_type", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}; - + static gint *ett[] = { &ett_frame, &ett_flags, @@ -790,9 +792,9 @@ proto_register_frame(void) int encap_count = wtap_get_num_encap_types(); value_string *arr; int i; - - hf_encap.hfinfo.strings = arr = g_new(value_string, encap_count+1); - + + hf_encap.hfinfo.strings = arr = g_new(value_string, encap_count+1); + for (i = 0; i < encap_count; i++) { arr[i].value = i; arr[i].strptr = wtap_encap_string(i); diff --git a/epan/dissectors/packet-ieee80211-radiotap-iter.c b/epan/dissectors/packet-ieee80211-radiotap-iter.c index c2f83b9683..f6f0b94450 100644 --- a/epan/dissectors/packet-ieee80211-radiotap-iter.c +++ b/epan/dissectors/packet-ieee80211-radiotap-iter.c @@ -21,7 +21,7 @@ #include <stddef.h> #include <errno.h> #include <glib.h> -#include "pint.h" +#include <wsutil/pint.h> #define le16_to_cpu GINT16_FROM_LE #define le32_to_cpu GINT32_FROM_LE diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index dd159a402a..70d4aff0f2 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -75,7 +75,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 diff --git a/epan/dissectors/packet-l2tp.c b/epan/dissectors/packet-l2tp.c index d9295c4ec0..289dea91eb 100644 --- a/epan/dissectors/packet-l2tp.c +++ b/epan/dissectors/packet-l2tp.c @@ -58,14 +58,15 @@ #include <glib.h> +#include <wsutil/md5.h> +#include <wsutil/sha1.h> + #include <epan/packet.h> #include <epan/addr_resolv.h> #include <epan/ipproto.h> #include <epan/sminmpec.h> #include <epan/prefs.h> #include <epan/conversation.h> -#include <epan/crypt/md5.h> -#include <epan/crypt/sha1.h> #include <epan/expert.h> #include <epan/proto.h> diff --git a/epan/dissectors/packet-ntlmssp.c b/epan/dissectors/packet-ntlmssp.c index da8bd38467..47d7168323 100644 --- a/epan/dissectors/packet-ntlmssp.c +++ b/epan/dissectors/packet-ntlmssp.c @@ -34,6 +34,13 @@ #include <ctype.h> #include <glib.h> + +#include <wsutil/rc4.h> +#include <wsutil/md4.h> +#include <wsutil/md5.h> +#include <wsutil/des.h> +#include <wsutil/crc32.h> + #include <epan/packet.h> #include <epan/asn1.h> #include <epan/prefs.h> @@ -41,17 +48,12 @@ #include <epan/tap.h> #include <epan/expert.h> #include <epan/show_exception.h> -#include <epan/crypt/rc4.h> -#include <epan/crypt/md4.h> -#include <epan/crypt/md5.h> -#include <epan/crypt/des.h> #include "packet-windows-common.h" #include "packet-smb-common.h" #include "packet-kerberos.h" #include "packet-dcerpc.h" #include "packet-gssapi.h" -#include <wsutil/crc32.h> #include "packet-ntlmssp.h" diff --git a/epan/dissectors/packet-radius.c b/epan/dissectors/packet-radius.c index 928969e02a..a61ba22009 100644 --- a/epan/dissectors/packet-radius.c +++ b/epan/dissectors/packet-radius.c @@ -63,10 +63,10 @@ #include <glib.h> #include <wsutil/report_err.h> +#include <wsutil/md5.h> #include <epan/packet.h> #include <epan/prefs.h> -#include <epan/crypt/md5.h> #include <epan/sminmpec.h> #include <epan/filesystem.h> #include <epan/conversation.h> diff --git a/epan/dissectors/packet-snmp.c b/epan/dissectors/packet-snmp.c index 2101fc8f54..e8ce3b156c 100644 --- a/epan/dissectors/packet-snmp.c +++ b/epan/dissectors/packet-snmp.c @@ -61,6 +61,9 @@ #include <glib.h> +#include <wsutil/sha1.h> +#include <wsutil/md5.h> + #include <epan/packet.h> #include <epan/strutil.h> #include <epan/conversation.h> @@ -73,18 +76,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 @@ -311,7 +309,7 @@ static int hf_snmp_priority = -1; /* INTEGER_M1_2147483647 */ static int hf_snmp_operation = -1; /* T_operation */ /*--- End of included file: packet-snmp-hf.c ---*/ -#line 238 "../../asn1/snmp/packet-snmp-template.c" +#line 235 "../../asn1/snmp/packet-snmp-template.c" static int hf_smux_version = -1; static int hf_smux_pdutype = -1; @@ -354,7 +352,7 @@ static gint ett_snmp_SimpleOpen_U = -1; static gint ett_snmp_RReqPDU_U = -1; /*--- End of included file: packet-snmp-ett.c ---*/ -#line 257 "../../asn1/snmp/packet-snmp-template.c" +#line 254 "../../asn1/snmp/packet-snmp-template.c" static expert_field ei_snmp_failed_decrypted_data_pdu = EI_INIT; static expert_field ei_snmp_decrypted_data_bad_formatted = EI_INIT; @@ -2978,7 +2976,7 @@ static void dissect_SMUX_PDUs_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pro /*--- End of included file: packet-snmp-fn.c ---*/ -#line 1768 "../../asn1/snmp/packet-snmp-template.c" +#line 1765 "../../asn1/snmp/packet-snmp-template.c" guint @@ -3904,7 +3902,7 @@ void proto_register_snmp(void) { NULL, HFILL }}, /*--- End of included file: packet-snmp-hfarr.c ---*/ -#line 2429 "../../asn1/snmp/packet-snmp-template.c" +#line 2426 "../../asn1/snmp/packet-snmp-template.c" }; /* List of subtrees */ @@ -3944,7 +3942,7 @@ void proto_register_snmp(void) { &ett_snmp_RReqPDU_U, /*--- End of included file: packet-snmp-ettarr.c ---*/ -#line 2445 "../../asn1/snmp/packet-snmp-template.c" +#line 2442 "../../asn1/snmp/packet-snmp-template.c" }; static ei_register_info ei[] = { { &ei_snmp_failed_decrypted_data_pdu, { "snmp.failed_decrypted_data_pdu", PI_MALFORMED, PI_WARN, "Failed to decrypt encryptedPDU", EXPFILL }}, diff --git a/epan/dissectors/packet-spnego.c b/epan/dissectors/packet-spnego.c index 869304517c..b727fd833d 100644 --- a/epan/dissectors/packet-spnego.c +++ b/epan/dissectors/packet-spnego.c @@ -42,12 +42,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> @@ -111,7 +113,7 @@ static int hf_spnego_ContextFlags_confFlag = -1; static int hf_spnego_ContextFlags_integFlag = -1; /*--- End of included file: packet-spnego-hf.c ---*/ -#line 80 "../../asn1/spnego/packet-spnego-template.c" +#line 82 "../../asn1/spnego/packet-spnego-template.c" /* Global variables */ static const char *MechType_oid; @@ -137,7 +139,7 @@ static gint ett_spnego_NegTokenTarg = -1; static gint ett_spnego_InitialContextToken_U = -1; /*--- End of included file: packet-spnego-ett.c ---*/ -#line 94 "../../asn1/spnego/packet-spnego-template.c" +#line 96 "../../asn1/spnego/packet-spnego-template.c" /* * Unfortunately, we have to have a forward declaration of this, @@ -582,7 +584,7 @@ dissect_spnego_InitialContextToken(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, /*--- End of included file: packet-spnego-fn.c ---*/ -#line 105 "../../asn1/spnego/packet-spnego-template.c" +#line 107 "../../asn1/spnego/packet-spnego-template.c" /* * This is the SPNEGO KRB5 dissector. It is not true KRB5, but some ASN.1 * wrapped blob with an OID, USHORT token ID, and a Ticket, that is also @@ -1957,7 +1959,7 @@ void proto_register_spnego(void) { NULL, HFILL }}, /*--- End of included file: packet-spnego-hfarr.c ---*/ -#line 1391 "../../asn1/spnego/packet-spnego-template.c" +#line 1393 "../../asn1/spnego/packet-spnego-template.c" }; /* List of subtrees */ @@ -1979,7 +1981,7 @@ void proto_register_spnego(void) { &ett_spnego_InitialContextToken_U, /*--- End of included file: packet-spnego-ettarr.c ---*/ -#line 1401 "../../asn1/spnego/packet-spnego-template.c" +#line 1403 "../../asn1/spnego/packet-spnego-template.c" }; /* Register protocol */ diff --git a/epan/dissectors/packet-tacacs.c b/epan/dissectors/packet-tacacs.c index e53d1b0267..bdf5b3c64a 100644 --- a/epan/dissectors/packet-tacacs.c +++ b/epan/dissectors/packet-tacacs.c @@ -58,10 +58,11 @@ #endif #include <glib.h> -#include <epan/packet.h> +#include <wsutil/md5.h> + +#include <epan/packet.h> #include <epan/prefs.h> -#include <epan/crypt/md5.h> #include <epan/emem.h> #include <epan/expert.h> #include "packet-tacacs.h" diff --git a/epan/packet.h b/epan/packet.h index 107eab3a5d..8ad9c18587 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -28,7 +28,7 @@ #include "wiretap/wtap.h" #include "proto.h" #include "tvbuff.h" -#include "pint.h" +#include "wsutil/pint.h" #include "to_str.h" #include "value_string.h" #include "column_info.h" diff --git a/epan/sigcomp-udvm.c b/epan/sigcomp-udvm.c index 76c67f839e..cf876b44e8 100644 --- a/epan/sigcomp-udvm.c +++ b/epan/sigcomp-udvm.c @@ -37,12 +37,13 @@ #include <string.h> #include <glib.h> +#include <wsutil/sha1.h> +#include <wsutil/crc16.h> + #include "packet.h" #include "strutil.h" #include "sigcomp-udvm.h" #include "sigcomp_state_hdlr.h" -#include "crypt/sha1.h" -#include "wsutil/crc16.h" #include "except.h" #define SIGCOMP_INSTR_DECOMPRESSION_FAILURE 0 @@ -2905,7 +2906,7 @@ decode_udvm_multitype_operand(guint8 *buff,guint operand_address, guint16 *value guint8 temp_data; guint16 temp_data16; guint16 memmory_addr = 0; - + *value = 0; bytecode = buff[operand_address]; diff --git a/epan/sna-utils.c b/epan/sna-utils.c index 27ed1a70a8..91bbb5b8a7 100644 --- a/epan/sna-utils.c +++ b/epan/sna-utils.c @@ -28,7 +28,7 @@ #include <string.h> #include "packet_info.h" -#include "pint.h" +#include "wsutil/pint.h" #include "sna-utils.h" #include "emem.h" diff --git a/epan/tvbtest.c b/epan/tvbtest.c index 2aa6b187f1..0ba1a33ef2 100644 --- a/epan/tvbtest.c +++ b/epan/tvbtest.c @@ -29,7 +29,7 @@ #include <string.h> #include "tvbuff.h" -#include "pint.h" +#include "wsutil/pint.h" gboolean failed = FALSE; diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 3a54ae68b5..ccda1a4832 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -43,7 +43,7 @@ #include <zlib.h> #endif -#include "pint.h" +#include "wsutil/pint.h" #include "tvbuff.h" #include "tvbuff-int.h" #include "strutil.h" @@ -86,7 +86,7 @@ static void tvb_free_internal(tvbuff_t *tvb) { gsize size; - + DISSECTOR_ASSERT(tvb); if (tvb->ops->tvb_free) @@ -288,7 +288,7 @@ check_offset_length(const tvbuff_t *tvb, guint *offset_ptr, guint *length_ptr) { int exception; - + exception = check_offset_length_no_exception(tvb, offset, length_val, offset_ptr, length_ptr); if (exception) THROW(exception); @@ -397,7 +397,7 @@ tvb_clone_offset_len(tvbuff_t *tvb, guint offset, guint len) { if (tvb->ops->tvb_clone) { tvbuff_t *cloned_tvb; - + cloned_tvb = tvb->ops->tvb_clone(tvb, offset, len); if (cloned_tvb) return cloned_tvb; diff --git a/ui/gtk/hostlist_table.c b/ui/gtk/hostlist_table.c index 350eeb57ff..cdd939d1a4 100644 --- a/ui/gtk/hostlist_table.c +++ b/ui/gtk/hostlist_table.c @@ -41,7 +41,7 @@ #ifdef HAVE_GEOIP #include <GeoIP.h> #include <epan/geoip_db.h> -#include <epan/pint.h> +#include <wsutil/pint.h> #include <epan/filesystem.h> #endif diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c index 54aa27b4aa..2019fff30f 100644 --- a/ui/gtk/iax2_analysis.c +++ b/ui/gtk/iax2_analysis.c @@ -54,10 +54,10 @@ #include <wsutil/file_util.h> #include <wsutil/g711.h> #include <wsutil/tempfile.h> +#include <wsutil/pint.h> #include <epan/epan_dissect.h> #include <epan/filesystem.h> -#include <epan/pint.h> #include <epan/tap.h> #include <epan/tap-voip.h> #include <epan/dissectors/packet-iax2.h> diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c index b6e01ba413..8f9295897d 100644 --- a/ui/gtk/rtp_analysis.c +++ b/ui/gtk/rtp_analysis.c @@ -53,10 +53,10 @@ #include <wsutil/file_util.h> #include <wsutil/tempfile.h> #include <wsutil/g711.h> +#include <wsutil/pint.h> #include <epan/epan_dissect.h> #include <epan/filesystem.h> -#include <epan/pint.h> #include <epan/tap.h> #include <epan/dissectors/packet-rtp.h> #include <epan/rtp_pt.h> diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index cce06d373f..d40e2cc630 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -35,6 +35,7 @@ set(WSUTIL_FILES # @INET_PTON_LO@ # inet_pton.c # @STRNCASECMP_LO@ # strncasecmp.c # @STRPTIME_LO@ # strptime.c + aes.c airpdcap_wep.c crash_info.c crc10.c @@ -46,12 +47,18 @@ set(WSUTIL_FILES crc8.c crc11.c crcdrm.c + des.c + eax.c g711.c + md4.c + md5.c mpeg-audio.c nstime.c privileges.c + sha1.c strnatcmp.c str_util.c + rc4.c report_err.c tempfile.c type_util.c @@ -61,6 +68,7 @@ set(WSUTIL_FILES set(wsutil_LIBS ${GLIB2_LIBRARIES} + ${GCRYPT_LIBRARIES} ) set(CLEAN_FILES diff --git a/wsutil/Makefile.am b/wsutil/Makefile.am index 828995c89f..4b35e8484f 100644 --- a/wsutil/Makefile.am +++ b/wsutil/Makefile.am @@ -29,15 +29,15 @@ wsutil_optional_objects = if NEED_GETOPT_LO wsutil_optional_objects += @GETOPT_LO@ endif - + if NEED_INET_ATON_LO wsutil_optional_objects += @INET_ATON_LO@ endif - + if NEED_INET_NTOP_LO wsutil_optional_objects += @INET_NTOP_LO@ endif - + if NEED_INET_PTON_LO wsutil_optional_objects += @INET_PTON_LO@ endif @@ -65,6 +65,7 @@ lib_LTLIBRARIES = libwsutil.la libwsutil_la_LDFLAGS = -version-info 0:0:0 @LDFLAGS_SHAREDLIB@ AM_CPPFLAGS = -I$(srcdir)/.. + $(LIBGCRYPT_CFLAGS) libwsutil_la_SOURCES = \ $(LIBWSUTIL_SRC) \ @@ -88,6 +89,7 @@ libwsutil_la_DEPENDENCIES= \ libwsutil_la_LIBADD = \ @GLIB_LIBS@ \ + @LIBGCRYPT_LIBS@ \ $(wsutil_optional_objects) EXTRA_DIST = \ diff --git a/wsutil/Makefile.common b/wsutil/Makefile.common index 8e2903bef5..9261ea469e 100644 --- a/wsutil/Makefile.common +++ b/wsutil/Makefile.common @@ -29,6 +29,7 @@ # generated from YACC or Lex files (as Automake doesn't want them in # _SOURCES variables). LIBWSUTIL_SRC = \ + aes.c \ airpdcap_wep.c \ crash_info.c \ crc6.c \ @@ -40,12 +41,18 @@ LIBWSUTIL_SRC = \ crc16-plain.c \ crc32.c \ crcdrm.c \ + des.c \ + eax.c \ g711.c \ + md4.c \ + md5.c \ mpeg-audio.c \ nstime.c \ privileges.c \ + sha1.c \ strnatcmp.c \ str_util.c \ + rc4.c \ report_err.c \ tempfile.c \ type_util.c \ @@ -53,6 +60,7 @@ LIBWSUTIL_SRC = \ # Header files that are not generated from other files LIBWSUTIL_INCLUDES = \ + aes.h \ crash_info.h \ crc6.h \ crc7.h \ @@ -63,12 +71,18 @@ LIBWSUTIL_INCLUDES = \ crc16-plain.h \ crc32.h \ crcdrm.h \ + des.h \ + eax.h \ g711.h \ + md4.h \ + md5.h \ mpeg-audio.h \ nstime.h \ privileges.h \ + sha1.h \ strnatcmp.h \ str_util.h \ + rc4.h \ report_err.h \ tempfile.h \ type_util.h \ diff --git a/epan/crypt/aes.c b/wsutil/aes.c index 51bacbb8bb..51bacbb8bb 100644 --- a/epan/crypt/aes.c +++ b/wsutil/aes.c diff --git a/epan/crypt/aes.h b/wsutil/aes.h index 54224ff6c1..45079eaa0e 100644 --- a/epan/crypt/aes.h +++ b/wsutil/aes.h @@ -33,6 +33,8 @@ #ifndef _AES #define _AES +#include "ws_symbol_export.h" + #define RIJNDAEL_MAXKC (256/32) #define RIJNDAEL_MAXKB (256/8) #define RIJNDAEL_MAXNR 14 @@ -44,16 +46,19 @@ typedef struct s_rijndael_ctx { } rijndael_ctx; +WS_DLL_PUBLIC void rijndael_set_key( rijndael_ctx *ctx, const guchar *key, gint bits); +WS_DLL_PUBLIC void rijndael_encrypt( const rijndael_ctx *ctx, const guchar *src, guchar *dst); +WS_DLL_PUBLIC void rijndael_decrypt( const rijndael_ctx *ctx, const guchar *src, diff --git a/epan/crypt/des.c b/wsutil/des.c index e219385a62..63990f4efd 100644 --- a/epan/crypt/des.c +++ b/wsutil/des.c @@ -26,7 +26,7 @@ #include "config.h" #include <glib.h> -#include <epan/crypt/des.h> +#include "des.h" /* NOTES: diff --git a/epan/crypt/des.h b/wsutil/des.h index 7a5fb442ea..717d64f0a1 100644 --- a/epan/crypt/des.h +++ b/wsutil/des.h @@ -1,26 +1,34 @@ -/* +/* Unix SMB/CIFS implementation. - a partial implementation of DES designed for use in the + a partial implementation of DES designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1998 $Id$ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef _DES_H +#define _DES_H + +#include "ws_symbol_export.h" + +WS_DLL_PUBLIC void crypt_des_ecb(unsigned char *out, const unsigned char *in, const unsigned char *key, int forw); + +#endif diff --git a/epan/crypt/eax.c b/wsutil/eax.c index 7e12fb71d0..217c107909 100644 --- a/epan/crypt/eax.c +++ b/wsutil/eax.c @@ -39,7 +39,7 @@ typedef struct { static eax_s instance; /* these are defined as macros so they'll be easy to redo in assembly if desired */ -#define BLK_CPY(dst, src) { memcpy(dst, src, EAX_SIZEOF_KEY); } +#define BLK_CPY(dst, src) { memcpy(dst, src, EAX_SIZEOF_KEY); } #define BLK_XOR(dst, src) { int z; for (z=0; z < EAX_SIZEOF_KEY; z++) dst[z] ^= src[z]; } static void Dbl(guint8 *out, const guint8 *in); static void CTR(const guint8 *ws, guint8 *pK, guint8 *pN, guint16 SizeN); @@ -54,21 +54,21 @@ void AesEncrypt(unsigned char msg[EAX_SIZEOF_KEY], unsigned char key[EAX_SIZEOF_ @param[in] pK pointer to secret key @param[in,out] pC pointer to ciphertext @param[in] SizeN byte length of cleartext (pN) buffer - @param[in] SizeK byte length of secret key (pK) + @param[in] SizeK byte length of secret key (pK) @param[in] SizeC byte length of ciphertext (pC) buffer @param[in] pMac four-byte Message Authentication Code @param[in] Mode EAX_MODE_CLEARTEXT_AUTH or EAX_MODE_CIPHERTEXT_AUTH - @return TRUE if message has been authenticated; FALSE if not + @return TRUE if message has been authenticated; FALSE if not authenticated, invalid Mode or error */ -gboolean Eax_Decrypt(guint8 *pN, guint8 *pK, guint8 *pC, - guint32 SizeN, guint32 SizeK, guint32 SizeC, MAC_T *pMac, +gboolean Eax_Decrypt(guint8 *pN, guint8 *pK, guint8 *pC, + guint32 SizeN, guint32 SizeK, guint32 SizeC, MAC_T *pMac, guint8 Mode) { guint8 wsn[EAX_SIZEOF_KEY]; guint8 wsc[EAX_SIZEOF_KEY]; int i; - + /* key size must match this implementation */ if (SizeK != EAX_SIZEOF_KEY) return FALSE; @@ -87,18 +87,18 @@ gboolean Eax_Decrypt(guint8 *pN, guint8 *pK, guint8 *pC, } else { CMAC(pK, wsn, pN, SizeN); } - /* - * In authentication mode the inputs are: pN, pK (and associated sizes), + /* + * In authentication mode the inputs are: pN, pK (and associated sizes), * the result is the 4 byte MAC. */ if (Mode == EAX_MODE_CLEARTEXT_AUTH) { return (memcmp(pMac, &wsn[EAX_SIZEOF_KEY-sizeof(*pMac)], sizeof(*pMac)) ? FALSE : TRUE); - + } - /* - * In cipher mode the inputs are: pN, pK, pP (and associated sizes), + /* + * In cipher mode the inputs are: pN, pK, pP (and associated sizes), * the results are pC (and its size) along with the 4 byte MAC. */ else if (Mode == EAX_MODE_CIPHERTEXT_AUTH) @@ -161,9 +161,9 @@ static void dCMAC(guint8 *pK, guint8 *ws, const guint8 *pN, guint16 SizeN, const if (pC != NULL) { memcpy(&work[SizeN], pC, SizeC); } - /* + /* * pad the data if necessary, and XOR Q or D, depending on - * whether data was padded or not + * whether data was padded or not */ if (worksize != SizeT) { work[SizeT] = 0x80; @@ -202,7 +202,7 @@ static void dCMAC(guint8 *pK, guint8 *ws, const guint8 *pN, guint16 SizeN, const return; } -static void CTR(const guint8 *ws, guint8 *pK, guint8 *pN, guint16 SizeN) +static void CTR(const guint8 *ws, guint8 *pK, guint8 *pN, guint16 SizeN) { gcry_cipher_hd_t cipher_hd; guint8 ctr[EAX_SIZEOF_KEY]; @@ -230,7 +230,7 @@ static void CTR(const guint8 *ws, guint8 *pK, guint8 *pN, guint16 SizeN) return; } -void AesEncrypt(unsigned char msg[EAX_SIZEOF_KEY], unsigned char key[EAX_SIZEOF_KEY]) +void AesEncrypt(unsigned char msg[EAX_SIZEOF_KEY], unsigned char key[EAX_SIZEOF_KEY]) { gcry_cipher_hd_t cipher_hd; diff --git a/epan/crypt/eax.h b/wsutil/eax.h index 46554f6d94..f1f50e0f16 100644 --- a/epan/crypt/eax.h +++ b/wsutil/eax.h @@ -22,9 +22,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" + +#ifndef _EAX_H +#define _EAX_H #include <glib.h> +#include "ws_symbol_export.h" + typedef struct tagMAC_T { guint8 Mac[4]; @@ -42,14 +46,16 @@ typedef struct tagMAC_T @param[in] pK pointer to secret key @param[in,out] pC pointer to ciphertext @param[in] SizeN byte length of cleartext (pN) buffer - @param[in] SizeK byte length of secret key (pK) + @param[in] SizeK byte length of secret key (pK) @param[in] SizeC byte length of ciphertext (pC) buffer @param[in] pMac four-byte Message Authentication Code @param[in] Mode EAX_MODE_CLEARTEXT_AUTH or EAX_MODE_CIPHERTEXT_AUTH - @return TRUE if message has been authenticated; FALSE if not + @return TRUE if message has been authenticated; FALSE if not authenticated, invalid Mode or error */ -gboolean Eax_Decrypt(guint8 *pN, guint8 *pK, guint8 *pC, - guint32 SizeN, guint32 SizeK, guint32 SizeC, MAC_T *pMac, +WS_DLL_PUBLIC +gboolean Eax_Decrypt(guint8 *pN, guint8 *pK, guint8 *pC, + guint32 SizeN, guint32 SizeK, guint32 SizeC, MAC_T *pMac, guint8 Mode); +#endif diff --git a/epan/crypt/md4.c b/wsutil/md4.c index 8eac4b2764..310a1c37aa 100644 --- a/epan/crypt/md4.c +++ b/wsutil/md4.c @@ -25,7 +25,7 @@ #include <glib.h> #include <string.h> -#include <epan/crypt/md4.h> +#include "md4.h" /* NOTE: This code makes no attempt to be fast! diff --git a/epan/crypt/md4.h b/wsutil/md4.h index b3bdb87a08..204bd3899d 100644 --- a/epan/crypt/md4.h +++ b/wsutil/md4.h @@ -1,23 +1,31 @@ -/* +/* Unix SMB/CIFS implementation. a implementation of MD4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1997-1998. $Id$ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef _MD4_H +#define _MD4_H + +#include "ws_symbol_export.h" + +WS_DLL_PUBLIC void crypt_md4(unsigned char *out, const unsigned char *in, size_t n); + +#endif diff --git a/epan/crypt/md5.c b/wsutil/md5.c index aaf6107f4c..0aefa0f0d8 100644 --- a/epan/crypt/md5.c +++ b/wsutil/md5.c @@ -20,7 +20,7 @@ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * 2012-08-21 - C Elston - Split md5_hmac function to allow incremental usage. * */ @@ -31,8 +31,8 @@ #include <glib.h> #include <string.h> -#include <epan/pint.h> -#include <epan/crypt/md5.h> +#include "pint.h" +#include "md5.h" /* * This code implements the MD5 message-digest algorithm. * The algorithm is due to Ron Rivest. This code was diff --git a/epan/crypt/md5.h b/wsutil/md5.h index 8aadf0a72a..c9a3592233 100644 --- a/epan/crypt/md5.h +++ b/wsutil/md5.h @@ -1,5 +1,5 @@ /* $Id$ */ -/* +/* * Copyright (C) 2003-2005 Benny Prijono <benny@prijono.org> * Copyright (C) 2012 C Elston, Katalix Systems Ltd <celston@katalix.com> * @@ -17,8 +17,8 @@ * * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * * 2012-08-21 - C Elston - Split md5_hmac function to allow incremental usage. * */ @@ -48,22 +48,22 @@ typedef struct md5_state_s guint32 in[16]; } md5_state_t; -/** Initialize the algorithm. +/** Initialize the algorithm. * @param pms MD5 context. */ WS_DLL_PUBLIC void md5_init(md5_state_t *pms); -/** Append a string to the message. +/** Append a string to the message. * @param pms MD5 context. * @param data Data. * @param nbytes Length of data. */ WS_DLL_PUBLIC -void md5_append( md5_state_t *pms, +void md5_append( md5_state_t *pms, const guint8 *data, size_t nbytes); -/** Finish the message and return the digest. +/** Finish the message and return the digest. * @param pms MD5 context. * @param digest 16 byte digest. */ @@ -76,12 +76,15 @@ typedef struct md5_hmac_state_s guint8 k_opad[65]; } md5_hmac_state_t; +WS_DLL_PUBLIC void md5_hmac_init(md5_hmac_state_t *hctx, const guint8* key, size_t key_len); +WS_DLL_PUBLIC void md5_hmac_append(md5_hmac_state_t *hctx, const guint8* text, size_t text_len); +WS_DLL_PUBLIC void md5_hmac_finish(md5_hmac_state_t *hctx, guint8 digest[16]); WS_DLL_PUBLIC diff --git a/epan/pint.h b/wsutil/pint.h index 6714c29272..6714c29272 100644 --- a/epan/pint.h +++ b/wsutil/pint.h diff --git a/epan/crypt/rc4.c b/wsutil/rc4.c index f2211de314..551ca8dc0f 100644 --- a/epan/crypt/rc4.c +++ b/wsutil/rc4.c @@ -28,7 +28,7 @@ #include <glib.h> #include <string.h> -#include <epan/crypt/rc4.h> +#include "rc4.h" /* Perform RC4 on a block of data using specified key. "data" is a pointer to the block to be processed. Output is written to same memory as input, diff --git a/epan/crypt/rc4.h b/wsutil/rc4.h index 56259acd7e..e59f34d6c1 100644 --- a/epan/crypt/rc4.h +++ b/wsutil/rc4.h @@ -1,36 +1,44 @@ -/* +/* Unix SMB/CIFS implementation. - a partial implementation of RC4 designed for use in the + a partial implementation of RC4 designed for use in the SMB authentication protocol Copyright (C) Andrew Tridgell 1998 $Id$ - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#ifndef __RC4_H__ +#define __RC4_H__ + +#include "ws_symbol_export.h" + typedef struct _rc4_state_struct { unsigned char s_box[256]; unsigned char index_i; unsigned char index_j; } rc4_state_struct; -void crypt_rc4_init(rc4_state_struct *rc4_state, +WS_DLL_PUBLIC +void crypt_rc4_init(rc4_state_struct *rc4_state, const unsigned char *key, int key_len); +WS_DLL_PUBLIC void crypt_rc4(rc4_state_struct *rc4_state, unsigned char *data, int data_len); +#endif diff --git a/epan/crypt/sha1.c b/wsutil/sha1.c index 64fff30226..526a2ed5d4 100644 --- a/epan/crypt/sha1.c +++ b/wsutil/sha1.c @@ -23,14 +23,14 @@ * Changed to use guint instead of uint 2004 by Anders Broman * Original code found at http://www.cr0.net:8040/code/crypto/sha1/ * References: http://www.ietf.org/rfc/rfc3174.txt?number=3174 - * + * * 2012-08-21 - C Elston - Split sha1_hmac function to allow incremental usage. */ #include <string.h> #include <glib.h> -#include <epan/crypt/sha1.h> +#include "sha1.h" #define GET_UINT32(n,b,i) \ { \ diff --git a/epan/crypt/sha1.h b/wsutil/sha1.h index d8daefbe0a..5a558c9f78 100644 --- a/epan/crypt/sha1.h +++ b/wsutil/sha1.h @@ -23,13 +23,15 @@ * Changed to use guint instead of uint 2004 by Anders Broman * Original code found at http://www.cr0.net:8040/code/crypto/sha1/ * References: http://www.ietf.org/rfc/rfc3174.txt?number=3174 - * + * * 2012-08-21 - C Elston - Split sha1_hmac function to allow incremental usage. */ #ifndef _SHA1_H #define _SHA1_H +#include "ws_symbol_export.h" + typedef struct { guint32 total[2]; @@ -38,8 +40,11 @@ typedef struct } sha1_context; +WS_DLL_PUBLIC void sha1_starts( sha1_context *ctx ); +WS_DLL_PUBLIC void sha1_update( sha1_context *ctx, const guint8 *input, guint32 length ); +WS_DLL_PUBLIC void sha1_finish( sha1_context *ctx, guint8 digest[20] ); typedef struct { @@ -48,9 +53,13 @@ typedef struct { } sha1_hmac_context; +WS_DLL_PUBLIC void sha1_hmac_starts( sha1_hmac_context *hctx, const guint8 *key, guint32 keylen ); +WS_DLL_PUBLIC void sha1_hmac_update( sha1_hmac_context *hctx, const guint8 *buf, guint32 buflen ); +WS_DLL_PUBLIC void sha1_hmac_finish( sha1_hmac_context *hctx, guint8 digest[20] ); +WS_DLL_PUBLIC void sha1_hmac( const guint8 *key, guint32 keylen, const guint8 *buf, guint32 buflen, guint8 digest[20] ); |