pub struct EncryptionEngine { /* private fields */ }Expand description
AES-256-GCM 暗号化エンジン
Implementations§
Source§impl EncryptionEngine
impl EncryptionEngine
Sourcepub fn new(config: EncryptionConfig) -> Self
pub fn new(config: EncryptionConfig) -> Self
新しい暗号化エンジンを作成
Sourcepub fn generate_nonce_internal() -> [u8; 12]
pub fn generate_nonce_internal() -> [u8; 12]
ランダムなナンスを生成(公開API、pipeline.rsから使用)
Sourcepub fn get_chunk_size(&self) -> usize
pub fn get_chunk_size(&self) -> usize
チャンクサイズを取得(公開API、pipeline.rsから使用)
Sourcepub fn encrypt(
&self,
data: &[u8],
master_key: &MasterKey,
salt: [u8; 16],
) -> Result<EncryptedData>
pub fn encrypt( &self, data: &[u8], master_key: &MasterKey, salt: [u8; 16], ) -> Result<EncryptedData>
Sourcepub fn decrypt(
&self,
encrypted_data: &EncryptedData,
master_key: &MasterKey,
) -> Result<Vec<u8>>
pub fn decrypt( &self, encrypted_data: &EncryptedData, master_key: &MasterKey, ) -> Result<Vec<u8>>
データを復号化
§Errors
以下の場合にエラーを返します:
- AES-256-GCM復号化処理が失敗した場合 (
BackupError::EncryptionError)- 認証タグの検証に失敗した場合(データが改ざんされている可能性)
- 不正なマスターキーが使用された場合
Sourcepub fn encrypt_stream<R: Read, W: Write>(
&self,
reader: R,
writer: W,
master_key: &MasterKey,
) -> Result<EncryptedData>
pub fn encrypt_stream<R: Read, W: Write>( &self, reader: R, writer: W, master_key: &MasterKey, ) -> Result<EncryptedData>
ストリーミング暗号化(大容量ファイル用)
§Errors
以下の場合にエラーを返します:
- ファイル読み込みエラー (
BackupError::IoError) - ファイル書き込みエラー (
BackupError::IoError) - チャンク毎のAES-256-GCM暗号化処理が失敗した場合 (
BackupError::EncryptionError)
Sourcepub fn decrypt_stream<R: Read, W: Write>(
&self,
reader: R,
writer: W,
master_key: &MasterKey,
) -> Result<u64>
pub fn decrypt_stream<R: Read, W: Write>( &self, reader: R, writer: W, master_key: &MasterKey, ) -> Result<u64>
ストリーミング復号化(大容量ファイル用)
§Errors
以下の場合にエラーを返します:
- ヘッダー情報(ナンス・ソルト)の読み取りエラー (
BackupError::IoError) - チャンクサイズまたはチャンクデータの読み取りエラー (
BackupError::IoError) - ファイル書き込みエラー (
BackupError::IoError) - チャンク毎のAES-256-GCM復号化処理が失敗した場合 (
BackupError::EncryptionError)- 認証タグの検証に失敗した場合(データが改ざんされている可能性)
- 不正なマスターキーが使用された場合
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EncryptionEngine
impl RefUnwindSafe for EncryptionEngine
impl Send for EncryptionEngine
impl Sync for EncryptionEngine
impl Unpin for EncryptionEngine
impl UnwindSafe for EncryptionEngine
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.