diff options
author | Katharina Fey <kookie@spacekookie.de> | 2018-09-16 18:29:07 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2018-09-16 18:29:07 +0100 |
commit | f7c0e6d59dc420d73916083af1dfd95a8b4c6fc9 (patch) | |
tree | bdf794ef49f866f6af66d80e09204f43414a710c | |
parent | c6a21b51e6c98a033c8d4ec7b2729714fa69125f (diff) |
Deprecating the entire `lockchain-crypto` API because it makes no gosh darn sense anymore 🤷
-rw-r--r-- | lockchain-core/src/crypto/mod.rs | 5 | ||||
-rw-r--r-- | lockchain-core/src/traits.rs | 10 | ||||
-rw-r--r-- | lockchain-crypto/src/databody.rs | 7 | ||||
-rw-r--r-- | lockchain-crypto/src/engine.rs | 6 | ||||
-rw-r--r-- | lockchain-crypto/src/lib.rs | 4 |
5 files changed, 20 insertions, 12 deletions
diff --git a/lockchain-core/src/crypto/mod.rs b/lockchain-core/src/crypto/mod.rs index 11aace0..2090e69 100644 --- a/lockchain-core/src/crypto/mod.rs +++ b/lockchain-core/src/crypto/mod.rs @@ -6,10 +6,13 @@ /// We re-export keybob's API here mod keys { pub use keybob::{Key, KeyType}; - use traits::AutoEncoder; + use traits::{AutoEncoder, Encryptable}; impl AutoEncoder for Key {} impl AutoEncoder for KeyType {} + + impl Encryptable for Key {} + impl Encryptable for KeyType {} } mod data; diff --git a/lockchain-core/src/traits.rs b/lockchain-core/src/traits.rs index a3af268..babd489 100644 --- a/lockchain-core/src/traits.rs +++ b/lockchain-core/src/traits.rs @@ -55,7 +55,7 @@ pub trait LoadRecord<T: Body> { /// Additional functions might be added to this trait further down /// the road but for now, it's really just a marker that you can easily /// implement for any type that's also `AutoEncoder` -/// +/// // TODO: Add documentation test code in again pub trait Encryptable: AutoEncoder {} @@ -64,11 +64,7 @@ pub trait Encryptable: AutoEncoder {} /// /// Encryption is never done directly on the bodies, only via /// this scheduler type with the help of the [[Encryptable]] trait. -#[deprecated] -pub trait EncryptionHandler<T> -where - T: Encryptable + AutoEncoder + Body, -{ +pub trait EncryptionHandler<T: Encryptable> { fn encrypt(&mut self, item: T) -> EncryptedBody; fn decrypt(&mut self, item: EncryptedBody) -> Option<T>; } @@ -130,7 +126,7 @@ where /// End a specific user session fn deauthenticate(&mut self, username: &str, _: Token); /// Create a new user with a list of initial access rights - /// + /// /// **Important Note** A backend can make no guarantee for the safety /// of it's persistence. This means that a client library author is /// responsible for encrypting all required secrets **before** submitting diff --git a/lockchain-crypto/src/databody.rs b/lockchain-crypto/src/databody.rs index aaedce7..568710c 100644 --- a/lockchain-crypto/src/databody.rs +++ b/lockchain-crypto/src/databody.rs @@ -1,4 +1,9 @@ -//! +//! A clear-text representation of a record body in memory +//! +//! This form is created by the `lockchain-crypto` crate and +//! should only exist in ephemeral form. All actions are first +//! encrypted before being written back to a persistence +//! medium. use lcc::traits::{AutoEncoder, Body}; use lcc::Payload; diff --git a/lockchain-crypto/src/engine.rs b/lockchain-crypto/src/engine.rs index 24d79dc..45470c1 100644 --- a/lockchain-crypto/src/engine.rs +++ b/lockchain-crypto/src/engine.rs @@ -2,8 +2,6 @@ //! //! Can be initialised from scratch or with a pw/salt //! combintaion which derives a key via the `keybob` crate. -//! -//! Implements use lcc::traits::{AutoEncoder, Encryptable, EncryptionHandler}; use lcc::{EncryptedBody, PackedData}; @@ -25,6 +23,7 @@ pub struct AesEngine { impl AesEngine { /// Generate new key and encryption engine + #[deprecated] pub fn generate() -> Self { let key = Key::new(KeyType::Aes256); let len = key.len(); @@ -36,6 +35,7 @@ impl AesEngine { } /// Generate an Aes context from password + #[deprecated] pub fn from_pw(pw: &str, salt: &str) -> Self { let key = Key::from_pw(KeyType::Aes256, pw, salt); let len = key.len(); @@ -47,6 +47,7 @@ impl AesEngine { } /// Load a packed data object which contains an Aes context + #[deprecated] pub fn load(packed: PackedData, pw: &str, salt: &str) -> Option<Self> { let mut temp = Self::from_pw(pw, salt); let k: Key = Key::decode(&String::from_utf8(temp.decrypt_primitive(&packed)?).ok()?).ok()?; @@ -59,6 +60,7 @@ impl AesEngine { } /// Serialise the current context to save it somewhere + #[deprecated] pub fn save(&mut self) -> PackedData { let k = self._key.as_slice().into(); self.encrypt_primitive(&k) diff --git a/lockchain-crypto/src/lib.rs b/lockchain-crypto/src/lib.rs index a33e8bc..8e64a4c 100644 --- a/lockchain-crypto/src/lib.rs +++ b/lockchain-crypto/src/lib.rs @@ -13,6 +13,8 @@ extern crate lockchain_core as lcc; mod databody; mod engine; +mod keyfold; -pub use databody::*; +pub use databody::DataBody; pub use engine::AesEngine; +pub use keyfold::Keyfold;
\ No newline at end of file |