cipherstash-client 0.34.0-alpha.2

The official CipherStash SDK
Documentation

CipherStash Client SDK

Crates.io Version docs.rs Built by CipherStash

Website | Docs | Discussions

The CipherStash SDK is the main way of interacting with CipherStash services. It includes clients for talking to ZeroKMS, CipherStash Token Service (CTS) and the services used to power Audit.

It also contains all the indexing and encryption logic used in CipherStash products.

Getting Started

To get started add the cipherstash-client dependency to your Cargo.toml

[dependencies]
cipherstash-client = "0.34.0"

Creating a ZeroKMS Client

Use [ZeroKMSBuilder] to create a new [ZeroKMS] client. With this you can:

  • Manage keysets, config and clients
  • Encrypt and decrypt data
use cipherstash_client::zerokms::ZeroKMSBuilder;

#[tokio::main]
async fn main() {
    let client = ZeroKMSBuilder::auto()
        .expect("failed to detect credentials")
        .build()
        .expect("failed to build client");

    let keyset = client.create_keyset("users", "A keyset used to encrypt my users' information")
        .await
        .expect("failed to create keyset");
}

Creating a CTS Client

Use [CtsClient] to manage access keys and identity tokens:

use cipherstash_client::{CtsClient, Region, WorkspaceId};
use cts_common::claims::Role;
use stack_auth::{AccessKey, AccessKeyStrategy};

#[tokio::main]
async fn main() {
    let region = Region::aws("ap-southeast-2").unwrap();
    let key: AccessKey = "CSAKmyKeyId.myKeySecret".parse().unwrap();
    let strategy = AccessKeyStrategy::new(region, key).unwrap();
    let client = CtsClient::new(strategy);

    let workspace_id = WorkspaceId::try_from("E4UMRN47WJNSMAKR").expect("Valid ID");
    let access_key = client.create_access_key("Test Access Key", workspace_id, Role::Admin)
        .await
        .expect("failed to create access key");
}