void CNcdServerReportManager::UpdateInstallReportAccessPointL( const TUid& aClientUid, TInt aReportId, CNcdNode& aNode, CNcdNodeMetaData& aMetaData, CNcdReportManager& aReportManager, MCatalogsHttpSession& aHttpSession ) { DLTRACEIN(("")); CNcdPurchaseHistoryDb& db = Provider().NodeManager().PurchaseHistory(); CNcdPurchaseDetails* purchase = NcdPurchaseHistoryUtils::PurchaseDetailsLC( db, aClientUid, aMetaData.Identifier(), EFalse ); // Create origin identifier CNcdNodeIdentifier* originIdentifier = CNcdNodeIdentifier::NewL( aNode.Identifier().NodeNameSpace(), purchase->OriginNodeId(), aNode.Identifier().ClientUid() ); CleanupStack::PopAndDestroy( purchase ); CleanupStack::PushL( originIdentifier ); // Get report ap TUint32 apId( 0 ); TInt error = Provider().AccessPointManager().AccessPointIdL( *originIdentifier, MCatalogsAccessPointManager::EBrowse, aClientUid, apId ); TCatalogsConnectionMethod reportAp; if ( error == KErrNone ) { DLTRACE(( "Setting access point %d for reports", apId )) reportAp = TCatalogsConnectionMethod( apId, ECatalogsConnectionMethodTypeAccessPoint ); } if ( reportAp.iId == 0 ) { reportAp = aHttpSession.ConnectionManager().DefaultConnectionMethod(); } CleanupStack::PopAndDestroy( originIdentifier ); aReportManager.SetInstallReportAccessPoint( aReportId, reportAp ); }
Edge::Edge(const string& aName, Elem* aMan, MEnv* aEnv): Elem(aName, aMan, aEnv), iPoint1(NULL), iPoint2(NULL) { if (!iInit) Init(); SetEType(Type(), Elem::PEType()); SetParent(Type()); // Adding properties "Points" Elem* p1 = Provider()->CreateNode("Prop", "P1", this, iEnv); Elem* p2 = Provider()->CreateNode("Prop", "P2", this, iEnv); __ASSERT(p1 != NULL && p2 != NULL); TBool res = AppendComp(p1); __ASSERT(res); res = AppendComp(p2); __ASSERT(res); }
NS_IMETHODIMP TelephonyCall::HangUp() { if (mCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTING || mCallState == nsITelephonyProvider::CALL_STATE_DISCONNECTED) { NS_WARNING("HangUp on previously disconnected call ignored!"); return NS_OK; } nsresult rv = mCallState == nsITelephonyProvider::CALL_STATE_INCOMING ? mTelephony->Provider()->RejectCall(mCallIndex) : mTelephony->Provider()->HangUp(mCallIndex); NS_ENSURE_SUCCESS(rv, rv); ChangeStateInternal(nsITelephonyProvider::CALL_STATE_DISCONNECTING, true); return NS_OK; }
BOOL InfFile::Compare( const char *_pClassGUID, const char *_pClass, const char *_pProvider, BOOL showErrors) const { return (!_pClassGUID || (ClassGUID(showErrors) && !lstrcmpi(pClassGUID, _pClassGUID))) && (!_pClass || (Class(showErrors) && !lstrcmpi(pClass, _pClass))) && (!_pProvider || (Provider(showErrors) && !lstrcmpi(pProvider, _pProvider))); }
CNcdReportManager& CNcdServerReportManager::ReportManagerL( MCatalogsBaseMessage& aMessage ) { // Get current context MCatalogsContext& context( aMessage.Session().Context() ); // All the clients have their own report manager. TNcdProviderContext providerContext; Provider().GetProviderContextL( context, providerContext ); CNcdReportManager& reportManager( *providerContext.iReportManager ); return reportManager; }
com_ptr<IDataObject> PidlFixture::data_object_from_sandbox() { vector<cpidl_t> pidls = pidls_in_sandbox(); pidl_array<cpidl_t> array(pidls.begin(), pidls.end()); BOOST_REQUIRE_EQUAL(array.size(), 2U); com_ptr<IDataObject> data_object = new CSftpDataObject( numeric_cast<UINT>(array.size()), array.as_array(), sandbox_pidl().get(), Provider()); BOOST_REQUIRE(data_object); return data_object; }
NS_IMETHODIMP TelephonyCall::Resume() { if (mCallState != nsITelephonyProvider::CALL_STATE_HELD) { NS_WARNING("Resume non-held call ignored!"); return NS_OK; } nsresult rv = mTelephony->Provider()->ResumeCall(mCallIndex); NS_ENSURE_SUCCESS(rv,rv); ChangeStateInternal(nsITelephonyProvider::CALL_STATE_RESUMING, true); return NS_OK; }
NS_IMETHODIMP TelephonyCall::Hold() { if (mCallState != nsITelephonyProvider::CALL_STATE_CONNECTED) { NS_WARNING("Hold non-connected call ignored!"); return NS_OK; } nsresult rv = mTelephony->Provider()->HoldCall(mCallIndex); NS_ENSURE_SUCCESS(rv,rv); ChangeStateInternal(nsITelephonyProvider::CALL_STATE_HOLDING, true); return NS_OK; }
NS_IMETHODIMP TelephonyCall::Answer() { if (mCallState != nsITelephonyProvider::CALL_STATE_INCOMING) { NS_WARNING("Answer on non-incoming call ignored!"); return NS_OK; } nsresult rv = mTelephony->Provider()->AnswerCall(mCallIndex); NS_ENSURE_SUCCESS(rv, rv); ChangeStateInternal(nsITelephonyProvider::CALL_STATE_CONNECTING, true); return NS_OK; }
vector<cpidl_t> PidlFixture::pidls_in_sandbox() { CSftpDirectory dir(sandbox_pidl(), Provider()); com_ptr<IEnumIDList> pidl_enum = dir.GetEnum( SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN); vector<cpidl_t> pidls; cpidl_t pidl; while (pidl_enum->Next(1, pidl.out(), NULL) == S_OK) { pidls.push_back(pidl); } return pidls; }
TVerdict CVerifyServerCertStep::doTestStepPreambleL() { ConstructL(); CTlsCryptoAttributes* atts = Provider()->Attributes(); // set the session ID and "server" name (localhost) atts->iSessionNameAndID.iSessionId = SessionId(); atts->iSessionNameAndID.iServerName.iAddress = KLocalHost; atts->iSessionNameAndID.iServerName.iPort = 443; atts->idomainName.Copy(DomainNameL()); // No client authentication or dialogs for this test, please atts->iClientAuthenticate = EFalse; atts->iDialogNonAttendedMode = ETrue; return EPass; }
TVerdict CVerifySignatureStep::doTestStepL() { INFO_PRINTF1(_L("Calling TLS Provider to fetch cipher suites.")); // first we have to retrieve the available cipher suites TInt err = GetCipherSuitesL(); if (err != KErrNone) { SetTestStepResult(EFail); return TestStepResult(); } INFO_PRINTF1(_L("Calling TLS Provider to verify server certificate.")); CX509Certificate* cert = NULL; err = VerifyServerCertificateL(cert); CleanupStack::PushL(cert); if (err != KErrNone) { SetTestStepResult(EFail); return TestStepResult(); } // sign some random data, and call it a signature.... // doesn't have to be an actual digest, since we don't pass the data buffer. TBuf8<36> digest; CTlsCryptoAttributes* atts = Provider()->Attributes(); TInt index = KErrNotFound; for(TInt j=0;j<CipherSuites().Count();j++) { if(CipherSuites()[j] == atts->iCurrentCipherSuite) { index = j; break; } } User::LeaveIfError(index); TTLSCipherSuite suite = CipherSuites()[index]; // ajust the pseudo-digest size for sig algorithm switch(suite.CipherDetails()->iSigAlg) { case EDsa: atts->isignatureAlgorithm = EDsa; digest.SetLength(20); // only one SHA-1 in size break; case ERsaSigAlg: atts->isignatureAlgorithm = ERsaSigAlg; digest.SetLength(36); // MD5 + SHA-1 in size break; default: User::Leave(KErrUnknown); break; } TRandom::RandomL(digest); // get the server private key data CDecPKCS8Data* keyData = ServerPrivateKeyL(); CleanupStack::PushL(keyData); // sign the "digest" with the appropriate signature algorithm HBufC8* signature = NULL; switch(suite.CipherDetails()->iSigAlg) { case EDsa: { // we don't own this pointer CPKCS8KeyPairDSA* key = static_cast<CPKCS8KeyPairDSA*>(keyData->KeyPairData()); CDSASigner* signer = CDSASigner::NewLC(key->PrivateKey()); const CDSASignature* sig = signer->SignL(digest); CleanupStack::PushL(const_cast<CDSASignature*>(sig)); // DSA sig is an ASN.1 sequence of R followed by S CASN1EncSequence* sigSeq = CASN1EncSequence::NewLC(); CASN1EncBigInt* rAsn = CASN1EncBigInt::NewLC(sig->R()); sigSeq->AddAndPopChildL(rAsn); CASN1EncBigInt* sAsn = CASN1EncBigInt::NewLC(sig->S()); sigSeq->AddAndPopChildL(sAsn); signature = HBufC8::NewLC(sigSeq->LengthDER()); TPtr8 sigPtr = signature->Des(); sigPtr.SetLength(sigSeq->LengthDER()); TUint pos = 0; sigSeq->WriteDERL(sigPtr, pos); CleanupStack::Pop(signature); CleanupStack::PopAndDestroy(3, signer); //sig, sigSeq } break; case ERsaSigAlg: { // we don't own this pointer CPKCS8KeyPairRSA* key = static_cast<CPKCS8KeyPairRSA*>(keyData->KeyPairData()); CRSAPKCS1v15Signer* signer = CRSAPKCS1v15Signer::NewLC(key->PrivateKey()); const CRSASignature* sig = signer->SignL(digest); CleanupStack::PushL(const_cast<CRSASignature*>(sig)); signature = sig->S().BufferLC(); CleanupStack::Pop(signature); CleanupStack::PopAndDestroy(2, signer); // sig } break; default: User::Leave(KErrUnknown); break; } CleanupStack::PushL(signature); //Code to check VerifySignatureL() TBool expectedResult = ETrue; // security test - we may wish to munge the digest we pass to the method TBool tamperDigest(EFalse); GetBoolFromConfig(ConfigSection(), KTamperedDigest, tamperDigest); // ignore error if (tamperDigest) { expectedResult = EFalse; TRandom::RandomL(digest); } // now, invoke the verify signature method. TBool result = Provider()->VerifySignatureL(cert->PublicKey(), digest, *signature); if (result == expectedResult) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } //now invoke the verify signature method with invalid params and ensure that it fails accordingly TRandom::RandomL(digest); result = Provider()->VerifySignatureL(cert->PublicKey(), digest, *signature); expectedResult = EFalse; if (result == expectedResult) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(3, cert); // keyData, signature return TestStepResult(); }
TVerdict CDelayedGetSessionStep::doTestStepL() { TInt sessionDelay; sessionDelay = ReadGetSessionDelayL(); // first we have to retrieve the available cipher suites TInt err = GetCipherSuitesL(); TInt sessionIdLength(0) ; CTlsCryptoAttributes* tlsCryptoAttributes = Provider()->Attributes(); CX509Certificate* cert = NULL; err = VerifyServerCertificateL(cert); delete cert; // don't really need the cert err = CreateSessionL(); // ensure we succeeded if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Create Session failed! (Error %d)"), err); SetTestStepResult(EFail); } HBufC8* keyExMessage = NULL; err = ClientKeyExchange(keyExMessage); if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Key exchange failed! (Error %d)"), err); SetTestStepResult(EFail); } CleanupStack::PushL(keyExMessage); // Call ServerFinished to do the chache // derive the premaster secret from the key exchange method INFO_PRINTF1(_L("Deriving master secret.")); HBufC8* premaster = DerivePreMasterSecretL(*keyExMessage); CleanupStack::PopAndDestroy(keyExMessage); // compute the master secret from the premaster. CleanupStack::PushL(premaster); HBufC8* master = ComputeMasterSecretL(*premaster); CleanupStack::PopAndDestroy(premaster); CleanupStack::PushL(master); // do the caching ValidateServerFinishL(*master); CleanupStack::PopAndDestroy(master); err = VerifyGetSessionL(tlsCryptoAttributes->iSessionNameAndID.iServerName, sessionIdLength); // case A if (err != KErrNone || sessionIdLength == 0) { INFO_PRINTF1(_L("Case A Failed! GetSession failed!")); SetTestStepResult(EFail); return TestStepResult(); } RTimer timer; TRequestStatus timerStatus; timer.CreateLocal(); TTimeIntervalMicroSeconds32 waitTime( 1000000*(sessionDelay)); timer.After( timerStatus, waitTime); User::WaitForRequest(timerStatus); timer.Close(); err = 0; sessionIdLength = 0; err = VerifyGetSessionL(tlsCryptoAttributes->iSessionNameAndID.iServerName, sessionIdLength); // case B, delay should have caused session to be cleared. if ( sessionIdLength != 0) { INFO_PRINTF1(_L("Case B Failed! GetSession failed!")); SetTestStepResult(EFail); } return TestStepResult(); }
MCatalogsHttpSession& CNcdServerReportManager::HttpSessionL( MCatalogsContext& aContext ) { TNcdProviderContext providerContext; Provider().GetProviderContextL( aContext, providerContext ); return *providerContext.iHttpSession; }
void CNcdServerReportManager::NodeSetAsInstalledRequestL( MCatalogsBaseMessage& aMessage ) { HBufC8* input = HBufC8::NewLC( aMessage.InputLength() ); TPtr8 inputPtr = input->Des(); aMessage.ReadInput( inputPtr ); RDesReadStream inputStream( *input ); CleanupClosePushL( inputStream ); TInt errorCode( inputStream.ReadInt32L() ); CNcdNodeIdentifier* identifier( CNcdNodeIdentifier::NewLC( inputStream ) ); CNcdReportManager& reportManager( ReportManagerL( aMessage ) ); CNcdNode& node( Provider().NodeManager().NodeL( *identifier ) ); CNcdNodeMetaData& metaData( node.NodeMetaDataL() ); TNcdReportStatusInfo info( ENcdReportCreate, errorCode ); // Use the node identifier to identify the content in install report. // Node id uniquely identifies the node that contains contents // that will be installed. One node may contains multiple contents but // they are all thought as one bundle, in one operation. Also, notice that // multiple nodes can contain same metadata and same content. TNcdReportId reportId = reportManager.RegisterInstallL( identifier->NodeId(), metaData.Identifier(), info, metaData.Identifier().ServerUri(), metaData.Identifier().NodeNameSpace() ); // Set access point for report. UpdateInstallReportAccessPointL( aMessage.Session().Context().FamilyId(), reportId, node, metaData, reportManager, HttpSessionL( aMessage.Session().Context() ) ); // Set the final success information directly into the report instead of // reporting other install statuses here. TNcdReportStatus status( ENcdReportSuccess ); if ( errorCode == KErrNone ) { status = ENcdReportSuccess; } else if ( errorCode == KErrCancel ) { status = ENcdReportCancel; } else { status = ENcdReportFail; } // Create the status info object with the given info. info.iStatus = status; info.iErrorCode = errorCode; reportManager.ReportInstallStatusL( reportId, info ); CleanupStack::PopAndDestroy( identifier ); CleanupStack::PopAndDestroy( &inputStream ); CleanupStack::PopAndDestroy( input ); aMessage.CompleteAndRelease( KErrNone ); }
TVerdict CVerifySignatureStep::doTestStepPreambleL() { ConstructL(); CTlsCryptoAttributes* atts = Provider()->Attributes(); // read the "server" random HBufC8* random = ServerRandomL(); atts->iMasterSecretInput.iServerRandom.Copy(*random); delete random; // and the client random random = ClientRandomL(); atts->iMasterSecretInput.iClientRandom.Copy(*random); delete random; // we only support null compression... atts->iCompressionMethod = ENullCompression; // read the cipher suite for the test atts->iCurrentCipherSuite = CipherSuiteL(); // read the protocol version TTLSProtocolVersion version = ProtocolVersionL(); atts->iNegotiatedProtocol = version; atts->iProposedProtocol = version; // set the session ID and "server" name (localhost) atts->iSessionNameAndID.iSessionId = SessionId(); atts->iSessionNameAndID.iServerName.iAddress = KLocalHost; atts->iSessionNameAndID.iServerName.iPort = 443; atts->idomainName.Copy(DomainNameL()); // try and read DH params, this section may not exist RInteger gen; CleanupClosePushL(gen); RInteger prime; CleanupClosePushL(prime); TRAPD(err, ReadDHParamsL()); if (err == KErrNone) { atts->iPublicKeyParams->iKeyType = EDHE; // The params are: // 1 - Prime // 2 - Generator // 3 - generator ^ random mod prime atts->iPublicKeyParams->iValue1 = Prime().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue1); atts->iPublicKeyParams->iValue2 = Generator().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue2); atts->iPublicKeyParams->iValue3 = KeyPair()->PublicKey().X().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue3); } CleanupStack::PopAndDestroy(2, &gen); // prime // No client authentication or dialogs for this test, please atts->iClientAuthenticate = EFalse; atts->iDialogNonAttendedMode = ETrue; return EPass; }
TVerdict CEncryptStep::doTestStepPreambleL() { ConstructL(); CTlsCryptoAttributes* atts = Provider()->Attributes(); // Reads PSK values if included in INI file. ReadPskToBeUsedL(); // Reads if NULL ciphers suites are to be allowed from INI file. ReadUseNullCipher(); // read the "server" random HBufC8* random = ServerRandomL(); atts->iMasterSecretInput.iServerRandom.Copy(*random); delete random; // and the client random random = ClientRandomL(); atts->iMasterSecretInput.iClientRandom.Copy(*random); delete random; // we only support null compression... atts->iCompressionMethod = ENullCompression; // read the cipher suite for the test atts->iCurrentCipherSuite = CipherSuiteL(); // read the protocol version TTLSProtocolVersion version = ProtocolVersionL(); atts->iNegotiatedProtocol = version; atts->iProposedProtocol = version; // set the session ID and "server" name (localhost) atts->iSessionNameAndID.iSessionId = SessionId(); atts->iSessionNameAndID.iServerName.iAddress = KLocalHost; atts->iSessionNameAndID.iServerName.iPort = 443; atts->idomainName.Copy(DomainNameL()); // If cipher suite under test is uses PSK (Pre Shared Key) if(UsePsk()) { // Populates values for PSK atts->iPskConfigured = true; atts->iPublicKeyParams->iKeyType = EPsk; atts->iPublicKeyParams->iValue4 = PskIdentity(); atts->iPublicKeyParams->iValue5 = PskKey(); } else { // If cipher suite under test is NOT PSK TRAPD(err, ReadDHParamsL()); if (err == KErrNone) { atts->iPublicKeyParams->iKeyType = EDHE; // The params are: // 1 - Prime // 2 - Generator // 3 - generator ^ random mod prime atts->iPublicKeyParams->iValue1 = Prime().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue1); atts->iPublicKeyParams->iValue2 = Generator().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue2); atts->iPublicKeyParams->iValue3 = KeyPair()->PublicKey().X().BufferLC(); CleanupStack::Pop(atts->iPublicKeyParams->iValue3); } } // No client authentication or dialogs for this test, please atts->iClientAuthenticate = EFalse; atts->iDialogNonAttendedMode = ETrue; if(UseNullCipher()) { // Enables null cipher by setting appropiate parameter atts->iAllowNullCipherSuites = ETrue; } return EPass; }
TVerdict CKeyDerivationStep::doTestStepL() { INFO_PRINTF1(_L("Calling TLS Provider to fetch cipher suites.")); // first we have to retrieve the available cipher suites TInt err = GetCipherSuitesL(); if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Cannot retrieve supported cipher suites! (Error %d)"), err); SetTestStepResult(EFail); return TestStepResult(); } // verifies certificate if is not a PSK cipher suite if( !UsePsk() ) { // we have to verify the server certificate, to supply the certificate // and its parameters to the TLS provider. INFO_PRINTF1(_L("Calling TLS Provider to verify server certificate.")); CX509Certificate* cert = NULL; err = VerifyServerCertificateL(cert); delete cert; // make sure it completed sucessfully. if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Server Certificate did not verify correctly! (Error %d)"), err); SetTestStepResult(EFail); return TestStepResult(); } } INFO_PRINTF1(_L("Creating TLS Session.")); // now, create a session with the parameters set in the preamble err = CreateSessionL(); // ensure we succeeded if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Create Session failed! (Error %d)"), err); SetTestStepResult(EFail); return TestStepResult(); } INFO_PRINTF1(_L("Calling TLS session key exchange.")); HBufC8* keyExMessage = NULL; err = ClientKeyExchange(keyExMessage); if (err != KErrNone) { INFO_PRINTF2(_L("Failed! Key exchange failed! (Error %d)"), err); delete keyExMessage; SetTestStepResult(EFail); return TestStepResult(); } INFO_PRINTF1(_L("Deriving premaster secret.")); // derive the premaster secret from the key exchange method CleanupStack::PushL(keyExMessage); HBufC8* premaster = DerivePreMasterSecretL(*keyExMessage); CleanupStack::PopAndDestroy(keyExMessage); INFO_PRINTF1(_L("Deriving master secret.")); // compute the master secret from the premaster. CleanupStack::PushL(premaster); HBufC8* master = ComputeMasterSecretL(*premaster); CleanupStack::PopAndDestroy(premaster); CleanupStack::PushL(master); // now generate what we think the derived EAP key block should look like. TBuf8<192> ourEAP; CTlsCryptoAttributes* atts = Provider()->Attributes(); TBuf8<64> random; random.Append(atts->iMasterSecretInput.iClientRandom); random.Append(atts->iMasterSecretInput.iServerRandom); // make sure we're using TLS. This step makes no sense for SSL 3.0 if (atts->iNegotiatedProtocol.iMajor == 3 && atts->iNegotiatedProtocol.iMinor == 0) { INFO_PRINTF1(_L("Error! Cannot use this test step with SSLv3!")); User::Leave(KErrNotSupported); } INFO_PRINTF1(_L("Computing our derived EAP-TLS key.")); // compute the 128 byte block that uses the master secret as key. _LIT8(KEAPEncryptionLabel, "client EAP encryption"); HBufC8* block1 = CTls10PsuedoRandom::PseudoRandomL(*master, KEAPEncryptionLabel, random, 128); ourEAP.Append(*block1); delete block1; // compute the 64 byte IV block HBufC8* block2 = CTls10PsuedoRandom::PseudoRandomL(KNullDesC8, KEAPEncryptionLabel, random, 64); ourEAP.Append(*block2); delete block2; INFO_PRINTF1(_L("Calling TLS Session key derivation.")); // get the TLS provider's idea of what the EAP keyblock should be, and check they match. TBuf8<192> theirEAP; User::LeaveIfError(Session()->KeyDerivation(KEAPEncryptionLabel, atts->iMasterSecretInput, theirEAP)); if (ourEAP == theirEAP) { INFO_PRINTF1(_L("Test passed.")); SetTestStepResult(EPass); } else { INFO_PRINTF1(_L("Failed! EAP-TLS is corrupt!")); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(master); return TestStepResult(); }