#include "components/enterprise/obfuscation/core/utils.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_file.h"
#include "base/no_destructor.h"
#include "base/numerics/byte_conversions.h"
#include "crypto/aead.h"
#include "crypto/hkdf.h"
#include "crypto/random.h"
#include "crypto/symmetric_key.h"
namespace enterprise_obfuscation {
namespace {
static constexpr size_t kKeySize = …;
static constexpr size_t kNonceSize = …;
static constexpr size_t kAuthTagSize = …;
static constexpr size_t kNoncePrefixSize = …;
static constexpr size_t kSaltSize = …;
static constexpr size_t kHeaderSize = …;
static constexpr size_t kMaxChunkSize = …;
static constexpr size_t kChunkSizePrefixSize = …;
const std::vector<uint8_t>& GetSymmetricKey() { … }
const std::vector<uint8_t> ComputeNonce(
const std::vector<uint8_t>& nonce_prefix,
uint32_t counter,
bool is_last_chunk) { … }
}
BASE_FEATURE(…);
bool IsFileObfuscationEnabled() { … }
base::expected<std::vector<uint8_t>, Error> CreateHeader(
std::vector<uint8_t>* derived_key,
std::vector<uint8_t>* nonce_prefix) { … }
base::expected<std::vector<uint8_t>, Error> ObfuscateDataChunk(
base::span<const uint8_t> data,
const std::vector<uint8_t>& derived_key,
const std::vector<uint8_t>& nonce_prefix,
uint32_t counter,
bool is_last_chunk) { … }
base::expected<size_t, Error> GetObfuscatedChunkSize(
base::span<const uint8_t> data) { … }
base::expected<std::pair< std::vector<uint8_t>,
std::vector<uint8_t>>,
Error>
GetHeaderData(const std::vector<uint8_t>& header) { … }
base::expected<std::vector<uint8_t>, Error> DeobfuscateDataChunk(
base::span<const uint8_t> data,
const std::vector<uint8_t>& derived_key,
const std::vector<uint8_t>& nonce_prefix,
uint32_t counter,
bool is_last_chunk) { … }
base::expected<void, Error> DeobfuscateFileInPlace(
const base::FilePath& file_path) { … }
}