RandomPadding throws exception instead of ASSERT when data is too large
This commit is contained in:
parent
9c86b619a6
commit
71c808b229
@ -8,7 +8,9 @@ using namespace cpputils::logging;
|
||||
namespace cpputils {
|
||||
Data RandomPadding::add(const Data &data, size_t targetSize) {
|
||||
uint32_t size = data.size();
|
||||
ASSERT(size < targetSize - sizeof(size), "Config data too large. We should increase padding target size.");
|
||||
if (size >= targetSize - sizeof(size)) {
|
||||
throw std::runtime_error("Data too large. We should increase padding target size.");
|
||||
}
|
||||
Data randomData = Random::PseudoRandom().get(targetSize-sizeof(size)-size);
|
||||
ASSERT(sizeof(size) + size + randomData.size() == targetSize, "Calculated size of randomData incorrectly");
|
||||
Data result(targetSize);
|
||||
|
@ -11,6 +11,7 @@ namespace cpputils {
|
||||
|
||||
//TODO Test Copy/move constructor and assignment
|
||||
//TODO Test operator==/!=
|
||||
//TODO Use SCryptSettings as a member here instead of storing _N, _r, _p.
|
||||
|
||||
class DerivedKeyConfig {
|
||||
public:
|
||||
|
Loading…
Reference in New Issue
Block a user