commit 7aa10094f23817e6b73dfdcd8991dfa6319b718a
parent 0cea78643dbb16ceeef7ef4e8430827506579028
Author: nolash <dev@holbrook.no>
Date: Thu, 23 Sep 2021 08:50:50 +0200
Unsign all buffers
Diffstat:
8 files changed, 41 insertions(+), 41 deletions(-)
diff --git a/src/keystore.c b/src/keystore.c
@@ -33,7 +33,7 @@ unsigned char* keystore_sign(const keystore_t *keystore, unsigned char *z, const
// will _copy_ key to keystore
-keystore_key_t* keystore_put(keystore_t *keystore, const keystore_key_t *key_in, const char *passphrase, size_t passphrase_sz) {
+keystore_key_t* keystore_put(keystore_t *keystore, const keystore_key_t *key_in, const unsigned char *passphrase, size_t passphrase_sz) {
keystore_key_t *key_out;
key_out = keystore->keys + keystore->keys_count;
diff --git a/src/keystore.h b/src/keystore.h
@@ -20,7 +20,7 @@ typedef struct keystore {
} keystore_t;
-keystore_key_t* keystore_put(keystore_t *keystore, const keystore_key_t *z, const char *passphrase, size_t passphrase_sz);
+keystore_key_t* keystore_put(keystore_t *keystore, const keystore_key_t *z, const unsigned char *passphrase, size_t passphrase_sz);
keystore_key_t* keystore_get(const keystore_t *keystore, keystore_key_t *z, const int idx);
unsigned char* keystore_sign(const keystore_t *keystore, unsigned char *z, const int key_idx, const unsigned char *digest);
keystore_key_t* key_recover(keystore_key_t *key, const unsigned char *signature, const unsigned char *digest);
diff --git a/src/soc.c b/src/soc.c
@@ -7,10 +7,10 @@
#include "soc.h"
// z must be minimum 84 bytes long (32 bytes for out, 20 bytes for topic, 32 bytes for index)
-int soc_identifier(char *z, const char *topic, const char *index) {
+int soc_identifier(unsigned char *z, const unsigned char *topic, const unsigned char *index) {
int r;
- char *p;
- char *src;
+ unsigned char *p;
+ unsigned char *src;
size_t src_sz;
src_sz = SWARM_SOC_TOPIC_SIZE + SWARM_SOC_INDEX_SIZE;
@@ -31,10 +31,10 @@ int soc_identifier(char *z, const char *topic, const char *index) {
}
// z must be minimum 84 bytes long (32 bytes for out, 20 bytes for topic, 32 bytes for index)
-int soc_address(char *z, const char *identifier, const char *address) {
+int soc_address(unsigned char *z, const unsigned char *identifier, const unsigned char *address) {
int r;
- char *p;
- char *src;
+ unsigned char *p;
+ unsigned char *src;
size_t src_sz;
src_sz = SWARM_SOC_IDENTIFIER_SIZE + SWARM_ADDRESS_SIZE;
diff --git a/src/soc.h b/src/soc.h
@@ -15,8 +15,8 @@ typedef struct soc_chunk {
swarm_chunk_t data;
} soc_chunk_t;
-int soc_identifier(char *z, const char *topic, const char *index);
-int soc_address(char *z, const char *identifier, const char *address);
+int soc_identifier(unsigned char *z, const unsigned char *topic, const unsigned char *index);
+int soc_address(unsigned char *z, const unsigned char *identifier, const unsigned char *address);
int soc_digest(const soc_chunk_t* chunk, unsigned char *z);
unsigned char* soc_serialize(const soc_chunk_t *chunk, unsigned char *z, size_t *sz);
int soc_verify(const soc_chunk_t *chunk, const keystore_key_t *key_cmp);
diff --git a/src/swarmfile.c b/src/swarmfile.c
@@ -4,7 +4,7 @@
#include "def.h"
#include "swarmfile.h"
-static inline void filehash_callback(filehash_t *fctx, const char *hash, const char *data, const size_t data_length) {
+static inline void filehash_callback(filehash_t *fctx, const unsigned char *hash, const unsigned char *data, const size_t data_length) {
if (fctx->callback != NULL) {
(*fctx->callback)(hash, data, data_length, fctx->callback_static);
}
@@ -71,7 +71,7 @@ bmt_spansize_t filehash_sum(filehash_t *fctx) {
}
-void filehash_init_callback(filehash_t *fctx, void (*callback)(const char*, const char*, const size_t, void*), void *callback_static) {
+void filehash_init_callback(filehash_t *fctx, void (*callback)(const unsigned char*, const unsigned char*, const size_t, void*), void *callback_static) {
int i;
int l;
@@ -93,7 +93,7 @@ void filehash_init(filehash_t *fctx) {
}
-static int filehash_write_hash(filehash_t *fctx, int level, const char *data) {
+static int filehash_write_hash(filehash_t *fctx, int level, const unsigned char *data) {
bmt_t *bctx;
int next_level;
int r;
@@ -120,7 +120,7 @@ static int filehash_write_hash(filehash_t *fctx, int level, const char *data) {
return 0;
}
-int filehash_write(filehash_t *fctx, const char *data, const size_t data_length) {
+int filehash_write(filehash_t *fctx, const unsigned char *data, const size_t data_length) {
bmt_t *bctx;
int r;
diff --git a/src/swarmfile.h b/src/swarmfile.h
@@ -11,21 +11,21 @@
#define SWARM_LEVELS 9
typedef struct filehash {
- char buf[SWARM_LEVELS * SWARM_BLOCK_SIZE];
- char *ptr[SWARM_LEVELS];
- char *target;
+ unsigned char buf[SWARM_LEVELS * SWARM_BLOCK_SIZE];
+ unsigned char *ptr[SWARM_LEVELS];
+ unsigned char *target;
long long writes[SWARM_LEVELS];
long long spans[SWARM_LEVELS];
long long length;
- void (*callback)(const char*, const char*, const size_t, void*);
+ void (*callback)(const unsigned char*, const unsigned char*, const size_t, void*);
void *callback_static;
bmt_t bmt_context;
} filehash_t;
void filehash_reset(filehash_t *filehash_context);
void filehash_init(filehash_t *filehash_context);
-void filehash_init_callback(filehash_t *filehash_context, void (*callback)(const char*, const char*, const size_t, void*), void *callback_static);
-int filehash_write(filehash_t *filehash_context, const char *data, const size_t data_length);
+void filehash_init_callback(filehash_t *filehash_context, void (*callback)(const unsigned char*, const unsigned char*, const size_t, void*), void *callback_static);
+int filehash_write(filehash_t *filehash_context, const unsigned char *data, const size_t data_length);
bmt_spansize_t filehash_sum(filehash_t *filehash_content);
#endif // _LIBSWARM_FILE
diff --git a/test/check_bmt.c b/test/check_bmt.c
@@ -23,9 +23,9 @@ END_TEST
START_TEST(check_bmt_sum_foo) {
bmt_t bmt_context;
- char *input = "foo";
- char v_chk[SWARM_WORD_SIZE];
- char input_length = 3;
+ unsigned char *input = "foo";
+ unsigned char v_chk[SWARM_WORD_SIZE];
+ unsigned char input_length = 3;
int r;
bmt_init(&bmt_context, input, input_length, 3);
@@ -54,7 +54,7 @@ START_TEST(check_bmt_sum_vector) {
//SWARM_BLOCK_SIZE - 1,
SWARM_BLOCK_SIZE,
};
- char *vectors[] = {
+ unsigned char *vectors[] = {
"ece86edb20669cc60d142789d464d57bdf5e33cb789d443f608cbd81cfa5697d",
"0be77f0bb7abc9cd0abed640ee29849a3072ccfd1020019fe03658c38f087e02",
"3463b46d4f9d5bfcbf9a23224d635e51896c1daef7d225b86679db17c5fd868e",
@@ -64,8 +64,8 @@ START_TEST(check_bmt_sum_vector) {
//"",
"c10090961e7682a10890c334d759a28426647141213abda93b096b892824d2ef",
};
- char v_chk[SWARM_WORD_SIZE];
- char buf[SWARM_BLOCK_SIZE];
+ unsigned char v_chk[SWARM_WORD_SIZE];
+ unsigned char buf[SWARM_BLOCK_SIZE];
struct block_generator bg;
bg.m = 255;
diff --git a/test/check_file.c b/test/check_file.c
@@ -15,9 +15,9 @@ const char *callback_static_foo = "foo";
int file_callback_serial = 0;
int file_callback_dir_fd = -1;
-void file_callback(const char *hash, const char *data, const size_t data_length, void *callback_static) {
+void file_callback(const unsigned char *hash, const unsigned char *data, const size_t data_length, void *callback_static) {
int fd;
- char filename[32];
+ unsigned char filename[32];
sprintf(filename, "d%d", file_callback_serial);
fd = openat(file_callback_dir_fd, filename, O_CREAT | O_EXCL | O_RDWR | O_CLOEXEC | O_SYNC);
@@ -31,7 +31,7 @@ void file_callback(const char *hash, const char *data, const size_t data_length,
write(fd, hash, SWARM_WORD_SIZE);
close(fd);
- ck_assert_str_eq((char*)callback_static, callback_static_foo);
+ ck_assert_str_eq((unsigned char*)callback_static, callback_static_foo);
file_callback_serial++;
}
@@ -53,7 +53,7 @@ START_TEST(check_file_single_write) {
filehash_t fh;
int r;
- const char *data = "foo";
+ const unsigned char *data = "foo";
filehash_init(&fh);
@@ -97,9 +97,9 @@ START_TEST(check_file_callback_data) {
filehash_t fh;
int r;
- const char *data = "foo";
- char cbdir_template[] = "swarmfile_test_callback_data_XXXXXX";
- char *cbdir;
+ const unsigned char *data = "foo";
+ unsigned char cbdir_template[] = "swarmfile_test_callback_data_XXXXXX";
+ unsigned char *cbdir;
cbdir = mkdtemp(cbdir_template);
ck_assert_ptr_nonnull(cbdir);
@@ -124,12 +124,12 @@ START_TEST(check_file_callback_intermediate) {
int r;
struct block_generator bg;
- char buf[SWARM_BLOCK_SIZE * (SWARM_BATCH_SIZE + 1)];
- char cbdir_template[] = "swarmfile_test_callback_intermediate_XXXXXX";
- char *cbdir;
- char cbfilename[1024];
+ unsigned char buf[SWARM_BLOCK_SIZE * (SWARM_BATCH_SIZE + 1)];
+ unsigned char cbdir_template[] = "swarmfile_test_callback_intermediate_XXXXXX";
+ unsigned char *cbdir;
+ unsigned char cbfilename[1024];
int cbfd;
- char cbbuf[SWARM_BLOCK_SIZE];
+ unsigned char cbbuf[SWARM_BLOCK_SIZE];
file_callback_serial = 0;
cbdir = mkdtemp(cbdir_template);
@@ -200,9 +200,9 @@ START_TEST(check_file_vectors) {
int whole;
int part;
int writes;
- char v_chk[SWARM_WORD_SIZE];
+ unsigned char v_chk[SWARM_WORD_SIZE];
struct block_generator bg;
- char buf[SWARM_BLOCK_SIZE];
+ unsigned char buf[SWARM_BLOCK_SIZE];
int lengths[] = {
SWARM_BLOCK_SIZE,
@@ -220,7 +220,7 @@ START_TEST(check_file_vectors) {
SWARM_BLOCK_SIZE * SWARM_BATCH_SIZE * SWARM_BATCH_SIZE,
};
- char *vectors[] = {
+ unsigned char *vectors[] = {
"c10090961e7682a10890c334d759a28426647141213abda93b096b892824d2ef",
"91699c83ed93a1f87e326a29ccd8cc775323f9e7260035a5f014c975c5f3cd28",
"73759673a52c1f1707cbb61337645f4fcbd209cdc53d7e2cedaaa9f44df61285",