password(_password->acquireRef()),
random(new SecureRandom()),
salt(NULL),
password(_password->acquireRef()),
random(new SecureRandom()),
salt(NULL),
+void CloudComm::createIV() {
+ if (ivArray == NULL) {
+ ivArray = new Array<char>(CloudComm_IV_SIZE);
+ random->nextBytes(ivArray);
+ printf("Random bytes is generated: %d\n", ivArray->length());
+ }
+}
+
Array<char> *AESEncrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
Array<char> *output = new Array<char>(data->length());
aes_encrypt_ctr((BYTE *)data->internalArray(), data->length(), (BYTE *) output->internalArray(), (WORD *)key->getKeySchedule(), key->getKey()->length() * 8, (BYTE *)ivBytes->internalArray());
Array<char> *AESEncrypt(Array<char> *ivBytes, AESKey *key, Array<char> *data) {
Array<char> *output = new Array<char>(data->length());
aes_encrypt_ctr((BYTE *)data->internalArray(), data->length(), (BYTE *) output->internalArray(), (WORD *)key->getKeySchedule(), key->getKey()->length() * 8, (BYTE *)ivBytes->internalArray());
- Array<char> * ivBytes = slot->getSlotCryptIV();
- Array<char> *chars = encryptSlotAndPrependIV(slotBytes, ivBytes);
- delete ivBytes;
+ //Array<char> *ivBytes = slot->getSlotCryptIV();
+ //Array<char> *chars = encryptSlotAndPrependIV(slotBytes, ivBytes);
+ //delete ivBytes;
+ createIV();
+ Array<char> *chars = encryptSlotAndPrependIV(slotBytes, ivArray);
WebConnection wc = {-1, -1};
try {
if (salt == NULL) {
if (!getSalt()) {
throw new ServerException("getSlots failed", ServerException_TypeSalt);
WebConnection wc = {-1, -1};
try {
if (salt == NULL) {
if (!getSalt()) {
throw new ServerException("getSlots failed", ServerException_TypeSalt);
} catch (SocketTimeoutException *e) {
timer->endTime();
throw new ServerException("getSlots failed", ServerException_TypeConnectTimeout);
} catch (ServerException *e) {
timer->endTime();
} catch (SocketTimeoutException *e) {
timer->endTime();
throw new ServerException("getSlots failed", ServerException_TypeConnectTimeout);
} catch (ServerException *e) {
timer->endTime();
System_arraycopy(genmac, 0, totalData, sendData->length(), genmac->length());
// Encrypt the data for sending
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);
+ //Array<char> *iv = createIV(table->getMachineId(), table->getLocalSequenceNumber());
+ //Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, iv);
+ createIV();
+ Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, ivArray);
// Open a TCP socket connection to a local device
int socket = createSocket(host, port);
// Open a TCP socket connection to a local device
int socket = createSocket(host, port);
System_arraycopy(realmac, 0, totalData, sendData->length(), realmac->length());
// Encrypt the data for sending
System_arraycopy(realmac, 0, totalData, sendData->length(), realmac->length());
// Encrypt the data for sending
- Array<char> *iv = createIV(table->getMachineId(), table->getLocalSequenceNumber());
- Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, iv);
+ //Array<char> *iv = createIV(table->getMachineId(), table->getLocalSequenceNumber());
+ //Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, iv);
+ createIV();
+ Array<char> *encryptedData = encryptSlotAndPrependIV(totalData, ivArray);