edits
authorbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 05:48:59 +0000 (21:48 -0800)
committerbdemsky <bdemsky@uci.edu>
Sat, 20 Jan 2018 05:48:59 +0000 (21:48 -0800)
version2/src/C/CloudComm.cc
version2/src/C/CloudComm.h
version2/src/C/SecureRandom.h
version2/src/C/TimingSingleton.h

index 97a96c2..452317f 100644 (file)
@@ -124,7 +124,7 @@ void CloudComm::setSalt() {
                }
 
 
-               URLurl = new URL(baseurl + "?req=setsalt");
+               URL *url = new URL(baseurl + "?req=setsalt");
 
                timer->startTime();
                URLConnection con = url->openConnection();
@@ -138,7 +138,7 @@ void CloudComm::setSalt() {
 
                http->connect();
 
-               OutputStreamos = http->getOutputStream();
+               OutputStream *os = http->getOutputStream();
                os->write(saltTmp);
                os->flush();
 
@@ -200,9 +200,9 @@ bool CloudComm::getSalt() {
 
                InputStream is = http->getInputStream();
                if (is->available() > 0) {
-                       DataInputStreamdis = new DataInputStream(is);
+                       DataInputStream *dis = new DataInputStream(is);
                        int salt_length = dis->readInt();
-                       Array<char> * tmp = new Array<char>(salt_length);
+                       Array<char> *tmp = new Array<char>(salt_length);
                        dis->readFully(tmp);
                        salt = tmp;
                        timer->endTime();
@@ -257,9 +257,9 @@ Array<char> *CloudComm::stripIVAndDecryptSlot(Array<char> *rawData) {
                System_arraycopy(rawData, 0, ivBytes, 0, CloudComm_IV_SIZE);
                System_arraycopy(rawData, CloudComm_IV_SIZE, encryptedBytes, 0, encryptedBytes->length);
 
-               IvParameterSpecivSpec = new IvParameterSpec(ivBytes);
+               IvParameterSpec *ivSpec = new IvParameterSpec(ivBytes);
 
-               Ciphercipher = Cipher_getInstance("AES/CTR/NoPadding");
+               Cipher *cipher = Cipher_getInstance("AES/CTR/NoPadding");
                cipher->init(Cipher_DECRYPT_MODE, key, ivSpec);
                return cipher->doFinal(encryptedBytes);
 
@@ -291,8 +291,8 @@ Array<Slot *> *CloudComm::putSlot(Slot *slot, int max) {
                URL *url = buildRequest(true, sequencenumber, max);
 
                timer->startTime();
-               URLConnection * con = url->openConnection();
-               HttpURLConnection * http = (HttpURLConnection *) con;
+               URLConnection *con = url->openConnection();
+               HttpURLConnection *http = (HttpURLConnection *) con;
 
                http->setRequestMethod("POST");
                http->setFixedLengthStreamingMode(chars->length);
@@ -301,7 +301,7 @@ Array<Slot *> *CloudComm::putSlot(Slot *slot, int max) {
                http->setReadTimeout(CloudComm_TIMEOUT_MILLIS);
                http->connect();
 
-               OutputStream * os = http->getOutputStream();
+               OutputStream *os = http->getOutputStream();
                os->write(chars);
                os->flush();
 
@@ -325,8 +325,8 @@ Array<Slot *> *CloudComm::putSlot(Slot *slot, int max) {
        try {
                timer->startTime();
                InputStream is = http->getInputStream();
-               DataInputStream * dis = new DataInputStream(is);
-               Array<char> *resptype = new char[7];
+               DataInputStream *dis = new DataInputStream(is);
+               Array<char> *resptype = new Array<char>(7);
                dis->readFully(resptype);
                timer->endTime();
 
@@ -412,26 +412,17 @@ Array<Slot *> *CloudComm::getSlots(int64_t sequencenumber) {
  */
 Array<Slot *> *CloudComm::processSlots(DataInputStream *dis) {
        int numberofslots = dis->readInt();
-       Array<int> * sizesofslots = new Array<int>(numberofslots);
+       Array<int> *sizesofslots = new Array<int>(numberofslots);
 
-       Array<Slot*> * slots = new Array<Slot*>(numberofslots);
+       Array<Slot *> *slots = new Array<Slot *>(numberofslots);
        for (int i = 0; i < numberofslots; i++)
-               sizesofslots->set(i], dis->readInt());
+               sizesofslots->set(i, dis->readInt());
 
        for (int i = 0; i < numberofslots; i++) {
-
                Array<char> *rawData = new Array<char>(sizesofslots->get(i));
                dis->readFully(rawData);
 
-
-               // Array<char> * data = new char[rawData.length - IV_SIZE];
-               // System.arraycopy(rawData, IV_SIZE, data, 0, data.length);
-
-
                Array<char> *data = stripIVAndDecryptSlot(rawData);
-
-               // data = decryptCipher.doFinal(data);
-               
                slots->set(i, Slot_decode(table, data, mac));
        }
        dis->close();
@@ -443,23 +434,23 @@ Array<char> *sendLocalData(Array<char> *sendData, int64_t localSequenceNumber, S
                return NULL;
        }
        try {
-               printf("Passing Locally"\m);
+               printf("Passing Locally\n");
 
                mac->update(sendData);
                Array<char> *genmac = mac->doFinal();
                Array<char> *totalData = new Array<char>(sendData->length() + genmac->length());
                System_arraycopy(sendData, 0, totalData, 0, sendData.length());
-               System-arraycopy(genmac, 0, totalData, sendData.length, genmac->length());
+               System - arraycopy(genmac, 0, totalData, sendData.length, genmac->length());
 
                // Encrypt the data for sending
                Array<char> *iv = createIV(table->getMachineId(), table->getLocalSequenceNumber());
                Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, iv);
 
                // Open a TCP socket connection to a local device
-               Socketsocket = new Socket(host, port);
+               Socket *socket = new Socket(host, port);
                socket->setReuseAddress(true);
-               DataOutputStreamoutput = new DataOutputStream(socket->getOutputStream());
-               DataInputStreaminput = new DataInputStream(socket->getInputStream());
+               DataOutputStream *output = new DataOutputStream(socket->getOutputStream());
+               DataInputStream *input = new DataInputStream(socket->getInputStream());
 
                timer->startTime();
                // Send data to output (length of data, the data)
index fb16165..cdec495 100644 (file)
@@ -44,7 +44,7 @@ private:
        /*
         * Builds the URL for the given request.
         */
-       URLbuildRequest(bool isput, int64_t sequencenumber, int64_t maxentries);
+       URL *buildRequest(bool isput, int64_t sequencenumber, int64_t maxentries);
        void setSalt();
        bool getSalt();
        Array<char> *createIV(int64_t machineId, int64_t localSequenceNumber);
index 643efb4..34ccd72 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SECURERANDOM_H
 #define SECURERANDOM_H
 class SecureRandom {
- public:
+public:
        SecureRandom();
 };
 #endif
index 8083c04..c9189c2 100644 (file)
@@ -7,7 +7,7 @@ private:
        int64_t fldstartTime;
        int64_t fldtotalTime;
 
- public:
+public:
        TimingSingleton() : fldstartTime(0),
                fldtotalTime(0) {
        }