clrecip.c
来自「PGP8.0源码 请认真阅读您的文件包然后写出其具体功能」· C语言 代码 · 共 970 行 · 第 1/2 页
C
970 行
if(apref.enforceRemoteADKClass)
arrEnforcement=kPGPARREnforcement_Strict;
/*
if(apref.WarnNotCorpSigned)
{
if(apref.corpKey==NULL)
{
// Warn if we can't find it AND exit since required.
NoCorpKey(prds->hwndParent);
return FALSE;
}
}*/
if(apref.haveOutgoingADK)
{
if(PGPKeyDBObjRefIsValid(apref.outgoingADK))
{
PGPRecipientSpec spec;
PGPBoolean bDisabled;
bDisabled=TRUE;
err = PGPGetKeyDBObjBooleanProperty( apref.outgoingADK,
kPGPKeyProperty_IsDisabled, &bDisabled );
if(!bDisabled)
{
pgpClearMemory( &spec, sizeof( spec ) );
spec.type = kPGPRecipientSpecType_Key;
if(apref.enforceOutgoingADK)
spec.flags = kPGPRecipientSpecFlags_Locked;
spec.u.key = apref.outgoingADK;
err = PGPAppendOptionList( rdoptionList,
PGPOUIDefaultRecipients( prds->context, 1, &spec ),
PGPOLastOption( prds->context ) );
}
else
{
if(apref.enforceOutgoingADK)
{
// HaveOutgoing, Enforced, but disabled? No way!
NoOutADKKey(prds->hwndParent);
err = kPGPError_UserAbort;
}
}
}
else
{
if(apref.enforceOutgoingADK)
{
// HaveOutgoing, Enforced, but no key? No way!
NoOutADKKey(prds->hwndParent);
err = kPGPError_UserAbort;
}
else
{
err = kPGPError_NoErr;
}
}
}
}
}
// ******************END BUSINESS SECURITY*******************
// Get client prefs
if(IsntPGPError(err))
{
err=GrabRecipClientPrefs(prds->hwndParent,
prds->context,
prds->keydbOriginal,
&apref);
}
// Add recipients
if((IsntPGPError(err))&&
(prds->szRecipientArray!=NULL)&&
(prds->dwNumRecipients!=0))
{
PGPRecipientSpec *spec;
int memamt,i;
memamt=sizeof(PGPRecipientSpec)*prds->dwNumRecipients;
spec=(PGPRecipientSpec *)malloc(memamt);
memset(spec,0x00,memamt);
for(i=0;i<(int)prds->dwNumRecipients;i++)
{
spec[i].type=kPGPRecipientSpecType_UserID;
strcpy(spec[i].u.userIDStr,prds->szRecipientArray[i]);
}
err = PGPAppendOptionList( rdoptionList,
PGPOUIDefaultRecipients( prds->context,
prds->dwNumRecipients,spec),
PGPOLastOption( prds->context ) );
free(spec);
}
// Open groups file
if( IsntPGPError( err ) )
{
err=PGPclOpenGroupFile (prds->context,&pGroup);
if(IsntPGPError(err))
{
err = PGPAppendOptionList( rdoptionList,
PGPOUIRecipientGroups( prds->context, pGroup->groupset ),
PGPOLastOption( prds->context ) );
}
}
// AddDefaultKey
if( IsntPGPError( err ) && apref.encryptToSelf )
{
if(PGPKeyDBObjRefIsValid(apref.defaultKey))
{
PGPRecipientSpec spec;
pgpClearMemory( &spec, sizeof( spec ) );
spec.type = kPGPRecipientSpecType_Key;
spec.u.key = apref.defaultKey;
err = PGPAppendOptionList( rdoptionList,
PGPOUIDefaultRecipients( prds->context, 1, &spec ),
PGPOLastOption( prds->context ) );
}
else
{
NoDefaultKey(prds->hwndParent);
// Don't let the recipient dialog automatically
// proceed
dwDisableFlags=dwDisableFlags|kPGPclDisableAutoMode;
}
}
// Make options control
if( IsntPGPError( err ) )
{
err = PGPBuildOptionList( prds->context, &optionList,
PGPOLastOption( prds->context ) );
if(prds->dwOptions&kPGPclASCIIArmor)
textOutput=1;
if(prds->dwOptions&kPGPclInputIsText)
inputIsText=1;
if((prds->dwOptions&kPGPclPassOnly)&&(apref.allowConvEncrypt))
conventionalEncrypt=1;
if(prds->dwOptions&kPGPclWipeOriginal)
wipeOriginal=1;
if(prds->dwOptions&kPGPclSecureViewer)
fyeo=1;
if(prds->dwOptions&kPGPclSelfDecryptingArchive)
sda=1;
#if SDKUITEST
// Just some code here to stress test the sdkUI options....
{
static char one[]="one";
static char two[]="two";
char *list[2];
static char descript[]=
"She smiled at a sorrowful stranger. "
"The smile seemed to make him feel better. "
"He remembered past kindnesses of a friend "
"And wrote him a thank you letter.";
list[0]=one;
list[1]=two;
err = PGPAppendOptionList( optionList,
PGPOUIPopupList( prds->context, 900, one, descript, 2,
list,0, &sda,
PGPOUIPopupList( prds->context, 901, two, descript, 2,
list,0, &sda,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
err = PGPAppendOptionList( optionList,
PGPOUIPopupList( prds->context, 902, one, descript, 2,
list,0, &sda,
PGPOUIPopupList( prds->context, 903, two, descript, 2,
list,0, &sda,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
#endif
if(!(dwDisableFlags&kPGPclDisableASCIIArmor))
{
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_TEXTOUTPUT, StrRes1, sizeof(StrRes1));
err = PGPAppendOptionList( optionList,
PGPOUICheckbox( prds->context, 801,
StrRes1,NULL,
textOutput, &textOutput,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
if(!(dwDisableFlags&kPGPclDisableInputIsText))
{
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_INPUTISTEXT, StrRes1, sizeof(StrRes1));
err = PGPAppendOptionList( optionList,
PGPOUICheckbox( prds->context, 807,
StrRes1,NULL,
inputIsText, &inputIsText,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
if(!(dwDisableFlags&kPGPclDisableWipeOriginal))
{
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_WIPEORIGINAL, StrRes3, sizeof(StrRes3));
err = PGPAppendOptionList( optionList,
PGPOUICheckbox( prds->context, 803,
StrRes3,NULL,
wipeOriginal, &wipeOriginal,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
if(!(dwDisableFlags&kPGPclDisableSecureViewer))
{
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_FYEO, StrRes3, sizeof(StrRes3));
err = PGPAppendOptionList( optionList,
PGPOUICheckbox( prds->context, 805,
StrRes3,NULL,
fyeo, &fyeo, PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
if((!(dwDisableFlags&kPGPclDisablePassOnly))&&
(apref.allowConvEncrypt))
{
PGPOptionListRef ConvOptionList;
// Create NULL suboption list for conventional encryption
err = PGPBuildOptionList( prds->context, &ConvOptionList,
PGPOLastOption( prds->context ) );
// If SDA is specified, make it a suboption
if(!(dwDisableFlags&kPGPclDisableSelfDecryptingArchive))
{
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_SDA, StrRes3, sizeof(StrRes3));
err = PGPAppendOptionList( ConvOptionList,
PGPOUICheckbox( prds->context, 806,
StrRes3,NULL,
sda, &sda, PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
haveFileOptions=TRUE;
LoadString (g_hInst, IDS_CONVENCRYPTION,
StrRes2, sizeof(StrRes2));
err = PGPAppendOptionList( optionList,
PGPOUICheckbox( prds->context, 802,
StrRes2,NULL,
conventionalEncrypt, &conventionalEncrypt,
ConvOptionList,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
PGPFreeOptionList(ConvOptionList);
}
}
if( IsntPGPError( err ) && ( haveFileOptions ))
{
err = PGPAppendOptionList( rdoptionList,
PGPOUIDialogOptions( prds->context,
optionList,
PGPOLastOption( prds->context ) ),
PGPOLastOption( prds->context ) );
}
if( IsntPGPError( err ))
{
PGPOptionListRef ksup;
// Create Option List for keyservers in case something
// goes wrong in the parsing
ksup=PGPOUIKeyServerUpdateParams(prds->context,
apref.numKSEntries,
apref.serverList, prds->tlsContext,
apref.synchUnknown,&foundKeys,
PGPOLastOption( prds->context ) );
if(ksup==(PGPOptionListRef)(-3L))
{
err=kPGPError_BadParams;
PGPclMessageBox(prds->hwndParent,
IDS_CAPTIONINFO,IDS_ERRORPARSINGKEYSERVERS,
MB_OK|MB_ICONSTOP);
}
else
{
err = PGPBuildOptionList( prds->context, &ksupoptionList,
ksup,
PGPOLastOption( prds->context ) );
}
}
// Call recipient dialog
if( IsntPGPError( err ))
{
/* Test for the options dialog. Leave commented out.
err=PGPOptionsDialog(prds->context,
optionList,
PGPOLastOption( prds->context ));
*/
err=PGPRecipientDialog(prds->context,
prds->keydbOriginal,
(unsigned char)(dwDisableFlags&kPGPclDisableAutoMode),
&(prds->keydbSelected),
rdoptionList,
PGPOUIParentWindowHandle(prds->context,prds->hwndParent),
PGPOUIWindowTitle(prds->context,prds->szTitle),
PGPOUIDisplayMarginalValidity( prds->context,
apref.showMarginalValidity ),
PGPOUIIgnoreMarginalValidity( prds->context,
apref.marginalIsInvalid ),
ksupoptionList,
PGPOUIEnforceAdditionalRecipientRequests( prds->context,
arrEnforcement, apref.bWarnOnADK ),
PGPOLastOption( prds->context ) );
// If we had options, read the results and send em back
if( IsntPGPError( err ) && haveFileOptions )
{
prds->dwOptions&=(~kPGPclASCIIArmor);
if( textOutput != 0 )
prds->dwOptions |= kPGPclASCIIArmor;
prds->dwOptions&=(~kPGPclInputIsText);
if( inputIsText != 0 )
prds->dwOptions |= kPGPclInputIsText;
prds->dwOptions&=(~kPGPclPassOnly);
if( conventionalEncrypt != 0 )
prds->dwOptions |= kPGPclPassOnly;
prds->dwOptions&=(~kPGPclWipeOriginal);
if( wipeOriginal != 0 )
prds->dwOptions |= kPGPclWipeOriginal;
prds->dwOptions&=(~kPGPclSecureViewer);
if( fyeo != 0 )
prds->dwOptions |= kPGPclSecureViewer;
prds->dwOptions&=(~kPGPclSelfDecryptingArchive);
if( sda != 0 )
prds->dwOptions |= kPGPclSelfDecryptingArchive;
}
}
if(apref.bKeyserversInited)
{
CLUninitKeyServerPrefs(kPGPclDefaultServer,
apref.pcss,apref.ksEntries,
apref.serverList,apref.numKSEntries);
}
if(optionList)
PGPFreeOptionList( optionList );
if(rdoptionList)
PGPFreeOptionList( rdoptionList );
if(ksupoptionList)
PGPFreeOptionList( ksupoptionList );
if(pGroup)
PGPclCloseGroupFile(pGroup);
prds->keydbAdded=foundKeys;
// Do some last minute checks
if(IsntPGPError(err))
{
PGPCountKeysInKeyDB( prds->keydbSelected, &numKeys );
if((numKeys==0)&&(!conventionalEncrypt)&&(!sda))
{
PGPclMessageBox(prds->hwndParent,
IDS_CAPTIONINFO,IDS_ATLEASTONEORCONV,
MB_OK|MB_ICONINFORMATION);
return FALSE;
}
// Check to make sure they have encrypted to
// themselves if WIPEORIG is checked.
if((prds->dwOptions&kPGPclWipeOriginal)&&
((prds->dwOptions&kPGPclPassOnly)==0)&&
((prds->dwOptions&kPGPclSelfDecryptingArchive)==0))
{
if(!DefaultKeyCheck(prds->hwndParent,
apref.defaultKey,
prds->keydbSelected))
{
int msgrst;
LoadString (g_hInst, IDS_CAPTIONWARNING,
StrRes1, sizeof(StrRes1));
LoadString (g_hInst, IDS_WIPEWODEFAULT,
StrRes2, sizeof(StrRes2));
msgrst=MessageBox(prds->hwndParent,StrRes2,StrRes1,
MB_YESNO|MB_ICONEXCLAMATION|MB_SETFOREGROUND);
if(msgrst==IDNO)
return FALSE;
}
}
prds->dwFlags&=(~kPGPclRSAEncrypt);
// So passphrase dialog can check for DSS/RSA combo
if(RSACheck(prds->hwndParent,
prds->keydbSelected))
{
prds->dwFlags |= kPGPclRSAEncrypt;
}
// ******************BUSINESS SECURITY***********************
if(PGPlnEnterprise())
{
/*
if((apref.WarnNotCorpSigned)&&(!conventionalEncrypt))
{
if(!CorpCheck(prds->hwndParent,
prds->keydbOriginal,
prds->keydbSelected,
apref.corpKey))
err=kPGPError_UserAbort;
}*/
if((!(apref.allowInvalidEncrypt))&&(!conventionalEncrypt))
{
if(!InvalidCheck(prds->hwndParent,
prds->keydbOriginal,
prds->keydbSelected))
{
EncryptingToInvalidKeys(prds->hwndParent);
err=kPGPError_UserAbort;
}
}
}
// ******************END BUSINESS SECURITY*******************
}
if(IsPGPError(err))
return FALSE;
return TRUE;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?