pub struct LocalFileKms { /* private fields */ }Expand description
A KEK read from a file. See the module docs for why it refuses production.
Implementations§
Source§impl LocalFileKms
impl LocalFileKms
Sourcepub fn open(path: impl AsRef<Path>, env: &str) -> Result<Self, KmsError>
pub fn open(path: impl AsRef<Path>, env: &str) -> Result<Self, KmsError>
Reads the master key from path.
env is the deployment environment, as
cratefield_core::VentureEnv spells it: anything equal to
"production" (case-insensitively) is refused. The environment
is a parameter rather than read from the process here, so the
refusal cannot be sidestepped by unsetting a variable, and so the
caller passes the same value it validated everything else with.
The file holds 32 raw bytes, or their hex or base64 encoding on
one line; a trailing newline is ignored, because the difference
between printf and echo should not be a cryptographic event.
§Errors
KmsError::Refused in production, KmsError::Unavailable
when the file cannot be read, KmsError::Invalid when its
contents are not a 32-byte key.
Sourcepub fn from_key(
kek: Dek,
key_ref: impl Into<String>,
env: &str,
) -> Result<Self, KmsError>
pub fn from_key( kek: Dek, key_ref: impl Into<String>, env: &str, ) -> Result<Self, KmsError>
A KEK the caller already holds, for tests that do not want a file. Refuses production for the same reason.
§Errors
KmsError::Refused in production.
Sourcepub fn create(path: impl AsRef<Path>) -> Result<(), KmsError>
pub fn create(path: impl AsRef<Path>) -> Result<(), KmsError>
Writes a fresh master key to path for a development
environment. Refuses to overwrite: losing a KEK means losing
every secret wrapped under it, so the destructive version of this
is a human deleting the file on purpose.
§Errors
KmsError::Refused when the file exists,
KmsError::Unavailable when it cannot be written.
Trait Implementations§
Source§impl Debug for LocalFileKms
impl Debug for LocalFileKms
Source§impl Kms for LocalFileKms
impl Kms for LocalFileKms
Source§fn provider(&self) -> &'static str
fn provider(&self) -> &'static str
"local-file", "worker-secret",
"aws-kms", "gcp-kms".Source§fn key_ref(&self) -> &str
fn key_ref(&self) -> &str
Source§fn wrap<'life0, 'life1, 'async_trait>(
&'life0 self,
dek: &'life1 Dek,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, KmsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn wrap<'life0, 'life1, 'async_trait>(
&'life0 self,
dek: &'life1 Dek,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, KmsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
docs/SECRETS-DESIGN.md §3). Read more