pub struct PureCrypto {}
Expand description
This module represents a stopgap solution to provide access to primitive crypto functions for JS clients. It is not intended to be used outside of the JS clients and this pattern should not be proliferated. It is necessary because we want to use SDK crypto prior to the SDK being fully responsible for state and keys.
Implementations§
Source§impl PureCrypto
impl PureCrypto
Sourcepub fn symmetric_decrypt(
enc_string: String,
key: Vec<u8>,
) -> Result<String, CryptoError>
pub fn symmetric_decrypt( enc_string: String, key: Vec<u8>, ) -> Result<String, CryptoError>
DEPRECATED: Use symmetric_decrypt_string
instead.
Cleanup ticket: https://bitwarden.atlassian.net/browse/PM-21247
pub fn symmetric_decrypt_string( enc_string: String, key: Vec<u8>, ) -> Result<String, CryptoError>
pub fn symmetric_decrypt_bytes( enc_string: String, key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
Sourcepub fn symmetric_decrypt_array_buffer(
enc_bytes: Vec<u8>,
key: Vec<u8>,
) -> Result<Vec<u8>, CryptoError>
pub fn symmetric_decrypt_array_buffer( enc_bytes: Vec<u8>, key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
DEPRECATED: Use symmetric_decrypt_filedata
instead.
Cleanup ticket: https://bitwarden.atlassian.net/browse/PM-21247
pub fn symmetric_decrypt_filedata( enc_bytes: Vec<u8>, key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
pub fn symmetric_encrypt_string( plain: String, key: Vec<u8>, ) -> Result<String, CryptoError>
pub fn symmetric_encrypt_bytes( plain: Vec<u8>, key: Vec<u8>, ) -> Result<String, CryptoError>
pub fn symmetric_encrypt_filedata( plain: Vec<u8>, key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
pub fn decrypt_user_key_with_master_password( encrypted_user_key: String, master_password: String, email: String, kdf: Kdf, ) -> Result<Vec<u8>, CryptoError>
pub fn encrypt_user_key_with_master_password( user_key: Vec<u8>, master_password: String, email: String, kdf: Kdf, ) -> Result<String, CryptoError>
pub fn make_user_key_aes256_cbc_hmac() -> Vec<u8> ⓘ
pub fn make_user_key_xchacha20_poly1305() -> Vec<u8> ⓘ
Sourcepub fn wrap_symmetric_key(
key_to_be_wrapped: Vec<u8>,
wrapping_key: Vec<u8>,
) -> Result<String, CryptoError>
pub fn wrap_symmetric_key( key_to_be_wrapped: Vec<u8>, wrapping_key: Vec<u8>, ) -> Result<String, CryptoError>
Wraps (encrypts) a symmetric key using a symmetric wrapping key, returning the wrapped key as an EncString.
Sourcepub fn unwrap_symmetric_key(
wrapped_key: String,
wrapping_key: Vec<u8>,
) -> Result<Vec<u8>, CryptoError>
pub fn unwrap_symmetric_key( wrapped_key: String, wrapping_key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
Unwraps (decrypts) a wrapped symmetric key using a symmetric wrapping key, returning the unwrapped key as a serialized byte array.
Sourcepub fn wrap_encapsulation_key(
encapsulation_key: Vec<u8>,
wrapping_key: Vec<u8>,
) -> Result<String, CryptoError>
pub fn wrap_encapsulation_key( encapsulation_key: Vec<u8>, wrapping_key: Vec<u8>, ) -> Result<String, CryptoError>
Wraps (encrypts) an SPKI DER encoded encapsulation (public) key using a symmetric wrapping key. Note: Usually, a public key is - by definition - public, so this should not be used. The specific use-case for this function is to enable rotateable key sets, where the “public key” is not public, with the intent of preventing the server from being able to overwrite the user key unlocked by the rotateable keyset.
Sourcepub fn unwrap_encapsulation_key(
wrapped_key: String,
wrapping_key: Vec<u8>,
) -> Result<Vec<u8>, CryptoError>
pub fn unwrap_encapsulation_key( wrapped_key: String, wrapping_key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
Unwraps (decrypts) a wrapped SPKI DER encoded encapsulation (public) key using a symmetric wrapping key.
Sourcepub fn wrap_decapsulation_key(
decapsulation_key: Vec<u8>,
wrapping_key: Vec<u8>,
) -> Result<String, CryptoError>
pub fn wrap_decapsulation_key( decapsulation_key: Vec<u8>, wrapping_key: Vec<u8>, ) -> Result<String, CryptoError>
Wraps (encrypts) a PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping key,
Sourcepub fn unwrap_decapsulation_key(
wrapped_key: String,
wrapping_key: Vec<u8>,
) -> Result<Vec<u8>, CryptoError>
pub fn unwrap_decapsulation_key( wrapped_key: String, wrapping_key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
Unwraps (decrypts) a wrapped PKCS8 DER encoded decapsulation (private) key using a symmetric wrapping key.
Sourcepub fn encapsulate_key_unsigned(
shared_key: Vec<u8>,
encapsulation_key: Vec<u8>,
) -> Result<String, CryptoError>
pub fn encapsulate_key_unsigned( shared_key: Vec<u8>, encapsulation_key: Vec<u8>, ) -> Result<String, CryptoError>
Encapsulates (encrypts) a symmetric key using an asymmetric encapsulation key (public key) in SPKI format, returning the encapsulated key as a string. Note: This is unsigned, so the sender’s authenticity cannot be verified by the recipient.
Sourcepub fn decapsulate_key_unsigned(
encapsulated_key: String,
decapsulation_key: Vec<u8>,
) -> Result<Vec<u8>, CryptoError>
pub fn decapsulate_key_unsigned( encapsulated_key: String, decapsulation_key: Vec<u8>, ) -> Result<Vec<u8>, CryptoError>
Decapsulates (decrypts) a symmetric key using an decapsulation key (private key) in PKCS8 DER format. Note: This is unsigned, so the sender’s authenticity cannot be verified by the recipient.
Trait Implementations§
Source§impl From<PureCrypto> for JsValue
impl From<PureCrypto> for JsValue
Source§fn from(value: PureCrypto) -> Self
fn from(value: PureCrypto) -> Self
Source§impl FromWasmAbi for PureCrypto
impl FromWasmAbi for PureCrypto
Source§impl IntoWasmAbi for PureCrypto
impl IntoWasmAbi for PureCrypto
Source§impl LongRefFromWasmAbi for PureCrypto
impl LongRefFromWasmAbi for PureCrypto
Source§impl OptionFromWasmAbi for PureCrypto
impl OptionFromWasmAbi for PureCrypto
Source§impl OptionIntoWasmAbi for PureCrypto
impl OptionIntoWasmAbi for PureCrypto
Source§impl RefFromWasmAbi for PureCrypto
impl RefFromWasmAbi for PureCrypto
Source§type Anchor = RcRef<PureCrypto>
type Anchor = RcRef<PureCrypto>
Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for PureCrypto
impl RefMutFromWasmAbi for PureCrypto
Source§impl TryFromJsValue for PureCrypto
impl TryFromJsValue for PureCrypto
Source§impl VectorFromWasmAbi for PureCrypto
impl VectorFromWasmAbi for PureCrypto
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[PureCrypto]>
Source§impl VectorIntoJsValue for PureCrypto
impl VectorIntoJsValue for PureCrypto
fn vector_into_jsvalue(vector: Box<[PureCrypto]>) -> JsValue
Source§impl VectorIntoWasmAbi for PureCrypto
impl VectorIntoWasmAbi for PureCrypto
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[PureCrypto]>) -> Self::Abi
Source§impl WasmDescribe for PureCrypto
impl WasmDescribe for PureCrypto
Source§impl WasmDescribeVector for PureCrypto
impl WasmDescribeVector for PureCrypto
impl SupportsConstructor for PureCrypto
impl SupportsInstanceProperty for PureCrypto
impl SupportsStaticProperty for PureCrypto
Auto Trait Implementations§
impl Freeze for PureCrypto
impl RefUnwindSafe for PureCrypto
impl Send for PureCrypto
impl Sync for PureCrypto
impl Unpin for PureCrypto
impl UnwindSafe for PureCrypto
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
§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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::Abi
Source§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
.