pub struct TransitEngine { /* private fields */ }Expand description
The Transit Engine provides encryption-as-a-service.
Applications can encrypt and decrypt data without ever seeing the keys.
Implementations§
Source§impl TransitEngine
impl TransitEngine
Sourcepub async fn new(
data_path: impl AsRef<Path>,
master_key: MasterKey,
) -> Result<Self, TransitError>
pub async fn new( data_path: impl AsRef<Path>, master_key: MasterKey, ) -> Result<Self, TransitError>
Creates a new TransitEngine with the given storage path and master key.
Sourcepub async fn create_key(
&self,
name: &str,
config: KeyConfig,
) -> Result<TransitKey, TransitError>
pub async fn create_key( &self, name: &str, config: KeyConfig, ) -> Result<TransitKey, TransitError>
Creates a new transit key.
Sourcepub async fn get_key(&self, name: &str) -> Result<TransitKey, TransitError>
pub async fn get_key(&self, name: &str) -> Result<TransitKey, TransitError>
Gets metadata for a transit key.
Sourcepub async fn list_keys(&self) -> Result<Vec<String>, TransitError>
pub async fn list_keys(&self) -> Result<Vec<String>, TransitError>
Lists all transit key names.
Sourcepub async fn list_versions(
&self,
name: &str,
) -> Result<Vec<KeyVersionInfo>, TransitError>
pub async fn list_versions( &self, name: &str, ) -> Result<Vec<KeyVersionInfo>, TransitError>
Lists all versions of a key.
Sourcepub async fn rotate_key(&self, name: &str) -> Result<u32, TransitError>
pub async fn rotate_key(&self, name: &str) -> Result<u32, TransitError>
Rotates a key to a new version.
Sourcepub async fn delete_key(&self, name: &str) -> Result<(), TransitError>
pub async fn delete_key(&self, name: &str) -> Result<(), TransitError>
Deletes a transit key (if deletion is allowed).
Sourcepub async fn update_key_config(
&self,
name: &str,
min_encryption_version: Option<u32>,
min_decryption_version: Option<u32>,
deletion_allowed: Option<bool>,
) -> Result<(), TransitError>
pub async fn update_key_config( &self, name: &str, min_encryption_version: Option<u32>, min_decryption_version: Option<u32>, deletion_allowed: Option<bool>, ) -> Result<(), TransitError>
Updates key configuration (min versions, etc.).
Sourcepub async fn encrypt(
&self,
name: &str,
plaintext: &[u8],
) -> Result<String, TransitError>
pub async fn encrypt( &self, name: &str, plaintext: &[u8], ) -> Result<String, TransitError>
Encrypts plaintext using the latest version of a key.
Returns ciphertext in format: egide:v{version}:{base64}
Sourcepub async fn encrypt_with_version(
&self,
name: &str,
plaintext: &[u8],
version: u32,
) -> Result<String, TransitError>
pub async fn encrypt_with_version( &self, name: &str, plaintext: &[u8], version: u32, ) -> Result<String, TransitError>
Encrypts plaintext using a specific key version.
Sourcepub async fn decrypt(
&self,
name: &str,
ciphertext: &str,
) -> Result<Vec<u8>, TransitError>
pub async fn decrypt( &self, name: &str, ciphertext: &str, ) -> Result<Vec<u8>, TransitError>
Decrypts ciphertext.
Automatically determines the key version from the ciphertext format.
Sourcepub async fn rewrap(
&self,
name: &str,
ciphertext: &str,
) -> Result<String, TransitError>
pub async fn rewrap( &self, name: &str, ciphertext: &str, ) -> Result<String, TransitError>
Rewraps ciphertext with the latest key version.
This decrypts and re-encrypts without exposing plaintext to the caller.
Sourcepub async fn generate_datakey(
&self,
name: &str,
) -> Result<DataKey, TransitError>
pub async fn generate_datakey( &self, name: &str, ) -> Result<DataKey, TransitError>
Generates a new data encryption key (DEK).
Returns both the plaintext key (for immediate use) and the wrapped key (for storage). The plaintext key should be used and then discarded.
Sourcepub async fn decrypt_datakey(
&self,
name: &str,
wrapped: &str,
) -> Result<Vec<u8>, TransitError>
pub async fn decrypt_datakey( &self, name: &str, wrapped: &str, ) -> Result<Vec<u8>, TransitError>
Decrypts a wrapped data key.
Auto Trait Implementations§
impl !RefUnwindSafe for TransitEngine
impl !UnwindSafe for TransitEngine
impl Freeze for TransitEngine
impl Send for TransitEngine
impl Sync for TransitEngine
impl Unpin for TransitEngine
impl UnsafeUnpin for TransitEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more