summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/CMakeLists.txt3
-rw-r--r--src/lib/btree.c3
-rw-r--r--src/lib/dev.c9
-rw-r--r--src/lib/hash.c (renamed from src/lib/btree.h)36
-rw-r--r--src/lib/ipcp_config.proto (renamed from src/lib/dif_config.proto)33
-rw-r--r--src/lib/ipcpd_messages.proto31
-rw-r--r--src/lib/irm.c13
-rw-r--r--src/lib/irmd_messages.proto35
-rw-r--r--src/lib/rib.c24
-rw-r--r--src/lib/sha3.c6
-rw-r--r--src/lib/sha3.h86
-rw-r--r--src/lib/tests/btree_test.c2
-rw-r--r--src/lib/tests/sha3_test.c100
13 files changed, 149 insertions, 232 deletions
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index f6a30ef7..cb94ef53 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -7,7 +7,7 @@ include_directories(${CMAKE_BINARY_DIR}/include)
protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS irmd_messages.proto)
protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS ipcpd_messages.proto)
protobuf_generate_c(DIF_CONFIG_PROTO_SRCS DIF_CONFIG_PROTO_HDRS
- dif_config.proto)
+ ipcp_config.proto)
protobuf_generate_c(CDAP_PROTO_SRCS CDAP_PROTO_HDRS cdap.proto)
protobuf_generate_c(RO_PROTO_SRCS RO_PROTO_HDRS ro.proto)
protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS cacep.proto)
@@ -35,6 +35,7 @@ set(SOURCE_FILES
cdap_req.c
crc32.c
dev.c
+ hash.c
hashtable.c
irm.c
list.c
diff --git a/src/lib/btree.c b/src/lib/btree.c
index 48df8e39..03047a18 100644
--- a/src/lib/btree.c
+++ b/src/lib/btree.c
@@ -22,8 +22,7 @@
*/
#include <ouroboros/errno.h>
-
-#include "btree.h"
+#include <ouroboros/btree.h>
#include <stdlib.h>
#include <stdbool.h>
diff --git a/src/lib/dev.c b/src/lib/dev.c
index 18890234..d68fb471 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -1210,7 +1210,8 @@ int ipcp_create_r(pid_t api,
}
int ipcp_flow_req_arr(pid_t api,
- char * dst_name,
+ uint8_t * dst,
+ size_t len,
qoscube_t cube)
{
irm_msg_t msg = IRM_MSG__INIT;
@@ -1218,13 +1219,15 @@ int ipcp_flow_req_arr(pid_t api,
int port_id = -1;
int fd = -1;
- if (dst_name == NULL)
+ if (dst == NULL)
return -EINVAL;
msg.code = IRM_MSG_CODE__IPCP_FLOW_REQ_ARR;
msg.has_api = true;
msg.api = api;
- msg.dst_name = dst_name;
+ msg.has_hash = true;
+ msg.hash.len = len;
+ msg.hash.data = dst;
msg.has_qoscube = true;
msg.qoscube = cube;
diff --git a/src/lib/btree.h b/src/lib/hash.c
index f7c293c5..f4fd75ea 100644
--- a/src/lib/btree.h
+++ b/src/lib/hash.c
@@ -1,11 +1,14 @@
/*
* Ouroboros - Copyright (C) 2016 - 2017
*
- * B-trees
+ * Hashing
*
* Dimitri Staessens <dimitri.staessens@ugent.be>
* Sander Vrijders <sander.vrijders@ugent.be>
*
+ * This implementation is adapted and redistributed from the RHASH
+ * project
+ *
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
@@ -21,27 +24,20 @@
* 02110-1301 USA
*/
-#ifndef OUROBOROS_LIB_BTREE_H
-#define OUROBOROS_LIB_BTREE_H
-
-#include <stddef.h>
-#include <stdint.h>
-
-struct btree;
-
-/* Create a B-tree of order k */
-struct btree * btree_create(size_t k);
+#include <ouroboros/config.h>
+#include <ouroboros/hash.h>
-void btree_destroy(struct btree * tree);
+#include <string.h>
-int btree_insert(struct btree * tree,
- uint32_t key,
- void * val);
+void get_hash(uint8_t buf[],
+ const char * name)
+{
+ /* currently we only support 256 bit SHA-3 */
+ struct sha3_ctx ctx;
-int btree_remove(struct btree * tree,
- uint32_t key);
+ rhash_sha3_256_init(&ctx);
-void * btree_search(struct btree * tree,
- uint32_t key);
+ rhash_sha3_update(&ctx, name, strlen(name));
-#endif /* OUROBOROS_LIB_BTREE_H */
+ rhash_sha3_final(&ctx, buf);
+}
diff --git a/src/lib/dif_config.proto b/src/lib/ipcp_config.proto
index d47af049..a0c14c41 100644
--- a/src/lib/dif_config.proto
+++ b/src/lib/ipcp_config.proto
@@ -23,24 +23,25 @@
syntax = "proto2";
-message dif_config_msg {
+message ipcp_config_msg {
required string dif_name = 1;
- required int32 ipcp_type = 2;
+ required uint32 dir_hash_len = 2;
+ required int32 ipcp_type = 3;
// Config for normal IPCP
- optional uint32 addr_size = 3;
- optional uint32 cep_id_size = 4;
- optional uint32 pdu_length_size = 5;
- optional uint32 seqno_size = 6;
- optional bool has_ttl = 7;
- optional bool has_chk = 8;
- optional uint32 min_pdu_size = 9;
- optional uint32 max_pdu_size = 10;
- optional uint32 addr_auth_type = 11;
- optional uint32 dt_gam_type = 12;
- optional uint32 rm_gam_type = 13;
+ optional uint32 addr_size = 4;
+ optional uint32 cep_id_size = 5;
+ optional uint32 pdu_length_size = 6;
+ optional uint32 seqno_size = 7;
+ optional bool has_ttl = 8;
+ optional bool has_chk = 9;
+ optional uint32 min_pdu_size = 10;
+ optional uint32 max_pdu_size = 11;
+ optional uint32 addr_auth_type = 12;
+ optional uint32 dt_gam_type = 13;
+ optional uint32 rm_gam_type = 14;
// Config for shim UDP
- optional uint32 ip_addr = 14;
- optional uint32 dns_addr = 15;
+ optional uint32 ip_addr = 15;
+ optional uint32 dns_addr = 16;
// Config for the shim Ethernet LLC
- optional string if_name = 16;
+ optional string if_name = 17;
} \ No newline at end of file
diff --git a/src/lib/ipcpd_messages.proto b/src/lib/ipcpd_messages.proto
index da817944..bd71d3f3 100644
--- a/src/lib/ipcpd_messages.proto
+++ b/src/lib/ipcpd_messages.proto
@@ -23,14 +23,14 @@
syntax = "proto2";
-import "dif_config.proto";
+import "ipcp_config.proto";
enum ipcp_msg_code {
IPCP_BOOTSTRAP = 1;
IPCP_ENROLL = 2;
- IPCP_NAME_REG = 3;
- IPCP_NAME_UNREG = 4;
- IPCP_NAME_QUERY = 5;
+ IPCP_REG = 3;
+ IPCP_UNREG = 4;
+ IPCP_QUERY = 5;
IPCP_FLOW_ALLOC = 6;
IPCP_FLOW_ALLOC_RESP = 7;
IPCP_FLOW_DEALLOC = 8;
@@ -38,17 +38,14 @@ enum ipcp_msg_code {
};
message ipcp_msg {
- required ipcp_msg_code code = 1;
- optional string dif_name = 2;
- repeated string dif_names = 3;
- optional int32 len = 4;
- optional string name = 5;
- optional sint32 port_id = 6;
- optional string dst_name = 7;
- optional sint32 qoscube = 8;
- optional dif_config_msg conf = 9;
- optional sint32 fd = 10;
- optional sint32 api = 11;
- optional sint32 response = 12;
- optional sint32 result = 13;
+ required ipcp_msg_code code = 1;
+ optional string name = 2;
+ optional bytes hash = 3;
+ optional int32 port_id = 4;
+ optional string dst_name = 5;
+ optional uint32 qoscube = 6;
+ optional ipcp_config_msg conf = 7;
+ optional int32 api = 8;
+ optional int32 response = 9;
+ optional int32 result = 10;
};
diff --git a/src/lib/irm.c b/src/lib/irm.c
index 57e09369..a2fd5d0b 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -87,13 +87,13 @@ int irm_destroy_ipcp(pid_t api)
return ret;
}
-int irm_bootstrap_ipcp(pid_t api,
- const struct dif_config * conf)
+int irm_bootstrap_ipcp(pid_t api,
+ const struct ipcp_config * conf)
{
- irm_msg_t msg = IRM_MSG__INIT;
- dif_config_msg_t config = DIF_CONFIG_MSG__INIT;
- irm_msg_t * recv_msg = NULL;
- int ret = -1;
+ irm_msg_t msg = IRM_MSG__INIT;
+ ipcp_config_msg_t config = IPCP_CONFIG_MSG__INIT;
+ irm_msg_t * recv_msg = NULL;
+ int ret = -1;
if (api == -1 || conf == NULL)
return -EINVAL;
@@ -105,6 +105,7 @@ int irm_bootstrap_ipcp(pid_t api,
msg.conf = &config;
config.dif_name = conf->dif_name;
config.ipcp_type = conf->type;
+ config.dir_hash_len = (uint16_t) conf->dir_hash_len;
switch (conf->type) {
case IPCP_NORMAL:
diff --git a/src/lib/irmd_messages.proto b/src/lib/irmd_messages.proto
index e218f6f6..138810da 100644
--- a/src/lib/irmd_messages.proto
+++ b/src/lib/irmd_messages.proto
@@ -23,7 +23,7 @@
syntax = "proto2";
-import "dif_config.proto";
+import "ipcp_config.proto";
enum irm_msg_code {
IRM_CREATE_IPCP = 1;
@@ -48,20 +48,21 @@ enum irm_msg_code {
};
message irm_msg {
- required irm_msg_code code = 1;
- optional string ap_name = 2;
- optional sint32 api = 3;
- optional uint32 ipcp_type = 4;
- repeated string dif_name = 5;
- repeated string args = 6;
- optional sint32 response = 7;
- optional string dst_name = 8;
- optional sint32 port_id = 9;
- optional sint32 qoscube = 10;
- optional dif_config_msg conf = 11;
- optional uint32 opts = 12;
- repeated sint32 apis = 13;
- optional uint32 timeo_sec = 14;
- optional uint32 timeo_nsec = 15;
- optional sint32 result = 16;
+ required irm_msg_code code = 1;
+ optional string ap_name = 2;
+ optional sint32 api = 3;
+ optional uint32 ipcp_type = 4;
+ repeated string dif_name = 5;
+ repeated string args = 6;
+ optional sint32 response = 7;
+ optional string dst_name = 8;
+ optional bytes hash = 9;
+ optional sint32 port_id = 10;
+ optional sint32 qoscube = 11;
+ optional ipcp_config_msg conf = 12;
+ optional uint32 opts = 13;
+ repeated sint32 apis = 14;
+ optional uint32 timeo_sec = 15;
+ optional uint32 timeo_nsec = 16;
+ optional sint32 result = 17;
};
diff --git a/src/lib/rib.c b/src/lib/rib.c
index d39a17d2..2645e90b 100644
--- a/src/lib/rib.c
+++ b/src/lib/rib.c
@@ -29,9 +29,8 @@
#include <ouroboros/bitmap.h>
#include <ouroboros/crc32.h>
#include <ouroboros/time_utils.h>
-
-#include "sha3.h"
-#include "btree.h"
+#include <ouroboros/sha3.h>
+#include <ouroboros/btree.h>
#include "ro.pb-c.h"
typedef RoMsg ro_msg_t;
@@ -94,7 +93,7 @@ struct rnode {
uint8_t * data;
size_t len;
- uint8_t sha3[sha3_256_hash_size];
+ uint8_t sha3[SHA3_256_HASH_LEN];
struct rnode * parent;
@@ -142,7 +141,7 @@ static void rnode_hash(struct rnode * node)
list_for_each(p, &node->children) {
struct child * c = list_entry(p, struct child, next);
- rhash_sha3_update(&ctx, c->node->sha3, sha3_256_hash_size);
+ rhash_sha3_update(&ctx, c->node->sha3, SHA3_256_HASH_LEN);
}
rhash_sha3_final(&ctx, node->sha3);
@@ -654,7 +653,7 @@ int rib_write(const char * path,
uint8_t * cdata;
- if (path == NULL)
+ if (path == NULL || data == NULL || len == 0)
return -EINVAL;
cdata = malloc(len);
@@ -666,8 +665,13 @@ int rib_write(const char * path,
pthread_rwlock_rdlock(&rib.lock);
node = find_rnode_by_path(path);
- if (node != NULL)
- rnode_update(node, cdata, len);
+ if (node == NULL) {
+ pthread_rwlock_unlock(&rib.lock);
+ free(cdata);
+ return -1;
+ }
+
+ rnode_update(node, cdata, len);
pthread_rwlock_unlock(&rib.lock);
@@ -1226,7 +1230,7 @@ static ro_msg_t * rnode_pack(struct rnode * node,
(flags & PACK_HASH_ALL)) {
msg->has_hash = true;
msg->hash.data = node->sha3;
- msg->hash.len = sha3_256_hash_size;
+ msg->hash.len = SHA3_256_HASH_LEN;
}
if (node->data != NULL) {
@@ -1407,7 +1411,7 @@ int rib_unpack(uint8_t * packed,
if (ret == 0 && msg->has_hash) {
root = rnode_get_child(root, msg->name);
- if (memcmp(msg->hash.data, root->sha3, sha3_256_hash_size)) {
+ if (memcmp(msg->hash.data, root->sha3, SHA3_256_HASH_LEN)) {
ro_msg__free_unpacked(msg, NULL);
return -EFAULT;
}
diff --git a/src/lib/sha3.c b/src/lib/sha3.c
index 750038f2..f80cc4bd 100644
--- a/src/lib/sha3.c
+++ b/src/lib/sha3.c
@@ -44,12 +44,11 @@
*/
#include <ouroboros/endian.h>
+#include <ouroboros/sha3.h>
#include <assert.h>
#include <string.h>
-#include "sha3.h"
-
#define IS_ALIGNED_64(p) (0 == (7 & ((const uint8_t *) (p) \
- (const uint8_t *) 0)))
#define I64(x) x##LL
@@ -262,11 +261,12 @@ static void rhash_sha3_process_block(uint64_t hash[25],
#define SHA3_FINALIZED 0x80000000
void rhash_sha3_update(struct sha3_ctx * ctx,
- const uint8_t * msg,
+ const void * pmsg,
size_t size)
{
size_t idx = (size_t) ctx->rest;
size_t block_size = (size_t) ctx->block_size;
+ uint8_t * msg = (uint8_t *) pmsg;
if (ctx->rest & SHA3_FINALIZED) return;
ctx->rest = (unsigned) ((ctx->rest + size) % block_size);
diff --git a/src/lib/sha3.h b/src/lib/sha3.h
deleted file mode 100644
index 6ce67482..00000000
--- a/src/lib/sha3.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * SHA3 algorithm
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This implementation is adapted and redistributed from the RHASH
- * project implementation of the sha3 algorithm
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- * -- original license
- *
- * sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak).
- * based on the
- * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011
- * by Guido Bertoni, Joan Daemen, Michaƫl Peeters and Gilles Van Assche
- *
- * Copyright: 2013 Aleksey Kravchenko <rhash.admin@gmail.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk!
- */
-
-#ifndef OUROBOROS_LIB_SHA3_H
-#define OUROBOROS_LIB_SHA3_H
-
-#include <unistd.h>
-#include <stdint.h>
-
-#define sha3_224_hash_size 28
-#define sha3_256_hash_size 32
-#define sha3_384_hash_size 48
-#define sha3_512_hash_size 64
-#define sha3_max_permutation_size 25
-#define sha3_max_rate_in_qwords 24
-
-struct sha3_ctx {
- /* 1600 bits algorithm hashing state */
- uint64_t hash[sha3_max_permutation_size];
- /* 1536-bit buffer for leftovers */
- uint64_t message[sha3_max_rate_in_qwords];
- /* count of bytes in the message[] buffer */
- unsigned rest;
- /* size of a message block processed at once */
- unsigned block_size;
-};
-
-void rhash_sha3_224_init(struct sha3_ctx * ctx);
-
-void rhash_sha3_256_init(struct sha3_ctx * ctx);
-
-void rhash_sha3_384_init(struct sha3_ctx * ctx);
-
-void rhash_sha3_512_init(struct sha3_ctx * ctx);
-
-void rhash_sha3_update(struct sha3_ctx * ctx,
- const uint8_t * msg,
- size_t size);
-
-void rhash_sha3_final(struct sha3_ctx * ctx,
- uint8_t * res);
-
-#endif /* OUROBOROS_LIB_SHA3_H */
diff --git a/src/lib/tests/btree_test.c b/src/lib/tests/btree_test.c
index a6344060..83fafabd 100644
--- a/src/lib/tests/btree_test.c
+++ b/src/lib/tests/btree_test.c
@@ -21,7 +21,7 @@
*/
-#include "btree.h"
+#include <ouroboros/btree.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/src/lib/tests/sha3_test.c b/src/lib/tests/sha3_test.c
index 212452ef..8f1bce05 100644
--- a/src/lib/tests/sha3_test.c
+++ b/src/lib/tests/sha3_test.c
@@ -20,7 +20,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#include "sha3.h"
+#include <ouroboros/sha3.h>
#include <stdlib.h>
#include <stdint.h>
@@ -84,7 +84,7 @@ int sha3_test(int argc,
struct sha3_ctx ctx;
/* Storage for result. */
- uint8_t res[sha3_512_hash_size];
+ uint8_t res[SHA3_512_HASH_LEN];
/* SHA3 test vectors */
char * str1_inp = "abc";
@@ -172,124 +172,124 @@ int sha3_test(int argc,
printf("test: %s.\n\n", str1_inp);
rhash_sha3_224_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str1_inp, strlen(str1_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str1_inp, strlen(str1_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str1_224, res, sha3_224_hash_size))
+ if (check_hash(str1_224, res, SHA3_224_HASH_LEN))
return -1;
rhash_sha3_256_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str1_inp, strlen(str1_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str1_inp, strlen(str1_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str1_256, res, sha3_256_hash_size))
+ if (check_hash(str1_256, res, SHA3_256_HASH_LEN))
return -1;
rhash_sha3_384_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str1_inp, strlen(str1_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str1_inp, strlen(str1_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str1_384, res, sha3_384_hash_size))
+ if (check_hash(str1_384, res, SHA3_384_HASH_LEN))
return -1;
rhash_sha3_512_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str1_inp, strlen(str1_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str1_inp, strlen(str1_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str1_512, res, sha3_512_hash_size))
+ if (check_hash(str1_512, res, SHA3_512_HASH_LEN))
return -1;
/* 2nd input string. */
printf("test: <empty string>.\n\n");
rhash_sha3_224_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str2_inp, strlen(str2_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str2_inp, strlen(str2_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str2_224, res, sha3_224_hash_size))
+ if (check_hash(str2_224, res, SHA3_224_HASH_LEN))
return -1;
rhash_sha3_256_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str2_inp, strlen(str2_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str2_inp, strlen(str2_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str2_256, res, sha3_256_hash_size))
+ if (check_hash(str2_256, res, SHA3_256_HASH_LEN))
return -1;
rhash_sha3_384_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str2_inp, strlen(str2_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str2_inp, strlen(str2_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str2_384, res, sha3_384_hash_size))
+ if (check_hash(str2_384, res, SHA3_384_HASH_LEN))
return -1;
rhash_sha3_512_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str2_inp, strlen(str2_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str2_inp, strlen(str2_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str2_512, res, sha3_512_hash_size))
+ if (check_hash(str2_512, res, SHA3_512_HASH_LEN))
return -1;
/* 3rd input string */
printf("test: %s.\n\n", str3_inp);
rhash_sha3_224_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str3_inp, strlen(str3_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str3_inp, strlen(str3_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str3_224, res, sha3_224_hash_size))
+ if (check_hash(str3_224, res, SHA3_224_HASH_LEN))
return -1;
rhash_sha3_256_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str3_inp, strlen(str3_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str3_inp, strlen(str3_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str3_256, res, sha3_256_hash_size))
+ if (check_hash(str3_256, res, SHA3_256_HASH_LEN))
return -1;
rhash_sha3_384_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str3_inp, strlen(str3_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str3_inp, strlen(str3_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str3_384, res, sha3_384_hash_size))
+ if (check_hash(str3_384, res, SHA3_384_HASH_LEN))
return -1;
rhash_sha3_512_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str3_inp, strlen(str3_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str3_inp, strlen(str3_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str3_512, res, sha3_512_hash_size))
+ if (check_hash(str3_512, res, SHA3_512_HASH_LEN))
return -1;
/* 4th input string. */
printf("test: %s.\n\n", str4_inp);
rhash_sha3_224_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str4_inp, strlen(str4_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str4_inp, strlen(str4_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str4_224, res, sha3_224_hash_size))
+ if (check_hash(str4_224, res, SHA3_224_HASH_LEN))
return -1;
rhash_sha3_256_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str4_inp, strlen(str4_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str4_inp, strlen(str4_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str4_256, res, sha3_256_hash_size))
+ if (check_hash(str4_256, res, SHA3_256_HASH_LEN))
return -1;
rhash_sha3_384_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str4_inp, strlen(str4_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str4_inp, strlen(str4_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str4_384, res, sha3_384_hash_size))
+ if (check_hash(str4_384, res, SHA3_384_HASH_LEN))
return -1;
rhash_sha3_512_init(&ctx);
- rhash_sha3_update(&ctx, (uint8_t *) str4_inp, strlen(str4_inp));
- rhash_sha3_final(&ctx, (uint8_t *) res);
+ rhash_sha3_update(&ctx, str4_inp, strlen(str4_inp));
+ rhash_sha3_final(&ctx, res);
- if (check_hash(str4_512, res, sha3_512_hash_size))
+ if (check_hash(str4_512, res, SHA3_512_HASH_LEN))
return -1;
return 0;