From: bdemsky Date: Sat, 3 Mar 2018 11:45:10 +0000 (-0800) Subject: edits X-Git-Url: http://plrg.eecs.uci.edu/git/?p=iotcloud.git;a=commitdiff_plain;h=8981ac1037b9381ff64428f9236cbf2d4954d1e2;ds=sidebyside edits --- diff --git a/version2/src/C/Makefile b/version2/src/C/Makefile index 7603cc4..e450130 100644 --- a/version2/src/C/Makefile +++ b/version2/src/C/Makefile @@ -10,7 +10,7 @@ HEADERS := $(wildcard *.h) OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o) -CFLAGS := -Wall -O0 -g +CFLAGS := -Wall -O3 -g CFLAGS += -I. LDFLAGS := -ldl -lrt -rdynamic -g SHARED := -shared @@ -23,18 +23,19 @@ endif MARKDOWN := ../docs/Markdown/Markdown.pl -all: directories ${OBJ_DIR}/$(LIB_SO) +all: directories ${OBJ_DIR}/$(LIB_SO) test directories: ${OBJ_DIR} +test: bin/lib_iotcloud.so + g++ Test.C -L./bin/ -l_iotcloud -o bin/Test + ${OBJ_DIR}: ${MKDIR_P} ${OBJ_DIR} debug: CFLAGS += -DCONFIG_DEBUG debug: all -test: all - make -C Test PHONY += docs docs: $(C_SOURCES) $(HEADERS) diff --git a/version2/src/C/Random.h b/version2/src/C/Random.h deleted file mode 100644 index 17d1881..0000000 --- a/version2/src/C/Random.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef RANDOM_H -#define RANDOM_H -#include -class Random { -public: - Random(); - int32_t nextInt() { - return random(); - } - int32_t nextInt(int32_t val) { - return random() % val; - } -}; -#endif diff --git a/version2/src/C/SecureRandom.cc b/version2/src/C/SecureRandom.cc new file mode 100644 index 0000000..201de08 --- /dev/null +++ b/version2/src/C/SecureRandom.cc @@ -0,0 +1,13 @@ +#include "SecureRandom.h" +#include + +SecureRandom::SecureRandom() { +} + +void SecureRandom::nextBytes(Array *array) { + arc4random_buf(array->internalArray(), array->length()); +} + +int32_t SecureRandom::nextInt(int32_t val) { + return arc4random_uniform(val); +} diff --git a/version2/src/C/SecureRandom.h b/version2/src/C/SecureRandom.h index a62c7e7..50ed6f8 100644 --- a/version2/src/C/SecureRandom.h +++ b/version2/src/C/SecureRandom.h @@ -1,8 +1,12 @@ #ifndef SECURERANDOM_H #define SECURERANDOM_H +#include "common.h" + class SecureRandom { -public: + public: SecureRandom(); void nextBytes(Array *array); + int32_t nextInt(int32_t val); + private: }; #endif diff --git a/version2/src/C/Table.cc b/version2/src/C/Table.cc index 400ecc3..d70a590 100644 --- a/version2/src/C/Table.cc +++ b/version2/src/C/Table.cc @@ -10,7 +10,7 @@ #include "TransactionStatus.h" #include "Transaction.h" #include "LastMessage.h" -#include "Random.h" +#include "SecureRandom.h" #include "ByteBuffer.h" #include "Abort.h" #include "CommitPart.h" @@ -161,7 +161,7 @@ Table::Table(CloudComm *_cloud, int64_t _localMachineId) : */ void Table::init() { // Init helper objects - random = new Random(); + random = new SecureRandom(); buffer = new SlotBuffer(); // init data structs diff --git a/version2/src/C/Table.h b/version2/src/C/Table.h index 394e6d6..a8a759d 100644 --- a/version2/src/C/Table.h +++ b/version2/src/C/Table.h @@ -22,7 +22,7 @@ private: /* Helper Objects */ SlotBuffer *buffer; CloudComm *cloud; - Random *random; + SecureRandom *random; TableStatus *liveTableStatus; PendingTransaction *pendingTransactionBuilder; // Pending Transaction used in building a Pending Transaction Transaction *lastPendingTransactionSpeculatedOn; // Last transaction that was speculated on from the pending transaction diff --git a/version2/src/C/Test.C b/version2/src/C/Test.C new file mode 100644 index 0000000..c804e75 --- /dev/null +++ b/version2/src/C/Test.C @@ -0,0 +1,6 @@ +#include "Table.h" + +int main(int numargs, char ** args) { + Table * t = new Table(NULL, NULL, 0, 0); + delete t; +} diff --git a/version2/src/C/common.h b/version2/src/C/common.h index 1b6a854..7966477 100644 --- a/version2/src/C/common.h +++ b/version2/src/C/common.h @@ -52,6 +52,5 @@ class AESKey; class Mac; class SecureRandom; class Thread; -class Random; class Key; #endif diff --git a/version2/src/C/common.mk b/version2/src/C/common.mk index 8ffb364..479a31c 100644 --- a/version2/src/C/common.mk +++ b/version2/src/C/common.mk @@ -5,7 +5,7 @@ CXX := g++ UNAME := $(shell uname) -LIB_NAME := cons_comp +LIB_NAME := iotcloud LIB_SO := lib_$(LIB_NAME).so CPPFLAGS += -Wall -g -O0