00001 #ifndef DDAR_H_ 00002 #define DDAR_H_ 00003 00004 namespace ddar { 00005 00006 class secret; 00007 00014 class context { 00015 public: 00019 virtual secret *get_secret(const char *alias) = 0; 00020 00024 virtual int get_userid() = 0; 00025 00029 virtual void logd (const char *fmt, ...) = 0; 00030 00034 virtual void loge (const char *fmt, ...) = 0; 00035 00036 protected: 00037 virtual ~context() { }; 00038 }; 00039 00040 00051 class secret { 00052 public: 00053 static constexpr const int MAX_SECRET_ALIAS_LEN = 32; 00054 static constexpr const int MAX_SECRET_LEN = 128; 00055 00059 char alias[MAX_SECRET_ALIAS_LEN]; 00063 void *data; 00067 int size; 00068 00069 protected: 00070 virtual ~secret() { }; 00071 }; 00072 00095 class metadata { 00096 public: 00097 static constexpr const int MAX_PERSISTENT_CACHE_NAME_LEN = 32; 00098 static constexpr const int MAX_PERSISTENT_CACHE_VALUE_LEN = 128; 00109 virtual int persistent_set(const char *name, const void *value, int size) = 0; 00120 virtual int persistent_get(const char *name, void *value) = 0; 00121 00128 void *ephemeral_addr; 00132 int ephemeral_size; 00133 00137 context *context; 00138 00142 virtual unsigned long get_inode() = 0; 00143 00144 00145 protected: 00146 virtual ~metadata() { }; 00147 }; 00148 00210 class abstract_crypto { 00211 public: 00243 virtual bool prepare(context *context, metadata *md) = 0; 00244 00264 virtual bool encrypt(metadata *md, void *pt, void *ct, unsigned long page_offset, int page_len) = 0; 00265 00285 virtual bool decrypt(metadata *md, void *ct, unsigned long page_offset, int page_len) = 0; 00286 00287 protected: 00288 virtual ~abstract_crypto() {} 00289 }; 00290 00291 } 00292 00293 #endif /* DDAR_H_ */