📄 adminoptions.c
字号:
sizeof(PGPKeyID) * (pConfig->nNumDefaultKeys + 1), 0);
memcpy(pConfig->defaultKeys[pConfig->nNumDefaultKeys].opaqueBytes,
pConfig->incomingADKID.opaqueBytes, sizeof(PGPKeyID));
pConfig->nNumDefaultKeys++;
}
}
if (pConfig->bUseOutgoingADK)
{
BOOL bGotKey = FALSE;
for (index=0; index<pConfig->nNumDefaultKeys; index++)
{
if (!memcmp(pConfig->defaultKeys[index].opaqueBytes,
pConfig->outgoingADKID.opaqueBytes, sizeof(PGPKeyID)))
{
bGotKey = TRUE;
break;
}
}
if (!bGotKey)
{
PGPReallocData(pConfig->memoryMgr, &(pConfig->defaultKeys),
sizeof(PGPKeyID) * (pConfig->nNumDefaultKeys + 1), 0);
memcpy(pConfig->defaultKeys[pConfig->nNumDefaultKeys].opaqueBytes,
pConfig->outgoingADKID.opaqueBytes, sizeof(PGPKeyID));
pConfig->nNumDefaultKeys++;
}
}
// Add the Corporate Key
if (pConfig->bAutoSignTrustCorp)
{
BOOL bGotKey = FALSE;
for (index=0; index<pConfig->nNumDefaultKeys; index++)
{
if (!memcmp(pConfig->defaultKeys[index].opaqueBytes,
pConfig->corpKeyID.opaqueBytes, sizeof(PGPKeyID)))
{
bGotKey = TRUE;
break;
}
}
if (!bGotKey)
{
PGPReallocData(pConfig->memoryMgr, &(pConfig->defaultKeys),
sizeof(PGPKeyID) * (pConfig->nNumDefaultKeys + 1), 0);
memcpy(pConfig->defaultKeys[pConfig->nNumDefaultKeys].opaqueBytes,
pConfig->corpKeyID.opaqueBytes, sizeof(PGPKeyID));
pConfig->nNumDefaultKeys++;
}
}
// Add the Designated Revoker Key
if (pConfig->bAutoAddRevoker)
{
BOOL bGotKey = FALSE;
for (index=0; index<pConfig->nNumDefaultKeys; index++)
{
if (!memcmp(pConfig->defaultKeys[index].opaqueBytes,
pConfig->revokerKeyID.opaqueBytes, sizeof(PGPKeyID)))
{
bGotKey = TRUE;
break;
}
}
if (!bGotKey)
{
PGPReallocData(pConfig->memoryMgr, &(pConfig->defaultKeys),
sizeof(PGPKeyID) * (pConfig->nNumDefaultKeys + 1), 0);
memcpy(pConfig->defaultKeys[pConfig->nNumDefaultKeys].opaqueBytes,
pConfig->revokerKeyID.opaqueBytes, sizeof(PGPKeyID));
pConfig->nNumDefaultKeys++;
}
}
// Save the default keys if any were specified
if (pConfig->szDefaultKeysBuffer != NULL)
{
PGPFreeData(pConfig->szDefaultKeysBuffer);
pConfig->szDefaultKeysBuffer = NULL;
}
if (pConfig->defaultKeys != NULL)
{
char szComments[256];
PGPKeyDBRef newKeyDB;
PGPKeySetRef defaultKeySet;
PGPKeyDBObjRef key;
PGPFileSpecRef defaultKeyFile = NULL;
PGPOptionListRef options;
PGPCreatePrefArray(prefRef, kPGPPrefType_Byte, pConfig->nNumDefaultKeys,
NULL, &prefArray);
PGPNewKeyDB(pConfig->pgpContext, &newKeyDB);
PGPNewEmptyKeySet(pConfig->keyDB, &defaultKeySet);
for (index=0; index<pConfig->nNumDefaultKeys; index++)
{
PGPSetPrefArrayByte(prefRef, prefArray, index,
sizeof(pConfig->defaultKeys[index].opaqueBytes),
pConfig->defaultKeys[index].opaqueBytes);
PGPFindKeyByKeyID(pConfig->keyDB, &(pConfig->defaultKeys[index]), &key);
PGPAddKey(key, defaultKeySet);
}
PGPSetPrefArray(prefRef, kPGPPrefDefaultKeys, prefArray);
PGPFreePrefArray(prefArray);
szComments[0] = 0;
PGPGetPrefStringBuffer(prefRef, kPGPPrefComment, sizeof(szComments),
szComments);
if (strlen(szComments) > 0)
{
PGPBuildOptionList(pConfig->pgpContext, &options,
PGPOCommentString(pConfig->pgpContext, szComments),
PGPOLastOption(pConfig->pgpContext));
}
else
{
PGPBuildOptionList(pConfig->pgpContext, &options,
PGPOLastOption(pConfig->pgpContext));
}
if (strlen(pConfig->szDefaultKeys) > 0)
{
PGPNewFileSpecFromFullPath(pConfig->pgpContext, pConfig->szDefaultKeys,
&defaultKeyFile);
PGPAppendOptionList(options,
PGPOOutputFile(pConfig->pgpContext, defaultKeyFile),
PGPOLastOption(pConfig->pgpContext));
}
else
{
PGPAppendOptionList(options,
PGPOAllocatedOutputBuffer(pConfig->pgpContext,
&(pConfig->szDefaultKeysBuffer),
INT_MAX,
&(pConfig->nDefaultKeysBufferSize)),
PGPOLastOption(pConfig->pgpContext));
}
PGPExport(pConfig->pgpContext,
PGPOExportKeySet(pConfig->pgpContext, defaultKeySet),
PGPOExportFormat(pConfig->pgpContext, kPGPExportFormat_Complete),
PGPOVersionString(pConfig->pgpContext, pgpVersionHeaderString()),
options,
PGPOExportPrivateKeys(pConfig->pgpContext, FALSE),
PGPOArmorOutput(pConfig->pgpContext, TRUE),
PGPOLastOption(pConfig->pgpContext));
if (defaultKeyFile != NULL)
PGPFreeFileSpec(defaultKeyFile);
PGPFreeOptionList(options);
PGPFreeKeySet(defaultKeySet);
PGPFreeKeyDB(newKeyDB);
}
else
PGPSetPrefArray(prefRef, kPGPPrefDefaultKeys, &DefaultKeys);
if (!pConfig->bCopyClientPrefs)
{
for (index=kPGPPrefBoolFirst; index<kPGPPrefBoolLast; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPPrefNumberFirst; index<kPGPPrefNumberLast; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPPrefStringFirst; index<kPGPPrefStringLast; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPPrefByteFirst; index<kPGPPrefByteLast; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPPrefStructFirst; index<kPGPPrefStructLast; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPPrefArrayFirst; index<kPGPPrefArrayFirst; index++)
PGPClearPrefFlags(prefRef, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefBoolFirst; index<kPGPPrefBoolLast; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefNumberFirst; index<kPGPPrefNumberLast; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefStringFirst; index<kPGPPrefStringLast; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefByteFirst; index<kPGPPrefByteLast; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefStructFirst; index<kPGPPrefStructLast; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
for (index=kPGPNetPrefArrayFirst; index<kPGPPrefArrayFirst; index++)
PGPClearPrefFlags(pConfig->prefRefNet, index, kPGPPrefFlags_All);
}
for (index=kPGPAdminPrefBoolFirst; index<kPGPAdminPrefBoolLast; index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
for (index=kPGPAdminPrefNumberFirst; index<kPGPAdminPrefNumberLast;
index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
for (index=kPGPAdminPrefStringFirst; index<kPGPAdminPrefStringLast;
index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
for (index=kPGPAdminPrefByteFirst; index<kPGPAdminPrefByteLast; index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
for (index=kPGPAdminPrefStructFirst; index<kPGPAdminPrefStructLast;
index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
for (index=kPGPAdminPrefArrayFirst; index<kPGPAdminPrefArrayFirst;
index++)
PGPSetPrefFlags(prefRef, index,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite);
PGPSetPrefFlags(prefRef, kPGPPrefLicenseName,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite | kPGPPrefFlags_DisableGUI);
PGPSetPrefFlags(prefRef, kPGPPrefLicenseCompany,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite | kPGPPrefFlags_DisableGUI);
PGPSetPrefFlags(prefRef, kPGPPrefLicenseNumber,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite | kPGPPrefFlags_DisableGUI);
PGPSetPrefFlags(prefRef, kPGPPrefLicenseAuthorization,
kPGPPrefFlags_Hash | kPGPPrefFlags_Overwrite | kPGPPrefFlags_DisableGUI);
PGPWritePrefsHash(pConfig->pgpContext, prefRef);
PGPSavePrefFile(prefRef);
if (pConfig->bCopyClientPrefs)
{
PGPWritePrefsHash(pConfig->pgpContext, pConfig->prefRefNet);
PGPSavePrefFile(pConfig->prefRefNet);
}
return;
}
void FreeAdminOptions(pgpConfigInfo *pConfig)
{
// Free allocated memory and objects
if (pConfig->szLDAPServer)
{
PGPFreeData(pConfig->szLDAPServer);
pConfig->szLDAPServer = NULL;
}
if (pConfig->szReconServer)
{
PGPFreeData(pConfig->szReconServer);
pConfig->szReconServer = NULL;
}
if (pConfig->defaultKeys != NULL)
{
PGPFreeData(pConfig->defaultKeys);
pConfig->defaultKeys = NULL;
}
if (pConfig->szDefaultKeysBuffer != NULL)
{
PGPFreeData(pConfig->szDefaultKeysBuffer);
pConfig->szDefaultKeysBuffer = NULL;
}
if (pConfig->szAdminInstaller)
{
PGPFreeData(pConfig->szAdminInstaller);
pConfig->szAdminInstaller = NULL;
}
if (pConfig->szClientInstaller)
{
PGPFreeData(pConfig->szClientInstaller);
pConfig->szClientInstaller = NULL;
}
if (pConfig->szUserInstallDir)
{
PGPFreeData(pConfig->szUserInstallDir);
pConfig->szUserInstallDir = NULL;
}
if (pConfig->avData)
{
PGPFreeData(pConfig->avData);
pConfig->avData = NULL;
pConfig->avDataSize = 0;
}
if (pConfig->keyDB)
{
PGPFreeKeyDB(pConfig->keyDB);
pConfig->keyDB = NULL;
}
if (pConfig->tlsContext)
{
PGPFreeTLSContext(pConfig->tlsContext);
pConfig->tlsContext = NULL;
}
return;
}
/*__Editor_settings____
Local Variables:
tab-width: 4
End:
vi: ts=4 sw=4
vim: si
_____________________*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -