1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Update CipherType/CipherMode to StringId.

As in 6cc521b, this allows option values and enums to be easily mapped together.
This commit is contained in:
David Steele
2021-04-28 11:36:20 -04:00
committed by GitHub
parent c3b15fc3bd
commit 85fc3da4c3
36 changed files with 128 additions and 189 deletions

View File

@ -90,12 +90,15 @@
<commit subject="Update storage module to use StringIds."> <commit subject="Update storage module to use StringIds.">
<github-pull-request id="1379"/> <github-pull-request id="1379"/>
</commit> </commit>
<commit subject="Update CipherType/CipherMode to StringId.">
<github-pull-request id="1384"/>
</commit>
<release-item-contributor-list> <release-item-contributor-list>
<release-item-reviewer id="cynthia.shang"/> <release-item-reviewer id="cynthia.shang"/>
</release-item-contributor-list> </release-item-contributor-list>
<p>Add StringId type.</p> <p>Add <code>StringId</code> type.</p>
</release-item> </release-item>
<release-item> <release-item>

View File

@ -390,7 +390,7 @@ archiveGetCheck(const StringList *archiveRequestList)
ArchiveGetFindCacheRepo cacheRepo = ArchiveGetFindCacheRepo cacheRepo =
{ {
.repoIdx = repoIdx, .repoIdx = repoIdx,
.cipherType = cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), .cipherType = cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
.archiveList = lstNewP(sizeof(ArchiveGetFindCacheArchive)), .archiveList = lstNewP(sizeof(ArchiveGetFindCacheArchive)),
.warnList = strLstNew(), .warnList = strLstNew(),
}; };
@ -839,7 +839,7 @@ static ProtocolParallelJob *archiveGetAsyncCallback(void *data, unsigned int cli
protocolCommandParamAdd(command, VARSTR(actual->file)); protocolCommandParamAdd(command, VARSTR(actual->file));
protocolCommandParamAdd(command, VARUINT(actual->repoIdx)); protocolCommandParamAdd(command, VARUINT(actual->repoIdx));
protocolCommandParamAdd(command, VARSTR(actual->archiveId)); protocolCommandParamAdd(command, VARSTR(actual->archiveId));
protocolCommandParamAdd(command, VARUINT(actual->cipherType)); protocolCommandParamAdd(command, VARUINT64(actual->cipherType));
protocolCommandParamAdd(command, VARSTR(actual->cipherPassArchive)); protocolCommandParamAdd(command, VARSTR(actual->cipherPassArchive));
} }

View File

@ -48,7 +48,7 @@ archiveGetFileProtocol(const VariantList *paramList, ProtocolServer *server)
.file = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual))), .file = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual))),
.repoIdx = varUIntForce(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 1)), .repoIdx = varUIntForce(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 1)),
.archiveId = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 2)), .archiveId = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 2)),
.cipherType = (CipherType)varUIntForce(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 3)), .cipherType = varUInt64(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 3)),
.cipherPassArchive = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 4)), .cipherPassArchive = varStr(varLstGet(paramList, paramFixed + (actualIdx * paramActual) + 4)),
}); });
} }

View File

@ -39,7 +39,7 @@ archivePushFileProtocol(const VariantList *paramList, ProtocolServer *server)
{ {
.repoIdx = varUIntForce(varLstGet(paramList, paramIdx)), .repoIdx = varUIntForce(varLstGet(paramList, paramIdx)),
.archiveId = varStr(varLstGet(paramList, paramIdx + 1)), .archiveId = varStr(varLstGet(paramList, paramIdx + 1)),
.cipherType = (CipherType)varUIntForce(varLstGet(paramList, paramIdx + 2)), .cipherType = varUInt64(varLstGet(paramList, paramIdx + 2)),
.cipherPass = varStr(varLstGet(paramList, paramIdx + 3)), .cipherPass = varStr(varLstGet(paramList, paramIdx + 3)),
}); });

View File

@ -229,7 +229,7 @@ archivePushCheck(bool pgPathSet)
storageRepoIdx(repoIdx); storageRepoIdx(repoIdx);
// Get cipher type // Get cipher type
CipherType repoCipherType = cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)); CipherType repoCipherType = cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx);
// Attempt to load the archive info file // Attempt to load the archive info file
InfoArchive *info = infoArchiveLoadFile( InfoArchive *info = infoArchiveLoadFile(
@ -478,7 +478,7 @@ archivePushAsyncCallback(void *data, unsigned int clientIdx)
protocolCommandParamAdd(command, VARUINT(data->repoIdx)); protocolCommandParamAdd(command, VARUINT(data->repoIdx));
protocolCommandParamAdd(command, VARSTR(data->archiveId)); protocolCommandParamAdd(command, VARSTR(data->archiveId));
protocolCommandParamAdd(command, VARUINT(data->cipherType)); protocolCommandParamAdd(command, VARUINT64(data->cipherType));
protocolCommandParamAdd(command, VARSTR(data->cipherPass)); protocolCommandParamAdd(command, VARSTR(data->cipherPass));
} }

View File

@ -397,7 +397,7 @@ backupBuildIncrPrior(const InfoBackup *infoBackup)
{ {
result = manifestLoadFile( result = manifestLoadFile(
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabelPrior)), storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabelPrior)),
cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoPgCipherPass(infoBackupPg(infoBackup))); cfgOptionStrId(cfgOptRepoCipherType), infoPgCipherPass(infoBackupPg(infoBackup)));
const ManifestData *manifestPriorData = manifestData(result); const ManifestData *manifestPriorData = manifestData(result);
LOG_INFO_FMT( LOG_INFO_FMT(
@ -707,7 +707,7 @@ backupResumeFind(const Manifest *manifest, const String *cipherPassBackup)
TRY_BEGIN() TRY_BEGIN()
{ {
manifestResume = manifestLoadFile( manifestResume = manifestLoadFile(
storageRepo(), manifestFile, cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherPassBackup); storageRepo(), manifestFile, cfgOptionStrId(cfgOptRepoCipherType), cipherPassBackup);
const ManifestData *manifestResumeData = manifestData(manifestResume); const ManifestData *manifestResumeData = manifestData(manifestResume);
// Check pgBackRest version. This allows the resume implementation to be changed with each version of // Check pgBackRest version. This allows the resume implementation to be changed with each version of
@ -961,7 +961,7 @@ backupFilePut(BackupData *backupData, Manifest *manifest, const String *name, ti
// Add encryption filter if required // Add encryption filter if required
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
filterGroup, cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeEncrypt, manifestCipherSubPass(manifest)); filterGroup, cfgOptionStrId(cfgOptRepoCipherType), cipherModeEncrypt, manifestCipherSubPass(manifest));
// Add size filter last to calculate repo size // Add size filter last to calculate repo size
ioFilterGroupAdd(filterGroup, ioSizeNew()); ioFilterGroupAdd(filterGroup, ioSizeNew());
@ -1251,7 +1251,7 @@ backupManifestSaveCopy(Manifest *const manifest, const String *cipherPassBackup)
// Add encryption filter if required // Add encryption filter if required
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioWriteFilterGroup(write), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeEncrypt, cipherPassBackup); ioWriteFilterGroup(write), cfgOptionStrId(cfgOptRepoCipherType), cipherModeEncrypt, cipherPassBackup);
// Save file // Save file
manifestSave(manifest, write); manifestSave(manifest, write);
@ -1492,7 +1492,7 @@ static ProtocolParallelJob *backupJobCallback(void *data, unsigned int clientIdx
protocolCommandParamAdd(command, VARINT(jobData->compressLevel)); protocolCommandParamAdd(command, VARINT(jobData->compressLevel));
protocolCommandParamAdd(command, VARSTR(jobData->backupLabel)); protocolCommandParamAdd(command, VARSTR(jobData->backupLabel));
protocolCommandParamAdd(command, VARBOOL(jobData->delta)); protocolCommandParamAdd(command, VARBOOL(jobData->delta));
protocolCommandParamAdd(command, VARUINT(jobData->cipherType)); protocolCommandParamAdd(command, VARUINT64(jobData->cipherType));
protocolCommandParamAdd(command, VARSTR(jobData->cipherSubPass)); protocolCommandParamAdd(command, VARSTR(jobData->cipherSubPass));
// Remove job from the queue // Remove job from the queue
@ -1583,7 +1583,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
.backupStandby = backupStandby, .backupStandby = backupStandby,
.compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)), .compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)),
.compressLevel = cfgOptionInt(cfgOptCompressLevel), .compressLevel = cfgOptionInt(cfgOptCompressLevel),
.cipherType = cipherType(cfgOptionStr(cfgOptRepoCipherType)), .cipherType = cfgOptionStrId(cfgOptRepoCipherType),
.cipherSubPass = manifestCipherSubPass(manifest), .cipherSubPass = manifestCipherSubPass(manifest),
.delta = cfgOptionBool(cfgOptDelta), .delta = cfgOptionBool(cfgOptDelta),
.lsnStart = cfgOptionBool(cfgOptOnline) ? pgLsnFromStr(lsnStart) : 0xFFFFFFFFFFFFFFFF, .lsnStart = cfgOptionBool(cfgOptOnline) ? pgLsnFromStr(lsnStart) : 0xFFFFFFFFFFFFFFFF,
@ -1755,7 +1755,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
// Loop through all the segments in the lsn range // Loop through all the segments in the lsn range
InfoArchive *infoArchive = infoArchiveLoadFile( InfoArchive *infoArchive = infoArchiveLoadFile(
storageRepo(), INFO_ARCHIVE_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)), storageRepo(), INFO_ARCHIVE_PATH_FILE_STR, cfgOptionStrId(cfgOptRepoCipherType),
cfgOptionStrNull(cfgOptRepoCipherPass)); cfgOptionStrNull(cfgOptRepoCipherPass));
const String *archiveId = infoArchiveId(infoArchive); const String *archiveId = infoArchiveId(infoArchive);
@ -1788,7 +1788,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
// Decrypt with archive key if encrypted // Decrypt with archive key if encrypted
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
filterGroup, cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeDecrypt, filterGroup, cfgOptionStrId(cfgOptRepoCipherType), cipherModeDecrypt,
infoArchiveCipherPass(infoArchive)); infoArchiveCipherPass(infoArchive));
// Compress/decompress if archive and backup do not have the same compression settings // Compress/decompress if archive and backup do not have the same compression settings
@ -1806,8 +1806,7 @@ backupArchiveCheckCopy(Manifest *manifest, unsigned int walSegmentSize, const St
// Encrypt with backup key if encrypted // Encrypt with backup key if encrypted
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
filterGroup, cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeEncrypt, filterGroup, cfgOptionStrId(cfgOptRepoCipherType), cipherModeEncrypt, manifestCipherSubPass(manifest));
manifestCipherSubPass(manifest));
// Add size filter last to calculate repo size // Add size filter last to calculate repo size
ioFilterGroupAdd(filterGroup, ioSizeNew()); ioFilterGroupAdd(filterGroup, ioSizeNew());
@ -1891,7 +1890,7 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel))); storageRepo(), strNewFmt(STORAGE_REPO_BACKUP "/%s/" BACKUP_MANIFEST_FILE, strZ(backupLabel)));
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioReadFilterGroup(storageReadIo(manifestRead)), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeDecrypt, ioReadFilterGroup(storageReadIo(manifestRead)), cfgOptionStrId(cfgOptRepoCipherType), cipherModeDecrypt,
infoPgCipherPass(infoBackupPg(infoBackup))); infoPgCipherPass(infoBackupPg(infoBackup)));
StorageWrite *manifestWrite = storageNewWriteP( StorageWrite *manifestWrite = storageNewWriteP(
@ -1903,7 +1902,7 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
ioFilterGroupAdd(ioWriteFilterGroup(storageWriteIo(manifestWrite)), compressFilter(compressTypeGz, 9)); ioFilterGroupAdd(ioWriteFilterGroup(storageWriteIo(manifestWrite)), compressFilter(compressTypeGz, 9));
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioWriteFilterGroup(storageWriteIo(manifestWrite)), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeEncrypt, ioWriteFilterGroup(storageWriteIo(manifestWrite)), cfgOptionStrId(cfgOptRepoCipherType), cipherModeEncrypt,
infoPgCipherPass(infoBackupPg(infoBackup))); infoPgCipherPass(infoBackupPg(infoBackup)));
storageCopyP(manifestRead, manifestWrite); storageCopyP(manifestRead, manifestWrite);
@ -1922,7 +1921,7 @@ backupComplete(InfoBackup *const infoBackup, Manifest *const manifest)
infoBackupDataAdd(infoBackup, manifest); infoBackupDataAdd(infoBackup, manifest);
infoBackupSaveFile( infoBackupSaveFile(
infoBackup, storageRepoWrite(), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)), infoBackup, storageRepoWrite(), INFO_BACKUP_PATH_FILE_STR, cfgOptionStrId(cfgOptRepoCipherType),
cfgOptionStrNull(cfgOptRepoCipherPass)); cfgOptionStrNull(cfgOptRepoCipherPass));
} }
MEM_CONTEXT_TEMP_END(); MEM_CONTEXT_TEMP_END();
@ -1954,8 +1953,7 @@ cmdBackup(void)
// Load backup.info // Load backup.info
InfoBackup *infoBackup = infoBackupLoadFileReconstruct( InfoBackup *infoBackup = infoBackupLoadFileReconstruct(
storageRepo(), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)), storageRepo(), INFO_BACKUP_PATH_FILE_STR, cfgOptionStrId(cfgOptRepoCipherType), cfgOptionStrNull(cfgOptRepoCipherPass));
cfgOptionStrNull(cfgOptRepoCipherPass));
InfoPgData infoPg = infoPgDataCurrent(infoBackupPg(infoBackup)); InfoPgData infoPg = infoPgDataCurrent(infoBackupPg(infoBackup));
const String *cipherPassBackup = infoPgCipherPass(infoBackupPg(infoBackup)); const String *cipherPassBackup = infoPgCipherPass(infoBackupPg(infoBackup));
@ -1982,7 +1980,7 @@ cmdBackup(void)
// Build an incremental backup if type is not full (manifestPrior will be freed in this call) // Build an incremental backup if type is not full (manifestPrior will be freed in this call)
if (!backupBuildIncr(infoBackup, manifest, manifestPrior, backupStartResult.walSegmentName)) if (!backupBuildIncr(infoBackup, manifest, manifestPrior, backupStartResult.walSegmentName))
manifestCipherSubPassSet(manifest, cipherPassGen(cipherType(cfgOptionStr(cfgOptRepoCipherType)))); manifestCipherSubPassSet(manifest, cipherPassGen(cfgOptionStrId(cfgOptRepoCipherType)));
// Set delta if it is not already set and the manifest requires it // Set delta if it is not already set and the manifest requires it
if (!cfgOptionBool(cfgOptDelta) && varBool(manifestData(manifest)->backupOptionDelta)) if (!cfgOptionBool(cfgOptDelta) && varBool(manifestData(manifest)->backupOptionDelta))

View File

