// openssl::sha::sha256(b"Proxmox Backup zstd compressed encrypted chunk v1.0")[0..8]
pub static ENCR_COMPR_CHUNK_MAGIC_1_0: [u8; 8] = [9, 40, 53, 200, 37, 150, 90, 196];
+// openssl::sha::sha256(b"Proxmox Backup fixed sized chunk index v1.0")[0..8]
+pub static FIXED_SIZED_CHUNK_INDEX_1_0: [u8; 8] = [47, 127, 65, 237, 145, 253, 15, 205];
+
+// openssl::sha::sha256(b"Proxmox Backup dynamic sized chunk index v1.0")[0..8]
+pub static DYNAMIC_SIZED_CHUNK_INDEX_1_0: [u8; 8] = [28, 145, 78, 165, 25, 186, 179, 205];
+
mod crypt_setup;
pub use crypt_setup::*;
#[repr(C)]
pub struct DynamicIndexHeader {
/// The string `PROXMOX-DIDX`
- pub magic: [u8; 12],
- pub version: u32,
+ pub magic: [u8; 8],
pub uuid: [u8; 16],
pub ctime: u64,
/// Sha256 over the index ``SHA256(offset1||digest1||offset2||digest2||...)``
pub index_csum: [u8; 32],
- reserved: [u8; 4024], // overall size is one page (4096 bytes)
+ reserved: [u8; 4030], // overall size is one page (4096 bytes)
}
let header = unsafe { &* (buffer.as_ptr() as *const DynamicIndexHeader) };
- if header.magic != *b"PROXMOX-DIDX" {
+ if header.magic != super::DYNAMIC_SIZED_CHUNK_INDEX_1_0 {
bail!("got unknown magic number for {:?}", path);
}
- let version = u32::from_le(header.version);
- if version != 1 {
- bail!("got unsupported version number ({}) for {:?}", version, path);
- }
-
let ctime = u64::from_le(header.ctime);
let rawfd = file.as_raw_fd();
let mut buffer = vec::undefined(header_size);
let header = crate::tools::map_struct_mut::<DynamicIndexHeader>(&mut buffer)?;
- header.magic = *b"PROXMOX-DIDX";
- header.version = u32::to_le(1);
+ header.magic = super::DYNAMIC_SIZED_CHUNK_INDEX_1_0;
header.ctime = u64::to_le(ctime);
header.uuid = *uuid.as_bytes();
/// Header format definition for fixed index files (`.fidx`)
#[repr(C)]
pub struct FixedIndexHeader {
- /// The string `PROXMOX-FIDX`
- pub magic: [u8; 12],
- pub version: u32,
+ pub magic: [u8; 8],
pub uuid: [u8; 16],
pub ctime: u64,
- pub size: u64,
- pub chunk_size: u64,
/// Sha256 over the index ``SHA256(digest1||digest2||...)``
pub index_csum: [u8; 32],
- reserved: [u8; 4008], // overall size is one page (4096 bytes)
+ pub size: u64,
+ pub chunk_size: u64,
+ reserved: [u8; 4016], // overall size is one page (4096 bytes)
}
// split image into fixed size chunks
let header = unsafe { &mut * (buffer.as_ptr() as *mut FixedIndexHeader) };
- if header.magic != *b"PROXMOX-FIDX" {
+ if header.magic != super::FIXED_SIZED_CHUNK_INDEX_1_0 {
bail!("got unknown magic number for {:?}", path);
}
- let version = u32::from_le(header.version);
- if version != 1 {
- bail!("got unsupported version number ({})", version);
- }
-
let size = u64::from_le(header.size) as usize;
let ctime = u64::from_le(header.ctime);
let chunk_size = u64::from_le(header.chunk_size) as usize;
let buffer = vec![0u8; header_size];
let header = unsafe { &mut * (buffer.as_ptr() as *mut FixedIndexHeader) };
- header.magic = *b"PROXMOX-FIDX";
- header.version = u32::to_le(1);
+ header.magic = super::FIXED_SIZED_CHUNK_INDEX_1_0;
header.ctime = u64::to_le(ctime);
header.size = u64::to_le(size as u64);
header.chunk_size = u64::to_le(chunk_size as u64);