static void DestroyUnionSet( PGPKeySetRef set) { UnionSetPriv * priv = (UnionSetPriv *)set->priv; pgpa(( pgpaAddrValid(set, PGPKeySet), pgpaAddrValid(priv, UnionSetPriv))); PGPFreeKeySet(priv->set1); PGPFreeKeySet(priv->set2); }
BOOL KMDisableOnServer (PKEYMAN pKM) { PGPKeySetRef keysetDisable = kInvalidPGPKeySetRef; PGPError err = kPGPError_BadParams; PGPKeyServerKeySpace space; if (pKM->ulOptionFlags & KMF_PENDINGBUCKET) space = kPGPKeyServerKeySpace_Normal; else space = kPGPKeyServerKeySpace_Default; KMGetSelectedKeys (pKM, &keysetDisable, NULL); if (PGPRefIsValid (keysetDisable)) { err = PGPclDisableKeysOnServer (pKM->Context, pKM->tlsContext, pKM->hWndParent, &pKM->keyserver, space, pKM->KeySetMain, keysetDisable); PGPFreeKeySet (keysetDisable); } if (IsPGPError (err)) PGPclErrorBox (NULL, err); else { KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_DISABLEONSERVEROK, MB_OK|MB_ICONINFORMATION); } return TRUE; }
/* * Create a singleton enumerated key set */ PGPError PGPNewSingletonKeySet( PGPKeyRef key, PGPKeySetRef * newSet) { PGPContextRef context = PGPGetKeyContext(key); EnumeratedSubsetPriv * priv; PGPKeySetRef set; PGPError err = kPGPError_NoErr; PGPValidatePtr( newSet ); *newSet = NULL; /* In case there's an error */ PGPValidateKey( key ); err = NewEnumeratedSubsetInternal(key->keyDB, &set); if (IsPGPError(err)) return err; priv = (EnumeratedSubsetPriv *)set->priv; priv->keyArray = (RingObject **)pgpContextMemAlloc(context, sizeof(RingObject *), 0); if (NULL==(int)(priv->keyArray)) { PGPFreeKeySet(set); return kPGPError_OutOfMemory; } priv->numKeys = 1; priv->keyArray[0] = key->key; *newSet = set; pgpAssertErrWithPtr( err, *newSet ); return err; }
BOOL KMAddCertificate (PKEYMAN pKM) { PGPKeySetRef keysetKey = kInvalidPGPKeySetRef; PGPKeyRef key = kInvalidPGPKeyRef; PGPUserIDRef userid = kInvalidPGPUserIDRef; PGPError err; if (KMSelectedFlags (pKM) == OBJECT_USERID) { userid = (PGPUserIDRef)KMFocusedObject (pKM); key = KMGetKeyFromUserID (pKM, userid); } else { key = (PGPKeyRef)KMFocusedObject (pKM); PGPGetPrimaryUserID (key, &userid); } PGPNewSingletonKeySet (key, &keysetKey); if (PGPRefIsValid (keysetKey)) { err = PGPclSendCertificateRequestToServer ( pKM->Context, pKM->tlsContext, pKM->hWndParent, pKM->KeySetMain, userid, keysetKey); PGPFreeKeySet (keysetKey); } if (err == kPGPError_InvalidProperty) { if (KMIsThisTheOnlyUserID (pKM, userid)) KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_CANTDERIVEATTRIBUTESONLY, MB_OK|MB_ICONEXCLAMATION); else KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_CANTDERIVEATTRIBUTES, MB_OK|MB_ICONEXCLAMATION); } else if (IsPGPError (err)) { PGPclErrorBox (pKM->hWndParent, err); } else { KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_CERTIFICATEREQUESTED, MB_OK|MB_ICONINFORMATION); } return TRUE; }
PGPError PGPclExport PGPclSearchServerForUserID ( PGPContextRef context, PGPtlsContextRef tlsContext, HWND hwndParent, LPSTR szUserID, UINT uServer, PGPKeySetRef keysetMain, PGPKeySetRef* pkeysetResult) { PGPError err = kPGPError_NoErr; PGPKeySetRef keyset = kInvalidPGPKeySetRef; PGPOptionListRef optionSearch = kInvalidPGPOptionListRef; PGPFilterRef filter = kInvalidPGPFilterRef; // initialize return keyset PGPValidatePtr (pkeysetResult); *pkeysetResult = kInvalidPGPKeySetRef; err = PGPNewUserIDStringFilter (context, szUserID, kPGPMatchSubString, &filter); if (IsntPGPError (err) && PGPFilterRefIsValid (filter)) { optionSearch = PGPOUIKeyServerSearchFilter (context, filter); if (PGPOptionListRefIsValid (optionSearch)) { err = sQueryServerInternal (hwndParent, context, tlsContext, optionSearch, uServer, szUserID, keysetMain, &keyset); if (IsntPGPError (err)) { *pkeysetResult = keyset; keyset = kInvalidPGPKeySetRef; } } } if (PGPKeySetRefIsValid (keyset)) PGPFreeKeySet (keyset); if (PGPFilterRefIsValid (filter)) PGPFreeFilter (filter); return err; }
static PGPError sSendToServerInternal ( HWND hwndParent, PGPContextRef context, PGPtlsContextRef tlsContext, UINT uServer, PGPKeyServerEntry* pkeyserver, LPSTR pszUserID, PGPKeySetRef keysetMain, PGPKeySetRef keysetToSend) { PGPError err = kPGPError_NoErr; PGPKeyServerEntry* pentryList = NULL; PGPKeyServerSpec* pserverList = NULL; PGPInt32 iNumEntries = 0; PCLIENTSERVERSTRUCT pcss = NULL; PGPKeySetRef keysetFailed = kInvalidPGPKeySetRef; PGPMemoryMgrRef memMgr; PGPPrefRef clientPrefsRef; PGPValidatePtr (keysetToSend); PGPValidatePtr (context); PGPValidatePtr (pszUserID); memMgr=PGPGetContextMemoryMgr(context); err=PGPclOpenClientPrefs (memMgr,&clientPrefsRef); if(IsntPGPError(err)) { err=CLInitKeyServerPrefs(uServer,pkeyserver, hwndParent,context,keysetMain,clientPrefsRef,pszUserID, &pcss,&pentryList,&pserverList,&iNumEntries); PGPclCloseClientPrefs (clientPrefsRef, FALSE); } if (IsntPGPError (err)) { err = PGPSendToKeyServerDialog (context, &(pserverList[0]), tlsContext, keysetToSend, &keysetFailed, PGPOUIParentWindowHandle (context, hwndParent), PGPOLastOption (context)); if (PGPKeySetRefIsValid (keysetFailed)) PGPFreeKeySet (keysetFailed); } CLUninitKeyServerPrefs(uServer, pcss,pentryList,pserverList,iNumEntries); return err; }
PGPError pgpAddKeyToKeySet( PGPKeyRef key, PGPKeySetRef keySet) { PGPError err,er2; PGPKeySetRef tmpset; err = PGPNewSingletonKeySet( key, &tmpset ); if( IsPGPError(err)) return err; err = PGPAddKeys( tmpset, keySet ); er2 = PGPFreeKeySet( tmpset ); pgpAssertNoErr(er2); return err; }
int __cdecl _pgp_close_keyrings() { #if (PGP_WIN32 < 0x700) if (pgpKeyDB) { PGPFreeKeySet(pgpKeyDB); pgpKeyDB = 0; } #else if (pgpKeyDB) { PGPFreeKeyDB(pgpKeyDB); pgpKeyDB = 0; } #endif return 1; }
LPSTR __cdecl _pgp_encrypt_keydb(LPCSTR szPlainMsg, PVOID pgpKeyID) { PGPKeyID *RemoteKeyID = (PGPKeyID *) pgpKeyID; LPSTR szEncMsg = 0; DWORD dwEncMsgLen; ClearPGPError(); if(!pgpKeyDB) return 0; #if (PGP_WIN32 < 0x700) PGPFilterRef IDFilter; PGPNewKeyIDFilter(pgpContext, RemoteKeyID, &IDFilter); PGPKeySetRef PublicKey; PGPFilterKeySet(pgpKeyDB, IDFilter, &PublicKey); #else PGPKeyDBObjRef PublicKey; PGPFindKeyByKeyID(pgpKeyDB, RemoteKeyID, &PublicKey); #endif PGPError err = PGPEncode(pgpContext, PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), PGPOArmorOutput(pgpContext, TRUE), PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), #if (PGP_WIN32 < 0x700) PGPOEncryptToKeySet(pgpContext, PublicKey), #else PGPOEncryptToKeyDBObj(pgpContext, PublicKey), #endif PGPOVersionString(pgpContext, szVersionStr), PGPOLastOption(pgpContext)); #if (PGP_WIN32 < 0x700) PGPFreeKeySet(PublicKey); PGPFreeFilter(IDFilter); #endif if (CheckPGPError(err)) return 0; LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); szMsg[dwEncMsgLen] = 0; PGPFreeData((LPVOID)szEncMsg); return szMsg; }
BOOL AddKeyFileList(HWND hwnd,void *PGPsc,void *PGPtls,FILELIST *ListHead) { PGPContextRef context; PGPtlsContextRef tls; MYSTATE *ms; PGPError err; err=kPGPError_NoErr; context=(PGPContextRef)PGPsc; tls=(PGPtlsContextRef)PGPtls; if(IsPGPError(PGPclEvalExpired(hwnd, PGPCL_ALLEXPIRED))) return FALSE; ms=(MYSTATE *)malloc(sizeof(MYSTATE)); if(ms) { memset(ms, 0x00, sizeof(MYSTATE) ); ms->context=context; ms->tlsContext=tls; ms->ListHead=ListHead; ms->Operation=MS_ADDKEYFILELIST; if(OpenRings(hwnd,context,&(ms->KeySet))) { err=SCProgressDialog(hwnd,DoWorkThread,ms, 0,"Adding Keys from File(s)...", "","",IDR_PROGAVI); if(!(ms->FoundPGPData)) PGPscMessageBox (hwnd,IDS_PGPERROR,IDS_NOPGPKEYSINFILE, MB_OK|MB_ICONEXCLAMATION); PGPFreeKeySet(ms->KeySet); } free(ms); } FreeFileList(ListHead); if(IsPGPError(err)) return FALSE; return TRUE; }
PGPError PGPclExport PGPclSearchServerForKeyIDs ( PGPContextRef context, PGPtlsContextRef tlsContext, HWND hwndParent, PGPKeyID* pkeyidList, INT iNumKeyIDs, UINT uServer, PGPKeySetRef keysetMain, PGPKeySetRef* pkeysetResult) { PGPError err = kPGPError_NoErr; PGPKeySetRef keyset = kInvalidPGPKeySetRef; PGPOptionListRef optionSearch = kInvalidPGPOptionListRef; // initialize return keyset PGPValidatePtr (pkeysetResult); *pkeysetResult = kInvalidPGPKeySetRef; optionSearch = PGPOUIKeyServerSearchKeyIDList (context, iNumKeyIDs, pkeyidList ); if (PGPOptionListRefIsValid (optionSearch)) { err = sQueryServerInternal (hwndParent, context, tlsContext, optionSearch, uServer, "", keysetMain, &keyset); if (IsntPGPError (err)) { *pkeysetResult = keyset; keyset = kInvalidPGPKeySetRef; } } if (PGPKeySetRefIsValid (keyset)) PGPFreeKeySet (keyset); return err; }
PGPError dokeycheck(struct pgpmainBones *mainbPtr, char *useridStr, PGPFileSpecRef ringFileSpec) { PGPKeySetRef ringSet = NULL; char *ringfile = NULL; PGPError err, er2; struct pgpenvBones *envbPtr = mainbPtr->envbPtr; struct pgpfileBones *filebPtr = mainbPtr->filebPtr; PGPEnv *env = envbPtr->m_env; PGPInt32 pri; PGPBoolean quietmode = pgpenvGetInt( env, PGPENV_NOOUT, &pri, &err); PGPBoolean compatible = envbPtr->compatible; err = PGPGetFullPathFromFileSpec( ringFileSpec, &ringfile ); pgpAssertNoErr(err); err = PGPOpenKeyRing(mainbPtr->pgpContext, 0, ringFileSpec, &ringSet); #if 0 err = pgpOpenKeyringsFromPubringSpec( mainbPtr, ringFileSpec, &ringSet, 0); #endif 0 if( IsPGPError(err) ) goto done; if (!quietmode) fprintf(filebPtr->pgpout, LANG("\nKey ring: '%s'"), ringfile); mainbPtr->workingRingSet=ringSet; err = pgpDoCheckKeyRing(mainbPtr, useridStr); pgpAssertNoErr(err); done: if (ringfile) er2 = PGPFreeData( ringfile ); if (ringSet) er2 = PGPFreeKeySet( ringSet ); mainbPtr->workingRingSet = NULL; if( !compatible && IsPGPError(err) && pgpenvGetInt( env, PGPENV_VERBOSE, &pri, &er2) ) pgpShowError(filebPtr, err, __FILE__,__LINE__); return err; }
BOOL KMSendToServer (PKEYMAN pKM, UINT uServerFlags) { PGPKeySetRef keysetSend = kInvalidPGPKeySetRef; PGPError err = kPGPError_BadParams; INT iKeyCount; if ((uServerFlags == PGPCL_SPECIFIEDSERVER) && (pKM->keyserver.structSize == 0)) { uServerFlags = PGPCL_USERIDBASEDSERVER; } KMGetSelectedKeys (pKM, &keysetSend, &iKeyCount); if (PGPRefIsValid (keysetSend)) { err = PGPclSendKeysToServer (pKM->Context, pKM->tlsContext, pKM->hWndParent, uServerFlags, &pKM->keyserver, pKM->KeySetMain, keysetSend); PGPFreeKeySet (keysetSend); } if (err == kPGPError_ServerKeyAlreadyExists) { if (iKeyCount > 1) { KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_KEYSALREADYONSERVER, MB_OK|MB_ICONINFORMATION); } else { KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_KEYALREADYONSERVER, MB_OK|MB_ICONINFORMATION); } } else if (IsPGPError (err)) { PGPclErrorBox (NULL, err); } else { KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_UPLOADOK, MB_OK|MB_ICONINFORMATION); } return TRUE; }
void FreeRecipients(RECIPIENTDIALOGSTRUCT *prds) { DWORD dwIndex; for (dwIndex=0; dwIndex<prds->dwNumRecipients; dwIndex++) { if ((prds->szRecipientArray)[dwIndex] != NULL) { free((prds->szRecipientArray)[dwIndex]); (prds->szRecipientArray)[dwIndex] = NULL; } } if (prds->SelectedKeySetRef != NULL) { PGPFreeKeySet(prds->SelectedKeySetRef); prds->SelectedKeySetRef = NULL; } return; }
PGPError GenericAddKey(MYSTATE *ms, PGPOptionListRef opts, char *OperationTarget) { PGPKeySetRef AddKeySet; PGPContextRef context; PGPError err; err=kPGPError_NoErr; context=ms->context; ms->fileName=OperationTarget; if(ms->Operation!=MS_ADDKEYCLIPBOARD) SCSetProgressNewFilename(ms->hPrgDlg,"From '%s'",ms->fileName,TRUE); err=PGPImportKeySet(context,&AddKeySet, opts, PGPOSendNullEvents(context,75), PGPOEventHandler(context,AddEvents,ms), PGPOLastOption(context)); SCSetProgressBar(ms->hPrgDlg,100,TRUE); if(IsntPGPError(err)) { PGPUInt32 numKeys; PGPCountKeys( AddKeySet, &numKeys); if ( numKeys > 0) { err=PGPclQueryAddKeys (context, ms->tlsContext,ms->hwndWorking,AddKeySet,NULL); } PGPFreeKeySet (AddKeySet); } return err; }
/* Called by the pgp -kc option. */ PGPError pgpDoCheckKeyRing(struct pgpmainBones *mainbPtr, char *useridStr ) { struct pgpfileBones *filebPtr = mainbPtr->filebPtr; PGPError err; PGPKeySetRef checkSet = NULL; err = pgpGetMatchingKeySet(mainbPtr, useridStr, 0, &checkSet ); if( IsPGPError(err) ) goto done; err = PGPCheckKeyRingSigs( checkSet, mainbPtr->workingRingSet, TRUE, NULL, NULL ); pgpAssertNoErr(err); err = viewKeySet( mainbPtr, checkSet, kShow_Sigs | kShow_Checks ); pgpAssertNoErr(err); done: if( checkSet ) PGPFreeKeySet( checkSet ); return err; }
int __cdecl _pgp_done() { pgpVer = 0; __try { if(pgpErrMsg) LocalFree(pgpErrMsg); if (pszPassphrase) PGPFreeData(pszPassphrase); #if (PGP_WIN32 < 0x700) if (pgpKeyDB) PGPFreeKeySet(pgpKeyDB); #else if (pgpKeyDB) PGPFreeKeyDB(pgpKeyDB); #endif PGPFreeContext(pgpContext); PGPsdkUILibCleanup(); PGPsdkCleanup(); pszPassphrase = pgpErrMsg = 0; pgpKeyDB = 0; pgpContext = 0; } __except ( EXCEPTION_EXECUTE_HANDLER ) { return 0; } return 1; }
PGPError TestGroupsUtil() { PGPContextRef context; PGPError err = kPGPError_NoErr; err = PGPNewContext( kPGPsdkAPIVersion, &context ); if ( IsntPGPError( err ) ) { PGPKeySetRef keySet; err = PGPOpenDefaultKeyRings( context, 0, &keySet ); if ( IsntPGPError( err ) ) { err = sTestGroupValidity( keySet ); PGPFreeKeySet( keySet ); } PGPFreeContext( context ); } pgpAssertNoErr( err ); return( err ); }
STDMETHODIMP CExtImpl::OnWriteComplete(IExchExtCallback* pecb, ULONG ulFlags) { if (_context != EECONTEXT_SENDNOTEMESSAGE) return S_FALSE; if (ulFlags == EEME_COMPLETE_FAILED) // Nothing to unwind return S_FALSE; if (!_fInSubmitState) // This is not a submission. return S_FALSE; if (_bEncrypt || _bSign) { IMessage *pmsg = 0; RECIPIENTDIALOGSTRUCT *prds; PGPOptionListRef signOptions = NULL; HWND hwnd; PGPError nError = kPGPError_NoErr; pecb->GetWindow(&hwnd); if (!hwnd) hwnd = GetTopWindow(NULL); CWaitCursor wait; // Mark busy HRESULT hr = pecb->GetObject(NULL, (IMAPIProp**)&pmsg); if (FAILED(hr)) { UIDisplayStringID(hwnd, IDS_E_NOMESSAGE); return E_ABORT; } prds = (RECIPIENTDIALOGSTRUCT *) calloc(sizeof(RECIPIENTDIALOGSTRUCT), 1); nError = PGPsdkLoadDefaultPrefs(_pgpContext); if (IsPGPError(nError)) { UIDisplayErrorCode(__FILE__, __LINE__, NULL, nError); return E_ABORT; } nError = PGPOpenDefaultKeyRings(_pgpContext, (PGPKeyRingOpenFlags)0, &(prds->OriginalKeySetRef)); if (IsPGPError(nError)) { UIDisplayErrorCode(__FILE__, __LINE__, NULL, nError); return E_ABORT; } if (_bEncrypt) nError = GetRecipients(pecb, _pgpContext, _tlsContext, prds); if (IsPGPError(nError)) { if (nError != kPGPError_UserAbort) UIDisplayErrorCode(__FILE__, __LINE__, NULL, nError); return E_ABORT; } nError = EncryptSignMessage(hwnd, pmsg, prds, &signOptions); if (signOptions != NULL) { PGPFreeOptionList(signOptions); signOptions = NULL; } FreeRecipients(prds); if (NULL!=(int)(prds->OriginalKeySetRef)) { PGPFreeKeySet(prds->OriginalKeySetRef); prds->OriginalKeySetRef = NULL; } free(prds); pmsg->Release(); if (IsPGPError(nError)) return E_ABORT; } return S_FALSE; }
/***** * * verify_signature * * Call-out routine used by the CMS library for verifying a signature. * Parameters and return values defined in CMS docs. This uses the * PGP SDK. See "PGP Software Developer's Kit, Reference Manual" * for details on calls used here. * *****/ int x509CMSVerifyCallback ( unsigned char *data, size_t dataLen, unsigned char *sigalg, size_t algLen, unsigned char *params, size_t paramLen, unsigned char *signature, size_t sigLen, unsigned char *pubkey, size_t pubkeyLen, TC_CERT *issuer, void *verData, TC_CONTEXT *ctx) { X509CMSCallbackData *pgpData = (X509CMSCallbackData *) verData; PGPMemoryMgrRef mgrRef; PGPPublicKeyContextRef publicKey; PGPHashContextRef hash; PGPKeySetRef keySet; PGPKeyListRef klist; PGPKeyIterRef kiter; PGPKeyRef mykey; PGPError err; PGPByte *certData; PGPSize certDataLen; int rtn = -1; PGPHashAlgorithm hashAlg; (void) params; (void) paramLen; (void) pubkey; (void) pubkeyLen; do { /* check that the algorithm ID is allowed */ /* TODO... */ /* if we dont have the issuer's certificate, we can't verify the signature. */ /* PGPsdk needs to have a function that takes raw ASN.1 encoded key material and returns a KeyRef in order to support verification of PKCS10 requests */ if (!issuer) break; /* import the certificate into pgp */ tc_pack_cert (&certData, &certDataLen, issuer, ctx); /* import the key into a PGP key set */ err = PGPImportKeySet (pgpData->context, &keySet, PGPOX509Encoding (pgpData->context, 1), PGPOInputBuffer (pgpData->context, certData, certDataLen), PGPOLastOption (pgpData->context)); TC_Free (ctx->memMgr, certData); if (IsPGPError (err)) break; /* extract the key into a PGPKeyRef */ err = PGPOrderKeySet (keySet, kPGPAnyOrdering, &klist); if (IsPGPError (err)) break; err = PGPNewKeyIter (klist, &kiter); if (IsPGPError (err)) break; err = PGPKeyIterNext (kiter, &mykey); if (IsPGPError (err)) break; /* create the public key context */ err = PGPNewPublicKeyContext (mykey, kPGPPublicKeyMessageFormat_X509, &publicKey); if (IsPGPError (err)) break; hashAlg = x509HashAlgorithm (sigalg, algLen); /* create and calculate the hash, do not finalize hash for PGPPublicKeyVerify() call */ mgrRef = PGPGetContextMemoryMgr (pgpData->context); err = PGPNewHashContext (mgrRef, hashAlg, &hash); if (IsPGPError (err)) break; err = PGPContinueHash (hash, data, dataLen); if (IsPGPError (err)) break; err = PGPPublicKeyVerifySignature ( publicKey, hash, (void *)signature, sigLen); hash = NULL; if ( IsPGPError(err) ) break; rtn = 0; } while (0); /* clean-up */ PGPFreeKeyIter(kiter); PGPFreeKeyList(klist); PGPFreeKeySet(keySet); if (hash) PGPFreeHashContext(hash); PGPFreePublicKeyContext (publicKey); return rtn; } /* verify_signature */
PGPError pgpUserChooseAndDisableKeys( struct pgpmainBones *mainbPtr, PGPKeySetRef keysToDisable ) { struct pgpfileBones *filebPtr = mainbPtr->filebPtr; PGPError err; PGPKeyListRef keylist; PGPKeyIterRef keyiter; PGPKeyRef key; err = PGPOrderKeySet( keysToDisable, kPGPAnyOrdering, &keylist ); pgpAssertNoErr(err); err = PGPNewKeyIter( keylist, &keyiter ); pgpAssertNoErr(err); err = PGPKeyIterRewind( keyiter ); pgpAssertNoErr(err); err = PGPKeyIterNext( keyiter, &key ); while( key != NULL ) { PGPBoolean propData = FALSE; pgpShowKeyBrief( filebPtr, key ); err = PGPGetKeyBoolean( key, kPGPKeyPropIsDisabled, &propData ); pgpAssertNoErr( err ); if( propData ) { fprintf( filebPtr->pgpout, LANG("\nKey is already disabled.\n" "Do you want to enable this key again (y/N)? ")); if( getyesno( filebPtr,'n',0) ) { if( mainbPtr->workingKeyServer ) { PGPKeySetRef single,failed=NULL; err = PGPNewSingletonKeySet( key, &single ); pgpAssertNoErr(err); /* does it get re-enabled??*/ err = PGPDisableFromKeyServer( mainbPtr->workingKeyServer, single, &failed ); if( IsPGPError(err) ) { pgpShowError( filebPtr, err, 0,0); if( failed ) PGPFreeKeySet(failed); } PGPFreeKeySet( single ); } else { err = PGPEnableKey( key ); pgpAssertNoErr( err ); } } } else { fprintf( filebPtr->pgpout, LANG("\nDisable this key (y/N)? ")); if( getyesno( filebPtr,'n',0) ) { if( mainbPtr->workingKeyServer ) { PGPKeySetRef single,failed=NULL; err = PGPNewSingletonKeySet( key, &single ); pgpAssertNoErr(err); err = PGPDisableFromKeyServer( mainbPtr->workingKeyServer, single, &failed ); if( IsPGPError(err) ) { pgpShowError( filebPtr, err, 0,0); if( failed ) PGPFreeKeySet(failed); } PGPFreeKeySet( single ); } else { err = PGPDisableKey( key ); pgpAssertNoErr( err ); } } } err = PGPKeyIterNext( keyiter, &key ); } if( err == kPGPError_EndOfIteration ) err = kPGPError_NoErr; return err; }
LPSTR __cdecl _pgp_decrypt_key(LPCSTR szEncMsg, LPCSTR pgpKey) { LPSTR szPlainMsg = 0; DWORD dwPlainMsgLen; PGPUInt32 dwKeys; #if (PGP_WIN32 < 0x700) PGPKeySetRef PrivateKeyDB; if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey))) return 0; PGPCountKeys(PrivateKeyDB, &dwKeys); #else PGPKeyDBRef PrivateKeyDB; if (CheckPGPError(_pgp_import_key(&PrivateKeyDB,pgpKey))) return 0; PGPCountKeysInKeyDB(PrivateKeyDB, &dwKeys); #endif if(dwKeys==0) { #if (PGP_WIN32 < 0x700) PGPFreeKeySet(PrivateKeyDB); #else PGPFreeKeyDB(PrivateKeyDB); #endif return 0; } int iTry = 0; do { if (!pszPassphrase && PGPPassphraseDialog(pgpContext, PGPOUIOutputPassphrase(pgpContext, &pszPassphrase), PGPOLastOption(pgpContext)) == kPGPError_UserAbort) { iTry = 3; break; } /* #if (PGP_WIN32 < 0x700) PGPKeyListRef PrivateKeyList; PGPOrderKeySet(PrivateKeyDB, kPGPKeyIDOrdering, &PrivateKeyList); PGPKeyIterRef KeyIterRef; PGPNewKeyIter(PrivateKeyList, &KeyIterRef); PGPKeyRef PrivateKey; for(int i=0;i<dwKeys;i++) { PGPKeyIterNext(KeyIterRef, &PrivateKey); PGPOPassphraseIsValid(PrivateKey, PGPOPassphrase(pgpContext, pszPassphrase), PGPOLastOption(pgpContext)); } PGPFreeKeyList(PrivateKeyList); PGPFreeKeyIter(KeyIterRef); #else PGPKeyIterRef KeyIterRef; PGPNewKeyIterFromKeyDB(PrivateKeyDB, &KeyIterRef); PGPKeyDBObjRef KeyDBObjRef; for(int i=0;i<dwKeys;i++) { PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef); PGPOPassphraseIsValid(PrivateKey, PGPOPassphrase(pgpContext, pszPassphrase), PGPOLastOption(pgpContext)); } PGPFreeKeyIter(KeyIterRef); #endif */ PGPError err = PGPDecode(pgpContext, PGPOInputBuffer(pgpContext, szEncMsg, lstrlen(szEncMsg)), PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szPlainMsg, 16384, (PGPUInt32 *)&dwPlainMsgLen), #if (PGP_WIN32 < 0x700) PGPOKeySetRef(pgpContext, PrivateKeyDB), #else PGPOKeyDBRef(pgpContext, PrivateKeyDB), #endif PGPOPassphrase(pgpContext, pszPassphrase), PGPOLastOption(pgpContext)); if (CheckPGPError(err)) iTry = 3; else if (!dwPlainMsgLen) { PGPFreeData(pszPassphrase); pszPassphrase = 0; iTry++; } } while(!dwPlainMsgLen && iTry<3); #if (PGP_WIN32 < 0x700) PGPFreeKeySet(PrivateKeyDB); #else PGPFreeKeyDB(PrivateKeyDB); #endif if(iTry == 3) return 0; LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwPlainMsgLen+1); _pgp_memcpy(szMsg, szPlainMsg, dwPlainMsgLen); szMsg[dwPlainMsgLen] = 0; PGPFreeData((LPVOID)szPlainMsg); return szMsg; }
LPSTR __cdecl _pgp_encrypt_key(LPCSTR szPlainMsg, LPCSTR pgpKey) { LPSTR szEncMsg = 0; DWORD dwEncMsgLen; PGPUInt32 dwKeys; #if (PGP_WIN32 < 0x700) PGPKeySetRef PublicKey; if (CheckPGPError(_pgp_import_key(&PublicKey,pgpKey))) return 0; PGPCountKeys(PublicKey, &dwKeys); #else PGPKeyDBRef PublicKeyDB; if (CheckPGPError(_pgp_import_key(&PublicKeyDB,pgpKey))) return 0; PGPKeyIterRef KeyIterRef; PGPNewKeyIterFromKeyDB(PublicKeyDB, &KeyIterRef); PGPKeyDBObjRef PublicKey; PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &PublicKey); PGPCountKeysInKeyDB(PublicKeyDB, &dwKeys); #endif if(dwKeys==0) { #if (PGP_WIN32 < 0x700) PGPFreeKeySet(PublicKey); #else PGPFreeKeyIter(KeyIterRef); PGPFreeKeyDB(PublicKeyDB); #endif return 0; } PGPError err = PGPEncode(pgpContext, PGPOInputBuffer(pgpContext, szPlainMsg, lstrlen(szPlainMsg)), PGPOArmorOutput(pgpContext, TRUE), PGPOAllocatedOutputBuffer(pgpContext, (LPVOID *)&szEncMsg, 16384, (PGPUInt32 *)&dwEncMsgLen), #if (PGP_WIN32 < 0x700) PGPOEncryptToKeySet(pgpContext, PublicKey), #else PGPOEncryptToKeyDBObj(pgpContext, PublicKey), #endif PGPOVersionString(pgpContext, szVersionStr), PGPOLastOption(pgpContext)); #if (PGP_WIN32 < 0x700) PGPFreeKeySet(PublicKey); #else PGPFreeKeyIter(KeyIterRef); PGPFreeKeyDB(PublicKeyDB); #endif if (CheckPGPError(err)) return 0; LPSTR szMsg = (LPSTR) LocalAlloc(LPTR,dwEncMsgLen+1); _pgp_memcpy(szMsg, szEncMsg, dwEncMsgLen); szMsg[dwEncMsgLen] = 0; PGPFreeData((LPVOID)szEncMsg); return szMsg; }
PVOID __cdecl _pgp_select_keyid(HWND hDlg,LPSTR szKeyID) { #if (PGP_WIN32 < 0x700) PGPKeySetRef ContactKeyDB; #else PGPKeyDBRef ContactKeyDB; #endif PGPError err; err = PGPRecipientDialog(pgpContext, pgpKeyDB, TRUE, &ContactKeyDB, PGPOUIParentWindowHandle(pgpContext, hDlg), PGPOUIWindowTitle(pgpContext, "Select Contact's Key"), PGPOLastOption(pgpContext)); if (err == kPGPError_UserAbort) return 0; PGPUInt32 dwKeys; #if (PGP_WIN32 < 0x700) PGPCountKeys(ContactKeyDB, &dwKeys); #else PGPCountKeysInKeyDB(ContactKeyDB, &dwKeys); #endif if (!dwKeys) { return 0; } else if (dwKeys > 1) MessageBox(hDlg, "You selected more than one key. Only the first key will be used.", szModuleName, MB_ICONINFORMATION); static PGPKeyID KeyID; #if (PGP_WIN32 < 0x700) PGPKeyListRef ContactKeyList; PGPOrderKeySet(ContactKeyDB, kPGPKeyIDOrdering, &ContactKeyList); PGPKeyIterRef KeyIterRef; PGPNewKeyIter(ContactKeyList, &KeyIterRef); PGPKeyRef ContactKey; PGPKeyIterNext(KeyIterRef, &ContactKey); PGPGetKeyIDFromKey(ContactKey, &KeyID); PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID); PGPFreeKeyList(ContactKeyList); PGPFreeKeyIter(KeyIterRef); PGPFreeKeySet(ContactKeyDB); #else PGPKeyIterRef KeyIterRef; PGPNewKeyIterFromKeyDB(ContactKeyDB, &KeyIterRef); PGPKeyDBObjRef KeyDBObjRef; PGPKeyIterNextKeyDBObj(KeyIterRef, kPGPKeyDBObjType_Key, &KeyDBObjRef); PGPSize dwFilled; PGPGetKeyDBObjDataProperty(KeyDBObjRef, kPGPKeyProperty_KeyID, &KeyID, sizeof(PGPKeyID), &dwFilled); PGPGetKeyIDString(&KeyID, kPGPKeyIDString_Abbreviated, szKeyID); PGPFreeKeyIter(KeyIterRef); PGPFreeKeyDB(ContactKeyDB); #endif return (PVOID)&KeyID; }
BOOL KMRetrieveCertificate (PKEYMAN pKM) { PGPKeySetRef keysetKey = kInvalidPGPKeySetRef; PGPKeySetRef keysetReturned = kInvalidPGPKeySetRef; PGPUserIDRef userid = kInvalidPGPUserIDRef; PGPKeyRef key = kInvalidPGPKeyRef; PGPError err; if (KMSelectedFlags (pKM) == OBJECT_USERID) { userid = (PGPUserIDRef)KMFocusedObject (pKM); key = KMGetKeyFromUserID (pKM, userid); } else { key = (PGPKeyRef)KMFocusedObject (pKM); PGPGetPrimaryUserID (key, &userid); } PGPNewSingletonKeySet (key, &keysetKey); if (PGPRefIsValid (keysetKey)) { err = PGPclRetrieveCertificateFromServer ( pKM->Context, pKM->tlsContext, pKM->hWndParent, pKM->KeySetMain, keysetKey, userid, &keysetReturned); PGPFreeKeySet (keysetKey); } if (err == kPGPError_UserAbort) return FALSE; if (IsPGPError (err)) { PGPclErrorBox (pKM->hWndParent, err); } else { if (PGPRefIsValid (keysetReturned)) { PGPUInt32 u; PGPCountKeys (keysetReturned, &u); if (u > 0) { #if 0 // <- set to "1" to enable selective import dialog PGPclQueryAddKeys (pKM->Context, pKM->tlsContext, pKM->hWndParent, keysetReturned, pKM->KeySetDisp); #else if (pKM->ulOptionFlags & KMF_ENABLECOMMITS) { PGPAddKeys (keysetReturned, pKM->KeySetDisp); KMCommitKeyRingChanges (pKM); KMLoadKeyRingIntoTree (pKM, FALSE, TRUE, FALSE); InvalidateRect (pKM->hWndTree, NULL, TRUE); KMMessageBox (pKM->hWndParent, IDS_PGP, IDS_CERTRETRIEVALSUCCESS, MB_OK|MB_ICONINFORMATION); } #endif } else { KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_CERTRETRIEVALFAIL, MB_OK|MB_ICONEXCLAMATION); } PGPFreeKeySet (keysetReturned); } } return TRUE; }
BOOL KMGetFromServerInternal ( PKEYMAN pKM, BOOL bQueryAdd, BOOL bWarn, BOOL bGetSigners) { SERVERSTRUCT ss; PGPKeySetRef keysetGet = kInvalidPGPKeySetRef; PGPKeySetRef keysetFound = kInvalidPGPKeySetRef; PGPError err = kPGPError_NoErr; ss.context = pKM->Context; ss.pKM = pKM; ss.icount = 0; // get selected keys if ((KMFocusedObjectType (pKM) == OBJECT_KEY) || (KMFocusedObjectType (pKM) == OBJECT_USERID) || (!bGetSigners)) { KMGetSelectedKeys (pKM, &keysetGet, NULL); if (PGPRefIsValid (keysetGet)) { err = PGPclUpdateKeySetFromServer (pKM->Context, pKM->tlsContext, pKM->hWndParent, keysetGet, PGPCL_USERIDBASEDSERVER, pKM->KeySetMain, &keysetFound); PGPFreeKeySet (keysetGet); } } // get signing keys else { KMGetSelectedKeys (pKM, NULL, &ss.icount); if (ss.icount) { ss.pkeyidList = (PGPKeyID*)malloc ((ss.icount) * sizeof(PGPKeyID)); ss.icount = 0; ss.lpfnCallback = sAddKeyIDToList; TreeList_IterateSelected (pKM->hWndTree, &ss); err = PGPclSearchServerForKeyIDs (pKM->Context, pKM->tlsContext, pKM->hWndParent, ss.pkeyidList, ss.icount, PGPCL_DEFAULTSERVER, pKM->KeySetMain, &keysetFound); free (ss.pkeyidList); } } if (err == kPGPError_UserAbort) return FALSE; if (IsPGPError (err)) { if (bWarn) PGPclErrorBox (NULL, err); } else { if (PGPRefIsValid (keysetFound)) { PGPUInt32 u; PGPCountKeys (keysetFound, &u); if (u > 0) { if (bQueryAdd) { PGPclQueryAddKeys (pKM->Context, pKM->tlsContext, pKM->hWndParent, keysetFound, pKM->KeySetDisp); } else { if (pKM->ulOptionFlags & KMF_ENABLECOMMITS) { PGPAddKeys (keysetFound, pKM->KeySetDisp); PGPCommitKeyRingChanges (pKM->KeySetDisp); } } } else { KMMessageBox (pKM->hWndParent, IDS_CAPTION, IDS_SERVERSEARCHFAIL, MB_OK|MB_ICONEXCLAMATION); } PGPFreeKeySet (keysetFound); } } return TRUE; }
/*____________________________________________________________________________ All all the keys in the group (and its subgroups) to the keyset ____________________________________________________________________________*/ PGPError PGPNewKeySetFromGroup( PGPGroupSetRef set, PGPGroupID id, PGPKeySetRef masterSet, /* resolve key IDs using the set */ PGPKeySetRef * outKeys, PGPUInt32 * numKeysNotFound ) { PGPError err = kPGPError_NoErr; PGPGroupItemIterRef iter; PGPKeySetRef workingSet = kInvalidPGPKeySetRef; if ( NULL!=(int)( numKeysNotFound ) ) *numKeysNotFound = 0; if ( NULL!=(int)( outKeys ) ) *outKeys = kInvalidPGPKeySetRef; PGPValidatePtr( numKeysNotFound ); PGPValidatePtr( outKeys ); PGPValidateGroupSet( set ); PGPValidatePtr( masterSet ); err = PGPNewEmptyKeySet( masterSet, &workingSet ); if ( IsntPGPError( err ) ) { err = PGPNewGroupItemIter( set, id, kPGPGroupIterFlags_Recursive | kPGPGroupIterFlags_Keys, &iter ); } if ( IsntPGPError( err ) ) { PGPGroupItem item; while( IsntPGPError( err = PGPGroupItemIterNext( iter, &item ) ) ) { PGPKeyRef key; pgpAssert( item.type == kPGPGroupItem_KeyID ); err = sGroupItemToKey( &item, masterSet, &key ); if ( IsntPGPError( err ) ) { PGPKeySetRef singleKeySet; err = PGPNewSingletonKeySet( key, &singleKeySet ); if ( IsntPGPError( err ) ) { PGPKeySetRef oldKeys = workingSet; err = PGPUnionKeySets( workingSet, singleKeySet, &workingSet ); (void) PGPFreeKeySet( singleKeySet ); (void) PGPFreeKeySet( oldKeys ); } if ( IsPGPError( err ) ) break; } else if ( err == kPGPError_ItemNotFound ) { *numKeysNotFound += 1; } else { break; } } if ( err == kPGPError_EndOfIteration ) err = kPGPError_NoErr; PGPFreeGroupItemIter( iter ); } if ( IsPGPError( err ) && PGPKeySetRefIsValid( workingSet ) ) { (void) PGPFreeKeySet( workingSet ); workingSet = kInvalidPGPKeySetRef; } *outKeys = workingSet; return( err ); }
static PGPError MakeUnionOfEnumeratedSubsets( PGPKeySetRef set1, PGPKeySetRef set2, PGPKeySetRef * newSet) { PGPContextRef context = PGPGetKeySetContext(set1); RingSet const * ringSet = pgpKeyDBRingSet(set1->keyDB); EnumeratedSubsetPriv * priv1 = (EnumeratedSubsetPriv *)set1->priv; EnumeratedSubsetPriv * priv2 = (EnumeratedSubsetPriv *)set2->priv; EnumeratedSubsetPriv * priv; RingObject ** keyArray1 = priv1->keyArray; RingObject ** keyArray2 = priv2->keyArray; RingObject ** keyArray; PGPKeyID keyID1; PGPKeyID keyID2; PGPKeySetRef set; long in1; long in2; long out; int comparison; PGPError err = kPGPError_NoErr; *newSet = NULL; /* In case there's an error */ err = NewEnumeratedSubsetInternal(set1->keyDB, &set); if (IsPGPError(err)) return err; priv = (EnumeratedSubsetPriv *)set->priv; priv->numKeys = priv1->numKeys + priv2->numKeys; keyArray = (RingObject **)pgpContextMemAlloc(context, priv->numKeys * sizeof(RingObject *), 0); if (NULL==(int)(keyArray)) { PGPFreeKeySet(set); return kPGPError_OutOfMemory; } in1 = in2 = out = 0; /* Merge the two sorted arrays until we reach the end of one of them */ while (in1 < priv1->numKeys && in2 < priv2->numKeys) { /* * Check for duplicate keys. Note that if keyIDs aren't unique * then this won't necessarily remove duplicates. This isn't * a bug, because duplicates needn't be removed for correctness. * It is merely an optimization. */ if (keyArray1[in1] == keyArray2[in2]) { in2++; continue; } ringKeyID8(ringSet, keyArray1[in1], NULL, &keyID1); ringKeyID8(ringSet, keyArray2[in2], NULL, &keyID2); comparison = compareRawKeyIDs(&keyID1, &keyID2); if (comparison <= 0) keyArray[out++] = keyArray1[in1++]; else if (comparison > 0) keyArray[out++] = keyArray2[in2++]; } /* * Copy the rest of the remaining array. * (at most one of these loops will be non-empty) */ while (in1 < priv1->numKeys) keyArray[out++] = keyArray1[in1++]; while (in2 < priv2->numKeys) keyArray[out++] = keyArray2[in2++]; /* Shrink the resulting array, in case there were duplicates */ if (out < priv->numKeys) { priv->numKeys = out; err = pgpContextMemRealloc(context, (void **)&keyArray, out * sizeof(RingObject *), 0); pgpAssert(IsntPGPError(err)); /* Shrinking should never fail */ } priv->keyArray = keyArray; *newSet = set; return kPGPError_NoErr; }
BOOL KMSplitDropKeys ( PSPLITKEYSTRUCT psks, HANDLE hMem) { PGPKeySetRef keyset = NULL; PGPKeyListRef keylist = NULL; PGPKeyIterRef keyiter = NULL; LPSTR pMem = NULL; PGPError err; PGPKeyRef key; PGPKeyID keyid; BOOL bKeys; PGPBoolean bKeyIsUsable; size_t sLen; PSHAREHOLDERSTRUCT pshs; PGPPublicKeyAlgorithm alg; bKeys = FALSE; if (hMem) { pMem = GlobalLock (hMem); if (pMem) { sLen = lstrlen (pMem); err = PGPImportKeySet (psks->pKM->Context, &keyset, PGPOInputBuffer (psks->pKM->Context, pMem, sLen), PGPOLastOption (psks->pKM->Context)); if (IsPGPError (err)) goto SplitDropCleanup; err = PGPOrderKeySet (keyset, kPGPAnyOrdering, &keylist); if (IsPGPError (err)) goto SplitDropCleanup; err = PGPNewKeyIter (keylist, &keyiter); if (IsPGPError (err)) goto SplitDropCleanup; PGPKeyIterNext (keyiter, &key); while (key) { bKeyIsUsable = FALSE; PGPGetKeyNumber (key, kPGPKeyPropAlgID, &alg); PGPGetKeyIDFromKey (key, &keyid); // key must either not be RSA or RSA ops must be enabled PGPGetKeyBoolean (key, kPGPKeyPropCanEncrypt, &bKeyIsUsable); // key must not be the same one that is being split if (alg == psks->keyalgToSplit) { if (PGPCompareKeyIDs (&keyid, &(psks->keyidToSplit))==0) bKeyIsUsable = FALSE; } // key must not already be in list if (sIsKeyIDAlreadyInList (&keyid, alg, psks)) bKeyIsUsable = FALSE; if (bKeyIsUsable) { bKeys = TRUE; pshs = KMAlloc (sizeof(SHAREHOLDERSTRUCT)); if (pshs) { PGPSize size; pshs->bPublicKey = TRUE; pshs->pszPassphrase = NULL; pshs->uShares = 1; PGPGetPrimaryUserIDNameBuffer (key, sizeof(pshs->szUserID), pshs->szUserID, &size); PGPGetKeyIDFromKey (key, &(pshs->keyid)); PGPGetKeyNumber (key, kPGPKeyPropAlgID, &(pshs->keyalg)); if (sAddShareHolder (psks, pshs, KMDetermineUserIDIcon (key, NULL, NULL), psks->hwndList)) { psks->uTotalShares += pshs->uShares; SetDlgItemInt (psks->hwndDlg, IDC_TOTALSHARES, psks->uTotalShares, FALSE); SendMessage (psks->hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_THRESHOLD, EN_CHANGE), 0); } else { KMFree (pshs); } } } PGPKeyIterNext (keyiter, &key); } SplitDropCleanup : if (keyiter) PGPFreeKeyIter (keyiter); if (keylist) PGPFreeKeyList (keylist); if (keyset) PGPFreeKeySet (keyset); if (pMem) GlobalUnlock (hMem); } } return bKeys; }
BOOL AddKeyClipboard(HWND hwnd,void *PGPsc,void *PGPtls) { PGPContextRef context; char *pInput; DWORD dwInputSize; UINT ClipboardFormat; MYSTATE *ms; PGPtlsContextRef tls; PGPError err; // Check for files copied into clipboard from explorer if(OpenClipboard(hwnd)) { if(IsClipboardFormatAvailable(CF_HDROP)) { FILELIST *ListHead; HDROP hDrop; hDrop=(HDROP)GetClipboardData(CF_HDROP); ListHead=HDropToFileList(hDrop); if(ListHead!=0) { CloseClipboard(); return AddKeyFileList(hwnd, PGPsc,PGPtls,ListHead); } } CloseClipboard(); } err=kPGPError_NoErr; context=(PGPContextRef)PGPsc; tls=(PGPtlsContextRef)PGPtls; if(IsPGPError(PGPclEvalExpired(hwnd, PGPCL_ALLEXPIRED))) return FALSE; pInput=RetrieveClipboardData(hwnd, &ClipboardFormat, &dwInputSize); if(!pInput) { PGPscMessageBox (hwnd,IDS_PGPERROR,IDS_NOCLIPBOARDCONTENTS, MB_OK|MB_ICONSTOP); } else { if((ClipboardFormat != CF_TEXT)||(*pInput==0)) { PGPscMessageBox (hwnd,IDS_PGPERROR,IDS_NOCLIPBOARDTEXT, MB_OK|MB_ICONSTOP); } else { ms=(MYSTATE *)malloc(sizeof(MYSTATE)); if(ms) { memset(ms, 0x00, sizeof(MYSTATE) ); ms->context=context; ms->tlsContext=tls; ms->pInput=pInput; ms->dwInputSize=dwInputSize; ms->Operation=MS_ADDKEYCLIPBOARD; if(OpenRings(hwnd,context,&(ms->KeySet))) { err=SCProgressDialog(hwnd,DoWorkThread,ms, 0,"Adding Keys from Clipboard...", "","",IDR_PROGAVI); // If no PGP data in clipboard, warn.... if(!(ms->FoundPGPData)) PGPscMessageBox (hwnd,IDS_PGPERROR,IDS_NOPGPKEYSINCLIPBOARD, MB_OK|MB_ICONEXCLAMATION); PGPFreeKeySet(ms->KeySet); } free(ms); } } memset(pInput,0x00,dwInputSize); free(pInput); } if(IsPGPError(err)) return FALSE; return TRUE; }