aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2020-01-07 11:46:02 +0100
committerMauro Sardara <msardara@cisco.com>2020-02-21 15:48:18 +0100
commit35058cdfe0134c88f1aa8d23342d1d7b9d39e296 (patch)
tree978ca9c2232ac381c8391b3d1eeb0f875670d5b1 /lib
parent0710f1ff754ebf01ae5befabb055349fe472b0c2 (diff)
[HICN-2] Added P2P confidential communication on hICN
P2P confidential communications exploit the TLS 1.3 protocol to let a consumer to establish a secure communication on an hICN name. Currently we don't support the consumer authentication (mutual authentication in TLS) and the 0-rtt session establishment. Change-Id: I2be073847c08a17f28c837d444081920c5e57a07 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com> Signed-off-by: Olivier Roques <oroques+fdio@cisco.com> Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/includes/hicn/name.h3
-rw-r--r--lib/src/name.c16
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/includes/hicn/name.h b/lib/includes/hicn/name.h
index 0a100dbce..7234a5159 100644
--- a/lib/includes/hicn/name.h
+++ b/lib/includes/hicn/name.h
@@ -186,9 +186,10 @@ int hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2,
* @brief Provides a 32-bit hash of an hICN name
* @param [in] name - Name to hash
* @param [out] hash - Resulting hash
+ * @param [in] consider_suffix - Consider the suffix in the hash computation
* @return hICN error code
*/
-int hicn_name_hash (const hicn_name_t * name, u32 * hash);
+int hicn_name_hash (const hicn_name_t * name, u32 * hash, bool consider_suffix);
/**
* @brief Test whether an hICN name is empty
diff --git a/lib/src/name.c b/lib/src/name.c
index 7c1f7582a..9388c35e7 100644
--- a/lib/src/name.c
+++ b/lib/src/name.c
@@ -212,23 +212,25 @@ hicn_name_compare (const hicn_name_t * name_1, const hicn_name_t * name_2,
}
int
-hicn_name_hash (const hicn_name_t * name, u32 * hash)
+hicn_name_hash (const hicn_name_t * name, u32 * hash, bool consider_suffix)
{
switch (name->type)
{
case HNT_CONTIGUOUS_V4:
- *hash = hash32 (name->buffer, HICN_V4_NAME_LEN);
+ *hash = hash32 (name->buffer, consider_suffix ? HICN_V4_NAME_LEN : HICN_V4_PREFIX_LEN);
break;
case HNT_CONTIGUOUS_V6:
- *hash = hash32 (name->buffer, HICN_V6_NAME_LEN);
+ *hash = hash32 (name->buffer, consider_suffix ? HICN_V6_NAME_LEN : HICN_V6_PREFIX_LEN);
break;
case HNT_IOV_V4:
case HNT_IOV_V6:
*hash =
- hash32 (name->iov.buffers[0].iov_base, name->iov.buffers[0].iov_len);
- *hash =
- cumulative_hash32 (name->iov.buffers[1].iov_base,
- name->iov.buffers[1].iov_len, *hash);
+ hash32 (name->iov.buffers[0].iov_base, name->iov.buffers[0].iov_len);
+ if (consider_suffix)
+ {
+ *hash = cumulative_hash32 (name->iov.buffers[1].iov_base,
+ name->iov.buffers[1].iov_len, *hash);
+ }
break;
default:
return HICN_LIB_ERROR_NOT_IMPLEMENTED;