pub struct SendAccessKey {
secret: Zeroizing<[u8; 16]>,
key: SymmetricCryptoKey,
}Expand description
Symmetric key material for an anonymous Send access, derived entirely from the URL
fragment — no account key store or logged-in user involved. This is the only Send flow
whose key doesn’t come from the user’s key store, hence a standalone type rather than a
[bitwarden_crypto::KeyStoreContext] slot.
The key is opaque by design: callers need to use it three ways (hash a password, decrypt a response, decrypt a downloaded blob) but never need to see it.
Fields§
§secret: Zeroizing<[u8; 16]>The raw fragment key. Retained because the send password hash is salted with the
unstretched key, not with Self::key.
key: SymmetricCryptoKeyThe stretched send key that actually encrypts the send’s fields and file blob.
Implementations§
Source§impl SendAccessKey
impl SendAccessKey
Sourcepub fn from_url_b64(key_b64: &str) -> Result<Self, SendAccessKeyError>
pub fn from_url_b64(key_b64: &str) -> Result<Self, SendAccessKeyError>
Parse the URL-safe-base64 key from a Send URL fragment and stretch it into the
send’s symmetric key. Equivalent to the legacy clients’ Utils.fromUrlB64ToArray
followed by KeyService.makeSendKey.
The "send"/Some("send") name/info pair must stay in lockstep with
Send::derive_shareable_key — that is what bw send create used to encrypt the send,
so any divergence makes every send undecryptable through this path. The round-trip
test below pins the two together.
Sourcepub fn hash_password_b64(&self, password: &str) -> String
pub fn hash_password_b64(&self, password: &str) -> String
PBKDF2-HMAC-SHA256 over password, SEND_ITERATIONS (100,000) rounds, salted with the
raw URL key — the password_hash_b64 credential the send-access token grant expects.
Identical recipe to SendAuthType::auth_data, which is what bw send create --password
stored on the server. A pinning test asserts the two agree; if they ever diverge, every
password-protected receive fails with an opaque server-side rejection.
Sourcepub fn decrypt_response(
&self,
response: SendAccessResponse,
) -> Result<SendAccessView, SendAccessDecryptError>
pub fn decrypt_response( &self, response: SendAccessResponse, ) -> Result<SendAccessView, SendAccessDecryptError>
Decrypt a SendAccessResponse’s encrypted fields into a plaintext
SendAccessView.
Sourcepub fn decrypt_file_buffer(
&self,
buffer: &[u8],
) -> Result<Vec<u8>, SendAccessDecryptError>
pub fn decrypt_file_buffer( &self, buffer: &[u8], ) -> Result<Vec<u8>, SendAccessDecryptError>
Decrypt a downloaded file-send blob. The blob is a single whole-buffer [EncString]
(not the chunked attachment format), matching the legacy clients’
EncArrayBuffer.fromResponse + EncryptService.decryptFileData.
Sourcefn decrypt_optional(
&self,
value: Option<String>,
) -> Result<Option<String>, SendAccessDecryptError>
fn decrypt_optional( &self, value: Option<String>, ) -> Result<Option<String>, SendAccessDecryptError>
Parse and decrypt an optional wire-format [EncString] field. Absent fields stay
absent — the caller decides whether a missing field is fatal.
Auto Trait Implementations§
impl Freeze for SendAccessKey
impl RefUnwindSafe for SendAccessKey
impl Send for SendAccessKey
impl Sync for SendAccessKey
impl Unpin for SendAccessKey
impl UnsafeUnpin for SendAccessKey
impl UnwindSafe for SendAccessKey
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<> Read more§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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