@ -55,7 +55,7 @@ backupFile(
FUNCTION_LOG_PARAM(INT, repoFileCompressLevel); // Compression level for repo file FUNCTION_LOG_PARAM(INT, repoFileCompressLevel); // Compression level for repo file
FUNCTION_LOG_PARAM(STRING, backupLabel); // Label of current backup FUNCTION_LOG_PARAM(STRING, backupLabel); // Label of current backup
FUNCTION_LOG_PARAM(BOOL, delta); // Is the delta option on? FUNCTION_LOG_PARAM(BOOL, delta); // Is the delta option on?
FUNCTION_LOG_PARAM(ENUM, cipherType); // Encryption type FUNCTION_LOG_PARAM(STRING_ID, cipherType); // Encryption type
FUNCTION_TEST_PARAM(STRING, cipherPass); // Password to access the repo file if encrypted FUNCTION_TEST_PARAM(STRING, cipherPass); // Password to access the repo file if encrypted
FUNCTION_LOG_END(); FUNCTION_LOG_END();

View File

@ -32,8 +32,8 @@ backupFileProtocol(const VariantList *paramList, ProtocolServer *server)
varBool(varLstGet(paramList, 3)), varStr(varLstGet(paramList, 4)), varBool(varLstGet(paramList, 5)), varBool(varLstGet(paramList, 3)), varStr(varLstGet(paramList, 4)), varBool(varLstGet(paramList, 5)),
varUInt64(varLstGet(paramList, 6)), varStr(varLstGet(paramList, 7)), varBool(varLstGet(paramList, 8)), varUInt64(varLstGet(paramList, 6)), varStr(varLstGet(paramList, 7)), varBool(varLstGet(paramList, 8)),
(CompressType)varUIntForce(varLstGet(paramList, 9)), varIntForce(varLstGet(paramList, 10)), (CompressType)varUIntForce(varLstGet(paramList, 9)), varIntForce(varLstGet(paramList, 10)),
varStr(varLstGet(paramList, 11)), varBool(varLstGet(paramList, 12)), varStr(varLstGet(paramList, 11)), varBool(varLstGet(paramList, 12)), varUInt64(varLstGet(paramList, 13)),
(CipherType)varUIntForce(varLstGet(paramList, 13)), varStr(varLstGet(paramList, 14))); varStr(varLstGet(paramList, 14)));
// Return backup result // Return backup result
VariantList *resultList = varLstNew(); VariantList *resultList = varLstNew();

View File

