Crates.io | tangy-lib |
lib.rs | tangy-lib |
version | 0.1.9 |
source | src |
created_at | 2024-04-07 07:53:03.925468 |
updated_at | 2024-04-12 07:20:31.022183 |
description | Tang protocol library implementation |
homepage | |
repository | https://github.com/martynp/tangy-lib |
max_upload_size | |
id | 1198894 |
size | 40,460 |
Tangy-lib is a library implementation of the Tang server, written in rust.
The Tang protocol allows clients to store secrets which can only be recovered when they have access to the Tang server. For example, the Clevis tools allows the automated decryption of LUKS partitions when the encrypted device is connected to the local network that Tang is accessible on.
See the original Tang project for a complete description: https://github.com/latchset/tang
Fraser Tweedale's 2020 Linux Conference Australia talk on "Clevis and Tang: securing your secrets at rest" is a great resource:
Installation via cargo:
cargo add tangy-lib
Or directly using in the dependencies section of Cargo.toml:
[dependencies]
tangy-lib = "0.1"
Tangy-lib has an initialization method which can take a local directory or vector of JWK string as input:
use tangy_lib::{KeySource, TangyLib};
let mut tangy = TangyLib::init(KeySource::LocalDir(&dir_path)).unwrap();
// or
let mut tangy = TangyLib::init(KeySource::Vector(&vec_of_keys)).unwrap();
If the LocalDir
does not contain a key set, a new key set is generated and saved to that folder.
The local directory and vector load methods will process the keys and generate errors if a JWK cannot be loaded or if some keys are missing an std::io::Error
is returned with kind set to std::io::ErrorKind::Unsupported
or std::io::ErrorKind::NotFound
.
If init
returns Ok
then everything else should work.
Tang uses advertise
and recovery
stages, to generate an adversise response and then recovery response:
use tangy_lib::{KeySource, TangyLib};
let mut tangy = TangyLib::init(KeySource::LocalDir(&dir_path));
let adv = tangy.adv(None).unwrap();
let rec = tangy.rec(&kid, &data).unwrap();
Where the parameter passed to adv
is a thumbprint of which signing key to use, often set to None which will use all signing keys. If the signing key is set but not found adv
will return Err(std::io::Error)
with ErrorKind set to std::io::ErrorKind::NotFound.
For recovery the thumbprint of the Elliptic Curve Message Recovery (ECMR) key, and the data is public key generated by the client in JWK format.
A key creation mechanism is provided:
let keys : Vec<String> = tangy_lib::create_new_key_set();
It creates ES512 and ECMR keys.
The original authors of Tang are Latchset. Tang is based on the protocol described by Nathaniel McCallum and Robert Relyea (https://marc.info/?m=144173814525805).
Apache-2.0 or MIT - you decide!
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed (Apache-2.0 and MIT), without any additional terms or conditions.