X-Git-Url: http://git.vrable.net/?a=blobdiff_plain;f=bluesky%2Fbluesky.h;h=b250206eed4fbb4bb3425455270402d944efcaa2;hb=ad69f66b9a25bf03e446427d6943d6eefe48ec7c;hp=856dd75a6244bce3b1bf22ba65a6f4cb01373abf;hpb=70fdd2326239a9a5e02b3c3699d2588d5fee48fa;p=bluesky.git diff --git a/bluesky/bluesky.h b/bluesky/bluesky.h index 856dd75..b250206 100644 --- a/bluesky/bluesky.h +++ b/bluesky/bluesky.h @@ -31,6 +31,15 @@ void bluesky_string_ref(BlueSkyRCStr *string); void bluesky_string_unref(BlueSkyRCStr *string); BlueSkyRCStr *bluesky_string_dup(BlueSkyRCStr *string); +/* Cryptographic operations. */ +#define CRYPTO_BLOCK_SIZE 16 /* 128-bit AES */ +#define CRYPTO_KEY_SIZE 16 + +void bluesky_crypt_init(); +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); + /* File types. The numeric values are chosen to match with those used in * NFSv3. */ typedef enum { @@ -53,6 +62,8 @@ typedef struct { uint64_t next_inum; /* Next available inode for allocation */ struct S3Store *store; + + uint8_t *encryption_key; } BlueSkyFS; /* Inode number of the root directory. */ @@ -63,10 +74,18 @@ typedef int64_t bluesky_time; /* In-memory representation of an inode within a Blue Sky server. This * corresponds roughly with information that is committed to persistent - * storage. */ + * storage. Locking/refcounting rules: + * - To access or modify any data fields, the lock must be held. This + * includes file blocks. + * - One reference is held by the BlueSkyFS inode hash table. If that is the + * only reference (and the inode is unlocked), the inode is subject to + * dropping from the cache. + * - Any pending operations should hold extra references to the inode as + * appropriate to keep it available until the operation completes. + * */ typedef struct { - gint refcnt; /* May be accessed atomically without lock */ GMutex *lock; + gint refcount; BlueSkyFS *fs;