Skip to main content

Crate securetar

Crate securetar 

Source
Expand description

SecureTar v3 reader primitives.

This crate is an independent Rust implementation aligned with the Python home-assistant-libs/securetar package. It currently implements the SecureTar v3 read path: header parsing, password validation, key restoration, and streaming decryption.

Legacy SecureTar v1/v2 AES-CBC and archive-writing helpers are intentionally not implemented yet.

use std::{fs::File, io::Read};
use securetar::{SecureTarDecryptStream, SecureTarRootKeyContext};

let file = File::open("encrypted.securetar")?;
let context = SecureTarRootKeyContext::new("password");
let mut stream = SecureTarDecryptStream::new(file, context)?;

let mut plaintext_tar = Vec::new();
stream.read_to_end(&mut plaintext_tar)?;

Structs§

DecryptReader
Plaintext reader returned by SecureTarDecryptStream.
SecureTarDecryptStream
Decrypting SecureTar v3 stream.
SecureTarDerivedKeyMaterialV3
Restored v3 key material.
SecureTarHeader
Parsed SecureTar header.
SecureTarRootKeyContext
Password context for restoring per-file v3 key material.

Enums§

CipherMode
Cipher direction.
SecureTarError
SecureTar errors.

Constants§

AES_BLOCK_SIZE
AES block size used by legacy SecureTar v1/v2.
AES_IV_SIZE
AES IV size used by legacy SecureTar v1/v2.
DEFAULT_BUFSIZE
Default Python securetar buffer size.
DEFAULT_CIPHER_VERSION
Default SecureTar version for new encrypted data in Python.
GZIP_MAGIC_BYTES
Gzip magic bytes used by Python validation.
SECURETAR_FILE_ID_SIZE
Size of the SecureTar file id section.
SECURETAR_FILE_METADATA_SIZE
Size of the SecureTar metadata section.
SECURETAR_LEGACY_HEADER_SIZE
Header size for legacy magic-less SecureTar v1.
SECURETAR_MAGIC
SecureTar magic bytes.
SECURETAR_MAGIC_RESERVED
Required reserved bytes in the SecureTar file id.
SECURETAR_V2_CIPHER_INIT_SIZE
Size of the v2 cipher initialization section.
SECURETAR_V2_HEADER_SIZE
Size of a v2 header.
SECURETAR_V3_CIPHER_INIT_SIZE
Size of the v3 cipher initialization section.
SECURETAR_V3_HEADER_SIZE
Size of a v3 header.
TAR_BLOCK_SIZE
Tar block size.
TAR_MAGIC_BYTES
Tar magic bytes used by Python validation.
TAR_MAGIC_OFFSET
Tar magic offset used by Python validation.
V3_CHACHA20_HEADER_SIZE
Size of the XChaCha20-Poly1305 secretstream header.
V3_DERIVED_KEY_SALT_SIZE
Size of v3 BLAKE2b salts.
V3_DERIVED_KEY_SIZE
Size of v3 derived keys.
V3_KDF_MEMLIMIT
Argon2id memory limit, in bytes, for v3 keys.
V3_KDF_OPSLIMIT
Argon2id operation limit for v3 keys.
V3_SECRETSTREAM_ABYTES
Secretstream authentication bytes per v3 chunk.
V3_SECRETSTREAM_CHUNK_SIZE
Plaintext bytes per v3 secretstream chunk.

Functions§

get_archive_max_ciphertext_size
Returns Python-compatible maximum outer archive ciphertext size.
is_securetar_magic
Checks whether bytes start with SecureTar magic.
secretstream_overhead
Returns v3 secretstream overhead for a plaintext size.
v3_ciphertext_size
Returns v3 payload ciphertext size, excluding the header.
validate
Validates a stream; pass false to read through the final tag.
validate_password
Validates that a password can decrypt the beginning of the stream.

Type Aliases§

Result
Crate result type.