1 use endian_trait
::Endian
;
3 // WARNING: PLEASE DO NOT MODIFY THOSE MAGIC VALUES
5 // openssl::sha::sha256(b"Proxmox Backup Catalog file v1.0")[0..8]
6 pub const PROXMOX_CATALOG_FILE_MAGIC_1_0
: [u8; 8] = [145, 253, 96, 249, 196, 103, 88, 213];
8 // openssl::sha::sha256(b"Proxmox Backup uncompressed blob v1.0")[0..8]
9 pub const UNCOMPRESSED_BLOB_MAGIC_1_0
: [u8; 8] = [66, 171, 56, 7, 190, 131, 112, 161];
11 //openssl::sha::sha256(b"Proxmox Backup zstd compressed blob v1.0")[0..8]
12 pub const COMPRESSED_BLOB_MAGIC_1_0
: [u8; 8] = [49, 185, 88, 66, 111, 182, 163, 127];
14 // openssl::sha::sha256(b"Proxmox Backup encrypted blob v1.0")[0..8]
15 pub const ENCRYPTED_BLOB_MAGIC_1_0
: [u8; 8] = [123, 103, 133, 190, 34, 45, 76, 240];
17 // openssl::sha::sha256(b"Proxmox Backup zstd compressed encrypted blob v1.0")[0..8]
18 pub const ENCR_COMPR_BLOB_MAGIC_1_0
: [u8; 8] = [230, 89, 27, 191, 11, 191, 216, 11];
20 // openssl::sha::sha256(b"Proxmox Backup fixed sized chunk index v1.0")[0..8]
21 pub const FIXED_SIZED_CHUNK_INDEX_1_0
: [u8; 8] = [47, 127, 65, 237, 145, 253, 15, 205];
23 // openssl::sha::sha256(b"Proxmox Backup dynamic sized chunk index v1.0")[0..8]
24 pub const DYNAMIC_SIZED_CHUNK_INDEX_1_0
: [u8; 8] = [28, 145, 78, 165, 25, 186, 179, 205];
26 /// Data blob binary storage format
28 /// The format start with a 8 byte magic number to identify the type,
29 /// followed by a 4 byte CRC. This CRC is used on the server side to
30 /// detect file corruption (computed when upload data), so there is
31 /// usually no need to compute it on the client side.
33 /// Unencrypted blobs simply contain the CRC, followed by the
34 /// (compressed) data.
36 /// (MAGIC || CRC32 || Data)
38 /// This is basically the same format we use for chunks, but
39 /// with other magic numbers so that we can distinguish them.
42 pub struct DataBlobHeader
{
47 /// Encrypted data blob binary storage format
49 /// The ``DataBlobHeader`` for encrypted blobs additionally contains
50 /// a 16 byte IV, followed by a 16 byte Authenticated Encyrypten (AE)
51 /// tag, followed by the encrypted data:
53 /// (MAGIC || CRC32 || IV || TAG || EncryptedData).
56 pub struct EncryptedDataBlobHeader
{
57 pub head
: DataBlobHeader
,
62 /// Header size for different file types
64 /// Panics on unknown magic numbers.
65 pub fn header_size(magic
: &[u8; 8]) -> usize {
67 &UNCOMPRESSED_BLOB_MAGIC_1_0
=> std
::mem
::size_of
::<DataBlobHeader
>(),
68 &COMPRESSED_BLOB_MAGIC_1_0
=> std
::mem
::size_of
::<DataBlobHeader
>(),
69 &ENCRYPTED_BLOB_MAGIC_1_0
=> std
::mem
::size_of
::<EncryptedDataBlobHeader
>(),
70 &ENCR_COMPR_BLOB_MAGIC_1_0
=> std
::mem
::size_of
::<EncryptedDataBlobHeader
>(),
71 _
=> panic
!("unknown blob magic"),