pgbackrest.git / summary / log / commit / refs
commit 2ef5ad70a29b36db570f8f50a2ba821fc4ee02ff
Author: David Steele <david@pgmasters.net>
Date: Sun Mar 10 11:27:30 2019 +0000
Move crypto module to common/crypto.
It makes sense for the crypto code to be in common since it is not pgBackRest-specific.
Also combine the crypto tests into a single module.
doc/xml/release.xml | 4 +
libc/LibC.xs | 2 +-
libc/Makefile.PL | 6 +-
libc/xs/crypto/cipherBlock.xsh | 2 +-
libc/xs/crypto/hash.xsh | 2 +-
src/Makefile | 48 ++++-----
src/command/archive/get/file.c | 2 +-
src/command/archive/get/file.h | 2 +-
src/command/info/info.c | 2 +-
common}/crypto/cipherBlock.c | 9 +-
common}/crypto/cipherBlock.h | 6 +-
common/crypto/common.c} | 2 +-
common/crypto/common.h} | 4 +-
common}/crypto/hash.c | 9 +-
common}/crypto/hash.h | 4 +-
src/common/io/tls/client.c | 2 +-
src/info/info.c | 4 +-
src/info/info.h | 3 +-
src/info/infoArchive.h | 2 +-
src/info/infoPg.h | 4 +-
src/perl/libc.auto.c | 2 +-
src/protocol/helper.c | 2 +-
src/storage/driver/s3/storage.c | 2 +-
test/define.yaml | 34 ++----
test/src/common/harnessTls.c | 2 +-
common/cryptoTest.c} | 117 ++++++++++++++++++++-
test/src/module/crypto/cryptoTest.c | 73 -------------
test/src/module/crypto/hashTest.c | 82 ---------------
28 files changed, 185 insertions(+), 248 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index f2ff2d61e..9a52ba732 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -184,6 +184,10 @@
<release-item>
<p>Move <code>compress</code> module to <code>common/compress</code>.</p>
</release-item>
+
+ <release-item>
+ <p>Move <code>crypto</code> module to <code>common/crypto</code>.</p>
+ </release-item>
</release-development-list>
</release-core-list>
diff --git a/libc/LibC.xs b/libc/LibC.xs
index ef707924e..adcca578c 100644
--- a/libc/LibC.xs
+++ b/libc/LibC.xs
@@ -46,13 +46,13 @@ C includes
These includes are from the src directory. There is no Perl-specific code in them.
***********************************************************************************************************************************/
+#include "common/crypto/common.h"
#include "common/error.h"
#include "common/lock.h"
#include "config/config.h"
#include "config/define.h"
#include "config/load.h"
#include "config/parse.h"
-#include "crypto/crypto.h"
#include "perl/config.h"
#include "postgres/pageChecksum.h"
#include "storage/driver/posix/storage.h"
diff --git a/libc/Makefile.PL b/libc/Makefile.PL
index 8e8718750..c3fdbc644 100644
--- a/libc/Makefile.PL
+++ b/libc/Makefile.PL
@@ -46,6 +46,9 @@ my @stryCFile =
'common/compress/gzip/common.c',
'common/compress/gzip/compress.c',
'common/compress/gzip/decompress.c',
+ 'common/crypto/cipherBlock.c',
+ 'common/crypto/common.c',
+ 'common/crypto/hash.c',
'common/debug.c',
'common/encode.c',
'common/encode/base64.c',
@@ -82,9 +85,6 @@ my @stryCFile =
'config/define.c',
'config/load.c',
'config/parse.c',
- 'crypto/cipherBlock.c',
- 'crypto/crypto.c',
- 'crypto/hash.c',
'perl/config.c',
'postgres/pageChecksum.c',
'storage/driver/posix/storage.c',
diff --git a/libc/xs/crypto/cipherBlock.xsh b/libc/xs/crypto/cipherBlock.xsh
index e2bc44f79..393f5cd4f 100644
--- a/libc/xs/crypto/cipherBlock.xsh
+++ b/libc/xs/crypto/cipherBlock.xsh
@@ -1,8 +1,8 @@
/***********************************************************************************************************************************
Block Cipher XS Header
***********************************************************************************************************************************/
+#include "common/crypto/cipherBlock.h"
#include "common/memContext.h"
-#include "crypto/cipherBlock.h"
// Encrypt/decrypt modes
#define CIPHER_MODE_ENCRYPT ((int)cipherModeEncrypt)
diff --git a/libc/xs/crypto/hash.xsh b/libc/xs/crypto/hash.xsh
index 8e30ae7f6..4d500d5dc 100644
--- a/libc/xs/crypto/hash.xsh
+++ b/libc/xs/crypto/hash.xsh
@@ -1,8 +1,8 @@
/***********************************************************************************************************************************
Cryptographic Hashes XS Header
***********************************************************************************************************************************/
+#include "common/crypto/hash.h"
#include "common/memContext.h"
-#include "crypto/hash.h"
typedef struct CryptoHashXs
{
diff --git a/src/Makefile b/src/Makefile
index 5d836cdd7..3a2729727 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -73,6 +73,9 @@ SRCS = \
common/compress/gzip/common.c \
common/compress/gzip/compress.c \
common/compress/gzip/decompress.c \
+ common/crypto/cipherBlock.c \
+ common/crypto/common.c \
+ common/crypto/hash.c \
common/debug.c \
common/encode.c \
common/encode/base64.c \
@@ -120,9 +123,6 @@ SRCS = \
config/load.c \
config/parse.c \
config/protocol.c \
- crypto/cipherBlock.c \
- crypto/hash.c \
- crypto/crypto.c \
info/info.c \
info/infoArchive.c \
info/infoBackup.c \
@@ -201,13 +201,13 @@ clean:
command/archive/common.o: command/archive/common.c command/archive/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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/wait.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c command/archive/common.c -o command/archive/common.o
-command/archive/get/file.o: command/archive/get/file.c command/archive/common.h command/archive/get/file.h command/control/control.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/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h crypto/cipherBlock.h crypto/crypto.h info/infoArchive.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+command/archive/get/file.o: command/archive/get/file.c command/archive/common.h command/archive/get/file.h command/control/control.h common/assert.h common/compress/gzip/common.h common/compress/gzip/decompress.h common/crypto/cipherBlock.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h info/infoArchive.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c command/archive/get/file.c -o command/archive/get/file.o
-command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/archive/get/file.h command/archive/get/protocol.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/exec.h crypto/crypto.h perl/exec.h postgres/interface.h protocol/client.h protocol/command.h protocol/helper.h protocol/parallel.h protocol/parallelJob.h protocol/server.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+command/archive/get/get.o: command/archive/get/get.c command/archive/common.h command/archive/get/file.h command/archive/get/protocol.h command/command.h common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/exec.h perl/exec.h postgres/interface.h protocol/client.h protocol/command.h protocol/helper.h protocol/parallel.h protocol/parallelJob.h protocol/server.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c command/archive/get/get.c -o command/archive/get/get.o
-command/archive/get/protocol.o: command/archive/get/protocol.c command/archive/get/file.h command/archive/get/protocol.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h crypto/crypto.h protocol/server.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+command/archive/get/protocol.o: command/archive/get/protocol.c command/archive/get/file.h command/archive/get/protocol.h common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h protocol/server.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c command/archive/get/protocol.c -o command/archive/get/protocol.o
command/archive/push/push.o: command/archive/push/push.c command/archive/common.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/fork.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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/wait.h config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
@@ -222,7 +222,7 @@ command/control/control.o: command/control/control.c command/control/control.h c
command/help/help.o: command/help/help.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/handleWrite.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
$(CC) $(CFLAGS) -c command/help/help.c -o command/help/help.o
-command/info/info.o: command/info/info.c command/archive/common.h command/info/info.h common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/handleWrite.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h crypto/crypto.h crypto/hash.h info/info.h info/infoArchive.h info/infoBackup.h info/infoPg.h perl/exec.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+command/info/info.o: command/info/info.c command/archive/common.h command/info/info.h common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/handleWrite.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h info/info.h info/infoArchive.h info/infoBackup.h info/infoPg.h perl/exec.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c command/info/info.c -o command/info/info.o
command/local/local.o: command/local/local.c command/archive/get/protocol.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/handleRead.h common/io/handleWrite.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/protocol.h protocol/client.h protocol/command.h protocol/helper.h protocol/server.h
@@ -240,6 +240,15 @@ common/compress/gzip/compress.o: common/compress/gzip/compress.c common/assert.h
common/compress/gzip/decompress.o: common/compress/gzip/decompress.c 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/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/compress/gzip/decompress.c -o common/compress/gzip/decompress.o
+common/crypto/cipherBlock.o: common/crypto/cipherBlock.c 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/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
+ $(CC) $(CFLAGS) -c common/crypto/cipherBlock.c -o common/crypto/cipherBlock.o
+
+common/crypto/common.o: common/crypto/common.c 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
+ $(CC) $(CFLAGS) -c common/crypto/common.c -o common/crypto/common.o
+
+common/crypto/hash.o: common/crypto/hash.c common/assert.h common/crypto/common.h common/crypto/hash.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/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
+ $(CC) $(CFLAGS) -c common/crypto/hash.c -o common/crypto/hash.o
+
common/debug.o: common/debug.c common/assert.h common/debug.h common/error.auto.h common/error.h common/logLevel.h common/stackTrace.h common/type/convert.h
$(CC) $(CFLAGS) -c common/debug.c -o common/debug.o
@@ -306,7 +315,7 @@ common/io/io.o: common/io/io.c common/assert.h common/debug.h common/error.auto.
common/io/read.o: common/io/read.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/read.intern.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
$(CC) $(CFLAGS) -c common/io/read.c -o common/io/read.o
-common/io/tls/client.o: common/io/tls/client.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/read.intern.h common/io/tls/client.h common/io/write.h common/io/write.intern.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h common/wait.h crypto/crypto.h
+common/io/tls/client.o: common/io/tls/client.c common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/read.intern.h common/io/tls/client.h common/io/write.h common/io/write.intern.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h common/wait.h
$(CC) $(CFLAGS) -c common/io/tls/client.c -o common/io/tls/client.o
common/io/write.o: common/io/write.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/write.h common/io/write.intern.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h
@@ -381,28 +390,19 @@ config/parse.o: config/parse.c common/assert.h common/debug.h common/error.auto.
config/protocol.o: config/protocol.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/io.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/protocol.h protocol/client.h protocol/command.h protocol/server.h
$(CC) $(CFLAGS) -c config/protocol.c -o config/protocol.o
-crypto/cipherBlock.o: crypto/cipherBlock.c common/assert.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/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h crypto/cipherBlock.h crypto/crypto.h
- $(CC) $(CFLAGS) -c crypto/cipherBlock.c -o crypto/cipherBlock.o
-
-crypto/crypto.o: crypto/crypto.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h crypto/crypto.h
- $(CC) $(CFLAGS) -c crypto/crypto.c -o crypto/crypto.o
-
-crypto/hash.o: crypto/hash.c common/assert.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/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h crypto/crypto.h crypto/hash.h
- $(CC) $(CFLAGS) -c crypto/hash.c -o crypto/hash.o
-
-info/info.o: info/info.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 crypto/cipherBlock.h crypto/crypto.h crypto/hash.h info/info.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
+info/info.o: info/info.c common/assert.h common/crypto/cipherBlock.h common/crypto/common.h common/crypto/hash.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 info/info.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h version.h
$(CC) $(CFLAGS) -c info/info.c -o info/info.o
-info/infoArchive.o: info/infoArchive.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 crypto/crypto.h info/infoArchive.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+info/infoArchive.o: info/infoArchive.c common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 info/infoArchive.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c info/infoArchive.c -o info/infoArchive.o
-info/infoBackup.o: info/infoBackup.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/crypto.h crypto/hash.h info/info.h info/infoBackup.h info/infoManifest.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+info/infoBackup.o: info/infoBackup.c common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h info/info.h info/infoBackup.h info/infoManifest.h info/infoPg.h postgres/interface.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c info/infoBackup.c -o info/infoBackup.o
info/infoManifest.o: info/infoManifest.c common/error.auto.h common/error.h common/memContext.h common/type/buffer.h common/type/string.h info/infoManifest.h
$(CC) $(CFLAGS) -c info/infoManifest.c -o info/infoManifest.o
-info/infoPg.o: info/infoPg.c common/assert.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h crypto/crypto.h crypto/hash.h info/info.h info/infoPg.h postgres/interface.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
+info/infoPg.o: info/infoPg.c common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/ini.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h info/info.h info/infoPg.h postgres/interface.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
$(CC) $(CFLAGS) -c info/infoPg.c -o info/infoPg.o
main.o: main.c command/archive/get/get.h command/archive/push/push.h command/command.h command/help/help.h command/info/info.h command/local/local.h command/remote/remote.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exit.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h perl/exec.h postgres/interface.h version.h
@@ -411,7 +411,7 @@ main.o: main.c command/archive/get/get.h command/archive/push/push.h command/com
perl/config.o: perl/config.c common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h
$(CC) $(CFLAGS) -c perl/config.c -o perl/config.o
-perl/exec.o: perl/exec.c ../libc/LibC.h common/assert.h common/debug.h common/encode.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h crypto/cipherBlock.h crypto/crypto.h crypto/hash.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
+perl/exec.o: perl/exec.c ../libc/LibC.h common/assert.h common/crypto/cipherBlock.h common/crypto/common.h common/crypto/hash.h common/debug.h common/encode.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/load.h config/parse.h perl/config.h perl/embed.auto.c perl/exec.h perl/libc.auto.c postgres/pageChecksum.h storage/driver/posix/fileRead.h storage/driver/posix/fileWrite.h storage/driver/posix/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h version.h ../libc/xs/common/encode.xsh ../libc/xs/crypto/cipherBlock.xsh ../libc/xs/crypto/hash.xsh
$(CC) $(CFLAGS) -c perl/exec.c -o perl/exec.o
postgres/interface.o: postgres/interface.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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 postgres/interface.h postgres/interface/v083.h postgres/interface/v084.h postgres/interface/v090.h postgres/interface/v091.h postgres/interface/v092.h postgres/interface/v093.h postgres/interface/v094.h postgres/interface/v095.h postgres/interface/v096.h postgres/interface/v100.h postgres/interface/v110.h postgres/version.h storage/fileRead.h storage/fileWrite.h storage/helper.h storage/info.h storage/storage.h
@@ -459,7 +459,7 @@ protocol/client.o: protocol/client.c common/assert.h common/debug.h common/error
protocol/command.o: protocol/command.c common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/command.h
$(CC) $(CFLAGS) -c protocol/command.c -o protocol/command.o
-protocol/helper.o: protocol/helper.c common/assert.h common/debug.h common/error.auto.h common/error.h common/exec.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/exec.h config/protocol.h crypto/crypto.h protocol/client.h protocol/command.h protocol/helper.h protocol/server.h
+protocol/helper.o: protocol/helper.c common/assert.h common/crypto/common.h common/debug.h common/error.auto.h common/error.h common/exec.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 config/config.auto.h config/config.h config/define.auto.h config/define.h config/exec.h config/protocol.h protocol/client.h protocol/command.h protocol/helper.h protocol/server.h
$(CC) $(CFLAGS) -c protocol/helper.c -o protocol/helper.o
protocol/parallel.o: protocol/parallel.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/json.h common/type/keyValue.h common/type/list.h common/type/string.h common/type/variant.h common/type/variantList.h protocol/client.h protocol/command.h protocol/parallel.h protocol/parallelJob.h
@@ -495,7 +495,7 @@ storage/driver/remote/storage.o: storage/driver/remote/storage.c common/assert.h
storage/driver/s3/fileRead.o: storage/driver/s3/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/read.intern.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.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 storage/driver/s3/fileRead.h storage/driver/s3/storage.h storage/fileRead.h storage/fileRead.intern.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
$(CC) $(CFLAGS) -c storage/driver/s3/fileRead.c -o storage/driver/s3/fileRead.o
-storage/driver/s3/storage.o: storage/driver/s3/storage.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/http/client.h common/io/http/common.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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/type/xml.h crypto/hash.h storage/driver/s3/fileRead.h storage/driver/s3/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
+storage/driver/s3/storage.o: storage/driver/s3/storage.c common/assert.h common/crypto/hash.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/http/client.h common/io/http/common.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/write.h common/log.h common/logLevel.h common/memContext.h common/regExp.h common/stackTrace.h common/time.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/type/xml.h storage/driver/s3/fileRead.h storage/driver/s3/storage.h storage/fileRead.h storage/fileWrite.h storage/info.h storage/storage.h storage/storage.intern.h
$(CC) $(CFLAGS) -c storage/driver/s3/storage.c -o storage/driver/s3/storage.o
storage/fileRead.o: storage/fileRead.c common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h storage/fileRead.h storage/fileRead.intern.h
diff --git a/src/command/archive/get/file.c b/src/command/archive/get/file.c
index 5d05c2ce1..6306175d2 100644
--- a/src/command/archive/get/file.c
+++ b/src/command/archive/get/file.c
@@ -6,11 +6,11 @@ Archive Get File
#include "command/control/control.h"
#include "common/compress/gzip/common.h"
#include "common/compress/gzip/decompress.h"
+#include "common/crypto/cipherBlock.h"
#include "common/debug.h"
#include "common/io/filter/group.h"
#include "common/log.h"
#include "config/config.h"
-#include "crypto/cipherBlock.h"
#include "info/infoArchive.h"
#include "postgres/interface.h"
#include "storage/helper.h"
diff --git a/src/command/archive/get/file.h b/src/command/archive/get/file.h
index 9a8cfb801..13237247c 100644
--- a/src/command/archive/get/file.h
+++ b/src/command/archive/get/file.h
@@ -4,8 +4,8 @@ Archive Get File
#ifndef COMMAND_ARCHIVE_GET_FILE_H
#define COMMAND_ARCHIVE_GET_FILE_H
+#include "common/crypto/common.h"
#include "common/type/string.h"
-#include "crypto/crypto.h"
#include "storage/storage.h"
/***********************************************************************************************************************************
diff --git a/src/command/info/info.c b/src/command/info/info.c
index 0e92cbd9f..967831664 100644
--- a/src/command/info/info.c
+++ b/src/command/info/info.c
@@ -14,7 +14,7 @@ Info Command
#include "common/memContext.h"
#include "common/type/json.h"
#include "config/config.h"
-#include "crypto/crypto.h"
+#include "common/crypto/common.h"
#include "info/info.h"
#include "info/infoArchive.h"
#include "info/infoBackup.h"
diff --git a/src/crypto/cipherBlock.c b/src/common/crypto/cipherBlock.c
similarity index 99%
rename from src/crypto/cipherBlock.c
rename to src/common/crypto/cipherBlock.c
index dc0ec9fd0..bc8077863 100644
--- a/src/crypto/cipherBlock.c
+++ b/src/common/crypto/cipherBlock.c
@@ -6,12 +6,12 @@ Block Cipher
#include <openssl/evp.h>
#include <openssl/err.h>
+#include "common/crypto/cipherBlock.h"
+#include "common/crypto/common.h"
#include "common/debug.h"
#include "common/io/filter/filter.intern.h"
#include "common/log.h"
#include "common/memContext.h"
-#include "crypto/cipherBlock.h"
-#include "crypto/crypto.h"
/***********************************************************************************************************************************
Filter type constant
@@ -89,9 +89,8 @@ cipherBlockNewC(CipherMode mode, const char *cipherName, const unsigned char *pa
ASSERT(pass != NULL);
ASSERT(passSize > 0);
- // Only need to init once.
- if (!cryptoIsInit())
- cryptoInit();
+ // Init crypto subsystem
+ cryptoInit();
// Lookup cipher by name. This means the ciphers passed in must exactly match a name expected by OpenSSL. This is a good
// thing since the name required by the openssl command-line tool will match what is used by pgBackRest.
diff --git a/src/crypto/cipherBlock.h b/src/common/crypto/cipherBlock.h
similarity index 97%
rename from src/crypto/cipherBlock.h
rename to src/common/crypto/cipherBlock.h
index bab7d5ad1..385a38d38 100644
--- a/src/crypto/cipherBlock.h
+++ b/src/common/crypto/cipherBlock.h
@@ -1,8 +1,8 @@
/***********************************************************************************************************************************
Block Cipher Header
***********************************************************************************************************************************/
-#ifndef CRYPTO_CIPHERBLOCK_H
-#define CRYPTO_CIPHERBLOCK_H
+#ifndef COMMON_CRYPTO_CIPHERBLOCK_H
+#define COMMON_CRYPTO_CIPHERBLOCK_H
/***********************************************************************************************************************************
CipherBlock object
@@ -11,7 +11,7 @@ typedef struct CipherBlock CipherBlock;
#include "common/io/filter/filter.h"
#include "common/type/buffer.h"
-#include "crypto/crypto.h"
+#include "common/crypto/common.h"
/***********************************************************************************************************************************
Constructor
diff --git a/src/crypto/crypto.c b/src/common/crypto/common.c
similarity index 99%
rename from src/crypto/crypto.c
rename to src/common/crypto/common.c
index ec3fe8bd3..cb75a5b0b 100644
--- a/src/crypto/crypto.c
+++ b/src/common/crypto/common.c
@@ -10,7 +10,7 @@ Crypto Common
#include "common/debug.h"
#include "common/error.h"
#include "common/log.h"
-#include "crypto/crypto.h"
+#include "common/crypto/common.h"
/***********************************************************************************************************************************
Cipher types
diff --git a/src/crypto/crypto.h b/src/common/crypto/common.h
similarity index 96%
rename from src/crypto/crypto.h
rename to src/common/crypto/common.h
index 151aad291..f24c5d3aa 100644
--- a/src/crypto/crypto.h
+++ b/src/common/crypto/common.h
@@ -1,8 +1,8 @@
/***********************************************************************************************************************************
Crypto Common
***********************************************************************************************************************************/
-#ifndef CRYPTO_CRYPTO_H
-#define CRYPTO_CRYPTO_H
+#ifndef COMMON_CRYPTO_COMMON_H
+#define COMMON_CRYPTO_COMMON_H
/***********************************************************************************************************************************
Cipher modes
diff --git a/src/crypto/hash.c b/src/common/crypto/hash.c
similarity index 98%
rename from src/crypto/hash.c
rename to src/common/crypto/hash.c
index 7866737ca..f1abf97b3 100644
--- a/src/crypto/hash.c
+++ b/src/common/crypto/hash.c
@@ -7,12 +7,12 @@ Cryptographic Hash
#include <openssl/err.h>
#include <openssl/hmac.h>
+#include "common/crypto/hash.h"
#include "common/debug.h"
#include "common/io/filter/filter.intern.h"
#include "common/log.h"
#include "common/memContext.h"
-#include "crypto/crypto.h"
-#include "crypto/hash.h"
+#include "common/crypto/common.h"
/***********************************************************************************************************************************
Filter type constant
@@ -51,9 +51,8 @@ cryptoHashNew(const String *type)
ASSERT(type != NULL);
- // Only need to init once
- if (!cryptoIsInit())
- cryptoInit();
+ // Init crypto subsystem
+ cryptoInit();
// Allocate memory to hold process state
CryptoHash *this = NULL;
diff --git a/src/crypto/hash.h b/src/common/crypto/hash.h
similarity index 98%
rename from src/crypto/hash.h
rename to src/common/crypto/hash.h
index 1b82c8f32..888be0d88 100644
--- a/src/crypto/hash.h
+++ b/src/common/crypto/hash.h
@@ -3,8 +3,8 @@ Cryptographic Hash
Generate a hash (sha1, md5, etc.) from a string, Buffer, or using an IoFilter.
***********************************************************************************************************************************/
-#ifndef CRYPTO_HASH_H
-#define CRYPTO_HASH_H
+#ifndef COMMON_CRYPTO_HASH_H
+#define COMMON_CRYPTO_HASH_H
/***********************************************************************************************************************************
Hash object
diff --git a/src/common/io/tls/client.c b/src/common/io/tls/client.c
index ddddb790b..f0f4d1375 100644
--- a/src/common/io/tls/client.c
+++ b/src/common/io/tls/client.c
@@ -14,6 +14,7 @@ TLS Client
#include <openssl/ssl.h>
#include <openssl/x509v3.h>
+#include "common/crypto/common.h"
#include "common/debug.h"
#include "common/log.h"
#include "common/io/tls/client.h"
@@ -24,7 +25,6 @@ TLS Client
#include "common/time.h"
#include "common/type/keyValue.h"
#include "common/wait.h"
-#include "crypto/crypto.h"
/***********************************************************************************************************************************
Object type
diff --git a/src/info/info.c b/src/info/info.c
index debaca6ff..f92e29f3a 100644
--- a/src/info/info.c
+++ b/src/info/info.c
@@ -5,12 +5,12 @@ Info Handler
#include <stdlib.h>
#include <string.h>
+#include "common/crypto/cipherBlock.h"
+#include "common/crypto/hash.h"
#include "common/debug.h"
#include "common/ini.h"
#include "common/log.h"
#include "common/memContext.h"
-#include "crypto/cipherBlock.h"
-#include "crypto/hash.h"
#include "info/info.h"
#include "storage/helper.h"
#include "version.h"
diff --git a/src/info/info.h b/src/info/info.h
index 2af601f81..4e36785fe 100644
--- a/src/info/info.h
+++ b/src/info/info.h
@@ -9,9 +9,8 @@ Object type
***********************************************************************************************************************************/
typedef struct Info Info;
+#include "common/crypto/common.h"
#include "common/ini.h"
-#include "crypto/crypto.h"
-#include "crypto/hash.h"
#include "storage/storage.h"
/***********************************************************************************************************************************
diff --git a/src/info/infoArchive.h b/src/info/infoArchive.h
index d1a4d54fc..246e1dc00 100644
--- a/src/info/infoArchive.h
+++ b/src/info/infoArchive.h
@@ -9,8 +9,8 @@ Object type
***********************************************************************************************************************************/
typedef struct InfoArchive InfoArchive;
+#include "common/crypto/common.h"
#include "common/type/string.h"
-#include "crypto/crypto.h"
#include "info/infoPg.h"
#include "storage/storage.h"
diff --git a/src/info/infoPg.h b/src/info/infoPg.h
index ef61dc892..462a0be7c 100644
--- a/src/info/infoPg.h
+++ b/src/info/infoPg.h
@@ -11,9 +11,9 @@ typedef struct InfoPg InfoPg;
#include <stdint.h>
-#include "crypto/crypto.h"
-#include "storage/storage.h"
+#include "common/crypto/common.h"
#include "common/ini.h"
+#include "storage/storage.h"
/***********************************************************************************************************************************
Constants
diff --git a/src/perl/libc.auto.c b/src/perl/libc.auto.c
index fb3a42e1d..7737fa6c4 100644
--- a/src/perl/libc.auto.c
+++ b/src/perl/libc.auto.c
@@ -54,13 +54,13 @@ C includes
These includes are from the src directory. There is no Perl-specific code in them.
***********************************************************************************************************************************/
+#include "common/crypto/common.h"
#include "common/error.h"
#include "common/lock.h"
#include "config/config.h"
#include "config/define.h"
#include "config/load.h"
#include "config/parse.h"
-#include "crypto/crypto.h"
#include "perl/config.h"
#include "postgres/pageChecksum.h"
#include "storage/driver/posix/storage.h"
diff --git a/src/protocol/helper.c b/src/protocol/helper.c
index 7c9662f8f..31a12ed12 100644
--- a/src/protocol/helper.c
+++ b/src/protocol/helper.c
@@ -1,10 +1,10 @@
/***********************************************************************************************************************************
Protocol Helper
***********************************************************************************************************************************/
+#include "common/crypto/common.h"
#include "common/debug.h"
#include "common/exec.h"
#include "common/memContext.h"
-#include "crypto/crypto.h"
#include "config/config.h"
#include "config/exec.h"
#include "config/protocol.h"
diff --git a/src/storage/driver/s3/storage.c b/src/storage/driver/s3/storage.c
index 23fc0bdd7..b39fd3883 100644
--- a/src/storage/driver/s3/storage.c
+++ b/src/storage/driver/s3/storage.c
@@ -3,13 +3,13 @@ S3 Storage Driver
***********************************************************************************************************************************/
#include <time.h>
+#include "common/crypto/hash.h"
#include "common/debug.h"
#include "common/io/http/common.h"
#include "common/log.h"
#include "common/memContext.h"
#include "common/regExp.h"
#include "common/type/xml.h"
-#include "crypto/hash.h"
#include "storage/driver/s3/fileRead.h"
#include "storage/driver/s3/storage.h"
diff --git a/test/define.yaml b/test/define.yaml
index 068305c35..a787ad0aa 100644
--- a/test/define.yaml
+++ b/test/define.yaml
@@ -240,6 +240,15 @@ unit:
common/compress/gzip/compress: full
common/compress/gzip/decompress: full
+ # ----------------------------------------------------------------------------------------------------------------------------
+ - name: crypto
+ total: 3
+
+ coverage:
+ common/crypto/cipherBlock: full
+ common/crypto/common: full
+ common/crypto/hash: full
+
# ----------------------------------------------------------------------------------------------------------------------------
- name: exec
total: 1
@@ -315,31 +324,6 @@ unit:
coverage:
Common/Log: partial
- # ********************************************************************************************************************************
- - name: crypto
-
- test:
- # ----------------------------------------------------------------------------------------------------------------------------
- - name: crypto
- total: 4
-
- coverage:
- crypto/crypto: full
-
- # ----------------------------------------------------------------------------------------------------------------------------
- - name: hash
- total: 3
-
- coverage:
- crypto/hash: full
-
- # ----------------------------------------------------------------------------------------------------------------------------
- - name: cipher-block
- total: 2
-
- coverage:
- crypto/cipherBlock: full
-
# ********************************************************************************************************************************
- name: postgres
diff --git a/test/src/common/harnessTls.c b/test/src/common/harnessTls.c
index 93a698cea..56358d7de 100644
--- a/test/src/common/harnessTls.c
+++ b/test/src/common/harnessTls.c
@@ -9,10 +9,10 @@ Tls Test Harness
#include <openssl/conf.h>
#include <openssl/ssl.h>
+#include "common/crypto/common.h"
#include "common/error.h"
#include "common/type/buffer.h"
#include "common/wait.h"
-#include "crypto/crypto.h"
#include "common/harnessTls.h"
diff --git a/test/src/module/crypto/cipherBlockTest.c b/test/src/module/common/cryptoTest.c
similarity index 67%
rename from test/src/module/crypto/cipherBlockTest.c
rename to test/src/module/common/cryptoTest.c
index b9e37db22..c7cd118ad 100644
--- a/test/src/module/crypto/cipherBlockTest.c
+++ b/test/src/module/common/cryptoTest.c
@@ -24,7 +24,56 @@ testRun(void)
const Buffer *testPlainText = bufNewStr(strNew(TEST_PLAINTEXT));
// *****************************************************************************************************************************
- if (testBegin("blockCipherNew() and blockCipherFree()"))
+ if (testBegin("Common"))
+ {
+ TEST_RESULT_BOOL(cryptoIsInit(), false, "crypto is not initialized");
+ TEST_RESULT_VOID(cryptoInit(), "initialize crypto");
+ TEST_RESULT_BOOL(cryptoIsInit(), true, "crypto is initialized");
+ TEST_RESULT_VOID(cryptoInit(), "initialize crypto again");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ cryptoInit();
+
+ TEST_RESULT_VOID(cryptoError(false, "no error here"), "no error");
+
+ EVP_MD_CTX *context = EVP_MD_CTX_create();
+ TEST_ERROR(
+ cryptoError(EVP_DigestInit_ex(context, NULL, NULL) != 1, "unable to initialize hash context"), CryptoError,
+ "unable to initialize hash context: [101187723] no digest set");
+ EVP_MD_CTX_destroy(context);
+
+ TEST_ERROR(cryptoError(true, "no error"), CryptoError, "no error: [0] no details available");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ERROR(cipherType(strNew(BOGUS_STR)), AssertError, "invalid cipher name 'BOGUS'");
+ TEST_RESULT_UINT(cipherType(strNew("none")), cipherTypeNone, "none type");
+ TEST_RESULT_UINT(cipherType(strNew("aes-256-cbc")), cipherTypeAes256Cbc, "aes-256-cbc type");
+
+ TEST_ERROR(cipherTypeName((CipherType)2), AssertError, "invalid cipher type 2");
+ TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeNone)), "none", "none name");
+ TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeAes256Cbc)), "aes-256-cbc", "aes-256-cbc name");
+
+ // Test if the buffer was overrun
+ // -------------------------------------------------------------------------------------------------------------------------
+ size_t bufferSize = 256;
+ unsigned char *buffer = memNew(bufferSize + 1);
+
+ cryptoRandomBytes(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 (unsigned int charIdx = 0; charIdx < bufferSize; charIdx++)
+ if (buffer[charIdx] != 0) // {uncovered - ok if there are no zeros}
+ nonZeroTotal++;
+
+ TEST_RESULT_INT_NE(nonZeroTotal, 0, "check that there are non-zero values in the buffer");
+ }
+
+ // *****************************************************************************************************************************
+ if (testBegin("CipherBlock"))
{
// Cipher and digest errors
// -------------------------------------------------------------------------------------------------------------------------
@@ -53,11 +102,7 @@ testRun(void)
TEST_RESULT_VOID(cipherBlockFree(cipherBlock), "free cipher block");
TEST_RESULT_VOID(cipherBlockFree(NULL), "free null cipher block");
- }
- // *****************************************************************************************************************************
- if (testBegin("Encrypt and Decrypt"))
- {
// Encrypt
// -------------------------------------------------------------------------------------------------------------------------
Buffer *encryptBuffer = bufNew(TEST_BUFFER_SIZE);
@@ -243,5 +288,67 @@ testRun(void)
cipherBlockFree(blockDecrypt);
}
+ // *****************************************************************************************************************************
+ if (testBegin("CryptoHash"))
+ {
+ CryptoHash *hash = NULL;
+ IoFilter *hashFilter = NULL;
+
+ TEST_ERROR(cryptoHashNew(strNew(BOGUS_STR)), AssertError, "unable to load hash 'BOGUS'");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
+ TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
+ TEST_RESULT_VOID(cryptoHashFree(NULL), " free null hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
+ TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "da39a3ee5e6b4b0d3255bfef95601890afd80709", " check empty hash");
+ TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "da39a3ee5e6b4b0d3255bfef95601890afd80709", " check empty hash again");
+ TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
+ TEST_ASSIGN(hashFilter, cryptoHashFilter(hash), "create sha1 hash");
+ TEST_RESULT_VOID(cryptoHashProcessC(hash, (const unsigned char *)"1", 1), " add 1");
+ TEST_RESULT_VOID(cryptoHashProcessStr(hash, strNew("2")), " add 2");
+ TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("3")), " add 3");
+ TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("4")), " add 4");
+ TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("5")), " add 5");
+
+ TEST_RESULT_STR(
+ strPtr(varStr(ioFilterResult(hashFilter))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
+ TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_MD5)), "create md5 hash");
+ TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "d41d8cd98f00b204e9800998ecf8427e", " check empty hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA256)), "create sha256 hash");
+ TEST_RESULT_STR(
+ strPtr(bufHex(cryptoHash(hash))), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
+ " check empty hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_RESULT_STR(
+ strPtr(bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), bufNewZ("12345")))), "8cb2237d0679ca88db6464eac60da96345513964",
+ " check small hash");
+ TEST_RESULT_STR(
+ strPtr(bufHex(cryptoHashOneStr(strNew(HASH_TYPE_SHA1), strNew("12345")))), "8cb2237d0679ca88db6464eac60da96345513964",
+ " check small hash");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_RESULT_STR(
+ strPtr(
+ bufHex(
+ cryptoHmacOne(
+ strNew(HASH_TYPE_SHA256),
+ bufNewZ("AWS4wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
+ bufNewZ("20170412")))),
+ "8b05c497afe9e1f42c8ada4cb88392e118649db1e5c98f0f0fb0a158bdd2dd76",
+ " check hmac");
+ }
+
FUNCTION_HARNESS_RESULT_VOID();
}
diff --git a/test/src/module/crypto/cryptoTest.c b/test/src/module/crypto/cryptoTest.c
deleted file mode 100644
index 34f3d5b5d..000000000
--- a/test/src/module/crypto/cryptoTest.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/***********************************************************************************************************************************
-Test Crypto Common
-***********************************************************************************************************************************/
-
-/***********************************************************************************************************************************
-Test Run
-***********************************************************************************************************************************/
-void
-testRun(void)
-{
- FUNCTION_HARNESS_VOID();
-
- // *****************************************************************************************************************************
- if (testBegin("cryptoInit() and cryptoIsInit()"))
- {
- TEST_RESULT_BOOL(cryptoIsInit(), false, "crypto is not initialized");
- TEST_RESULT_VOID(cryptoInit(), "initialize crypto");
- TEST_RESULT_BOOL(cryptoIsInit(), true, "crypto is initialized");
- TEST_RESULT_VOID(cryptoInit(), "initialize crypto again");
- }
-
- // *****************************************************************************************************************************
- if (testBegin("cryptoError"))
- {
- cryptoInit();
-
- TEST_RESULT_VOID(cryptoError(false, "no error here"), "no error");
-
- EVP_MD_CTX *context = EVP_MD_CTX_create();
- TEST_ERROR(
- cryptoError(EVP_DigestInit_ex(context, NULL, NULL) != 1, "unable to initialize hash context"), CryptoError,
- "unable to initialize hash context: [101187723] no digest set");
- EVP_MD_CTX_destroy(context);
-
- TEST_ERROR(cryptoError(true, "no error"), CryptoError, "no error: [0] no details available");
- }
-
- // *****************************************************************************************************************************
- if (testBegin("cipherType() and cipherTypeName()"))
- {
- TEST_ERROR(cipherType(strNew(BOGUS_STR)), AssertError, "invalid cipher name 'BOGUS'");
- TEST_RESULT_UINT(cipherType(strNew("none")), cipherTypeNone, "none type");
- TEST_RESULT_UINT(cipherType(strNew("aes-256-cbc")), cipherTypeAes256Cbc, "aes-256-cbc type");
-
- TEST_ERROR(cipherTypeName((CipherType)2), AssertError, "invalid cipher type 2");
- TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeNone)), "none", "none name");
- TEST_RESULT_STR(strPtr(cipherTypeName(cipherTypeAes256Cbc)), "aes-256-cbc", "aes-256-cbc name");
- }
-
- // *****************************************************************************************************************************
- if (testBegin("cryptoRandomBytes()"))
- {
- // -------------------------------------------------------------------------------------------------------------------------
- // Test if the buffer was overrun
- size_t bufferSize = 256;
- unsigned char *buffer = memNew(bufferSize + 1);
-
- cryptoRandomBytes(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 (unsigned int charIdx = 0; charIdx < bufferSize; charIdx++)
- if (buffer[charIdx] != 0) // {uncovered - ok if there are no zeros}
- nonZeroTotal++;
-
- TEST_RESULT_INT_NE(nonZeroTotal, 0, "check that there are non-zero values in the buffer");
- }
-
- FUNCTION_HARNESS_RESULT_VOID();
-}
diff --git a/test/src/module/crypto/hashTest.c b/test/src/module/crypto/hashTest.c
deleted file mode 100644
index aabb1382c..000000000
--- a/test/src/module/crypto/hashTest.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/***********************************************************************************************************************************
-Test Cryptographic Hashes
-***********************************************************************************************************************************/
-
-/***********************************************************************************************************************************
-Test Run
-***********************************************************************************************************************************/
-void
-testRun(void)
-{
- FUNCTION_HARNESS_VOID();
-
- // *****************************************************************************************************************************
- if (testBegin("CryptoHash"))
- {
- CryptoHash *hash = NULL;
- IoFilter *hashFilter = NULL;
-
- TEST_ERROR(cryptoHashNew(strNew(BOGUS_STR)), AssertError, "unable to load hash 'BOGUS'");
-
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
- TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
- TEST_RESULT_VOID(cryptoHashFree(NULL), " free null hash");
-
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
- TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "da39a3ee5e6b4b0d3255bfef95601890afd80709", " check empty hash");
- TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "da39a3ee5e6b4b0d3255bfef95601890afd80709", " check empty hash again");
- TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
-
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA1)), "create sha1 hash");
- TEST_ASSIGN(hashFilter, cryptoHashFilter(hash), "create sha1 hash");
- TEST_RESULT_VOID(cryptoHashProcessC(hash, (const unsigned char *)"1", 1), " add 1");
- TEST_RESULT_VOID(cryptoHashProcessStr(hash, strNew("2")), " add 2");
- TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("3")), " add 3");
- TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("4")), " add 4");
- TEST_RESULT_VOID(ioFilterProcessIn(hashFilter, bufNewZ("5")), " add 5");
-
- TEST_RESULT_STR(
- strPtr(varStr(ioFilterResult(hashFilter))), "8cb2237d0679ca88db6464eac60da96345513964", " check small hash");
- TEST_RESULT_VOID(cryptoHashFree(hash), " free hash");
-
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_MD5)), "create md5 hash");
- TEST_RESULT_STR(strPtr(bufHex(cryptoHash(hash))), "d41d8cd98f00b204e9800998ecf8427e", " check empty hash");
-
- // -------------------------------------------------------------------------------------------------------------------------
- TEST_ASSIGN(hash, cryptoHashNew(strNew(HASH_TYPE_SHA256)), "create sha256 hash");
- TEST_RESULT_STR(
- strPtr(bufHex(cryptoHash(hash))), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
- " check empty hash");
- }
-
- // *****************************************************************************************************************************
- if (testBegin("cryptoHashOne*()"))
- {
- TEST_RESULT_STR(
- strPtr(bufHex(cryptoHashOne(strNew(HASH_TYPE_SHA1), bufNewZ("12345")))), "8cb2237d0679ca88db6464eac60da96345513964",
- " check small hash");
- TEST_RESULT_STR(
- strPtr(bufHex(cryptoHashOneStr(strNew(HASH_TYPE_SHA1), strNew("12345")))), "8cb2237d0679ca88db6464eac60da96345513964",
- " check small hash");
- }
-
- // *****************************************************************************************************************************
- if (testBegin("cryptoHmacOne()"))
- {
- TEST_RESULT_STR(
- strPtr(
- bufHex(
- cryptoHmacOne(
- strNew(HASH_TYPE_SHA256),
- bufNewZ("AWS4wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"),
- bufNewZ("20170412")))),
- "8b05c497afe9e1f42c8ada4cb88392e118649db1e5c98f0f0fb0a158bdd2dd76",
- " check hmac");
- }
-
- FUNCTION_HARNESS_RESULT_VOID();
-}
[parent: 95597be81e74]