pub struct EncryptedShard(/* private fields */);Expand description
Encrypted content shard blob (AAD_SHARD).
Contains a shard header + compressed file content encrypted with
AES-256-GCM. Stored in the ObjectStore, addressed by ShardCid.
Implementations§
Source§impl EncryptedShard
impl EncryptedShard
Sourcepub fn from_bytes(bytes: Vec<u8>) -> EncryptedShard
pub fn from_bytes(bytes: Vec<u8>) -> EncryptedShard
Wrap raw ciphertext bytes.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consume and return the underlying ciphertext bytes.
Sourcepub fn encrypt(
key: &[u8; 32],
plaintext: &[u8],
) -> Result<EncryptedShard, CryptoError>
pub fn encrypt( key: &[u8; 32], plaintext: &[u8], ) -> Result<EncryptedShard, CryptoError>
Encrypt plaintext with this blob type’s AAD.
Sourcepub fn decrypt(&self, key: &[u8; 32]) -> Result<Vec<u8>, CryptoError>
pub fn decrypt(&self, key: &[u8; 32]) -> Result<Vec<u8>, CryptoError>
Decrypt this blob with the correct AAD.
Sourcepub fn decrypt_and_parse<T>(&self, key: &[u8; 32]) -> Result<T, CryptoError>where
T: DeserializeOwned,
pub fn decrypt_and_parse<T>(&self, key: &[u8; 32]) -> Result<T, CryptoError>where
T: DeserializeOwned,
Decrypt and parse a CBOR-encoded type with the correct AAD.
Trait Implementations§
Source§impl Debug for EncryptedShard
impl Debug for EncryptedShard
Source§impl EncryptedBlob for EncryptedShard
impl EncryptedBlob for EncryptedShard
Auto Trait Implementations§
impl Freeze for EncryptedShard
impl RefUnwindSafe for EncryptedShard
impl Send for EncryptedShard
impl Sync for EncryptedShard
impl Unpin for EncryptedShard
impl UnsafeUnpin for EncryptedShard
impl UnwindSafe for EncryptedShard
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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