edits
authorbdemsky <bdemsky@uci.edu>
Sat, 3 Mar 2018 11:45:10 +0000 (03:45 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 3 Mar 2018 11:45:10 +0000 (03:45 -0800)
version2/src/C/Makefile
version2/src/C/Random.h [deleted file]
version2/src/C/SecureRandom.cc [new file with mode: 0644]
version2/src/C/SecureRandom.h
version2/src/C/Table.cc
version2/src/C/Table.h
version2/src/C/Test.C [new file with mode: 0644]
version2/src/C/common.h
version2/src/C/common.mk

index 7603cc4c2416fdea7b20b1b780e774c58f073716..e4501305522151e6f6bb64de6116b7f5ee23dc26 100644 (file)
@@ -10,7 +10,7 @@ HEADERS := $(wildcard *.h)
 
 OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
 
 
 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
 CFLAGS += -I.
 LDFLAGS := -ldl -lrt -rdynamic -g
 SHARED := -shared
@@ -23,18 +23,19 @@ endif
 
 MARKDOWN := ../docs/Markdown/Markdown.pl
 
 
 MARKDOWN := ../docs/Markdown/Markdown.pl
 
-all: directories ${OBJ_DIR}/$(LIB_SO)
+all: directories ${OBJ_DIR}/$(LIB_SO) test
 
 directories: ${OBJ_DIR}
 
 
 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
 
 ${OBJ_DIR}:
        ${MKDIR_P} ${OBJ_DIR}
 
 debug: CFLAGS += -DCONFIG_DEBUG
 debug: all
 
-test: all
-       make -C Test
 
 PHONY += docs
 docs: $(C_SOURCES) $(HEADERS)
 
 PHONY += docs
 docs: $(C_SOURCES) $(HEADERS)
diff --git a/version2/src/C/Random.h b/version2/src/C/Random.h
deleted file mode 100644 (file)
index 17d1881..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef RANDOM_H
-#define RANDOM_H
-#include <stdlib.h>
-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 (file)
index 0000000..201de08
--- /dev/null
@@ -0,0 +1,13 @@
+#include "SecureRandom.h"
+#include <stdlib.h>
+
+SecureRandom::SecureRandom() {
+}
+
+void SecureRandom::nextBytes(Array<char> *array) {
+       arc4random_buf(array->internalArray(), array->length());
+}
+
+int32_t SecureRandom::nextInt(int32_t val) {
+       return arc4random_uniform(val);
+}
index a62c7e746124da80c7dc139f93afdd2c7a8042ae..50ed6f86729090bfb610dd91de08a68c25fc4eb8 100644 (file)
@@ -1,8 +1,12 @@
 #ifndef SECURERANDOM_H
 #define SECURERANDOM_H
 #ifndef SECURERANDOM_H
 #define SECURERANDOM_H
+#include "common.h"
+
 class SecureRandom {
 class SecureRandom {
-public:
+ public:
        SecureRandom();
        void nextBytes(Array<char> *array);
        SecureRandom();
        void nextBytes(Array<char> *array);
+       int32_t nextInt(int32_t val);
+ private:
 };
 #endif
 };
 #endif
index 400ecc344bf4e4bed0932d556b7222c1c15cb759..d70a590890b170fac9417fc6ab049437304de286 100644 (file)
@@ -10,7 +10,7 @@
 #include "TransactionStatus.h"
 #include "Transaction.h"
 #include "LastMessage.h"
 #include "TransactionStatus.h"
 #include "Transaction.h"
 #include "LastMessage.h"
-#include "Random.h"
+#include "SecureRandom.h"
 #include "ByteBuffer.h"
 #include "Abort.h"
 #include "CommitPart.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
  */
 void Table::init() {
        // Init helper objects
-       random = new Random();
+       random = new SecureRandom();
        buffer = new SlotBuffer();
 
        // init data structs
        buffer = new SlotBuffer();
 
        // init data structs
index 394e6d63e3053ede1658005fbb10e5b2a22c7900..a8a759dfe1e94b98ffe507c63cbee34f53a0b3ea 100644 (file)
@@ -22,7 +22,7 @@ private:
        /* Helper Objects */
        SlotBuffer *buffer;
        CloudComm *cloud;
        /* 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
        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 (file)
index 0000000..c804e75
--- /dev/null
@@ -0,0 +1,6 @@
+#include "Table.h"
+
+int main(int numargs, char ** args) {
+       Table * t = new Table(NULL, NULL, 0, 0);
+       delete t;
+}
index 1b6a8549d14da6c945ef0a14f6f7c3b651a241c2..7966477835d3cba23a07601a29997109512c9b32 100644 (file)
@@ -52,6 +52,5 @@ class AESKey;
 class Mac;
 class SecureRandom;
 class Thread;
 class Mac;
 class SecureRandom;
 class Thread;
-class Random;
 class Key;
 #endif
 class Key;
 #endif
index 8ffb36415bedd1a82654855695bdbf3b0be88dcd..479a31c6b1d51e984c044551d1d5f2fbc4757a3a 100644 (file)
@@ -5,7 +5,7 @@ CXX := g++
 
 UNAME := $(shell uname)
 
 
 UNAME := $(shell uname)
 
-LIB_NAME := cons_comp
+LIB_NAME := iotcloud
 LIB_SO := lib_$(LIB_NAME).so
 
 CPPFLAGS += -Wall -g -O0
 LIB_SO := lib_$(LIB_NAME).so
 
 CPPFLAGS += -Wall -g -O0