fc00: skip sha512 calculations for glib < 2.36

Our minimum supported version of glib is 2.22 at the moment.
SHA512 support was added in glib 2.36.

Bring up an expert info if checksum calculation is not supported
by our glib version.

Change-Id: I116b32f63a4342a7e4198eaae8a35189fcc92edc
Reviewed-on: https://code.wireshark.org/review/18391
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
Martin Kaiser 2016-10-21 19:47:11 +02:00 committed by Michael Mann
parent ce9405b00b
commit 49a525a97e
1 changed files with 20 additions and 0 deletions

View File

@ -27,6 +27,9 @@
#include <config.h>
#include <glib.h>
#include <epan/expert.h>
#include <epan/packet.h>
/* Prototypes */
@ -51,6 +54,8 @@ static int hf_fc00_authenticator = -1;
static int hf_fc00_temp_publicy_key = -1;
static int hf_fc00_payload = -1;
static expert_field ei_fc00_chksum_unsupported = EI_INIT;
/* Cjdns constants */
#define SESSION_STATE_OFF 0
#define SESSION_STATE_LEN 4
@ -174,6 +179,7 @@ dissect_cryptoauth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
proto_tree_add_item(fc00_tree, hf_fc00_random_nonce, tvb,
NONCE_OFF, NONCE_LEN, ENC_NA);
#if GLIB_CHECK_VERSION(2, 36, 0) /* sha512 support was added in glib 2.36 */
{
GChecksum *hash = g_checksum_new(G_CHECKSUM_SHA512);
gsize digest_len = g_checksum_type_get_length(G_CHECKSUM_SHA512);
@ -202,6 +208,9 @@ dissect_cryptoauth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
proto_tree_add_ipv6(key_tree, hf_fc00_ip_address, tvb, PUBLIC_KEY_OFF, PUBLIC_KEY_LEN, (struct e_in6_addr*)ip_buf);
}
#else
proto_tree_add_expert(fc00_tree, pinfo, &ei_fc00_chksum_unsupported, tvb, PUBLIC_KEY_OFF, PUBLIC_KEY_LEN);
#endif
proto_tree_add_item(fc00_tree, hf_fc00_authenticator, tvb,
POLY_AUTH_OFF, POLY_AUTH_LEN, ENC_NA);
@ -310,16 +319,27 @@ proto_register_fc00(void)
}
};
static ei_register_info ei[] = {
{ &ei_fc00_chksum_unsupported,
{ "fc00.chksum_unsupported", PI_DECRYPTION, PI_NOTE,
"checksum calculation is not supported",
EXPFILL }}
};
static gint *ett[] = {
&ett_fc00,
&ett_fc00_auth,
&ett_fc00_key
};
expert_module_t *expert_fc00;
proto_fc00 = proto_register_protocol("Fc00 CryptoAuth", "Fc00", "fc00");
proto_register_field_array(proto_fc00, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
expert_fc00 = expert_register_protocol(proto_fc00);
expert_register_field_array(expert_fc00, ei, array_length(ei));
}
void