chore: make some zone classes use const references

This commit is contained in:
Jan
2024-10-19 20:17:06 +02:00
parent 897a571a41
commit 778361728c
6 changed files with 12 additions and 11 deletions

View File

@ -2,7 +2,7 @@
#include <cassert>
AbstractSalsa20Processor::AbstractSalsa20Processor(const int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize)
AbstractSalsa20Processor::AbstractSalsa20Processor(const int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize)
: m_stream_count(streamCount),
m_stream_contexts(std::make_unique<StreamContext[]>(streamCount)),
m_stream_block_indices(std::make_unique<unsigned int[]>(streamCount))
@ -19,9 +19,9 @@ uint8_t* AbstractSalsa20Processor::GetHashBlock(const int streamNumber) const
return &m_block_hashes[blockIndexOffset + streamOffset];
}
void AbstractSalsa20Processor::InitStreams(std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const
void AbstractSalsa20Processor::InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, const size_t keySize) const
{
const int zoneNameLength = zoneName.length();
const auto zoneNameLength = zoneName.length();
const size_t blockHashBufferSize = BLOCK_HASHES_COUNT * m_stream_count * SHA1_HASH_SIZE;
assert(blockHashBufferSize % 4 == 0);

View File

@ -28,11 +28,11 @@ protected:
std::unique_ptr<uint8_t[]> m_block_hashes;
std::unique_ptr<unsigned int[]> m_stream_block_indices;
AbstractSalsa20Processor(int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
AbstractSalsa20Processor(int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
_NODISCARD uint8_t* GetHashBlock(int streamNumber) const;
void InitStreams(std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const;
void InitStreams(const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize) const;
public:
virtual ~AbstractSalsa20Processor() = default;

View File

@ -3,7 +3,7 @@
#include <cassert>
XChunkProcessorSalsa20Encryption::XChunkProcessorSalsa20Encryption(const int streamCount,
std::string& zoneName,
const std::string& zoneName,
const uint8_t* salsa20Key,
const size_t keySize)
: AbstractSalsa20Processor(streamCount, zoneName, salsa20Key, keySize)

View File

@ -8,7 +8,7 @@
class XChunkProcessorSalsa20Encryption final : public IXChunkProcessor, public AbstractSalsa20Processor
{
public:
XChunkProcessorSalsa20Encryption(int streamCount, std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
XChunkProcessorSalsa20Encryption(int streamCount, const std::string& zoneName, const uint8_t* salsa20Key, size_t keySize);
size_t Process(int streamNumber, const uint8_t* input, size_t inputLength, uint8_t* output, size_t outputBufferSize) override;
};