#include <wsutil/sha1.h>
#include <wsutil/sober128.h>
-#ifdef HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-
-#ifdef HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
static dissector_handle_t corosync_totemsrp_handle;
/* This dissector deals packets defined in totemnet.c of corosync
#define PORT_COROSYNC_TOTEMNET 5405
/* Forward declaration we need below */
+void proto_register_corosync_totemnet(void);
void proto_reg_handoff_corosync_totemnet(void);
/* Initialize the protocol and registered fields */
static gint ett_corosync_totemnet_security_header = -1;
-#define HMAC_HASH_SIZE 20
#define SALT_SIZE 16
#define TOTEM_CRYPTO_SOBER 0
if (parent_tree)
{
item = proto_tree_add_item(parent_tree, proto_corosync_totemnet, tvb, 0,
- -1, FALSE);
+ -1, ENC_NA);
tree = proto_item_add_subtree(item, ett_corosync_totemnet_security_header);
proto_tree_add_item(tree,
hf_corosync_totemnet_security_header_hash_digest,
- tvb, 0, HMAC_HASH_SIZE, FALSE);
+ tvb, 0, SHA1_DIGEST_LEN, ENC_NA);
proto_tree_add_item(tree,
hf_corosync_totemnet_security_header_salt,
- tvb, HMAC_HASH_SIZE, SALT_SIZE, FALSE);
+ tvb, SHA1_DIGEST_LEN, SALT_SIZE, ENC_NA);
if (check_crypt_type)
{
proto_tree_add_item(tree,
hf_corosync_totemnet_security_crypto_type,
- tvb, io_len - 1, 1, FALSE);
+ tvb, io_len - 1, 1, ENC_BIG_ENDIAN);
key_item = proto_tree_add_string(tree,
hf_corosync_totemnet_security_crypto_key,
tvb, 0, 0, key);
PROTO_ITEM_SET_GENERATED(key_item);
}
}
- return HMAC_HASH_SIZE + SALT_SIZE;
+ return SHA1_DIGEST_LEN + SALT_SIZE;
}
/* About totemnet.c of corosync cluster engine:
unsigned char *hmac_key = &keys[32];
unsigned char *cipher_key = &keys[16];
unsigned char *initial_vector = &keys[0];
- unsigned char digest_comparison[HMAC_HASH_SIZE];
+ unsigned char digest_comparison[SHA1_DIGEST_LEN];
int io_len;
guint8 *io_base;
unsigned char* salt;
io_len = tvb_reported_length(tvb) - (check_crypt_type? 1: 0);
- if (io_len < HMAC_HASH_SIZE + SALT_SIZE) {
+ if (io_len < SHA1_DIGEST_LEN + SALT_SIZE) {
return 0;
}
}
hash_digest = io_base;
- salt = io_base + HMAC_HASH_SIZE;
+ salt = io_base + SHA1_DIGEST_LEN;
memset(private_key, 0, sizeof(private_key));
private_key_len = (strlen(key_for_trial)+4) & 0xFC;
- if (private_key_len > PRIVATE_KEY_LEN_MAX)
- private_key_len = PRIVATE_KEY_LEN_MAX;
g_strlcpy(private_key, key_for_trial, private_key_len);
/*
* Authenticate contents of message
*/
sha1_hmac(hmac_key, 16,
- io_base + HMAC_HASH_SIZE, io_len - HMAC_HASH_SIZE,
+ io_base + SHA1_DIGEST_LEN, io_len - SHA1_DIGEST_LEN,
digest_comparison);
- if (memcmp (digest_comparison, hash_digest, HMAC_HASH_SIZE) != 0)
+ if (memcmp (digest_comparison, hash_digest, SHA1_DIGEST_LEN) != 0)
return 0;
/*
* Decrypt the contents of the message with the cipher key
*/
- sober128_read (io_base + HMAC_HASH_SIZE + SALT_SIZE,
- io_len - (HMAC_HASH_SIZE + SALT_SIZE),
+ sober128_read (io_base + SHA1_DIGEST_LEN + SALT_SIZE,
+ io_len - (SHA1_DIGEST_LEN + SALT_SIZE),
&stream_prng_state);
check_crypt_type, key_for_trial);
next_tvb = tvb_new_subset(decrypted_tvb,
- HMAC_HASH_SIZE + SALT_SIZE,
- io_len - (HMAC_HASH_SIZE + SALT_SIZE),
- io_len - (HMAC_HASH_SIZE + SALT_SIZE));
+ SHA1_DIGEST_LEN + SALT_SIZE,
+ io_len - (SHA1_DIGEST_LEN + SALT_SIZE),
+ io_len - (SHA1_DIGEST_LEN + SALT_SIZE));
- return call_dissector(corosync_totemsrp_handle, next_tvb, pinfo, parent_tree) + HMAC_HASH_SIZE + SALT_SIZE;
+ return call_dissector(corosync_totemsrp_handle, next_tvb, pinfo, parent_tree) + SHA1_DIGEST_LEN + SALT_SIZE;
}
}
}
else
{
- corosync_totemnet_handle = new_create_dissector_handle(dissect_corosynec_totemnet,
+ corosync_totemnet_handle = create_dissector_handle(dissect_corosynec_totemnet,
proto_corosync_totemnet);
- corosync_totemsrp_handle = find_dissector("corosync_totemsrp");
+ corosync_totemsrp_handle = find_dissector_add_dependency("corosync_totemsrp", proto_corosync_totemnet);
initialized = TRUE;
}
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
-
-/* packet-corosync-totemnet.c ends here */