summaryrefslogtreecommitdiffstats
path: root/lib/src
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2019-02-12 00:07:11 +0100
committerMauro Sardara <msardara@cisco.com>2019-02-12 16:17:06 +0000
commit45ae2768f2842cc55f153a71fa66b1d3e25e9ab7 (patch)
tree64c37894239daf920cd50d886e918271106d14b8 /lib/src
parentfbd4dd9c5eba6f8f10bcc0db30a72ea3378c149b (diff)
[HICN-52] Fix signature computation and verification in libtransport
Change-Id: I9b30a9c9e95e2cb2f135fe7efd43e633235196d9 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'lib/src')
-rw-r--r--lib/src/protocol/ah.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/src/protocol/ah.c b/lib/src/protocol/ah.c
index 8bd9bca83..5a30f66f6 100644
--- a/lib/src/protocol/ah.c
+++ b/lib/src/protocol/ah.c
@@ -144,8 +144,7 @@ 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)
+ah_get_signature (hicn_type_t type, hicn_protocol_t * h, uint8_t ** signature)
{
*signature = h->ah.validationPayload;
return HICN_LIB_ERROR_NONE;
@@ -163,29 +162,31 @@ int
ah_set_signature_size (hicn_type_t type, hicn_protocol_t * h,
const size_t signature_size)
{
- h->ah.payloadlen = (u8)(signature_size >> 2);
+ h->ah.payloadlen = (u8) (signature_size >> 2);
return HICN_LIB_ERROR_NONE;
}
int
-ah_set_signature_timestamp(hicn_type_t type, hicn_protocol_t * h,
- uint64_t signature_timestamp)
+ah_set_signature_timestamp (hicn_type_t type, hicn_protocol_t * h,
+ uint64_t signature_timestamp)
{
- memcpy(h->ah.timestamp_as_u8, &signature_timestamp, 8);
+ uint64_t netwok_order_timestamp = htonll (signature_timestamp);
+ memcpy (h->ah.timestamp_as_u8, &netwok_order_timestamp, sizeof (uint64_t));
return HICN_LIB_ERROR_NONE;
}
int
ah_get_signature_timestamp (hicn_type_t type, const hicn_protocol_t * h,
- uint64_t * signature_timestamp)
+ uint64_t * signature_timestamp)
{
- memcpy(signature_timestamp, h->ah.timestamp_as_u8, 8);
+ memcpy (signature_timestamp, h->ah.timestamp_as_u8, sizeof (uint64_t));
+ *signature_timestamp = ntohll (*signature_timestamp);
return HICN_LIB_ERROR_NONE;
}
int
ah_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
- uint8_t validation_algorithm)
+ uint8_t validation_algorithm)
{
h->ah.validationAlgorithm = validation_algorithm;
return HICN_LIB_ERROR_NONE;
@@ -193,26 +194,25 @@ ah_set_validation_algorithm (hicn_type_t type, hicn_protocol_t * h,
int
ah_get_validation_algorithm (hicn_type_t type, const hicn_protocol_t * h,
- uint8_t * validation_algorithm)
+ uint8_t * validation_algorithm)
{
*validation_algorithm = h->ah.validationAlgorithm;
return HICN_LIB_ERROR_NONE;
}
int
-ah_set_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t *key_id)
+ah_set_key_id (hicn_type_t type, hicn_protocol_t * h, uint8_t * key_id)
{
- memcpy(h->ah.keyId, key_id, sizeof(h->ah.keyId));
+ memcpy (h->ah.keyId, key_id, sizeof (h->ah.keyId));
return HICN_LIB_ERROR_NONE;
}
int
ah_get_key_id (hicn_type_t type, hicn_protocol_t * h,
- uint8_t **key_id, uint8_t *key_id_size)
+ uint8_t ** key_id, uint8_t * key_id_size)
{
*key_id = h->ah.keyId;
- *key_id_size = sizeof(h->ah.keyId);
+ *key_id_size = sizeof (h->ah.keyId);
return HICN_LIB_ERROR_NONE;
}