From f7c0e6d59dc420d73916083af1dfd95a8b4c6fc9 Mon Sep 17 00:00:00 2001 From: Katharina Fey Date: Sun, 16 Sep 2018 18:29:07 +0100 Subject: =?UTF-8?q?Deprecating=20the=20entire=20`lockchain-crypto`=20API?= =?UTF-8?q?=20because=20it=20makes=20no=20gosh=20darn=20sense=20anymore=20?= =?UTF-8?q?=F0=9F=A4=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lockchain-core/src/crypto/mod.rs | 5 ++++- lockchain-core/src/traits.rs | 10 +++------- lockchain-crypto/src/databody.rs | 7 ++++++- lockchain-crypto/src/engine.rs | 6 ++++-- 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 { /// 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 -where - T: Encryptable + AutoEncoder + Body, -{ +pub trait EncryptionHandler { fn encrypt(&mut self, item: T) -> EncryptedBody; fn decrypt(&mut self, item: EncryptedBody) -> Option; } @@ -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 { 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 -- cgit v1.2.3