mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-30 05:39:12 +02:00
Add helper function for adding CipherBlock filters to groups.
Reviewed by Cynthia Shang.
This commit is contained in:
parent
5c314df098
commit
7334f30c35
@ -13,6 +13,17 @@
|
||||
|
||||
<release-list>
|
||||
<release date="XXXX-XX-XX" version="2.18dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-reviewer id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Add helper function for adding <code>CipherBlock</code> filters to groups.</p>
|
||||
</release-item>
|
||||
</release-development-list>
|
||||
</release-core-list>
|
||||
</release>
|
||||
|
||||
<release date="2019-09-03" version="2.17" title="C Migrations and Bug Fixes">
|
||||
|
@ -305,7 +305,7 @@ common/compress/gzip/compress.o: common/compress/gzip/compress.c build.auto.h co
|
||||
common/compress/gzip/decompress.o: common/compress/gzip/decompress.c build.auto.h common/assert.h common/compress/gzip/common.h common/compress/gzip/decompress.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/filter.intern.h common/log.h common/logLevel.h common/macro.h common/memContext.h common/object.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CMAKE) -c common/compress/gzip/decompress.c -o common/compress/gzip/decompress.o
|
||||
|
||||
common/crypto/cipherBlock.o: common/crypto/cipherBlock.c build.auto.h common/assert.h common/crypto/cipherBlock.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/filter.intern.h common/log.h common/logLevel.h common/macro.h common/memContext.h common/object.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
|
||||
common/crypto/cipherBlock.o: common/crypto/cipherBlock.c build.auto.h common/assert.h common/crypto/cipherBlock.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/filter.intern.h common/io/filter/group.h common/log.h common/logLevel.h common/macro.h common/memContext.h common/object.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h
|
||||
$(CC) $(CPPFLAGS) $(CFLAGS) $(CMAKE) -c common/crypto/cipherBlock.c -o common/crypto/cipherBlock.o
|
||||
|
||||
common/crypto/common.o: common/crypto/common.c build.auto.h common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
|
||||
|
@ -460,3 +460,25 @@ cipherBlockNewVar(const VariantList *paramList)
|
||||
(CipherMode)varUIntForce(varLstGet(paramList, 0)), (CipherType)varUIntForce(varLstGet(paramList, 1)),
|
||||
BUFSTR(varStr(varLstGet(paramList, 2))), varLstGet(paramList, 3) == NULL ? NULL : varStr(varLstGet(paramList, 3)));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Helper function to add a block cipher to an io object
|
||||
***********************************************************************************************************************************/
|
||||
IoFilterGroup *
|
||||
cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass)
|
||||
{
|
||||
FUNCTION_LOG_BEGIN(logLevelTrace);
|
||||
FUNCTION_LOG_PARAM(IO_FILTER_GROUP, filterGroup);
|
||||
FUNCTION_LOG_PARAM(ENUM, type);
|
||||
FUNCTION_LOG_PARAM(ENUM, mode);
|
||||
FUNCTION_LOG_PARAM(STRING, pass);
|
||||
FUNCTION_LOG_END();
|
||||
|
||||
ASSERT(filterGroup != NULL);
|
||||
ASSERT((type == cipherTypeNone && pass == NULL) || (type != cipherTypeNone && pass != NULL));
|
||||
|
||||
if (type != cipherTypeNone)
|
||||
ioFilterGroupAdd(filterGroup, cipherBlockNew(mode, type, BUFSTR(pass), NULL));
|
||||
|
||||
FUNCTION_LOG_RETURN(IO_FILTER_GROUP, filterGroup);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ Block Cipher Header
|
||||
#ifndef COMMON_CRYPTO_CIPHERBLOCK_H
|
||||
#define COMMON_CRYPTO_CIPHERBLOCK_H
|
||||
|
||||
#include "common/io/filter/filter.h"
|
||||
#include "common/io/filter/group.h"
|
||||
#include "common/crypto/common.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -19,4 +19,9 @@ Constructor
|
||||
IoFilter *cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName);
|
||||
IoFilter *cipherBlockNewVar(const VariantList *paramList);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Helper functions
|
||||
***********************************************************************************************************************************/
|
||||
IoFilterGroup *cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMode mode, const String *pass);
|
||||
|
||||
#endif
|
||||
|
@ -285,6 +285,18 @@ testRun(void)
|
||||
TEST_ERROR(ioFilterProcessInOut(blockDecryptFilter, NULL, decryptBuffer), CryptoError, "unable to flush");
|
||||
|
||||
ioFilterFree(blockDecryptFilter);
|
||||
|
||||
// Helper function
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
IoFilterGroup *filterGroup = ioFilterGroupNew();
|
||||
|
||||
TEST_RESULT_PTR(
|
||||
cipherBlockFilterGroupAdd(filterGroup, cipherTypeNone, cipherModeEncrypt, NULL), filterGroup, " no filter add");
|
||||
TEST_RESULT_UINT(ioFilterGroupSize(filterGroup), 0, " check no filter add");
|
||||
|
||||
TEST_RESULT_VOID(
|
||||
cipherBlockFilterGroupAdd(filterGroup, cipherTypeAes256Cbc, cipherModeEncrypt, STRDEF("X")), " filter add");
|
||||
TEST_RESULT_UINT(ioFilterGroupSize(filterGroup), 1, " check filter add");
|
||||
}
|
||||
|
||||
// *****************************************************************************************************************************
|
||||
|
Loading…
x
Reference in New Issue
Block a user