try to use use proxmox::tools::io::ops::ReadExtOps
This commit is contained in:
parent
27042ce637
commit
ba01828d38
|
@ -1,7 +1,7 @@
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
use crate::tools::read::ReadUtilOps;
|
use proxmox::tools::io::ops::ReadExtOps;
|
||||||
use crate::tools::write::WriteUtilOps;
|
use crate::tools::write::WriteUtilOps;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -139,7 +139,9 @@ impl DataBlob {
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
} else if magic == &ENCR_COMPR_BLOB_MAGIC_1_0 || magic == &ENCRYPTED_BLOB_MAGIC_1_0 {
|
} else if magic == &ENCR_COMPR_BLOB_MAGIC_1_0 || magic == &ENCRYPTED_BLOB_MAGIC_1_0 {
|
||||||
let header_len = std::mem::size_of::<EncryptedDataBlobHeader>();
|
let header_len = std::mem::size_of::<EncryptedDataBlobHeader>();
|
||||||
let head = (&self.raw_data[..header_len]).read_value::<EncryptedDataBlobHeader>()?;
|
let head = unsafe {
|
||||||
|
(&self.raw_data[..header_len]).read_le_value::<EncryptedDataBlobHeader>()?
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(config) = config {
|
if let Some(config) = config {
|
||||||
let data = if magic == &ENCR_COMPR_BLOB_MAGIC_1_0 {
|
let data = if magic == &ENCR_COMPR_BLOB_MAGIC_1_0 {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use failure::*;
|
use failure::*;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use crate::tools::read::ReadUtilOps;
|
use proxmox::tools::io::ops::ReadExtOps;
|
||||||
use crate::tools::write::WriteUtilOps;
|
use crate::tools::write::WriteUtilOps;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -150,7 +150,9 @@ impl DataChunk {
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
} else if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 || magic == &ENCRYPTED_CHUNK_MAGIC_1_0 {
|
} else if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 || magic == &ENCRYPTED_CHUNK_MAGIC_1_0 {
|
||||||
let header_len = std::mem::size_of::<EncryptedDataChunkHeader>();
|
let header_len = std::mem::size_of::<EncryptedDataChunkHeader>();
|
||||||
let head = (&self.raw_data[..header_len]).read_value::<EncryptedDataChunkHeader>()?;
|
let head = unsafe {
|
||||||
|
(&self.raw_data[..header_len]).read_le_value::<EncryptedDataChunkHeader>()?
|
||||||
|
};
|
||||||
|
|
||||||
if let Some(config) = config {
|
if let Some(config) = config {
|
||||||
let data = if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 {
|
let data = if magic == &ENCR_COMPR_CHUNK_MAGIC_1_0 {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use endian_trait::Endian;
|
||||||
|
|
||||||
// WARNING: PLEASE DO NOT MODIFY THOSE MAGIC VALUES
|
// WARNING: PLEASE DO NOT MODIFY THOSE MAGIC VALUES
|
||||||
|
|
||||||
// openssl::sha::sha256(b"Proxmox Backup uncompressed chunk v1.0")[0..8]
|
// openssl::sha::sha256(b"Proxmox Backup uncompressed chunk v1.0")[0..8]
|
||||||
|
@ -44,6 +46,7 @@ pub static DYNAMIC_SIZED_CHUNK_INDEX_1_0: [u8; 8] = [28, 145, 78, 165, 25, 186,
|
||||||
///
|
///
|
||||||
/// This is basically the same format we use for chunks, but
|
/// This is basically the same format we use for chunks, but
|
||||||
/// with other magic numbers so that we can distinguish them.
|
/// with other magic numbers so that we can distinguish them.
|
||||||
|
#[derive(Endian)]
|
||||||
#[repr(C,packed)]
|
#[repr(C,packed)]
|
||||||
pub struct DataBlobHeader {
|
pub struct DataBlobHeader {
|
||||||
pub magic: [u8; 8],
|
pub magic: [u8; 8],
|
||||||
|
@ -57,6 +60,7 @@ pub struct DataBlobHeader {
|
||||||
/// tag, followed by the encrypted data:
|
/// tag, followed by the encrypted data:
|
||||||
///
|
///
|
||||||
/// (MAGIC || CRC32 || IV || TAG || EncryptedData).
|
/// (MAGIC || CRC32 || IV || TAG || EncryptedData).
|
||||||
|
#[derive(Endian)]
|
||||||
#[repr(C,packed)]
|
#[repr(C,packed)]
|
||||||
pub struct EncryptedDataBlobHeader {
|
pub struct EncryptedDataBlobHeader {
|
||||||
pub head: DataBlobHeader,
|
pub head: DataBlobHeader,
|
||||||
|
@ -75,6 +79,7 @@ pub struct EncryptedDataBlobHeader {
|
||||||
/// (compressed) data.
|
/// (compressed) data.
|
||||||
///
|
///
|
||||||
/// (MAGIC || CRC32 || Data)
|
/// (MAGIC || CRC32 || Data)
|
||||||
|
#[derive(Endian)]
|
||||||
#[repr(C,packed)]
|
#[repr(C,packed)]
|
||||||
pub struct DataChunkHeader {
|
pub struct DataChunkHeader {
|
||||||
pub magic: [u8; 8],
|
pub magic: [u8; 8],
|
||||||
|
@ -88,6 +93,7 @@ pub struct DataChunkHeader {
|
||||||
/// tag, followed by the encrypted data:
|
/// tag, followed by the encrypted data:
|
||||||
///
|
///
|
||||||
/// (MAGIC || CRC32 || IV || TAG || EncryptedData).
|
/// (MAGIC || CRC32 || IV || TAG || EncryptedData).
|
||||||
|
#[derive(Endian)]
|
||||||
#[repr(C,packed)]
|
#[repr(C,packed)]
|
||||||
pub struct EncryptedDataChunkHeader {
|
pub struct EncryptedDataChunkHeader {
|
||||||
pub head: DataChunkHeader,
|
pub head: DataChunkHeader,
|
||||||
|
|
Loading…
Reference in New Issue