edits
authorbdemsky <bdemsky@uci.edu>
Fri, 2 Mar 2018 18:29:06 +0000 (10:29 -0800)
committerbdemsky <bdemsky@uci.edu>
Fri, 2 Mar 2018 18:29:06 +0000 (10:29 -0800)
version2/src/C/CloudComm.cc

index d1ba7ca..3b5fb97 100644 (file)
@@ -9,6 +9,7 @@
 #include "Slot.h"
 #include "Crypto.h"
 #include "ByteBuffer.h"
+#include "aes.h"
 #include <sys/socket.h>
 #include <unistd.h>
 
@@ -246,11 +247,15 @@ Array<char> *CloudComm::createIV(int64_t machineId, int64_t localSequenceNumber)
 }
 
 Array<char> *AESEncrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
-       return NULL;
+       Array<char> * output=new Array<char>(data->length());
+       aes_encrypt_ctr((BYTE *)data->internalArray(), data->length(), (BYTE *) output->internalArray(), (WORD *)key->getKey()->internalArray(), key->getKey()->length()/(sizeof(WORD)/sizeof(BYTE)), (BYTE *)ivBytes->internalArray());
+       return output;
 }
 
 Array<char> *AESDecrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
-       return NULL;
+       Array<char> * output=new Array<char>(data->length());
+       aes_decrypt_ctr((BYTE *)data->internalArray(), data->length(), (BYTE *)output->internalArray(), (WORD *)key->getKey()->internalArray(), key->getKey()->length()/(sizeof(WORD)/sizeof(BYTE)), (BYTE *)ivBytes->internalArray());
+       return output;
 }
 
 Array<char> *CloudComm::encryptSlotAndPrependIV(Array<char> *rawData, Array<char> *ivBytes) {