diff --git a/build/error.yaml b/build/error.yaml index 4ef84bf65..dee6d9a3d 100644 --- a/build/error.yaml +++ b/build/error.yaml @@ -77,7 +77,7 @@ file-exists: 93 # Memory allocation failed memory: 94 -cipher: 95 +crypto: 95 param-invalid: 96 # Unable to close a path diff --git a/doc/xml/release.xml b/doc/xml/release.xml index d6668a334..7124cc539 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -93,6 +93,10 @@ Add cryptoError() and update crypto code to use it. + + + Rename CipherError to CryptoError. + diff --git a/lib/pgBackRest/Archive/Info.pm b/lib/pgBackRest/Archive/Info.pm index 18483e60f..04bd7700d 100644 --- a/lib/pgBackRest/Archive/Info.pm +++ b/lib/pgBackRest/Archive/Info.pm @@ -119,7 +119,7 @@ sub new confess &log(ERROR, $strArchiveInfoMissingMsg, ERROR_FILE_MISSING); } } - elsif ($iResult == ERROR_CIPHER && $strResultMessage =~ "^unable to flush") + elsif ($iResult == ERROR_CRYPTO && $strResultMessage =~ "^unable to flush") { confess &log(ERROR, "unable to parse '$strArchiveInfoFile'\nHINT: Is or was the repo encrypted?", $iResult); } @@ -416,7 +416,7 @@ sub reconstruct if (!storageRepo()->encryptionValid(storageRepo()->encrypted($strArchiveFilePath))) { confess &log(ERROR, "encryption incompatible for '$strArchiveFilePath'" . - "\nHINT: Is or was the repo encrypted?", ERROR_CIPHER); + "\nHINT: Is or was the repo encrypted?", ERROR_CRYPTO); } # If the file is encrypted, then the passprase from the info file is required, else getEncryptionKeySub returns undefined diff --git a/lib/pgBackRest/Backup/Info.pm b/lib/pgBackRest/Backup/Info.pm index 2098a505d..63f31474e 100644 --- a/lib/pgBackRest/Backup/Info.pm +++ b/lib/pgBackRest/Backup/Info.pm @@ -163,7 +163,7 @@ sub new confess &log(ERROR, "${strBackupClusterPath}/$strBackupInfoMissingMsg", ERROR_FILE_MISSING); } } - elsif ($iResult == ERROR_CIPHER && $strResultMessage =~ "^unable to flush") + elsif ($iResult == ERROR_CRYPTO && $strResultMessage =~ "^unable to flush") { confess &log(ERROR, "unable to parse '$strBackupInfoFile'\nHINT: Is or was the repo encrypted?", $iResult); } diff --git a/lib/pgBackRest/Common/ExceptionAuto.pm b/lib/pgBackRest/Common/ExceptionAuto.pm index 45ab39eca..8ea5eee51 100644 --- a/lib/pgBackRest/Common/ExceptionAuto.pm +++ b/lib/pgBackRest/Common/ExceptionAuto.pm @@ -157,8 +157,8 @@ use constant ERROR_FILE_EXISTS => 93; push @EXPORT, qw(ERROR_FILE_EXISTS); use constant ERROR_MEMORY => 94; push @EXPORT, qw(ERROR_MEMORY); -use constant ERROR_CIPHER => 95; -push @EXPORT, qw(ERROR_CIPHER); +use constant ERROR_CRYPTO => 95; +push @EXPORT, qw(ERROR_CRYPTO); use constant ERROR_PARAM_INVALID => 96; push @EXPORT, qw(ERROR_PARAM_INVALID); use constant ERROR_PATH_CLOSE => 97; diff --git a/lib/pgBackRest/Common/Ini.pm b/lib/pgBackRest/Common/Ini.pm index 82b584791..f01de0ee2 100644 --- a/lib/pgBackRest/Common/Ini.pm +++ b/lib/pgBackRest/Common/Ini.pm @@ -107,7 +107,7 @@ sub new if (defined($self->{oStorage}->cipherPassUser()) && !defined($self->{strCipherPass})) { - confess &log(ERROR, 'passphrase is required when storage is encrypted', ERROR_CIPHER); + confess &log(ERROR, 'passphrase is required when storage is encrypted', ERROR_CRYPTO); } # Set changed to false @@ -188,7 +188,7 @@ sub loadVersion else { confess &log(ERROR, "unable to parse '$self->{strFileName}" . ($bCopy ? INI_COPY_EXT : '') . "'" . - "\nHINT: Is or was the repo encrypted?", ERROR_CIPHER); + "\nHINT: Is or was the repo encrypted?", ERROR_CRYPTO); } return defined($self->{oContent}); diff --git a/lib/pgBackRest/Info.pm b/lib/pgBackRest/Info.pm index 2e6358316..02fc1b97f 100644 --- a/lib/pgBackRest/Info.pm +++ b/lib/pgBackRest/Info.pm @@ -555,12 +555,12 @@ sub backupList { return; } - elsif (exceptionCode($EVAL_ERROR) == ERROR_CIPHER) + elsif (exceptionCode($EVAL_ERROR) == ERROR_CRYPTO) { # Confess the encryption error with additional hint confess &log(ERROR, exceptionMessage($EVAL_ERROR) . "\nHINT: use option --stanza if encryption settings are different for the stanza than the global settings", - ERROR_CIPHER); + ERROR_CRYPTO); } else { diff --git a/lib/pgBackRest/Stanza.pm b/lib/pgBackRest/Stanza.pm index 3b5964489..c3bca4035 100644 --- a/lib/pgBackRest/Stanza.pm +++ b/lib/pgBackRest/Stanza.pm @@ -600,7 +600,7 @@ sub infoObject else { # Confess unhandled exception - if (($iResult != ERROR_FILE_MISSING) && ($iResult != ERROR_CIPHER)) + if (($iResult != ERROR_FILE_MISSING) && ($iResult != ERROR_CRYPTO)) { confess &log(ERROR, $strResultMessage, $iResult); } diff --git a/src/common/error.auto.c b/src/common/error.auto.c index eeb97031d..61456ee95 100644 --- a/src/common/error.auto.c +++ b/src/common/error.auto.c @@ -76,7 +76,7 @@ ERROR_DEFINE( 91, GroupMissingError, RuntimeError); ERROR_DEFINE( 92, PathExistsError, RuntimeError); ERROR_DEFINE( 93, FileExistsError, RuntimeError); ERROR_DEFINE( 94, MemoryError, RuntimeError); -ERROR_DEFINE( 95, CipherError, RuntimeError); +ERROR_DEFINE( 95, CryptoError, RuntimeError); ERROR_DEFINE( 96, ParamInvalidError, RuntimeError); ERROR_DEFINE( 97, PathCloseError, RuntimeError); ERROR_DEFINE( 98, FileInfoError, RuntimeError); @@ -160,7 +160,7 @@ static const ErrorType *errorTypeList[] = &PathExistsError, &FileExistsError, &MemoryError, - &CipherError, + &CryptoError, &ParamInvalidError, &PathCloseError, &FileInfoError, diff --git a/src/common/error.auto.h b/src/common/error.auto.h index 1785e9362..b5354e1ad 100644 --- a/src/common/error.auto.h +++ b/src/common/error.auto.h @@ -78,7 +78,7 @@ ERROR_DECLARE(GroupMissingError); ERROR_DECLARE(PathExistsError); ERROR_DECLARE(FileExistsError); ERROR_DECLARE(MemoryError); -ERROR_DECLARE(CipherError); +ERROR_DECLARE(CryptoError); ERROR_DECLARE(ParamInvalidError); ERROR_DECLARE(PathCloseError); ERROR_DECLARE(FileInfoError); diff --git a/src/crypto/cipherBlock.c b/src/crypto/cipherBlock.c index 66344f6af..35c6f08da 100644 --- a/src/crypto/cipherBlock.c +++ b/src/crypto/cipherBlock.c @@ -187,7 +187,7 @@ cipherBlockProcess(CipherBlock *this, const unsigned char *source, size_t source // The first bytes of the file to decrypt should be equal to the magic. If not then this is not an // encrypted file, or at least not in a format we recognize. if (memcmp(this->header, CIPHER_BLOCK_MAGIC, CIPHER_BLOCK_MAGIC_SIZE) != 0) - THROW(CipherError, "cipher header invalid"); + THROW(CryptoError, "cipher header invalid"); } // Else copy what was provided into the header buffer and return 0 else @@ -265,11 +265,11 @@ cipherBlockFlush(CipherBlock *this, unsigned char *destination) // If no header was processed then error if (!this->saltDone) - THROW(CipherError, "cipher header missing"); + THROW(CryptoError, "cipher header missing"); // Only flush remaining data if some data was processed if (!EVP_CipherFinal(this->cipherContext, destination, (int *)&destinationSize)) - THROW(CipherError, "unable to flush"); + THROW(CryptoError, "unable to flush"); // Return actual destination size FUNCTION_DEBUG_RESULT(SIZE, destinationSize); diff --git a/src/crypto/crypto.c b/src/crypto/crypto.c index 59b6501a6..c685cc85f 100644 --- a/src/crypto/crypto.c +++ b/src/crypto/crypto.c @@ -29,7 +29,7 @@ cryptoError(bool error, const char *description) if (error) { const char *errorMessage = ERR_reason_error_string(ERR_get_error()); - THROW_FMT(CipherError, "%s: %s", description, errorMessage == NULL ? "no details available" : errorMessage); + THROW_FMT(CryptoError, "%s: %s", description, errorMessage == NULL ? "no details available" : errorMessage); } FUNCTION_TEST_RESULT_VOID(); diff --git a/src/perl/embed.auto.c b/src/perl/embed.auto.c index 9201fedd6..bc890a5e4 100644 --- a/src/perl/embed.auto.c +++ b/src/perl/embed.auto.c @@ -1017,7 +1017,7 @@ static const EmbeddedModule embeddedModule[] = "confess &log(ERROR, $strArchiveInfoMissingMsg, ERROR_FILE_MISSING);\n" "}\n" "}\n" - "elsif ($iResult == ERROR_CIPHER && $strResultMessage =~ \"^unable to flush\")\n" + "elsif ($iResult == ERROR_CRYPTO && $strResultMessage =~ \"^unable to flush\")\n" "{\n" "confess &log(ERROR, \"unable to parse '$strArchiveInfoFile'\\nHINT: Is or was the repo encrypted?\", $iResult);\n" "}\n" @@ -1263,7 +1263,7 @@ static const EmbeddedModule embeddedModule[] = "if (!storageRepo()->encryptionValid(storageRepo()->encrypted($strArchiveFilePath)))\n" "{\n" "confess &log(ERROR, \"encryption incompatible for '$strArchiveFilePath'\" .\n" - "\"\\nHINT: Is or was the repo encrypted?\", ERROR_CIPHER);\n" + "\"\\nHINT: Is or was the repo encrypted?\", ERROR_CRYPTO);\n" "}\n" "\n\n" "my $oFileIo = storageRepo()->openRead(\n" @@ -3882,7 +3882,7 @@ static const EmbeddedModule embeddedModule[] = "confess &log(ERROR, \"${strBackupClusterPath}/$strBackupInfoMissingMsg\", ERROR_FILE_MISSING);\n" "}\n" "}\n" - "elsif ($iResult == ERROR_CIPHER && $strResultMessage =~ \"^unable to flush\")\n" + "elsif ($iResult == ERROR_CRYPTO && $strResultMessage =~ \"^unable to flush\")\n" "{\n" "confess &log(ERROR, \"unable to parse '$strBackupInfoFile'\\nHINT: Is or was the repo encrypted?\", $iResult);\n" "}\n" @@ -5206,8 +5206,8 @@ static const EmbeddedModule embeddedModule[] = "push @EXPORT, qw(ERROR_FILE_EXISTS);\n" "use constant ERROR_MEMORY => 94;\n" "push @EXPORT, qw(ERROR_MEMORY);\n" - "use constant ERROR_CIPHER => 95;\n" - "push @EXPORT, qw(ERROR_CIPHER);\n" + "use constant ERROR_CRYPTO => 95;\n" + "push @EXPORT, qw(ERROR_CRYPTO);\n" "use constant ERROR_PARAM_INVALID => 96;\n" "push @EXPORT, qw(ERROR_PARAM_INVALID);\n" "use constant ERROR_PATH_CLOSE => 97;\n" @@ -5726,7 +5726,7 @@ static const EmbeddedModule embeddedModule[] = "\n" "if (defined($self->{oStorage}->cipherPassUser()) && !defined($self->{strCipherPass}))\n" "{\n" - "confess &log(ERROR, 'passphrase is required when storage is encrypted', ERROR_CIPHER);\n" + "confess &log(ERROR, 'passphrase is required when storage is encrypted', ERROR_CRYPTO);\n" "}\n" "\n\n" "$self->{bModified} = false;\n" @@ -5795,7 +5795,7 @@ static const EmbeddedModule embeddedModule[] = "else\n" "{\n" "confess &log(ERROR, \"unable to parse '$self->{strFileName}\" . ($bCopy ? INI_COPY_EXT : '') . \"'\" .\n" - "\"\\nHINT: Is or was the repo encrypted?\", ERROR_CIPHER);\n" + "\"\\nHINT: Is or was the repo encrypted?\", ERROR_CRYPTO);\n" "}\n" "\n" "return defined($self->{oContent});\n" @@ -10796,12 +10796,12 @@ static const EmbeddedModule embeddedModule[] = "{\n" "return;\n" "}\n" - "elsif (exceptionCode($EVAL_ERROR) == ERROR_CIPHER)\n" + "elsif (exceptionCode($EVAL_ERROR) == ERROR_CRYPTO)\n" "{\n" "\n" "confess &log(ERROR, exceptionMessage($EVAL_ERROR) .\n" "\"\\nHINT: use option --stanza if encryption settings are different for the stanza than the global settings\",\n" - "ERROR_CIPHER);\n" + "ERROR_CRYPTO);\n" "}\n" "else\n" "{\n" @@ -17533,7 +17533,7 @@ static const EmbeddedModule embeddedModule[] = "else\n" "{\n" "\n" - "if (($iResult != ERROR_FILE_MISSING) && ($iResult != ERROR_CIPHER))\n" + "if (($iResult != ERROR_FILE_MISSING) && ($iResult != ERROR_CRYPTO))\n" "{\n" "confess &log(ERROR, $strResultMessage, $iResult);\n" "}\n" diff --git a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm index 862be9e7f..07b49c81f 100644 --- a/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Archive/ArchiveInfoUnitPerlTest.pm @@ -108,7 +108,7 @@ sub run # Prepend encryption Magic signature to simulate encryption executeTest('echo "' . CIPHER_MAGIC . '$(cat ' . $strArchiveFile . ')" > ' . $strArchiveFile); - $self->testException(sub {$oArchiveInfo->reconstruct(PG_VERSION_94, $self->dbSysId(PG_VERSION_94))}, ERROR_CIPHER, + $self->testException(sub {$oArchiveInfo->reconstruct(PG_VERSION_94, $self->dbSysId(PG_VERSION_94))}, ERROR_CRYPTO, "encryption incompatible for '$strArchiveFile'" . "\nHINT: Is or was the repo encrypted?"); @@ -204,7 +204,7 @@ sub run # Prepend encryption Magic signature to simulate encryption executeTest('echo "' . CIPHER_MAGIC . '$(cat ' . $strFile . ')" > ' . $strFile); - $self->testException(sub {new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE))}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Archive::Info(storageRepo()->pathGet(STORAGE_REPO_ARCHIVE))}, ERROR_CRYPTO, "unable to parse '$strFile'" . "\nHINT: Is or was the repo encrypted?"); diff --git a/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitPerlTest.pm b/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitPerlTest.pm index decc27402..3368c81cd 100644 --- a/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Backup/BackupInfoUnitPerlTest.pm @@ -213,7 +213,7 @@ sub run # Prepend encryption Magic signature to simulate encryption executeTest('echo "' . CIPHER_MAGIC . '$(cat ' . $strFile . ')" > ' . $strFile); - $self->testException(sub {new pgBackRest::Backup::Info(storageRepo()->pathGet(STORAGE_REPO_BACKUP))}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Backup::Info(storageRepo()->pathGet(STORAGE_REPO_BACKUP))}, ERROR_CRYPTO, "unable to parse '$strFile'" . "\nHINT: Is or was the repo encrypted?"); @@ -253,7 +253,7 @@ sub run $self->optionTestSet(CFGOPT_REPO_PATH, $self->testPath() . '/repo'); $self->configTestLoad(CFGCMD_ARCHIVE_PUSH); - $self->testException(sub {new pgBackRest::Backup::Info(storageRepo()->pathGet(STORAGE_REPO_BACKUP))}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Backup::Info(storageRepo()->pathGet(STORAGE_REPO_BACKUP))}, ERROR_CRYPTO, "unable to parse '" . $oBackupInfo->{strFileName} . "'" . "\nHINT: Is or was the repo encrypted?"); } diff --git a/test/lib/pgBackRestTest/Module/Common/CommonIniPerlTest.pm b/test/lib/pgBackRestTest/Module/Common/CommonIniPerlTest.pm index 716c3b9df..b1c0f7963 100644 --- a/test/lib/pgBackRestTest/Module/Common/CommonIniPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Common/CommonIniPerlTest.pm @@ -287,14 +287,14 @@ sub run # Prepend encryption Magic signature to copy (main invalid) to simulate encryption executeTest('echo "' . CIPHER_MAGIC . '$(cat ' . $strTestFileCopy . ')" > ' . $strTestFileCopy); - $self->testException(sub {new pgBackRest::Common::Ini($strTestFile)}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Common::Ini($strTestFile)}, ERROR_CRYPTO, "unable to parse '$strTestFileCopy'" . "\nHINT: Is or was the repo encrypted?"); # Prepend encryption Magic signature to main to simulate encryption executeTest('echo "' . CIPHER_MAGIC . '$(cat ' . $strTestFile . ')" > ' . $strTestFile); - $self->testException(sub {new pgBackRest::Common::Ini($strTestFile)}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Common::Ini($strTestFile)}, ERROR_CRYPTO, "unable to parse '$strTestFile'" . "\nHINT: Is or was the repo encrypted?"); @@ -319,7 +319,7 @@ sub run my $oStorage = new pgBackRest::Storage::Local($self->testPath(), new pgBackRest::Storage::Posix::Driver(), {strCipherType => CFGOPTVAL_REPO_CIPHER_TYPE_AES_256_CBC, strCipherPassUser => $strCipherPass}); - $self->testException(sub {new pgBackRest::Common::Ini($strTestFile, {oStorage => $oStorage})}, ERROR_CIPHER, + $self->testException(sub {new pgBackRest::Common::Ini($strTestFile, {oStorage => $oStorage})}, ERROR_CRYPTO, "passphrase is required when storage is encrypted"); $self->testException(sub {new pgBackRest::Common::Ini($strTestFile, {bLoad => false, oStorage => $oStorage, diff --git a/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm b/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm index 34783d27e..ae272db10 100644 --- a/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Info/InfoUnitPerlTest.pm @@ -458,7 +458,7 @@ sub run $self->configTestLoad(CFGCMD_INFO); my $oInfo = new pgBackRest::Info(); - $self->testException(sub {$oInfo->stanzaList()}, ERROR_CIPHER, + $self->testException(sub {$oInfo->stanzaList()}, ERROR_CRYPTO, "unable to parse '" . $self->{strBackupPathEncrypt} . "/backup.info'" . "\nHINT: Is or was the repo encrypted?" . "\nHINT: use option --stanza if encryption settings are different for the stanza than the global settings"); diff --git a/test/lib/pgBackRestTest/Module/Stanza/StanzaAllPerlTest.pm b/test/lib/pgBackRestTest/Module/Stanza/StanzaAllPerlTest.pm index 5eecb7255..9ce33317e 100644 --- a/test/lib/pgBackRestTest/Module/Stanza/StanzaAllPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Stanza/StanzaAllPerlTest.pm @@ -336,7 +336,7 @@ sub run # Try to create a manifest without a passphrase in an encrypted storage $self->testException(sub {new pgBackRest::Manifest($strBackupManifestFile, {bLoad => false, strDbVersion => PG_VERSION_94, iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_94)})}, - ERROR_CIPHER, 'passphrase is required when storage is encrypted'); + ERROR_CRYPTO, 'passphrase is required when storage is encrypted'); # Get the encryption passphrase and create the new manifest my $oBackupInfo = new pgBackRest::Backup::Info($self->{strBackupPath}); @@ -525,7 +525,7 @@ sub run $self->optionTestSet(CFGOPT_REPO_CIPHER_PASS, 'x'); $self->configTestLoad(CFGCMD_STANZA_UPGRADE); - $self->testException(sub {$oStanza->stanzaUpgrade()}, ERROR_CIPHER, + $self->testException(sub {$oStanza->stanzaUpgrade()}, ERROR_CRYPTO, "unable to parse '" . $self->{strArchivePath} . "/archive.info'" . "\nHINT: Is or was the repo encrypted?"); @@ -548,7 +548,7 @@ sub run $self->optionTestSet(CFGOPT_REPO_CIPHER_PASS, 'y'); $self->configTestLoad(CFGCMD_STANZA_UPGRADE); - $self->testException(sub {$oStanza->stanzaUpgrade()}, ERROR_CIPHER, + $self->testException(sub {$oStanza->stanzaUpgrade()}, ERROR_CRYPTO, "unable to parse '" . $self->{strArchivePath} . "/archive.info'" . "\nHINT: Is or was the repo encrypted?"); diff --git a/test/lib/pgBackRestTest/Module/Storage/StorageFilterCipherBlockPerlTest.pm b/test/lib/pgBackRestTest/Module/Storage/StorageFilterCipherBlockPerlTest.pm index e90c5d085..6ba24724f 100644 --- a/test/lib/pgBackRestTest/Module/Storage/StorageFilterCipherBlockPerlTest.pm +++ b/test/lib/pgBackRestTest/Module/Storage/StorageFilterCipherBlockPerlTest.pm @@ -272,7 +272,7 @@ sub run {strMode => STORAGE_DECRYPT})}, '[object]', 'new read empty attempt decrypt'); - $self->testException(sub {$oEncryptFileIo->read(\$tBuffer, 16)}, ERROR_CIPHER, 'cipher header missing'); + $self->testException(sub {$oEncryptFileIo->read(\$tBuffer, 16)}, ERROR_CRYPTO, 'cipher header missing'); $self->testResult(sub {$oEncryptFileIo->close()}, true, 'close'); # OpenSSL should error on the empty file diff --git a/test/src/module/crypto/cipherBlockTest.c b/test/src/module/crypto/cipherBlockTest.c index 2b4643c4c..027955453 100644 --- a/test/src/module/crypto/cipherBlockTest.c +++ b/test/src/module/crypto/cipherBlockTest.c @@ -173,7 +173,7 @@ testRun(void) TEST_ERROR( cipherBlockProcess( - blockDecrypt, (unsigned char *)"1234567890123456", 16, decryptBuffer), CipherError, "cipher header invalid"); + blockDecrypt, (unsigned char *)"1234567890123456", 16, decryptBuffer), CryptoError, "cipher header invalid"); cipherBlockFree(blockDecrypt); @@ -188,7 +188,7 @@ testRun(void) cipherBlockProcess( blockDecrypt, (unsigned char *)"1234567890123456", 16, decryptBuffer), 0, "process 0 bytes"); - TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CipherError, "unable to flush"); + TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CryptoError, "unable to flush"); cipherBlockFree(blockDecrypt); @@ -197,7 +197,7 @@ testRun(void) blockDecrypt = cipherBlockNew(cipherModeDecrypt, TEST_CIPHER, (unsigned char *)TEST_PASS, TEST_PASS_SIZE, NULL); TEST_RESULT_INT(cipherBlockProcess(blockDecrypt, encryptBuffer, 0, decryptBuffer), 0, "no header processed"); - TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CipherError, "cipher header missing"); + TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CryptoError, "cipher header missing"); cipherBlockFree(blockDecrypt); @@ -208,7 +208,7 @@ testRun(void) TEST_RESULT_INT( cipherBlockProcess( blockDecrypt, (unsigned char *)(CIPHER_BLOCK_MAGIC "12345678"), 16, decryptBuffer), 0, "0 bytes processed"); - TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CipherError, "unable to flush"); + TEST_ERROR(cipherBlockFlush(blockDecrypt, decryptBuffer), CryptoError, "unable to flush"); cipherBlockFree(blockDecrypt); } diff --git a/test/src/module/crypto/cryptoTest.c b/test/src/module/crypto/cryptoTest.c index dac9e0c92..ae23ec31c 100644 --- a/test/src/module/crypto/cryptoTest.c +++ b/test/src/module/crypto/cryptoTest.c @@ -28,11 +28,11 @@ testRun(void) EVP_MD_CTX *context = EVP_MD_CTX_create(); TEST_ERROR( - cryptoError(EVP_DigestInit_ex(context, NULL, NULL) != 1, "unable to initialize hash context"), CipherError, + cryptoError(EVP_DigestInit_ex(context, NULL, NULL) != 1, "unable to initialize hash context"), CryptoError, "unable to initialize hash context: no digest set"); EVP_MD_CTX_destroy(context); - TEST_ERROR(cryptoError(true, "no error"), CipherError, "no error: no details available"); + TEST_ERROR(cryptoError(true, "no error"), CryptoError, "no error: no details available"); } FUNCTION_HARNESS_RESULT_VOID();
Add cryptoError() and update crypto code to use it.
cryptoError()
Rename CipherError to CryptoError.
CipherError
CryptoError