summaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2019-02-07 13:12:19 +0100
committerAlberto Compagno <acompagn+fdio@cisco.com>2019-02-07 13:15:40 +0000
commitdb1afad8749fce983636456c16c9df9c24d73af4 (patch)
treed78492674a1fbc5b923941991542d8115e11493d /lib/src
parent216e35ba535efa00af39b7624f363ca832836e3f (diff)
[HICN-39] Added api that return a pointer to the signature hold in a packet
[HICN-40] Fixed signature calculation by allocating a contiguous portion of memory that holds the entire hICN header (IP+TCP+AH) Change-Id: I9d40bab0e3ecb82949b8b3a00e2cc1214457e4e3 Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/compat.c7
-rw-r--r--lib/src/compat.h2
-rw-r--r--lib/src/ops.c1
-rw-r--r--lib/src/ops.h16
-rw-r--r--lib/src/protocol/ah.c8
-rw-r--r--lib/src/protocol/icmp.c4
-rw-r--r--lib/src/protocol/ipv4.c7
-rw-r--r--lib/src/protocol/ipv6.c7
-rw-r--r--lib/src/protocol/tcp.c7
9 files changed, 55 insertions, 4 deletions
diff --git a/lib/src/compat.c b/lib/src/compat.c
index 07f92105e..56504fe5e 100644
--- a/lib/src/compat.c
+++ b/lib/src/compat.c
@@ -1142,6 +1142,13 @@ hicn_data_reset_for_hash (hicn_format_t format, hicn_header_t * packet)
}
+int hicn_packet_get_signature(hicn_format_t format, hicn_header_t * packet, uint8_t ** sign_buf)
+{
+ hicn_type_t type = hicn_format_to_type (format);
+ return hicn_ops_vft[type.l1]->get_signature (type,
+ &packet->protocol, sign_buf);
+}
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/lib/src/compat.h b/lib/src/compat.h
index 1a1743de2..52dd41f1e 100644
--- a/lib/src/compat.h
+++ b/lib/src/compat.h
@@ -387,9 +387,9 @@ int hicn_packet_set_src_port (hicn_header_t * packet, u16 src_port);
int hicn_packet_get_src_port (const hicn_header_t * packet, u16 * src_port);
int hicn_packet_set_dst_port (hicn_header_t * packet, u16 dst_port);
int hicn_packet_get_dst_port (const hicn_header_t * packet, u16 * dst_port);
+int hicn_packet_get_signature(hicn_format_t format, hicn_header_t * packet, uint8_t ** sign_buf);
/* Interest */
-
int hicn_interest_get_name (hicn_format_t format,
const hicn_header_t * interest,
hicn_name_t * name);
diff --git a/lib/src/ops.c b/lib/src/ops.c
index 4ccf131b5..3e272572a 100644
--- a/lib/src/ops.c
+++ b/lib/src/ops.c
@@ -70,6 +70,7 @@ DECLARE_set_validation_algorithm (none, NONE);
DECLARE_get_validation_algorithm (none, NONE);
DECLARE_set_key_id (none, NONE);
DECLARE_get_key_id (none, NONE);
+DECLARE_get_signature (none, NONE);
DECLARE_HICN_OPS (none);
/**
diff --git a/lib/src/ops.h b/lib/src/ops.h
index b698a53fd..47795efd5 100644
--- a/lib/src/ops.h
+++ b/lib/src/ops.h
@@ -418,7 +418,15 @@ typedef struct hicn_ops_s
int (*set_key_id) (hicn_type_t type, hicn_protocol_t * h,
uint8_t *key_id);
-
+ /**
+ * @brief Get a pointer to the signature field in the packet
+ * @param [in] type - hICN packet type
+ * @param [in,out] h - Buffer holding the Interest or Data packet
+ * @param [out] signature - Pointer to the memory region holding the signature
+ * @return hICN error code
+ */
+ int (*get_signature) (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t ** signature);
} hicn_ops_t;
#define DECLARE_HICN_OPS(protocol) \
@@ -459,7 +467,8 @@ typedef struct hicn_ops_s
ATTR_INIT(get_validation_algorithm, protocol ## _get_validation_algorithm), \
ATTR_INIT(set_validation_algorithm, protocol ## _set_validation_algorithm), \
ATTR_INIT(get_key_id, protocol ## _get_key_id), \
- ATTR_INIT(set_key_id, protocol ## _set_key_id), \
+ ATTR_INIT(set_key_id, protocol ## _set_key_id), \
+ ATTR_INIT(get_signature, protocol ## _get_signature), \
}
/**
@@ -618,6 +627,9 @@ PAYLOAD (hicn_type_t type, const hicn_protocol_t * h)
#define DECLARE_get_key_id(protocol, error) \
int protocol ## _get_key_id(hicn_type_t type, hicn_protocol_t * h, uint8_t ** key_id, uint8_t *key_id_size) { return HICN_LIB_ERROR_ ## error ; }
+#define DECLARE_get_signature(protocol, error) \
+ int protocol ## _get_signature(hicn_type_t type, hicn_protocol_t * h, uint8_t ** signature) { return HICN_LIB_ERROR_ ## error ; }
+
#endif /* HICN_OPS_H */
/*
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index 3711a3f95..c1395dee8 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -144,6 +144,14 @@ ah_get_header_length (hicn_type_t type, const hicn_protocol_t * h,
}
int
+ah_get_signature (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t ** signature)
+{
+ *signature = h->ah.validationPayload;
+ return HICN_LIB_ERROR_NONE;
+}
+
+int
ah_get_signature_size (hicn_type_t type, const hicn_protocol_t * h,
size_t * signature_size)
{
diff --git a/lib/src/protocol/icmp.c b/lib/src/protocol/icmp.c
index 44b646fb2..45a28959c 100644
--- a/lib/src/protocol/icmp.c
+++ b/lib/src/protocol/icmp.c
@@ -39,7 +39,9 @@ DECLARE_set_lifetime (icmp, UNEXPECTED)
DECLARE_get_length (icmp, UNEXPECTED)
DECLARE_get_payload_length (icmp, UNEXPECTED)
DECLARE_set_payload_length (icmp, UNEXPECTED)
- int icmp_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
+DECLARE_get_signature (icmp, UNEXPECTED)
+
+int icmp_init_packet_header (hicn_type_t type, hicn_protocol_t * h)
{
h->icmp = (_icmp_header_t)
{
diff --git a/lib/src/protocol/ipv4.c b/lib/src/protocol/ipv4.c
index c0b2aaa8c..4e4c47f5b 100644
--- a/lib/src/protocol/ipv4.c
+++ b/lib/src/protocol/ipv4.c
@@ -443,6 +443,13 @@ ipv4_get_key_id (hicn_type_t type, hicn_protocol_t * h,
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
+int
+ipv4_get_signature (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t ** signature)
+{
+ return CHILD_OPS (get_signature, type, h, signature);
+}
+
DECLARE_HICN_OPS (ipv4);
/*
diff --git a/lib/src/protocol/ipv6.c b/lib/src/protocol/ipv6.c
index 41b00ec92..1cdcc75c0 100644
--- a/lib/src/protocol/ipv6.c
+++ b/lib/src/protocol/ipv6.c
@@ -401,6 +401,13 @@ ipv6_get_key_id (hicn_type_t type, hicn_protocol_t * h,
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
+int
+ipv6_get_signature (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t ** signature)
+{
+ return CHILD_OPS (get_signature, type, h, signature);
+}
+
DECLARE_HICN_OPS (ipv6);
/*
diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c
index 2afc4f6f4..08a1c73ef 100644
--- a/lib/src/protocol/tcp.c
+++ b/lib/src/protocol/tcp.c
@@ -359,6 +359,13 @@ tcp_get_key_id (hicn_type_t type, hicn_protocol_t * h,
return CHILD_OPS (get_key_id, type, h, key_id, key_id_size);
}
+int
+tcp_get_signature (hicn_type_t type, hicn_protocol_t * h,
+ uint8_t ** signature)
+{
+ return CHILD_OPS (get_signature, type, h, signature);
+}
+
DECLARE_HICN_OPS (tcp);
/*