Skip to content

Commit

Permalink
Make KeyStore pub
Browse files Browse the repository at this point in the history
  • Loading branch information
dani-garcia committed Sep 25, 2024
1 parent 22a8b17 commit c63f656
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::service::KeyRef;
pub(crate) mod linux_memfd_secret;
pub(crate) mod rust_slice;

pub(crate) fn create_key_store<Key: KeyRef>() -> Box<dyn KeyStore<Key>> {
pub fn create_key_store<Key: KeyRef>() -> Box<dyn KeyStore<Key>> {
#[cfg(all(target_os = "linux", not(feature = "no-memory-hardening")))]
if let Some(key_store) = linux_memfd_secret::LinuxMemfdSecretKeyStore::<Key>::new() {
return Box::new(key_store);
Expand Down
5 changes: 2 additions & 3 deletions crates/bitwarden-crypto/src/service/key_store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ use crate::service::KeyRef;
mod implementation;
mod slice;

pub(crate) use implementation::create_key_store;
pub use implementation::create_key_store;

/// This trait represents a platform that can securely store and return keys. The `SliceKeyStore`
/// implementation is a simple in-memory store with some platform-specific security features. Other
/// implementations could use secure enclaves or HSMs, or OS provided keychains.
#[allow(dead_code)]
pub(crate) trait KeyStore<Key: KeyRef>: ZeroizeOnDrop + Send + Sync {
pub trait KeyStore<Key: KeyRef>: ZeroizeOnDrop + Send + Sync {
fn insert(&mut self, key_ref: Key, key: Key::KeyValue);
fn get(&self, key_ref: Key) -> Option<&Key::KeyValue>;
fn remove(&mut self, key_ref: Key);
Expand Down
3 changes: 2 additions & 1 deletion crates/bitwarden-crypto/src/service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ mod key_store;
use context::RustCryptoServiceContext;
pub use encryptable::{Decryptable, Encryptable, KeyProvided, KeyProvidedExt, UsesKey};
use key_ref::{AsymmetricKeyRef, KeyRef, SymmetricKeyRef};
use key_store::{create_key_store, KeyStore};
pub use key_store::create_key_store;
use key_store::KeyStore;

#[derive(Clone)]
pub struct CryptoService<SymmKeyRef: SymmetricKeyRef, AsymmKeyRef: AsymmetricKeyRef> {
Expand Down

0 comments on commit c63f656

Please sign in to comment.