@ -88,7 +88,7 @@ checkStandby(const DbGetResult dbGroup, unsigned int pgPathDefinedTotal)
// Check that the backup and archive info files exist and are valid for the current database of the stanza // Check that the backup and archive info files exist and are valid for the current database of the stanza
checkStanzaInfoPg( checkStanzaInfoPg(
storageRepo, pgControl.version, pgControl.systemId, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepo, pgControl.version, pgControl.systemId, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
@ -134,12 +134,12 @@ checkPrimary(const DbGetResult dbGroup)
// Check that the backup and archive info files exist and are valid for the current database of the stanza // Check that the backup and archive info files exist and are valid for the current database of the stanza
checkStanzaInfoPg( checkStanzaInfoPg(
storageRepo, pgControl.version, pgControl.systemId, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepo, pgControl.version, pgControl.systemId, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
// Attempt to load the archive info file and retrieve the archiveId // Attempt to load the archive info file and retrieve the archiveId
InfoArchive *archiveInfo = infoArchiveLoadFile( InfoArchive *archiveInfo = infoArchiveLoadFile(
storageRepo, INFO_ARCHIVE_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepo, INFO_ARCHIVE_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
repoArchiveId[repoIdx] = infoArchiveId(archiveInfo); repoArchiveId[repoIdx] = infoArchiveId(archiveInfo);

View File

@ -131,7 +131,7 @@ checkStanzaInfoPg(
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(UINT, pgVersion); FUNCTION_LOG_PARAM(UINT, pgVersion);
FUNCTION_LOG_PARAM(UINT64, pgSystemId); FUNCTION_LOG_PARAM(UINT64, pgSystemId);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_TEST_END(); FUNCTION_TEST_END();

View File

@ -429,7 +429,7 @@ removeExpiredArchive(InfoBackup *infoBackup, bool timeBasedFullRetention, unsign
{ {
// Attempt to load the archive info file // Attempt to load the archive info file
InfoArchive *infoArchive = infoArchiveLoadFile( InfoArchive *infoArchive = infoArchiveLoadFile(
storageRepoIdx(repoIdx), INFO_ARCHIVE_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepoIdx(repoIdx), INFO_ARCHIVE_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
InfoPg *infoArchivePgData = infoArchivePg(infoArchive); InfoPg *infoArchivePgData = infoArchivePg(infoArchive);
@ -828,7 +828,7 @@ removeExpiredBackup(InfoBackup *infoBackup, const String *adhocBackupLabel, unsi
else else
{ {
Manifest *manifestResume = manifestLoadFile( Manifest *manifestResume = manifestLoadFile(
storageRepoIdx(repoIdx), manifestFileName, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepoIdx(repoIdx), manifestFileName, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
infoPgCipherPass(infoBackupPg(infoBackup))); infoPgCipherPass(infoBackupPg(infoBackup)));
// If the ancestor of the resumable backup still exists in backup.info then do not remove the resumable backup // If the ancestor of the resumable backup still exists in backup.info then do not remove the resumable backup
@ -915,7 +915,7 @@ cmdExpire(void)
{ {
// Load the backup.info // Load the backup.info
infoBackup = infoBackupLoadFileReconstruct( infoBackup = infoBackupLoadFileReconstruct(
storageRepo, INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepo, INFO_BACKUP_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
// If a backupLabel was set, then attempt to expire the requested backup // If a backupLabel was set, then attempt to expire the requested backup
@ -960,8 +960,7 @@ cmdExpire(void)
{ {
infoBackupSaveFile( infoBackupSaveFile(
infoBackup, storageRepoIdxWrite(repoIdx), INFO_BACKUP_PATH_FILE_STR, infoBackup, storageRepoIdxWrite(repoIdx), INFO_BACKUP_PATH_FILE_STR,
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
// Remove all files on disk that are now expired // Remove all files on disk that are now expired

View File

@ -106,7 +106,7 @@ Data types and structures
typedef struct InfoRepoData typedef struct InfoRepoData
{ {
unsigned int key; // User-defined repo key unsigned int key; // User-defined repo key
CipherType cipher; // Encryption type (0 = none) CipherType cipher; // Encryption type
const String *cipherPass; // Passphrase if the repo is encrypted (else NULL) const String *cipherPass; // Passphrase if the repo is encrypted (else NULL)
int stanzaStatus; // Status code of the the stanza on this repo int stanzaStatus; // Status code of the the stanza on this repo
unsigned int backupIdx; // Index of the next backup that may be a candidate for sorting unsigned int backupIdx; // Index of the next backup that may be a candidate for sorting
@ -640,7 +640,7 @@ stanzaInfoList(List *stanzaRepoList, const String *backupLabel, unsigned int rep
VariantList *repoSection = varLstNew(); VariantList *repoSection = varLstNew();
int stanzaStatusCode = -1; int stanzaStatusCode = -1;
unsigned int stanzaCipherType = 0; uint64_t stanzaCipherType = cipherTypeNone;
// Set the stanza name and initialize the overall stanza variables // Set the stanza name and initialize the overall stanza variables
kvPut(varKv(stanzaInfo), KEY_NAME_VAR, VARSTR(stanzaData->name)); kvPut(varKv(stanzaInfo), KEY_NAME_VAR, VARSTR(stanzaData->name));
@ -652,7 +652,7 @@ stanzaInfoList(List *stanzaRepoList, const String *backupLabel, unsigned int rep
Variant *repoInfo = varNewKv(kvNew()); Variant *repoInfo = varNewKv(kvNew());
kvPut(varKv(repoInfo), REPO_KEY_KEY_VAR, VARUINT(repoData->key)); kvPut(varKv(repoInfo), REPO_KEY_KEY_VAR, VARUINT(repoData->key));
kvPut(varKv(repoInfo), KEY_CIPHER_VAR, VARSTR(cipherTypeName(repoData->cipher))); kvPut(varKv(repoInfo), KEY_CIPHER_VAR, VARSTR(strIdToStr(repoData->cipher)));
// If the stanza on this repo has the default status of ok but the backupInfo was not read, then the stanza exists on // If the stanza on this repo has the default status of ok but the backupInfo was not read, then the stanza exists on
// other repos but not this one // other repos but not this one
@ -745,7 +745,7 @@ stanzaInfoList(List *stanzaRepoList, const String *backupLabel, unsigned int rep
// Set the overall cipher type // Set the overall cipher type
if (stanzaCipherType != INFO_STANZA_STATUS_CODE_MIXED) if (stanzaCipherType != INFO_STANZA_STATUS_CODE_MIXED)
kvPut(varKv(stanzaInfo), KEY_CIPHER_VAR, VARSTR(cipherTypeName(stanzaCipherType))); kvPut(varKv(stanzaInfo), KEY_CIPHER_VAR, VARSTR(strIdToStr(stanzaCipherType)));
else else
kvPut(varKv(stanzaInfo), KEY_CIPHER_VAR, VARSTRDEF(INFO_STANZA_MIXED)); kvPut(varKv(stanzaInfo), KEY_CIPHER_VAR, VARSTRDEF(INFO_STANZA_MIXED));
@ -1232,7 +1232,7 @@ infoRender(void)
repoErrorList[repoIdx] = (InfoRepoData) repoErrorList[repoIdx] = (InfoRepoData)
{ {
.key = cfgOptionGroupIdxToKey(cfgOptGrpRepo, repoIdx), .key = cfgOptionGroupIdxToKey(cfgOptGrpRepo, repoIdx),
.cipher = cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), .cipher = cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
.cipherPass = cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx), .cipherPass = cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx),
.error = NULL, .error = NULL,
}; };
@ -1304,7 +1304,7 @@ infoRender(void)
stanzaRepo.repoList[repoListIdx] = (InfoRepoData) stanzaRepo.repoList[repoListIdx] = (InfoRepoData)
{ {
.key = cfgOptionGroupIdxToKey(cfgOptGrpRepo, repoListIdx), .key = cfgOptionGroupIdxToKey(cfgOptGrpRepo, repoListIdx),
.cipher = cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoListIdx)), .cipher = cfgOptionIdxStrId(cfgOptRepoCipherType, repoListIdx),
.cipherPass = cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoListIdx), .cipherPass = cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoListIdx),
.error = NULL, .error = NULL,
}; };

View File

@ -61,7 +61,7 @@ storageGetProcess(IoWrite *destination)
// Add decryption if needed // Add decryption if needed
if (!cfgOptionBool(cfgOptRaw)) if (!cfgOptionBool(cfgOptRaw))
{ {
CipherType repoCipherType = cipherType(cfgOptionStr(cfgOptRepoCipherType)); CipherType repoCipherType = cfgOptionStrId(cfgOptRepoCipherType);
if (repoCipherType != cipherTypeNone) if (repoCipherType != cipherTypeNone)
{ {

View File

@ -39,7 +39,7 @@ storagePutProcess(IoRead *source)
// Add encryption if needed // Add encryption if needed
if (!cfgOptionBool(cfgOptRaw)) if (!cfgOptionBool(cfgOptRaw))
{ {
CipherType repoCipherType = cipherType(cfgOptionStr(cfgOptRepoCipherType)); CipherType repoCipherType = cfgOptionStrId(cfgOptRepoCipherType);
if (repoCipherType != cipherTypeNone) if (repoCipherType != cipherTypeNone)
{ {

View File

@ -232,7 +232,7 @@ restoreBackupData(const String *backupLabel, unsigned int repoIdx, const String
{ {
restoreBackup.backupSet = strDup(backupLabel); restoreBackup.backupSet = strDup(backupLabel);
restoreBackup.repoIdx = repoIdx; restoreBackup.repoIdx = repoIdx;
restoreBackup.repoCipherType = cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)); restoreBackup.repoCipherType = cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx);
restoreBackup.backupCipherPass = strDup(backupCipherPass); restoreBackup.backupCipherPass = strDup(backupCipherPass);
} }
MEM_CONTEXT_PRIOR_END(); MEM_CONTEXT_PRIOR_END();
@ -288,7 +288,7 @@ restoreBackupSet(void)
TRY_BEGIN() TRY_BEGIN()
{ {
infoBackup = infoBackupLoadFile( infoBackup = infoBackupLoadFile(
storageRepoIdx(repoIdx), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepoIdx(repoIdx), INFO_BACKUP_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
CATCH_ANY() CATCH_ANY()

View File

@ -73,24 +73,24 @@ cmdStanzaCreate(void)
} }
// If the repo is encrypted, generate a cipher passphrase for encrypting subsequent archive files // If the repo is encrypted, generate a cipher passphrase for encrypting subsequent archive files
String *cipherPassSub = cipherPassGen(cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx))); String *cipherPassSub = cipherPassGen(cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx));
// Create and save archive info // Create and save archive info
infoArchive = infoArchiveNew(pgControl.version, pgControl.systemId, cipherPassSub); infoArchive = infoArchiveNew(pgControl.version, pgControl.systemId, cipherPassSub);
infoArchiveSaveFile( infoArchiveSaveFile(
infoArchive, storageRepoWriteStanza, INFO_ARCHIVE_PATH_FILE_STR, infoArchive, storageRepoWriteStanza, INFO_ARCHIVE_PATH_FILE_STR,
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
// If the repo is encrypted, generate a cipher passphrase for encrypting subsequent backup files // If the repo is encrypted, generate a cipher passphrase for encrypting subsequent backup files
cipherPassSub = cipherPassGen(cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx))); cipherPassSub = cipherPassGen(cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx));
// Create and save backup info // Create and save backup info
infoBackup = infoBackupNew(pgControl.version, pgControl.systemId, pgControl.catalogVersion, cipherPassSub); infoBackup = infoBackupNew(pgControl.version, pgControl.systemId, pgControl.catalogVersion, cipherPassSub);
infoBackupSaveFile( infoBackupSaveFile(
infoBackup, storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_STR, infoBackup, storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_STR,
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
// Else if at least one archive and one backup info file exists, then ensure both are valid // Else if at least one archive and one backup info file exists, then ensure both are valid
else if ((archiveInfoFileExists || archiveInfoFileCopyExists) && (backupInfoFileExists || backupInfoFileCopyExists)) else if ((archiveInfoFileExists || archiveInfoFileCopyExists) && (backupInfoFileExists || backupInfoFileCopyExists))
@ -99,7 +99,7 @@ cmdStanzaCreate(void)
// current database // current database
checkStanzaInfoPg( checkStanzaInfoPg(
storageRepoReadStanza, pgControl.version, pgControl.systemId, storageRepoReadStanza, pgControl.version, pgControl.systemId,
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
// The files are valid - upgrade // The files are valid - upgrade
const String *sourceFile = NULL; const String *sourceFile = NULL;

View File

@ -51,12 +51,12 @@ cmdStanzaUpgrade(void)
// Load the info files (errors if missing) // Load the info files (errors if missing)
InfoArchive *infoArchive = infoArchiveLoadFile( InfoArchive *infoArchive = infoArchiveLoadFile(
storageRepoReadStanza, INFO_ARCHIVE_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepoReadStanza, INFO_ARCHIVE_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
InfoPgData archiveInfo = infoPgData(infoArchivePg(infoArchive), infoPgDataCurrentId(infoArchivePg(infoArchive))); InfoPgData archiveInfo = infoPgData(infoArchivePg(infoArchive), infoPgDataCurrentId(infoArchivePg(infoArchive)));
InfoBackup *infoBackup = infoBackupLoadFile( InfoBackup *infoBackup = infoBackupLoadFile(
storageRepoReadStanza, INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), storageRepoReadStanza, INFO_BACKUP_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
InfoPgData backupInfo = infoPgData(infoBackupPg(infoBackup), infoPgDataCurrentId(infoBackupPg(infoBackup))); InfoPgData backupInfo = infoPgData(infoBackupPg(infoBackup), infoPgDataCurrentId(infoBackupPg(infoBackup)));
@ -86,15 +86,15 @@ cmdStanzaUpgrade(void)
{ {
infoArchiveSaveFile( infoArchiveSaveFile(
infoArchive, storageRepoWriteStanza, INFO_ARCHIVE_PATH_FILE_STR, infoArchive, storageRepoWriteStanza, INFO_ARCHIVE_PATH_FILE_STR,
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
// Save backup info // Save backup info
if (infoBackupUpgrade) if (infoBackupUpgrade)
{ {
infoBackupSaveFile( infoBackupSaveFile(
infoBackup, storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_STR, infoBackup, storageRepoWriteStanza, INFO_BACKUP_PATH_FILE_STR, cfgOptionIdxStrId(cfgOptRepoCipherType, repoIdx),
cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, repoIdx)), cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx)); cfgOptionIdxStrNull(cfgOptRepoCipherPass, repoIdx));
} }
if (!(infoArchiveUpgrade || infoBackupUpgrade)) if (!(infoArchiveUpgrade || infoBackupUpgrade))

View File

@ -172,7 +172,7 @@ verifyFileLoad(const String *pathFileName, const String *cipherPass)
// *read points to a location within result so update result with contents based on necessary filters // *read points to a location within result so update result with contents based on necessary filters
IoRead *read = storageReadIo(result); IoRead *read = storageReadIo(result);
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioReadFilterGroup(read), cipherType(cfgOptionStr(cfgOptRepoCipherType)), cipherModeDecrypt, cipherPass); ioReadFilterGroup(read), cfgOptionStrId(cfgOptRepoCipherType), cipherModeDecrypt, cipherPass);
ioFilterGroupAdd(ioReadFilterGroup(read), cryptoHashNew(HASH_TYPE_SHA1_STR)); ioFilterGroupAdd(ioReadFilterGroup(read), cryptoHashNew(HASH_TYPE_SHA1_STR));
// If the file is compressed, add a decompression filter // If the file is compressed, add a decompression filter

View File

@ -392,8 +392,8 @@ IoFilter *
cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName) cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const String *digestName)
{ {
FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(ENUM, mode); FUNCTION_LOG_PARAM(STRING_ID, mode);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(BUFFER, pass); // Use FUNCTION_TEST so passphrase is not logged FUNCTION_TEST_PARAM(BUFFER, pass); // Use FUNCTION_TEST so passphrase is not logged
FUNCTION_LOG_PARAM(STRING, digestName); FUNCTION_LOG_PARAM(STRING, digestName);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
@ -406,10 +406,10 @@ cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const
// Lookup cipher by name. This means the ciphers passed in must exactly match a name expected by OpenSSL. This is a good // 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. // thing since the name required by the openssl command-line tool will match what is used by pgBackRest.
const EVP_CIPHER *cipher = EVP_get_cipherbyname(strZ(cipherTypeName(cipherType))); const EVP_CIPHER *cipher = EVP_get_cipherbyname(strZ(strIdToStr(cipherType)));
if (!cipher) if (!cipher)
THROW_FMT(AssertError, "unable to load cipher '%s'", strZ(cipherTypeName(cipherType))); THROW_FMT(AssertError, "unable to load cipher '%s'", strZ(strIdToStr(cipherType)));
// Lookup digest. If not defined it will be set to sha1. // Lookup digest. If not defined it will be set to sha1.
const EVP_MD *digest = NULL; const EVP_MD *digest = NULL;
@ -444,8 +444,8 @@ cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const
// Create param list // Create param list
VariantList *paramList = varLstNew(); VariantList *paramList = varLstNew();
varLstAdd(paramList, varNewUInt(mode)); varLstAdd(paramList, varNewUInt64(mode));
varLstAdd(paramList, varNewUInt(cipherType)); varLstAdd(paramList, varNewUInt64(cipherType));
// ??? Using a string here is not correct since the passphrase is being passed as a buffer so may contain null characters. // ??? Using a string here is not correct since the passphrase is being passed as a buffer so may contain null characters.
// However, since strings are used to hold the passphrase in the rest of the code this is currently valid. // However, since strings are used to hold the passphrase in the rest of the code this is currently valid.
varLstAdd(paramList, varNewStr(strNewBuf(pass))); varLstAdd(paramList, varNewStr(strNewBuf(pass)));
@ -465,7 +465,7 @@ IoFilter *
cipherBlockNewVar(const VariantList *paramList) cipherBlockNewVar(const VariantList *paramList)
{ {
return cipherBlockNew( return cipherBlockNew(
(CipherMode)varUIntForce(varLstGet(paramList, 0)), (CipherType)varUIntForce(varLstGet(paramList, 1)), (CipherMode)varUInt64(varLstGet(paramList, 0)), (CipherType)varUInt64(varLstGet(paramList, 1)),
BUFSTR(varStr(varLstGet(paramList, 2))), varLstGet(paramList, 3) == NULL ? NULL : varStr(varLstGet(paramList, 3))); BUFSTR(varStr(varLstGet(paramList, 2))), varLstGet(paramList, 3) == NULL ? NULL : varStr(varLstGet(paramList, 3)));
} }
@ -475,8 +475,8 @@ cipherBlockFilterGroupAdd(IoFilterGroup *filterGroup, CipherType type, CipherMod
{ {
FUNCTION_LOG_BEGIN(logLevelTrace); FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(IO_FILTER_GROUP, filterGroup); FUNCTION_LOG_PARAM(IO_FILTER_GROUP, filterGroup);
FUNCTION_LOG_PARAM(ENUM, type); FUNCTION_LOG_PARAM(STRING_ID, type);
FUNCTION_LOG_PARAM(ENUM, mode); FUNCTION_LOG_PARAM(STRING_ID, mode);
FUNCTION_TEST_PARAM(STRING, pass); // Use FUNCTION_TEST so passphrase is not logged FUNCTION_TEST_PARAM(STRING, pass); // Use FUNCTION_TEST so passphrase is not logged
FUNCTION_LOG_END(); FUNCTION_LOG_END();

View File

@ -14,12 +14,6 @@ Crypto Common
#include "common/log.h" #include "common/log.h"
#include "common/crypto/common.h" #include "common/crypto/common.h"
/***********************************************************************************************************************************
Cipher types
***********************************************************************************************************************************/
STRING_EXTERN(CIPHER_TYPE_NONE_STR, CIPHER_TYPE_NONE);
STRING_EXTERN(CIPHER_TYPE_AES_256_CBC_STR, CIPHER_TYPE_AES_256_CBC);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Flag to indicate if OpenSSL has already been initialized Flag to indicate if OpenSSL has already been initialized
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
@ -54,43 +48,6 @@ cryptoErrorCode(unsigned long code, const char *description)
FUNCTION_TEST_RETURN_VOID(); FUNCTION_TEST_RETURN_VOID();
} }
/**********************************************************************************************************************************/
CipherType
cipherType(const String *name)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(STRING, name);
FUNCTION_TEST_END();
ASSERT(name != NULL);
CipherType result = cipherTypeNone;
if (strEq(name, CIPHER_TYPE_AES_256_CBC_STR))
result = cipherTypeAes256Cbc;
else if (!strEq(name, CIPHER_TYPE_NONE_STR))
THROW_FMT(AssertError, "invalid cipher name '%s'", strZ(name));
FUNCTION_TEST_RETURN(result);
}
const String *
cipherTypeName(CipherType type)
{
FUNCTION_TEST_BEGIN();
FUNCTION_TEST_PARAM(ENUM, type);
FUNCTION_TEST_END();
const String *result = CIPHER_TYPE_NONE_STR;
if (type == cipherTypeAes256Cbc)
result = CIPHER_TYPE_AES_256_CBC_STR;
else if (type != cipherTypeNone)
THROW_FMT(AssertError, "invalid cipher type %u", type);
FUNCTION_TEST_RETURN(result);
}
/**********************************************************************************************************************************/ /**********************************************************************************************************************************/
void void
cryptoInit(void) cryptoInit(void)

View File

@ -4,13 +4,15 @@ Crypto Common
#ifndef COMMON_CRYPTO_COMMON_H #ifndef COMMON_CRYPTO_COMMON_H
#define COMMON_CRYPTO_COMMON_H #define COMMON_CRYPTO_COMMON_H
#include <common/type/stringId.h>
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Cipher modes Cipher modes
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef enum typedef enum
{ {
cipherModeEncrypt, cipherModeEncrypt = STRID5("encrypt", 0x521990dc50),
cipherModeDecrypt, cipherModeDecrypt = STRID5("decrypt", 0x521990ca40),
} CipherMode; } CipherMode;
/*********************************************************************************************************************************** /***********************************************************************************************************************************
@ -18,17 +20,10 @@ Cipher types
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
typedef enum typedef enum
{ {
cipherTypeNone, cipherTypeNone = STRID5("none", 0x2b9ee0),
cipherTypeAes256Cbc, cipherTypeAes256Cbc = STRID5("aes-256-cbc", 0xc43dfbbcdcca10),
} CipherType; } CipherType;
#include <common/type/string.h>
#define CIPHER_TYPE_NONE "none"
STRING_DECLARE(CIPHER_TYPE_NONE_STR);
#define CIPHER_TYPE_AES_256_CBC "aes-256-cbc"
STRING_DECLARE(CIPHER_TYPE_AES_256_CBC_STR);
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Functions Functions
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
@ -42,10 +37,6 @@ bool cryptoIsInit(void);
void cryptoError(bool error, const char *description); void cryptoError(bool error, const char *description);
void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__)); void cryptoErrorCode(unsigned long code, const char *description) __attribute__((__noreturn__));
// Get cipher type or name
CipherType cipherType(const String *name);
const String *cipherTypeName(CipherType type);
// Generate random bytes // Generate random bytes
void cryptoRandomBytes(unsigned char *buffer, size_t size); void cryptoRandomBytes(unsigned char *buffer, size_t size);

View File

@ -252,7 +252,7 @@ infoArchiveLoadFile(const Storage *storage, const String *fileName, CipherType c
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
@ -306,7 +306,7 @@ infoArchiveSaveFile(
FUNCTION_LOG_PARAM(INFO_ARCHIVE, infoArchive); FUNCTION_LOG_PARAM(INFO_ARCHIVE, infoArchive);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();

View File

@ -552,7 +552,7 @@ infoBackupLoadFile(const Storage *storage, const String *fileName, CipherType ci
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
@ -602,7 +602,7 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();
@ -707,7 +707,7 @@ infoBackupSaveFile(
FUNCTION_LOG_PARAM(INFO_BACKUP, infoBackup); FUNCTION_LOG_PARAM(INFO_BACKUP, infoBackup);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();

View File

@ -2837,7 +2837,7 @@ manifestLoadFile(const Storage *storage, const String *fileName, CipherType ciph
FUNCTION_LOG_BEGIN(logLevelDebug); FUNCTION_LOG_BEGIN(logLevelDebug);
FUNCTION_LOG_PARAM(STORAGE, storage); FUNCTION_LOG_PARAM(STORAGE, storage);
FUNCTION_LOG_PARAM(STRING, fileName); FUNCTION_LOG_PARAM(STRING, fileName);
FUNCTION_LOG_PARAM(ENUM, cipherType); FUNCTION_LOG_PARAM(STRING_ID, cipherType);
FUNCTION_TEST_PARAM(STRING, cipherPass); FUNCTION_TEST_PARAM(STRING, cipherPass);
FUNCTION_LOG_END(); FUNCTION_LOG_END();

View File

@ -495,7 +495,7 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx)
PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec)); PROTOCOL_SERVICE_REMOTE_STR, execIoRead(protocolHelperClient->exec), execIoWrite(protocolHelperClient->exec));
// Get cipher options from the remote if none are locally configured // Get cipher options from the remote if none are locally configured
if (isRepo && strEq(cfgOptionIdxStr(cfgOptRepoCipherType, hostIdx), CIPHER_TYPE_NONE_STR)) if (isRepo && cfgOptionIdxStrId(cfgOptRepoCipherType, hostIdx) == cipherTypeNone)
{ {
// Options to query // Options to query
VariantList *param = varLstNew(); VariantList *param = varLstNew();
@ -504,7 +504,7 @@ protocolRemoteGet(ProtocolStorageType protocolStorageType, unsigned int hostIdx)
VariantList *optionList = configOptionRemote(protocolHelperClient->client, param); VariantList *optionList = configOptionRemote(protocolHelperClient->client, param);
if (!strEq(varStr(varLstGet(optionList, 0)), CIPHER_TYPE_NONE_STR)) if (!strEq(varStr(varLstGet(optionList, 0)), strIdToStr(cipherTypeNone)))
{ {
cfgOptionIdxSet(cfgOptRepoCipherType, hostIdx, cfgSourceConfig, varLstGet(optionList, 0)); cfgOptionIdxSet(cfgOptRepoCipherType, hostIdx, cfgSourceConfig, varLstGet(optionList, 0));
cfgOptionIdxSet(cfgOptRepoCipherPass, hostIdx, cfgSourceConfig, varLstGet(optionList, 1)); cfgOptionIdxSet(cfgOptRepoCipherPass, hostIdx, cfgSourceConfig, varLstGet(optionList, 1));

View File

@ -269,7 +269,7 @@ hrnStoragePut(const Storage *storage, const char *file, const Buffer *buffer, Hr
} }
// Add encrypted filter // Add encrypted filter
if (param.cipherType != cipherTypeNone) if (param.cipherType != 0 && param.cipherType != cipherTypeNone)
{ {
// Default to main cipher pass // Default to main cipher pass
if (param.cipherPass == NULL) if (param.cipherPass == NULL)
@ -293,7 +293,7 @@ hrnStoragePutLog(const Storage *storage, const char *file, const Buffer *buffer,
strCatFmt(log, "cmp[%s]", strZ(compressTypeStr(param.compressType))); strCatFmt(log, "cmp[%s]", strZ(compressTypeStr(param.compressType)));
// Add encryption detail // Add encryption detail
if (param.cipherType != cipherTypeNone) if (param.cipherType != 0 && param.cipherType != cipherTypeNone)
{ {
if (param.cipherPass == NULL) if (param.cipherPass == NULL)
param.cipherPass = TEST_CIPHER_PASS; param.cipherPass = TEST_CIPHER_PASS;
@ -301,11 +301,11 @@ hrnStoragePutLog(const Storage *storage, const char *file, const Buffer *buffer,
if (param.compressType != compressTypeNone) if (param.compressType != compressTypeNone)
strCatZ(log, "/"); strCatZ(log, "/");
strCatFmt(log, "enc[%s,%s]", strZ(cipherTypeName(param.cipherType)), param.cipherPass); strCatFmt(log, "enc[%s,%s]", strZ(strIdToStr(param.cipherType)), param.cipherPass);
} }
// Add a space if compression/encryption defined // Add a space if compression/encryption defined
if (param.compressType != compressTypeNone || param.cipherType != cipherTypeNone) if (param.compressType != compressTypeNone || (param.cipherType != 0 && param.cipherType != cipherTypeNone))
strCatZ(log, " "); strCatZ(log, " ");
// Add file name // Add file name

View File

@ -960,7 +960,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH_PG); hrnCfgArgRawZ(argList, cfgOptPgPath, TEST_PATH_PG);
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH_REPO "-bogus"); hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH_REPO "-bogus");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, TEST_PATH_REPO); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, TEST_PATH_REPO);
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
strLstAddZ(argList, "01ABCDEF01ABCDEF01ABCDEF"); strLstAddZ(argList, "01ABCDEF01ABCDEF01ABCDEF");
@ -1098,7 +1098,7 @@ testRun(void)
paramList, varNewStrZ("10-1/01ABCDEF01ABCDEF/01ABCDEF01ABCDEF01ABCDEF-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.gz")); paramList, varNewStrZ("10-1/01ABCDEF01ABCDEF/01ABCDEF01ABCDEF01ABCDEF-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.gz"));
varLstAdd(paramList, varNewUInt(1)); varLstAdd(paramList, varNewUInt(1));
varLstAdd(paramList, varNewStrZ("10-1")); varLstAdd(paramList, varNewStrZ("10-1"));
varLstAdd(paramList, varNewUInt(cipherTypeAes256Cbc)); varLstAdd(paramList, varNewUInt64(cipherTypeAes256Cbc));
varLstAdd(paramList, varNewStrZ(TEST_CIPHER_PASS_ARCHIVE)); varLstAdd(paramList, varNewStrZ(TEST_CIPHER_PASS_ARCHIVE));
TEST_RESULT_VOID(archiveGetFileProtocol(paramList, server), "protocol archive get"); TEST_RESULT_VOID(archiveGetFileProtocol(paramList, server), "protocol archive get");

View File

@ -538,7 +538,7 @@ testRun(void)
hrnCfgArgRawZ(argListTemp, cfgOptStanza, "test"); hrnCfgArgRawZ(argListTemp, cfgOptStanza, "test");
hrnCfgArgKeyRawFmt(argListTemp, cfgOptPgPath, 1, "%s/pg", testPath()); hrnCfgArgKeyRawFmt(argListTemp, cfgOptPgPath, 1, "%s/pg", testPath());
hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argListTemp, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argListTemp, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "badpassphrase"); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "badpassphrase");
hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 3, "%s/repo3", testPath()); hrnCfgArgKeyRawFmt(argListTemp, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgRawNegate(argListTemp, cfgOptCompress); hrnCfgArgRawNegate(argListTemp, cfgOptCompress);

View File

@ -510,7 +510,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType varLstAdd(paramList, varNewUInt64(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - skip"); TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - skip");
@ -594,7 +594,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType varLstAdd(paramList, varNewUInt64(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - pageChecksum"); TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - pageChecksum");
@ -637,7 +637,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(true)); // delta varLstAdd(paramList, varNewBool(true)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType varLstAdd(paramList, varNewUInt64(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - noop"); TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - noop");
@ -779,7 +779,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(3)); // repoFileCompressLevel varLstAdd(paramList, varNewInt(3)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType varLstAdd(paramList, varNewUInt64(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - copy, compress"); TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - copy, compress");
@ -894,7 +894,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeAes256Cbc)); // cipherType varLstAdd(paramList, varNewUInt64(cipherTypeAes256Cbc));// cipherType
varLstAdd(paramList, varNewStrZ("12345678")); // cipherPass varLstAdd(paramList, varNewStrZ("12345678")); // cipherPass
TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - recopy, encrypt"); TEST_RESULT_VOID(backupFileProtocol(paramList, server), "protocol backup file - recopy, encrypt");
@ -1583,7 +1583,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawZ(argList, cfgOptStanza, "test1"); hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
hrnCfgArgRaw(argList, cfgOptPgPath, pg1Path); hrnCfgArgRaw(argList, cfgOptPgPath, pg1Path);
strLstAddZ(argList, "--no-" CFGOPT_ONLINE); strLstAddZ(argList, "--no-" CFGOPT_ONLINE);

View File

@ -553,7 +553,7 @@ testRun(void)
// Version mismatch // Version mismatch
TEST_ERROR_FMT( TEST_ERROR_FMT(
checkStanzaInfoPg( checkStanzaInfoPg(
storageRepoIdx(0), PG_VERSION_94, 6569239123849665679, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, 0)), storageRepoIdx(0), PG_VERSION_94, 6569239123849665679, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
cfgOptionIdxStr(cfgOptRepoCipherPass, 0)), cfgOptionIdxStr(cfgOptRepoCipherPass, 0)),
FileInvalidError, FileInvalidError,
"backup and archive info files exist but do not match the database\n" "backup and archive info files exist but do not match the database\n"
@ -563,7 +563,7 @@ testRun(void)
// SystemId mismatch // SystemId mismatch
TEST_ERROR_FMT( TEST_ERROR_FMT(
checkStanzaInfoPg( checkStanzaInfoPg(
storageRepoIdx(0), PG_VERSION_96, 6569239123849665699, cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, 0)), storageRepoIdx(0), PG_VERSION_96, 6569239123849665699, cfgOptionIdxStrId(cfgOptRepoCipherType, 0),
cfgOptionIdxStr(cfgOptRepoCipherPass, 0)), cfgOptionIdxStr(cfgOptRepoCipherPass, 0)),
FileInvalidError, FileInvalidError,
"backup and archive info files exist but do not match the database\n" "backup and archive info files exist but do not match the database\n"

View File

@ -2028,7 +2028,7 @@ testRun(void)
hrnCfgArgRawZ(argList, cfgOptSet, "20181119-152850F_20181119-152252D"); hrnCfgArgRawZ(argList, cfgOptSet, "20181119-152850F_20181119-152252D");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "1"); hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "1");
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
harnessCfgLoad(cfgCmdExpire, argList); harnessCfgLoad(cfgCmdExpire, argList);

View File

@ -1078,7 +1078,7 @@ testRun(void)
StringList *argListMultiRepo = strLstNew(); StringList *argListMultiRepo = strLstNew();
hrnCfgArgRawZ(argListMultiRepo, cfgOptRepoPath, TEST_PATH_REPO); hrnCfgArgRawZ(argListMultiRepo, cfgOptRepoPath, TEST_PATH_REPO);
hrnCfgArgKeyRawFmt(argListMultiRepo, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argListMultiRepo, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argListMultiRepo, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argListMultiRepo, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
StringList *argListMultiRepoJson = strLstDup(argListMultiRepo); StringList *argListMultiRepoJson = strLstDup(argListMultiRepo);

View File

@ -315,7 +315,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(argList, fileEncCustomName); strLstAdd(argList, fileEncCustomName);
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -327,7 +327,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--raw"); strLstAddZ(argList, "--raw");
strLstAdd(argList, fileRawName); strLstAdd(argList, fileRawName);
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -349,7 +349,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE); strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -360,7 +360,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy");
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -371,7 +371,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE);
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -382,7 +382,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy");
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -399,7 +399,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(argList, strNew(STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")); strLstAdd(argList, strNew(STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"));
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -414,7 +414,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE);
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -426,7 +426,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy");
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -440,7 +440,7 @@ testRun(void)
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/bogus"); hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/bogus");
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH_REPO); hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH_REPO);
hrnCfgArgRawZ(argList, cfgOptRepo, "2"); hrnCfgArgRawZ(argList, cfgOptRepo, "2");
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/backup.history/2020/label.manifest.gz"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/backup.history/2020/label.manifest.gz");
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -452,7 +452,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom2"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom2");
strLstAdd(argList, strNew(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label")); strLstAdd(argList, strNew(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label"));
harnessCfgLoad(cfgCmdRepoPut, argList); harnessCfgLoad(cfgCmdRepoPut, argList);
@ -495,7 +495,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom"); strLstAddZ(argList, "--" CFGOPT_CIPHER_PASS "=custom");
strLstAdd(argList, fileEncCustomName); strLstAdd(argList, fileEncCustomName);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -509,7 +509,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "--raw"); strLstAddZ(argList, "--raw");
strLstAdd(argList, fileRawName); strLstAdd(argList, fileRawName);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -550,7 +550,7 @@ testRun(void)
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/bogus"); hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/bogus");
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH_REPO); hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH_REPO);
hrnCfgArgRawZ(argList, cfgOptRepo, "2"); hrnCfgArgRawZ(argList, cfgOptRepo, "2");
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, "/somewhere/" INFO_ARCHIVE_FILE); strLstAddZ(argList, "/somewhere/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -564,7 +564,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, fileEncCustomName); strLstAdd(argList, fileEncCustomName);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -579,7 +579,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
strLstAddZ(argList, "--" CFGOPT_STANZA "=test2"); strLstAddZ(argList, "--" CFGOPT_STANZA "=test2");
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE); strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -592,7 +592,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE); strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -606,7 +606,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
strLstAddZ(argList, "--" CFGOPT_STANZA "=test"); strLstAddZ(argList, "--" CFGOPT_STANZA "=test");
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_ARCHIVE "/test/" INFO_ARCHIVE_FILE ".copy");
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -619,7 +619,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -632,7 +632,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/" INFO_BACKUP_FILE ".copy");
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -648,7 +648,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, strNewFmt( strLstAdd(argList, strNewFmt(
"%s/repo/" STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",testPath())); "%s/repo/" STORAGE_PATH_ARCHIVE "/test/12-1/000000010000000100000001-aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",testPath()));
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -662,7 +662,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE);
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -675,7 +675,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/latest/" BACKUP_MANIFEST_FILE ".copy");
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -688,7 +688,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/backup.history/2020/label.manifest.gz"); strLstAddZ(argList, STORAGE_PATH_BACKUP "/test/backup.history/2020/label.manifest.gz");
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);
@ -701,7 +701,7 @@ testRun(void)
argList = strLstNew(); argList = strLstNew();
hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath()); hrnCfgArgRawFmt(argList, cfgOptRepoPath, "%s/repo", testPath());
hrnCfgArgRawZ(argList, cfgOptRepoCipherType, CIPHER_TYPE_AES_256_CBC); hrnCfgArgRawStrId(argList, cfgOptRepoCipherType, cipherTypeAes256Cbc);
strLstAdd(argList, strNew(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label")); strLstAdd(argList, strNew(STORAGE_PATH_BACKUP "/test/latest/pg_data/backup_label"));
harnessCfgLoad(cfgCmdRepoGet, argList); harnessCfgLoad(cfgCmdRepoGet, argList);

View File

@ -1373,7 +1373,7 @@ testRun(void)
"system databases (template0, postgres, etc.) are included by default"); "system databases (template0, postgres, etc.) are included by default");
TEST_RESULT_LOG("P00 DETAIL: databases found for selective restore (1, 12168, 16380, 16381, 16384, 16385)"); TEST_RESULT_LOG("P00 DETAIL: databases found for selective restore (1, 12168, 16380, 16381, 16384, 16385)");
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error on missing database selected"); TEST_TITLE("error on missing database selected");
@ -1949,7 +1949,7 @@ testRun(void)
hrnCfgArgKeyRaw(argList, cfgOptRepoPath, 2, repoPathEncrpyt); hrnCfgArgKeyRaw(argList, cfgOptRepoPath, 2, repoPathEncrpyt);
strLstAdd(argList, strNewFmt("--pg1-path=%s", strZ(pgPath))); strLstAdd(argList, strNewFmt("--pg1-path=%s", strZ(pgPath)));
strLstAddZ(argList, "--set=20161219-212741F"); strLstAddZ(argList, "--set=20161219-212741F");
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
harnessCfgLoad(cfgCmdRestore, argList); harnessCfgLoad(cfgCmdRestore, argList);
@ -2051,7 +2051,7 @@ testRun(void)
// Add encryption filter and save the encrypted manifest // Add encryption filter and save the encrypted manifest
#define TEST_CIPHER_PASS_MANIFEST "backpass" #define TEST_CIPHER_PASS_MANIFEST "backpass"
cipherBlockFilterGroupAdd( cipherBlockFilterGroupAdd(
ioWriteFilterGroup(write), cipherType(cfgOptionIdxStr(cfgOptRepoCipherType, 1)), cipherModeEncrypt, ioWriteFilterGroup(write), cfgOptionIdxStrId(cfgOptRepoCipherType, 1), cipherModeEncrypt,
STRDEF(TEST_CIPHER_PASS_MANIFEST)); STRDEF(TEST_CIPHER_PASS_MANIFEST));
manifestSave(manifestEncrypted, write); manifestSave(manifestEncrypted, write);
@ -2115,7 +2115,7 @@ testRun(void)
strLstAddZ(argList, "--set=20161219-212741F"); strLstAddZ(argList, "--set=20161219-212741F");
strLstAddZ(argList, "--" CFGOPT_DELTA); strLstAddZ(argList, "--" CFGOPT_DELTA);
strLstAddZ(argList, "--force"); strLstAddZ(argList, "--force");
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, TEST_CIPHER_PASS);
harnessCfgLoad(cfgCmdRestore, argList); harnessCfgLoad(cfgCmdRestore, argList);

View File

@ -123,11 +123,11 @@ testRun(void)
argList = strLstDup(argListBase); argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678"); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678");
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 3, "%s/repo3", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 3, "%s/repo3", testPath());
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 4, "%s/repo4", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 4, "%s/repo4", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 4, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 4, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 4, "87654321"); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 4, "87654321");
harnessCfgLoad(cfgCmdStanzaCreate, argList); harnessCfgLoad(cfgCmdStanzaCreate, argList);
@ -302,7 +302,7 @@ testRun(void)
argList = strLstDup(argListBase); argList = strLstDup(argListBase);
hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath()); hrnCfgArgKeyRawFmt(argList, cfgOptRepoPath, 2, "%s/repo2", testPath());
hrnCfgArgKeyRawZ(argList, cfgOptRepoCipherType, 2, CIPHER_TYPE_AES_256_CBC); hrnCfgArgKeyRawStrId(argList, cfgOptRepoCipherType, 2, cipherTypeAes256Cbc);
hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678"); hrnCfgEnvKeyRawZ(cfgOptRepoCipherPass, 2, "12345678");
harnessCfgLoad(cfgCmdStanzaCreate, argList); harnessCfgLoad(cfgCmdStanzaCreate, argList);

View File

@ -45,15 +45,6 @@ testRun(void)
TEST_ERROR(cryptoError(true, "no error"), CryptoError, "no error: [0] no details available"); 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_Z(cipherTypeName(cipherTypeNone), "none", "none name");
TEST_RESULT_STR_Z(cipherTypeName(cipherTypeAes256Cbc), "aes-256-cbc", "aes-256-cbc name");
// Test if the buffer was overrun // Test if the buffer was overrun
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
unsigned char buffer[256] = {0}; unsigned char buffer[256] = {0};