1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-11 01:42:26 +03:00

Library code for repository encryption support.

This commit is contained in:
David Steele
2017-11-03 13:57:58 -04:00
parent ac542788da
commit 8d6a08a32b
29 changed files with 1285 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
/***********************************************************************************************************************************
Test Random
***********************************************************************************************************************************/
#include "common/memContext.h"
/***********************************************************************************************************************************
Test Run
***********************************************************************************************************************************/
void testRun()
{
// -----------------------------------------------------------------------------------------------------------------------------
if (testBegin("randomBytes()"))
{
// -------------------------------------------------------------------------------------------------------------------------
// Test if the buffer was overrun
int bufferSize = 256;
char *buffer = memNew(bufferSize);
randomBytes(buffer, bufferSize);
TEST_RESULT_BOOL(buffer[bufferSize] == 0, true, "check that buffer did not overrun (though random byte could be 0)");
// -------------------------------------------------------------------------------------------------------------------------
// Count bytes that are not zero (there shouldn't be all zeroes)
int nonZeroTotal = 0;
for (int charIdx = 0; charIdx < bufferSize; charIdx++)
if (buffer[charIdx] != 0)
nonZeroTotal++;
TEST_RESULT_INT_NE(nonZeroTotal, 0, "check that there are non-zero values in the buffer");
}
}