# SecureFAT: An Encrypted File System

## Group members
| Name        | GitHub ID  |
|-------------|------------|
| Bill Jannen | wjannen    |
| Iris Howley | UberHowley |
| Dan Barowy  | dbarowy    |

## Topic and Overview
We plan to enhance our FUSE FAT filesystem implementation by implementing encryption.
In particular, we will add the following features to our FUSE FAT design:
 * we will persistently store a _hash_ of the the encryption key in the superblock
 * we will encrypt both data and metadata
 * we will implement secure file deletion
 * we will support key updates

The details of our proposed implementation are explained below in the __Implementation Plan__ section.

## Interesting Components
We anticipate the following aspects of our design will be challenging:
  * Safely storing, revoking, and updating encryption keys will require careful thought.
    * When a key is revoked/changed, all data will need to be read/decrypted using the old key, and encrypted/rewritten using the new key. Otherwise existing data will be lost.
  * In addition to encrypting data, we want to make sure that the file system structure is not revealed (file names, sizes, etc. should be secret). We don't yet have a concrete plan for this part of our project.
  * Free space should be indistinguishable from valid data. It should also be indistinguishable from other free space. When we initialize our file system and delete data, we will need to make sure to initialize empty space intelligently

## Implementation details / changes from FUSE FAT
Below we list some of the key design points of our SecureFAT design.
   * When the user mounts the file system, they will provide their encryption key. We will hash their key and check its hash against the hash value stored in the superblock. If they do not match, mount will fail.
   * FAT entries will be encrypted. To prevent special values from being discernible, we will add the value's index to each FAT entry. Thus, an EOF at index 7 will appear different from an EOF at index 8.
   * Writes will encrypt an entire block (zero-padded if necessary), and write the encrypted contents
   * Reads will read and decrypt an entire disk block, and valid data will be returned from the user.
   * We will add a pseudo-file (it will not be stored on disk, much like our hello-world file) that will be used to set new keys
     * When this file is written, we will parse the input. If the input matches the specified format (TBD, but will specify the current key and new key), we will read and re-encrypt the contents using the new key. Finally, we will update the superblock with the new key.
	 * We will need to figure out how to survive crashes during key updates. We may initialize a "new" filesystem "out-of-place" so that the old file system is not lost.

## Implementation Plan
  * We will start by storing the hash of the key in the superblock. We will not change anything else about our LAB 2 implementation until we can verify that mounting successfully verifies the key.
    * We will only ever store the key in memory so that it cannot be recovered by an adversary
  * We will next add support for _data_ encryption. All writes will encrypt data. All reads will decrypt data
  * We will next add support for encrypting file names/types/sizes by encrypting the directory clusters where our dirents are stored
  * We will next encrypt the entire FAT
  * Finally, we will add support for key updates

## Definition of Success
This is an ambition project. We will measure success by our progress through the milestones listed above by implementing unit tests for each of the system calls/steps. If we complete all the steps except key revocation, we will define this project as a success. Performance is not a concern for us, only correctness. Unit tests will show our correctness.

### Project Deliverables
 * Code in `fat.c`
 * Unit tests (a series of short C files/shell scripts in the folder `tests/`)
 * A writeup that includes:
   * A specification of our design
   * A diagram of our on-disk layout
   * A list of milestones and description of the tests we used to verify our milestones
   * Documentation, including exact instructions on how to test and run our file system
   * A list of challenges that we encountered
   * A list of open questions/next steps

## External Libraries
 * [An open source encryption library](www.google.com)
 * [FUSE version 2.9](www.google.com)
