Esempio n. 1
0
def download_selected_file(selected_filename, path, filename_to_save_to, aes_crypto):
    logger.info('Start download of file %s as %s' % (selected_filename, filename_to_save_to))
    data_ids = FileMap().get_data_ids_of_file(selected_filename)
    downloaded_data_items = PathORAM(aes_crypto).download_data_items(data_ids)

    if len(data_ids) != len(downloaded_data_items):
        raise DownloadFileError('An error occurred during file download')

    combined_file = ChunkFile().combine(downloaded_data_items, FileMap().get_file_len(selected_filename))
    save_file(combined_file, path, filename_to_save_to)
    logger.info('End download of file %s', selected_filename)
Esempio n. 2
0
 def split(self, file_name, file_input):
     logger.info('length of the selected file %d ' % len(file_input))
     data_ids = []
     for x in range(0, len(file_input), config.BLOCK_SIZE):
         if self.data_id_counter == config.DUMMY_ID:
             self.data_id_counter += 1
         data_id = self.data_id_counter
         self.data_id_counter += 1
         data_ids.append(data_id)
         chunk = file_input[x:config.BLOCK_SIZE + x]
         logger.info('chunk size is %d after splitting' % len(chunk))
         if len(chunk) != config.BLOCK_SIZE:
             logger.info('chunk is smaller than the block size, add padding here')
             chunk = chunk.rjust(config.BLOCK_SIZE, PADDING)
             logger.info('chunk size %d after padding' % len(chunk))
         token = self.aes_crypto.encrypt(chunk, data_id)
         logger.info('chunk size is %d after encryption' % len(token))
         Stash().add_file(data_id, token)
         PositionMap().add_data(data_id)
     FileMap().add_file(file_name, len(file_input), data_ids, self.data_id_counter)
Esempio n. 3
0
 def __init__(self, aes_crypto=None):
     self.aes_crypto = aes_crypto
     self.data_id_counter = FileMap().get_id_counter()
Esempio n. 4
0
def delete_selected_node(filename):
    data_ids = FileMap().get_data_ids_of_file(filename)
    PositionMap().delete_data_ids(data_ids)
    Stash().delete_data_items(data_ids)
    FileMap().delete_file(filename)
Esempio n. 5
0
def update_data(filename, aes_crypto):
    data_ids = FileMap().get_data_ids_of_file(filename)
    data_properties = PositionMap().get_leaf_ids(data_ids)
    PathORAM(aes_crypto).update_data(data_properties)
    logger.info('End upload of file')
Esempio n. 6
0
def get_uploaded_file_names():
    return FileMap().get_files()