void CCRSVerisignServer::SendCertificateRequest( PGPKeyRef inCAKey, PGPKeyRef inRequestKey, const void * inBuffer, PGPSize inBufferSize, void ** outBuffer, PGPSize * outBufferSize) { (void) inRequestKey; (void) inCAKey; try { InitOperation(); if (NULL==(int)(inBuffer)) { ThrowPGPError_(kPGPError_OptionNotFound); } *outBufferSize = PostCRSMessage(kPGPKeyServerState_Uploading, (mPath == 0) ? kDefaultPath : mPath, reinterpret_cast<PGPByte **>(outBuffer), inBufferSize, static_cast<const PGPByte *>(inBuffer)); } catch (...) { if (mCanceled) { ThrowPGPError_(kPGPError_UserAbort); } else { throw; } } }
void CKadLookup::Start() { InitOperation(); ASSERT(m_LookupID.IsValid()); ASSERT(m_StartTime == 0); m_StartTime = GetCurTick(); m_Status = eStarted; }
// ---------------------------------------------------------------------------- // Asynchronous version // ---------------------------------------------------------------------------- EXPORT_C void CContactMatcher::OpenStoreL( const CVPbkContactStoreUriArray& aUriArray, TRequestStatus& aStatus ) { InitOperationL( EOpenStore ); OpenStoreCommonL( aUriArray ); InitOperation( &aStatus ); if ( iApiMethodStatus != EFinished ) { iApiMethodStatus = EExecuting; } }
// ---------------------------------------------------------------------------- // Asynchronous version // ---------------------------------------------------------------------------- EXPORT_C void CContactMatcher::GetStoreContactL( const MVPbkContactLink& aLink, MVPbkStoreContact** aStoreContact, TRequestStatus& aStatus ) { InitOperationL( EGetStoreContact ); iResultStoreContact = aStoreContact; // Start asynchronous operation FreeOldOperation(); iOperation = iContactManager->RetrieveContactL( aLink, *this ); InitOperation( &aStatus ); if ( iApiMethodStatus != EFinished ) { iApiMethodStatus = EExecuting; } }
// ---------------------------------------------------------------------------- // Asynchronous version // ---------------------------------------------------------------------------- EXPORT_C void CContactMatcher::MatchPhoneNumberL( const TDesC& aData, TInt aDigits, CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags aFlags, CVPbkContactLinkArray& aLinkArray, TRequestStatus& aStatus ) { InitOperationL( EMatchPhoneNumber ); iResultContactLinkArray = &aLinkArray; // Start asynchronous matching MatchPhoneNumberCommonL( aData, aDigits, aFlags ); InitOperation( &aStatus ); if ( iApiMethodStatus != EFinished ) { iApiMethodStatus = EExecuting; } }
// ---------------------------------------------------------------------------- // Asynchronous version // ---------------------------------------------------------------------------- EXPORT_C void CContactMatcher::MatchDataL( const TDesC& aData, const MVPbkFieldTypeList& aFieldTypes, CVPbkContactLinkArray& aLinkArray, TRequestStatus& aStatus) { InitOperationL( EMatchData ); iResultContactLinkArray = &aLinkArray; // Start asynchronous matching FreeOldOperation(); iOperation = iContactManager->FindL(aData, aFieldTypes, *this); InitOperation( &aStatus ); if ( iApiMethodStatus != EFinished ) { iApiMethodStatus = EExecuting; } }
// ---------------------------------------------------------------------------- // Asynchronous version // ---------------------------------------------------------------------------- EXPORT_C void CContactMatcher::IsOwnNumberL( const TDesC& aNumber, TRequestStatus& aStatus ) { InitOperationL( EMatchPhoneNumber ); // Not interested in links, only whether found or not iResultContactLinkArray = NULL; iResultContactLinkCnt = 0; // Start asynchronous matching MatchPhoneNumberCommonL( aNumber, aNumber.Length(), CVPbkPhoneNumberMatchStrategy::EVPbkStopOnFirstMatchFlag ); InitOperation( &aStatus ); if ( iApiMethodStatus != EFinished ) { iApiMethodStatus = EExecuting; } }
void CHTTPXcertServer::SendCertificateRequest( PGPKeyRef inCAKey, PGPKeyRef inRequestKey, const void * inBuffer, PGPSize inBufferSize, void ** outBuffer, PGPSize * outBufferSize) { try { PGPError pgpErr; StPGPDataRef result; StPGPDataRef digest; PGPSize digestSize; StPGPDataRef cnk; PGPSize cnkSize; StPGPDataRef encodedCNK; PGPSize bufSize; StPGPDataRef post; PGPSize postSize; StPGPDataRef encodedBuffer; InitOperation(); if (! PGPKeyRefIsValid(inCAKey)) { ThrowPGPError_(kPGPError_OptionNotFound); } if (! PGPKeyRefIsValid(inRequestKey)) { ThrowPGPError_(kPGPError_OptionNotFound); } digest = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), GetMaxDigestedKeyBufferSize(), kPGPMemoryMgrFlags_None)); if (digest == 0) { ThrowPGPError_(kPGPError_OutOfMemory); }; digestSize = DigestKey(inCAKey, digest); encodedBuffer = static_cast<PGPByte *>( PGPNewData( PGPGetContextMemoryMgr(mContext), GetMaxBase64EncodedBufferSize(inBufferSize), kPGPMemoryMgrFlags_None)); if (encodedBuffer == 0) { ThrowPGPError_(kPGPError_OutOfMemory); }; bufSize = Base64Encode( static_cast<const PGPByte *>(inBuffer), inBufferSize, encodedBuffer); pgpErr = PGPGetKeyPropertyBuffer(inRequestKey, kPGPKeyPropX509MD5Hash, 0, 0, &cnkSize); ThrowIfPGPError_(pgpErr); cnk = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), cnkSize, kPGPMemoryMgrFlags_None)); if (cnk == 0) { ThrowPGPError_(kPGPError_OutOfMemory); } pgpErr = PGPGetKeyPropertyBuffer( inRequestKey, kPGPKeyPropX509MD5Hash, cnkSize, static_cast<PGPByte *>(cnk), &cnkSize); ThrowIfPGPError_(pgpErr); encodedCNK = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), GetMaxHexEncodedBufferSize(cnkSize), kPGPMemoryMgrFlags_None)); if (encodedCNK == 0) { ThrowPGPError_(kPGPError_OutOfMemory); } cnkSize = HexEncode(cnk, cnkSize, encodedCNK); cnk.Free(); post = static_cast<PGPByte *>( PGPNewData( PGPGetContextMemoryMgr(mContext), strlen(kCA) + digestSize + strlen(kCNK) + cnkSize + strlen(kPKCS10_input) + GetMaxURLEncodedBufferSize(bufSize), kPGPMemoryMgrFlags_None)); if (post == 0) { ThrowPGPError_(kPGPError_OutOfMemory); }; postSize = sprintf(post, "%s%s%s%s%s", kCA, static_cast<char *>(digest), kCNK, static_cast<char *>(encodedCNK), kPKCS10_input); digest.Free(); encodedCNK.Free(); postSize += URLEncode(encodedBuffer, bufSize, static_cast<char *>(post) + postSize); encodedBuffer.Free(); GetPost( kPGPKeyServerState_Uploading, (mPath == 0) ? kDefaultRequestPath : mPath, &result, kContentType, postSize, post); post.Free(); ProcessSendCertResult(result, outBuffer, outBufferSize); } catch (...) { if (mCanceled) { ThrowPGPError_(kPGPError_UserAbort); } else { throw; } } }
void CHTTPXcertServer::RetrieveCRL( PGPKeyRef inCAKey, PGPKeySetRef inCAsKeySet, PGPKeyRef inSigningKey, PGPByte * inPassphrase, PGPSize inPassphraseLength, PGPBoolean inIsPassphrase, void ** outBuffer, PGPSize * outBufferSize) { (void) inCAsKeySet; (void) inSigningKey; (void) inPassphrase; (void) inPassphraseLength; (void) inIsPassphrase; try { StPGPDataRef digest; PGPUInt32 digestSize; StPGPDataRef path; StPGPDataRef result; PGPError pgpErr; const char * prefix = (mPath == 0) ? kDefaultCRLRetrievalPath : mPath; InitOperation(); if (! PGPKeyRefIsValid(inCAKey)) { ThrowPGPError_(kPGPError_OptionNotFound); } digest = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), GetMaxDigestedKeyBufferSize(), kPGPMemoryMgrFlags_None)); if (digest == 0) { ThrowPGPError_(kPGPError_OutOfMemory); }; digestSize = DigestKey(inCAKey, digest); path = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), strlen(prefix) + digestSize + 1, kPGPMemoryMgrFlags_None)); if (path == 0) { ThrowPGPError_(kPGPError_OutOfMemory); } sprintf(path, "%s%s", prefix, static_cast<char *>(digest)); digest.Free(); GetPost(kPGPKeyServerState_Querying, path, &result); path.Free(); pgpErr = pgpEventKeyServer( mContext, mEventHandler, mEventHandlerData, this, kPGPKeyServerState_ProcessingResults); ThrowIfPGPError_(pgpErr); ProcessRetrieveCRLResult(result, outBuffer, outBufferSize); } catch (...) { if (mCanceled) { ThrowPGPError_(kPGPError_UserAbort); } else { throw; } } }
void CHTTPXcertServer::RetrieveCertificate( PGPFilterRef inSearchFilter, PGPKeyRef inSearchKey, PGPKeyRef inSigningKey, PGPByte * inPassphrase, PGPSize inPassphraseLength, PGPBoolean inIsPassphrase, void ** outBuffer, PGPSize * outBufferSize) { (void) inSearchKey; (void) inSigningKey; (void) inPassphrase; (void) inPassphraseLength; (void) inIsPassphrase; try { StPGPDataRef query; StPGPDataRef path; StPGPDataRef result; PGPError pgpErr; const char * prefix = (mPath == 0) ? kDefaultRetrievalPath : mPath; InitOperation(); if (! PGPFilterRefIsValid(inSearchFilter)) { ThrowPGPError_(kPGPError_OptionNotFound); } pgpErr = PGPNetToolsCAHTTPQueryFromFilter( inSearchFilter, static_cast<char **>(static_cast<void *>(&query))); ThrowIfPGPError_(pgpErr); path = static_cast<PGPByte *>(PGPNewData( PGPGetContextMemoryMgr(mContext), strlen(prefix) + strlen(query) + 1, kPGPMemoryMgrFlags_None)); if (path == 0) { ThrowPGPError_(kPGPError_OutOfMemory); } sprintf(path, "%s%s", prefix, static_cast<char *>(query)); query.Free(); GetPost(kPGPKeyServerState_Querying, path, &result); path.Free(); pgpErr = pgpEventKeyServer( mContext, mEventHandler, mEventHandlerData, this, kPGPKeyServerState_ProcessingResults); ThrowIfPGPError_(pgpErr); ProcessRetrieveCertResult(result, outBuffer, outBufferSize); } catch (...) { if (mCanceled) { ThrowPGPError_(kPGPError_UserAbort); } else { throw; } } }
void CCRSVerisignServer::PackageAndSendCRSMessage( PGPExportFormat inExportFormat, PGPOutputFormat inOutputFormat, PGPKeyRef inKey, PGPKeyRef inSigningKey, PGPByte * inPassphrase, PGPSize inPassphraseLength, PGPBoolean inIsPassphrase, void ** outBuffer, PGPSize * outBufferSize) { PGPError pgpErr; StPGPKeySetRef singleKeySet; StPGPDataRef buffer; PGPSize bufSize; StPGPDataRef crsMessage; PGPSize crsMessageSize; InitOperation(); if (! PGPKeyRefIsValid(inKey)) { ThrowPGPError_(kPGPError_OptionNotFound); } if (! PGPKeyRefIsValid(inSigningKey)) { ThrowPGPError_(kPGPError_OptionNotFound); } if (NULL==(int)(inPassphrase)) { ThrowPGPError_(kPGPError_OptionNotFound); } pgpErr = PGPNewSingletonKeySet(inKey, &singleKeySet); ThrowIfPGPError_(pgpErr); pgpErr = PGPExportKeySet( singleKeySet, PGPOExportFormat( mContext, inExportFormat), PGPOAllocatedOutputBuffer( mContext, (void **) &buffer, MAX_PGPSize, &bufSize), PGPOLastOption(mContext)); ThrowIfPGPError_(pgpErr); singleKeySet.Free(); pgpErr = PGPEncode( mContext, PGPOSignWithKey( mContext, inSigningKey, (inIsPassphrase) ? PGPOPassphraseBuffer(mContext, inPassphrase, inPassphraseLength) : PGPOPasskeyBuffer(mContext, inPassphrase, inPassphraseLength), PGPOLastOption(mContext)), PGPOInputBuffer(mContext, static_cast<PGPByte *>(buffer), bufSize), PGPOAllocatedOutputBuffer( mContext, (void **) &crsMessage, MAX_PGPSize, &crsMessageSize), PGPOOutputFormat( mContext, inOutputFormat), PGPOLastOption(mContext)); ThrowIfPGPError_(pgpErr); buffer.Free(); *outBufferSize = PostCRSMessage(kPGPKeyServerState_Querying, (mPath == 0) ? kDefaultPath : mPath, reinterpret_cast<PGPByte **>(outBuffer), crsMessageSize, static_cast<const PGPByte *>(crsMessage)); }