Add per-item encryption/authentication to the cloud log storage.
[bluesky.git] / bluesky / bluesky.h
index ca3d130..a4dfbbe 100644 (file)
@@ -85,16 +85,6 @@ void bluesky_string_unref(BlueSkyRCStr *string);
 BlueSkyRCStr *bluesky_string_dup(BlueSkyRCStr *string);
 void bluesky_string_resize(BlueSkyRCStr *string, gsize len);
 
-/* Cryptographic operations. */
-#define CRYPTO_BLOCK_SIZE 16        /* 128-bit AES */
-#define CRYPTO_KEY_SIZE   16
-
-void bluesky_crypt_init();
-void bluesky_crypt_hash_key(const char *keystr, uint8_t *out);
-void bluesky_crypt_random_bytes(guchar *buf, gint len);
-BlueSkyRCStr *bluesky_crypt_encrypt(BlueSkyRCStr *in, const uint8_t *key);
-BlueSkyRCStr *bluesky_crypt_decrypt(BlueSkyRCStr *in, const uint8_t *key);
-
 /* Storage interface.  This presents a key-value store abstraction, and can
  * have multiple implementations: in-memory, on-disk, in-cloud. */
 struct _BlueSkyStore;
@@ -134,6 +124,8 @@ typedef enum {
 
 /* Filesystem state.  Each filesystem which is exported is represented by a
  * single bluesky_fs structure in memory. */
+struct BlueSkyCryptKeys;
+
 typedef struct {
     GMutex *lock;
 
@@ -145,6 +137,10 @@ typedef struct {
     BlueSkyLog *log;
     BlueSkyCloudLogState *log_state;
 
+    /* Filesystem crypto keys */
+    char *master_key;
+    struct BlueSkyCryptKeys *keys;
+
     /* Accounting for memory used for caches.  Space is measured in blocks, not
      * bytes.  Updates to these variables must be made atomically. */
     gint cache_dirty;
@@ -178,6 +174,16 @@ typedef struct {
     /* Mapping of object identifiers (blocks, inodes) to physical location (in
      * the local cache or in the logs in the cloud). */
     GHashTable *locations;
+
+    /* The inode map, which maps inode numbers to the location of the most
+     * recent version. */
+    GSequence *inode_map;
+
+    /* Queue for asynchronous cloudlog unrefs, where needed. */
+    GAsyncQueue *unref_queue;
+
+    /* Thread pool for asynchronous inode fetches */
+    GThreadPool *inode_fetch_thread_pool;
 } BlueSkyFS;
 
 /* Inode number of the root directory. */
@@ -297,8 +303,8 @@ typedef struct {
     BlueSkyRCStr *dirty;        /* if DIRTY: raw data in memory */
 } BlueSkyBlock;
 
-BlueSkyFS *bluesky_init_fs(gchar *name, BlueSkyStore *store);
-void bluesky_superblock_flush(BlueSkyFS *fs);
+BlueSkyFS *bluesky_init_fs(gchar *name, BlueSkyStore *store,
+                           const gchar *master_key);
 
 gboolean bluesky_inode_is_ready(BlueSkyInode *inode);