pub struct CacheKey(/* private fields */);Expand description
Secret key signing every cache entry with HMAC-SHA256, so an entry written without the key (a committed or planted file) is never trusted.
Implementations§
Source§impl CacheKey
impl CacheKey
Sourcepub fn from_bytes(bytes: [u8; 32]) -> Self
pub fn from_bytes(bytes: [u8; 32]) -> Self
Wrap raw key bytes.
Sourcepub fn load_or_create(dir: &Path) -> Result<Self, CacheError>
pub fn load_or_create(dir: &Path) -> Result<Self, CacheError>
Load the key stored in <dir>/cache.key, creating it (random bytes,
mode 0600 on unix) when missing. A key file of the wrong length is
replaced, which invalidates every entry signed with the old one.
§Errors
Returns CacheError::InvalidKey when the key path is not a regular
file (a symlink is never followed), and CacheError::Io when the key
cannot be read, generated or written.
Sourcepub fn load_or_create_default() -> Result<Self, CacheError>
pub fn load_or_create_default() -> Result<Self, CacheError>
Sourcepub fn seal(&self, name: &str, payload: &[u8]) -> Result<Vec<u8>, CacheError>
pub fn seal(&self, name: &str, payload: &[u8]) -> Result<Vec<u8>, CacheError>
Sign payload for the entry called name: the 32-byte HMAC-SHA256 tag
followed by the payload. Binding the name stops a validly signed entry
from being moved onto another key.
§Errors
Returns CacheError::Io if the HMAC cannot be initialized.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CacheKey
impl RefUnwindSafe for CacheKey
impl Send for CacheKey
impl Sync for CacheKey
impl Unpin for CacheKey
impl UnsafeUnpin for CacheKey
impl UnwindSafe for CacheKey
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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