aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock114
-rw-r--r--lockchain-core/Cargo.toml4
-rw-r--r--lockchain-core/src/crypto.rs10
-rw-r--r--lockchain-core/src/crypto/keys.rs (renamed from lockchain-crypto/src/keys.rs)6
-rw-r--r--lockchain-core/src/crypto/utils.rs (renamed from lockchain-crypto/src/utils.rs)0
-rw-r--r--lockchain-core/src/lib.rs7
-rw-r--r--lockchain-core/src/traits.rs34
-rw-r--r--lockchain-core/src/vault.rs84
-rw-r--r--lockchain-crypto/Cargo.toml5
-rw-r--r--lockchain-crypto/src/lib.rs3
-rw-r--r--lockchain-http/src/lib.rs16
-rw-r--r--lockchain-server/Cargo.toml5
-rw-r--r--lockchain-server/src/main.rs7
13 files changed, 191 insertions, 104 deletions
diff --git a/Cargo.lock b/Cargo.lock
index d4ed8ca..e3caabd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -16,6 +16,14 @@ dependencies = [
]
[[package]]
+name = "ansi_term"
+version = "0.11.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "arrayvec"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -24,6 +32,16 @@ dependencies = [
]
[[package]]
+name = "atty"
+version = "0.2.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "backtrace"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -187,6 +205,20 @@ dependencies = [
]
[[package]]
+name = "clap"
+version = "2.31.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "bitflags 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "clear_on_drop"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -498,7 +530,9 @@ version = "0.3.2"
dependencies = [
"base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bcrypt 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "blake2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.17 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -521,11 +555,8 @@ dependencies = [
name = "lockchain-crypto"
version = "0.1.0"
dependencies = [
- "base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "blake2 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"lockchain-core 0.3.2",
"miscreant 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -538,6 +569,14 @@ dependencies = [
]
[[package]]
+name = "lockchain-files"
+version = "0.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "lockchain-core 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "lockchain-http"
version = "0.0.0"
dependencies = [
@@ -548,8 +587,25 @@ dependencies = [
]
[[package]]
+name = "lockchain-http"
+version = "0.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "gotham 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gotham_derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gotham_serde_json_body_parser 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lockchain-core 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "lockchain-server"
version = "0.1.0"
+dependencies = [
+ "clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lockchain-core 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lockchain-files 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "lockchain-http 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
+]
[[package]]
name = "log"
@@ -766,6 +822,14 @@ version = "0.1.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "redox_termios"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "regex"
version = "0.2.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -900,6 +964,11 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "strsim"
+version = "0.7.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "subtle"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -966,6 +1035,24 @@ dependencies = [
]
[[package]]
+name = "termion"
+version = "1.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
+ "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "textwrap"
+version = "0.9.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "thread_local"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1165,6 +1252,11 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "unicode-width"
+version = "0.1.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "unicode-xid"
version = "0.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1207,6 +1299,11 @@ dependencies = [
]
[[package]]
+name = "vec_map"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "version_check"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1267,7 +1364,9 @@ dependencies = [
[metadata]
"checksum aesni 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5e88c3698cd61460af7bdbcc747d0e37b61255492fcfc81845dd4666f3bf6714"
"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
+"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
+"checksum atty 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc4a1aa4c24c0718a250f0681885c1af91419d242f29eb8f2ab28502d80dbd1"
"checksum backtrace 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "8ea58cd16fd6c9d120b5bcb01d63883ae4cc7ba2aed35c1841b862a3c7ef6639"
"checksum backtrace-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "44585761d6161b0f57afc49482ab6bd067e4edef48c12a152c237eb0203f7661"
"checksum base64 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c4a342b450b268e1be8036311e2c613d7f8a7ed31214dff1cc3b60852a3168d"
@@ -1288,6 +1387,7 @@ dependencies = [
"checksum cc 1.0.15 (registry+https://github.com/rust-lang/crates.io-index)" = "0ebb87d1116151416c0cf66a0e3fb6430cccd120fd6300794b4dfaa050ac40ba"
"checksum cfg-if 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "405216fd8fe65f718daa7102ea808a946b6ce40c742998fbfd3463645552de18"
"checksum chrono 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1cce36c92cb605414e9b824f866f5babe0a0368e39ea07393b9b63cf3844c0e6"
+"checksum clap 2.31.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f0f16b89cbb9ee36d87483dc939fe9f1e13c05898d56d7b230a0d4dff033a536"
"checksum clear_on_drop 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "97276801e127ffb46b66ce23f35cc96bd454fa311294bced4bbace7baa8b1d17"
"checksum cmac 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44f175b5f76aa82ebe4c7e85ef95b23e9293c5618db28461cb10ee929e0f6e2f"
"checksum constant_time_eq 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8ff012e225ce166d4422e0e78419d901719760f62ae2b7969ca6b564d1b54a9e"
@@ -1324,6 +1424,8 @@ dependencies = [
"checksum libc 0.2.40 (registry+https://github.com/rust-lang/crates.io-index)" = "6fd41f331ac7c5b8ac259b8bf82c75c0fb2e469bbf37d2becbba9a6a2221965b"
"checksum linked-hash-map 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "70fb39025bc7cdd76305867c4eccf2f2dcf6e9a57f5b21a93e1c2d86cd03ec9e"
"checksum lockchain-core 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8cc843193c0f63da17232b600423a6da3117a86ed43b91652ab81300d017f0c1"
+"checksum lockchain-files 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7c6404bea015818d89ea81e86c6eb463cfc0e0599a04c67bfcfbb285f4ff4133"
+"checksum lockchain-http 0.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cfef9fc7585ca94e9f5294854d208914fbff1bbd85a7f47a3e335665b08df302"
"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b"
"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2"
"checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376"
@@ -1350,6 +1452,7 @@ dependencies = [
"checksum rand 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)" = "15a732abf9d20f0ad8eeb6f909bf6868722d9a06e1e50802b6a70351f40b4eb1"
"checksum rand 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "eba5f8cb59cc50ed56be8880a5c7b496bfd9bd26394e176bc67884094145c2c5"
"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd"
+"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76"
"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384"
"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7"
"checksum relay 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1576e382688d7e9deecea24417e350d3062d97e32e45d70b1cde65994ff1489a"
@@ -1368,6 +1471,7 @@ dependencies = [
"checksum slab 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "17b4fcaed89ab08ef143da37bc52adbcc04d4a69014f4c1208d6b51f0c47bc23"
"checksum slab 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fdeff4cd9ecff59ec7e3744cbca73dfe5ac35c2aedb2cfba8a1c715a18912e9d"
"checksum smallvec 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c8cbcd6df1e117c2210e13ab5109635ad68a929fcbb8964dc965b76cb5ee013"
+"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550"
"checksum subtle 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c7a6bab57c3efd01ebd3d750f4244ae0af4cdd1fc505a7904a41603192b803c5"
"checksum syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad"
"checksum syn 0.12.15 (registry+https://github.com/rust-lang/crates.io-index)" = "c97c05b8ebc34ddd6b967994d5c6e9852fa92f8b82b3858c39451f97346dcce5"
@@ -1376,6 +1480,8 @@ dependencies = [
"checksum synstructure 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3a761d12e6d8dcb4dcf952a7a89b475e3a9d69e4a69307e01a470977642914bd"
"checksum take 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b157868d8ac1f56b64604539990685fa7611d8fa9e5476cf0c02cf34d32917c5"
"checksum tempdir 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
+"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096"
+"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693"
"checksum thread_local 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "279ef31c19ededf577bfd12dfae728040a21f635b06a24cd670ff510edd38963"
"checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098"
"checksum tokio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d00555353b013e170ed8bc4e13f648a317d1fd12157dbcae13f7013f6cf29f5"
@@ -1395,12 +1501,14 @@ dependencies = [
"checksum unicase 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "284b6d3db520d67fbe88fd778c21510d1b0ba4a551e5d0fbb023d33405f6de8a"
"checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5"
"checksum unicode-normalization 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "90d662d111b0dbb08a180f2761026cba648c258023c355954a7c00e00e354636"
+"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unicode-xid 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum url 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f808aadd8cfec6ef90e4a14eb46f24511824d1ac596b9682703c87056c8678b7"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"
"checksum uuid 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8630752f979f1b6b87c49830a5e3784082545de63920d59fbaac252474319447"
+"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c"
"checksum version_check 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6b772017e347561807c1aa192438c5fd74242a670a6cffacc40f2defd1dc069d"
"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
"checksum walkdir 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "bb08f9e670fab86099470b97cd2b252d6527f0b3cc1401acdb595ffc9dd288ff"
diff --git a/lockchain-core/Cargo.toml b/lockchain-core/Cargo.toml
index b40ba4c..4cccf54 100644
--- a/lockchain-core/Cargo.toml
+++ b/lockchain-core/Cargo.toml
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/lockchain-core"
homepage = "https://github.com/spacekookie/lockchain/tree/master/lockchain-core"
readme = "README.md"
license = "MIT/X11 OR Apache-2.0"
-version = "0.3.2"
+version = "0.4.0"
authors = ["Katharina Fey <kookie@spacekookie.de>"]
[dependencies]
@@ -17,3 +17,5 @@ serde = "1.0"
base64 = "0.8"
bcrypt = "0.2"
+rand = "0.4"
+blake2 = "0.7" \ No newline at end of file
diff --git a/lockchain-core/src/crypto.rs b/lockchain-core/src/crypto.rs
new file mode 100644
index 0000000..6144e01
--- /dev/null
+++ b/lockchain-core/src/crypto.rs
@@ -0,0 +1,10 @@
+//! Shared cryptographic primitives for the lockchain ecosystem
+//!
+//! This is a secure storage vault after all, we need some
+//! shared crypto helpers for all the other crates :)
+
+mod keys;
+mod utils;
+
+pub use self::keys::Key;
+pub use self::utils::*; \ No newline at end of file
diff --git a/lockchain-crypto/src/keys.rs b/lockchain-core/src/crypto/keys.rs
index bde3e69..f132075 100644
--- a/lockchain-crypto/src/keys.rs
+++ b/lockchain-core/src/crypto/keys.rs
@@ -1,8 +1,12 @@
//! A module that handles key generation and key loading
use super::utils::{hashing, random};
-pub const KEY_LENGTH: usize = 64;
+/// A shared key length parameter for all cryptographic operations
+///
+/// This is *not* ideal and should be replaced with something better
+/// at some point in the future
+pub const KEY_LENGTH: usize = 64;
/// A wrapper to represent a key for encryption
#[derive(Debug, Serialize, Deserialize, Eq, PartialEq, Clone)]
diff --git a/lockchain-crypto/src/utils.rs b/lockchain-core/src/crypto/utils.rs
index 36e611c..36e611c 100644
--- a/lockchain-crypto/src/utils.rs
+++ b/lockchain-core/src/crypto/utils.rs
diff --git a/lockchain-core/src/lib.rs b/lockchain-core/src/lib.rs
index 87a5c60..294f883 100644
--- a/lockchain-core/src/lib.rs
+++ b/lockchain-core/src/lib.rs
@@ -1,6 +1,7 @@
//! Common library types used in lockchain crates
#![feature(external_doc)]
#![doc(include = "../README.md")]
+#![feature(non_modrs_mods)]
#[macro_use]
extern crate serde_derive;
@@ -9,13 +10,15 @@ extern crate serde;
extern crate chrono;
extern crate bcrypt;
extern crate base64;
+extern crate blake2;
+extern crate rand;
pub mod errors;
pub mod traits;
+pub mod crypto;
mod users;
mod record;
-mod vault;
+
pub use self::record::{Header, Payload, Record, EncryptedBody};
-pub use self::vault::Vault;
pub use self::users::User; \ No newline at end of file
diff --git a/lockchain-core/src/traits.rs b/lockchain-core/src/traits.rs
index 122a7f4..bddbb71 100644
--- a/lockchain-core/src/traits.rs
+++ b/lockchain-core/src/traits.rs
@@ -11,7 +11,7 @@
//! compilation work without external crates but not calling
//! functions at runtime.
-use record::{EncryptedBody, Header, Payload};
+use record::{Record, EncryptedBody, Header, Payload};
use serde::{de::DeserializeOwned, Serialize};
use users::User;
@@ -77,13 +77,37 @@ pub trait Loading {
}
}
-/// A common vault abstraction trait that deals with
-/// data integrety and synchronisation for different
-/// platform backends.
-pub trait VaultLayer {
+/// Trait for an in-memory representation of a lockchain vault.
+///
+/// By itself it represents vault metadata (name, users, location)
+/// as well as a list of record headers.
+///
+/// To provide on-disk functionality it requires the `-storage`
+/// trait library and for encrypted file access the `-crypto`
+/// crate.
+///
+/// The body backend is being being generic with the `Body` trait.
+pub trait Vault<T> where T: Body {
+ /// A shared constructor for all vault implementations
+ fn new(name: &str, location: &str) -> Self;
+ /// Fetch metadata headers for all records
fn fetch(&mut self);
+ /// Pull a specific record from the backend
fn pull(&mut self, name: &str);
+ /// Sync all changes back to the backend
fn sync(&mut self);
+ /// Get a complete record from this vault
+ fn get_record(&self, name: &str) -> Option<&Record<T>>;
+ /// Probe if a record is contained
+ fn contains(&self, name: &str) -> bool;
+ /// Add a new record to this vault
+ fn add_record(&mut self, key: &str, category: &str, tags: Vec<&str>);
+ /// Delete a record from this vault
+ fn delete_record(&mut self, record: &str) -> Option<Record<T>>;
+ /// Add data to an existing record, overwriting existing fields
+ fn add_data(&mut self, record: &str, key: &str, data: Payload) -> Option<()>;
+ /// Get the (latest) value of a specific record data field
+ fn get_data(&self, record: &str, key: &str) -> Option<&Payload>;
}
/// Auto-implement this trait to serialise types to json
diff --git a/lockchain-core/src/vault.rs b/lockchain-core/src/vault.rs
deleted file mode 100644
index e1457f8..0000000
--- a/lockchain-core/src/vault.rs
+++ /dev/null
@@ -1,84 +0,0 @@
-//! Common vault data module
-//!
-//! A vault represents a collection of records of sensitive data. Each record
-//! is a versioned history of key-value store entries inside a body. By default
-//! only the headers of records are available as they don't contain secret
-//! information.
-//!
-//! In the future, Vaults will have user and rights management that determines
-//! how data can be written and read from records.
-
-use record::{Payload, Record};
-use std::collections::HashMap;
-use traits::{Body, VaultLayer};
-
-/// In-memory representation of a lockchain vault.
-///
-/// By itself it represents vault metadata (name, users, location)
-/// as well as a list of record headers.
-///
-/// To provide on-disk functionality it requires the `-storage`
-/// trait library and for encrypted file access the `-crypto`
-/// crate.
-///
-/// The body backend is being being generic with the `Body` trait.
-#[allow(dead_code)]
-pub struct Vault<T: Body> {
- /// The name of this vault
- name: String,
- /// The location of this vault (either local or remote)
- location: String,
- ///A list of known records in this vault
- records: HashMap<String, Record<T>>,
-}
-
-impl<T: Body> VaultLayer for Vault<T> {
- fn fetch(&mut self) {
- unimplemented!()
- }
- fn pull(&mut self, _name: &str) {
- unimplemented!()
- }
- fn sync(&mut self) {
- unimplemented!()
- }
-}
-
-impl<T: Body> Vault<T> {
- pub fn new(name: &str, location: &str) -> Vault<T> {
- Vault {
- name: name.to_owned(),
- location: location.to_owned(),
- records: HashMap::<String, Record<T>>::new(),
- }
- }
-
- /// Try to retrieve a record from this vault.
- ///
- /// Returns `None` if it doesn't exist or can't be retrieved
- /// from the selected storage backend for this vault.
- pub fn get_record(&self, name: &str) -> Option<&Record<T>> {
- self.records.get(name)
- }
-
- /// Checks if a record is present in this vault without
- /// ever trying to load it.
- ///
- /// This is good to check the in-memory metadata without causing
- /// load on a central backend store that might not be located
- /// on the same machine as the front-end client.
- pub fn contains(&self, name: &str) -> bool {
- self.records.contains_key(name)
- }
-
- /// Adds a new (empty) record to the vault
- pub fn add_record(&mut self, key: &str, category: &str, tags: Vec<&str>) {
- self.records
- .insert(String::from(key), Record::new(key, category, tags));
- }
-
- /// Fill an existing record with data
- pub fn add_data(&mut self, record: &str, key: &str, data: Payload) -> Option<()> {
- (self.records.get_mut(record)?).add_data(key, data)
- }
-}
diff --git a/lockchain-crypto/Cargo.toml b/lockchain-crypto/Cargo.toml
index 14369cb..a347eea 100644
--- a/lockchain-crypto/Cargo.toml
+++ b/lockchain-crypto/Cargo.toml
@@ -13,7 +13,4 @@ lockchain-core = { version = ">=0.3.2", path = "../lockchain-core" }
serde_derive = "1.0"
serde = "1.0"
-miscreant = "0.3"
-base64 = "0.8"
-rand = "0.4"
-blake2 = "0.7" \ No newline at end of file
+miscreant = "0.3" \ No newline at end of file
diff --git a/lockchain-crypto/src/lib.rs b/lockchain-crypto/src/lib.rs
index 5daba02..e4c5366 100644
--- a/lockchain-crypto/src/lib.rs
+++ b/lockchain-crypto/src/lib.rs
@@ -8,9 +8,6 @@
extern crate serde_derive;
extern crate serde;
extern crate miscreant;
-extern crate base64;
-extern crate blake2;
-extern crate rand;
extern crate lockchain_core as lcc;
diff --git a/lockchain-http/src/lib.rs b/lockchain-http/src/lib.rs
index cd81597..b159345 100644
--- a/lockchain-http/src/lib.rs
+++ b/lockchain-http/src/lib.rs
@@ -8,6 +8,20 @@ pub struct Server {
}
+impl Server {
+
+}
+
+/// An enum that represents optional features. At least
+/// one flag needs to be provided to initialise [[Server]]
+/// in order to make a working lockchain-http interface.
pub enum ApiFeature {
- BasicIo
+ /// Basic functionality for record I/O
+ Base,
+ /// Enables user access management
+ Users,
+ /// Allows management of user identities
+ UserManagement,
+ /// Allows management of filestorage scopes & loading
+ VaultManagement,
} \ No newline at end of file
diff --git a/lockchain-server/Cargo.toml b/lockchain-server/Cargo.toml
index 56d4f48..d9c8cb1 100644
--- a/lockchain-server/Cargo.toml
+++ b/lockchain-server/Cargo.toml
@@ -4,3 +4,8 @@ version = "0.1.0"
authors = ["Katharina Fey <kookie@spacekookie.de>"]
[dependencies]
+lockchain-core = "*"
+lockchain-files = "*"
+lockchain-http = "*"
+
+clap = "*" \ No newline at end of file
diff --git a/lockchain-server/src/main.rs b/lockchain-server/src/main.rs
index e7a11a9..00fc430 100644
--- a/lockchain-server/src/main.rs
+++ b/lockchain-server/src/main.rs
@@ -1,3 +1,10 @@
+extern crate lockchain_core as lockchain;
+extern crate lockchain_files as files;
+extern crate lockchain_http as http;
+
+extern crate clap;
+
+
fn main() {
println!("Hello, world!");
}