A few more minor fixes cleaning up the cloud log state counting.
[bluesky.git] / bluesky / bluesky.h
index 834097f..a4dfbbe 100644 (file)
@@ -85,22 +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
-#define CRYPTO_HASH_SIZE  32        /* SHA-256 */
-
-struct BlueSkyCryptKeys {
-    uint8_t encryption_key[CRYPTO_KEY_SIZE];
-    uint8_t authentication_key[CRYPTO_HASH_SIZE];
-};
-
-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;
@@ -140,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;
 
@@ -151,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;
@@ -191,6 +181,9 @@ typedef struct {
 
     /* 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. */
@@ -310,7 +303,8 @@ typedef struct {
     BlueSkyRCStr *dirty;        /* if DIRTY: raw data in memory */
 } BlueSkyBlock;
 
-BlueSkyFS *bluesky_init_fs(gchar *name, BlueSkyStore *store);
+BlueSkyFS *bluesky_init_fs(gchar *name, BlueSkyStore *store,
+                           const gchar *master_key);
 
 gboolean bluesky_inode_is_ready(BlueSkyInode *inode);