summaryrefslogtreecommitdiff
path: root/src/ipcpd/ipcp.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-04-16 12:04:59 +0200
committerdimitri staessens <dimitri.staessens@ugent.be>2017-04-16 13:40:12 +0200
commit97ef24340da7d3f55a39ba16b400d13f9bbe9e60 (patch)
treee13656c267343db47a4f79d2098222909222736d /src/ipcpd/ipcp.c
parentc884fb9d6b3d3ea59f5fc7c5d709bfff4fcf1849 (diff)
downloadouroboros-97ef24340da7d3f55a39ba16b400d13f9bbe9e60.tar.gz
ouroboros-97ef24340da7d3f55a39ba16b400d13f9bbe9e60.zip
ipcpd: Allow specifying the hash algorithm to use
Currently CRC32, MD5, and SHA3 (224, 256, 384 and 512 bit) are supported.
Diffstat (limited to 'src/ipcpd/ipcp.c')
-rw-r--r--src/ipcpd/ipcp.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 47c951f1..19607ee1 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -63,23 +63,23 @@ void ipcp_sig_handler(int sig,
uint8_t * ipcp_hash_dup(const uint8_t * hash)
{
- uint8_t * dup = malloc(ipcpi.dir_hash_len);
+ uint8_t * dup = malloc(hash_len(ipcpi.dir_hash_algo));
if (dup == NULL)
return NULL;
- memcpy(dup, hash, ipcpi.dir_hash_len);
+ memcpy(dup, hash, ipcp_dir_hash_len());
return dup;
}
-void ipcp_hash_str(char buf[DIR_HASH_STRLEN + 1],
+void ipcp_hash_str(char * buf,
const uint8_t * hash)
{
size_t i;
char * HEX = "0123456789abcdef";
- for (i = 0; i < ipcpi.dir_hash_len; ++i) {
+ for (i = 0; i < ipcp_dir_hash_len(); ++i) {
buf[i * 2] = HEX[(hash[i] & 0xF0) >> 4];
buf[i * 2 + 1] = HEX[hash[i] & 0x0F];
}
@@ -212,7 +212,7 @@ static void * ipcp_main_loop(void * o)
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dir_hash_len = conf_msg->dir_hash_len;
+ conf.dir_hash_algo = conf_msg->dir_hash_algo;
conf.dif_name = conf_msg->dif_name;
if (conf.dif_name == NULL) {
ret_msg.has_result = true;
@@ -270,7 +270,7 @@ static void * ipcp_main_loop(void * o)
break;
}
- assert(msg->hash.len == ipcpi.dir_hash_len);
+ assert(msg->hash.len == ipcp_dir_hash_len());
ret_msg.result =
ipcpi.ops->ipcp_reg(msg->hash.data);
@@ -284,7 +284,7 @@ static void * ipcp_main_loop(void * o)
break;
}
- assert(msg->hash.len == ipcpi.dir_hash_len);
+ assert(msg->hash.len == ipcp_dir_hash_len());
ret_msg.result =
ipcpi.ops->ipcp_unreg(msg->hash.data);
@@ -298,7 +298,7 @@ static void * ipcp_main_loop(void * o)
break;
}
- assert(msg->hash.len == ipcpi.dir_hash_len);
+ assert(msg->hash.len == ipcp_dir_hash_len());
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_err("IPCP in wrong state.");
@@ -318,7 +318,7 @@ static void * ipcp_main_loop(void * o)
break;
}
- assert(msg->hash.len == ipcpi.dir_hash_len);
+ assert(msg->hash.len == ipcp_dir_hash_len());
if (ipcp_get_state() != IPCP_OPERATIONAL) {
log_err("IPCP in wrong state.");