Example #1
0
// -----------------------------------------------------------------------------
// CRoapParser::OnContentL
// -----------------------------------------------------------------------------
//
void CRoapParser::OnContentL(
    const TDesC8& aBytes,
    TInt /*aErrorCode*/)
    {
    if ( !iContent )
        {
        iContent = HBufC8::NewL(aBytes.Size());
        *iContent = aBytes;
        }
    else
        {
        iContent = iContent->ReAllocL(iContent->Size() + aBytes.Size());
        TPtr8 c(iContent->Des());
        c.Append(aBytes);
        }
    }
Example #2
0
void CHMAC::InitialiseL(const TDesC8& aKey)
	{
	InitBlockSizeL();
	// initialisation
	if (iDigest)
		{
		iDigest->Reset();
		if( (TUint32)aKey.Size() > iBlockSize)
			{
			iInnerPad = iDigest->Final(aKey);
			}
		else 
			{
			iInnerPad = aKey;
			}
			
		TUint i;
		for (i=iInnerPad.Size();i<iBlockSize;i++)
			iInnerPad.Append(0);

		iOuterPad=iInnerPad;

		const TUint8 Magic1=0x36, Magic2=0x5c;
		for (i=0;i<iBlockSize;i++)
		{
			iInnerPad[i]^=Magic1;
			iOuterPad[i]^=Magic2;
		}
		//start inner hash
		iDigest->Hash(iInnerPad);
		}
	}
Example #3
0
EXPORT_C TBool TBtreeInlineIndexOrg::Update(TAny *aNode,TInt aPos,const TDesC8& anEntry) const
	{
	__ASSERT_DEBUG(anEntry.Size()<=KeySize(),Panic(EBadEntrySize));
	__ASSERT_DEBUG(aPos<Node(aNode)->iHead.iCount,Panic(EBadEntryPos));
	Mem::Copy(Entry(Node(aNode),aPos)->iKey,anEntry.Ptr(),KeySize());
	return ETrue;
	}
// -----------------------------------------------------------------------------
// BufferToArrayL
// Created buffer will contain <amount of elements:int32, element data1, element data2...>
// -----------------------------------------------------------------------------
//
LOCAL_C RPointerArray<HBufC8> BufferToArrayL( TDesC8& aBuffer )
    {
    TInt32 count = 0;
    HBufC8* element = NULL;
    RPointerArray<HBufC8> array;
    TInt size = aBuffer.Size();
    RMemReadStream stream( (TAny*)( aBuffer.Ptr() ), size );
    CleanupClosePushL( stream );

    CleanupResetAndDestroyPushL( array );

    // amount of elements
    count = stream.ReadInt32L();

    // for each in RPointerArray
    for ( TInt i = 0; i < count; i++ )
        {
        // Read the element and append it to array
        element = HBufC8::NewLC( stream, KMaxElementLength );
        array.AppendL( element );
        CleanupStack::Pop( element );
        }

    CleanupStack::Pop( &array );
    CleanupStack::PopAndDestroy( &stream );

    return array;
    }
Example #5
0
void CRC2::SetKey(const TDesC8& aKey, TInt aEffectiveKeyLenBits)
	{
	TUint keyLen = (TUint)aKey.Size();

	iKey.Copy(aKey);
	iEffectiveKeyLenBits = aEffectiveKeyLenBits;

	TUint8 L[KRC2MaxKeySizeBytes];	
	Mem::Copy((TUint8*)&L[0], (TUint8*)&aKey[0], keyLen);

	TInt maxKeySizeBytes = (TInt)KRC2MaxKeySizeBytes;
	TInt expandedKeyLen = (TInt)KRC2ExpandedKeyLen;
	TInt i = keyLen;
	for (; i < maxKeySizeBytes; i++)
		{
		L[i] = RC2_TABLE::PITABLE[(L[i-1] + L[i-keyLen]) & 255];
		}

	TUint T8 = (aEffectiveKeyLenBits+7) / 8;
	TUint8 TM = (TUint8)(255 >> ((8-(iEffectiveKeyLenBits%8))%8));
	L[128-T8] = RC2_TABLE::PITABLE[L[128-T8] & TM];

	for (i=127-T8; i>=0; i--)
		L[i] = RC2_TABLE::PITABLE[L[i+1] ^ L[i+T8]];

	for (i=0; i < expandedKeyLen; i++)
		iK[i] = (TUint16)(L[2*i] + (L[2*i+1] << 8));
	}
void CCheckedCertStore::DoAddL(	const TDesC& aLabel,
								TCertificateFormat aFormat,
                               	TCertificateOwnerType aCertificateOwnerType, 
                               	const TKeyIdentifier* aSubjectKeyId,
                               	const TKeyIdentifier* aIssuerKeyId,
                               	const TDesC8& aCert, 
                               	const TBool aDeletable,
                               	TRequestStatus& aStatus)
    {
    
    //	Store caller parameters for later use
	    aStatus			= KRequestPending;
	    iCallerStatus	= &aStatus;
	    iFormat 	 	= aFormat;
	    iCertificateOwnerType = aCertificateOwnerType;
	    iSubjectKeyId	= aSubjectKeyId;
	    iIssuerKeyId	= aIssuerKeyId;
		iDeletable  	= aDeletable;

	// Store (copy)  aCert (cert data) into iCertificate[:HBufC8]
	    assert(!iCertificate);
	    iCertificate = HBufC8::NewMaxL(aCert.Size());
	    TPtr8 theCert(iCertificate->Des());
	    theCert.FillZ();
	    theCert.Copy(aCert);

	// Store (copy) aLabel (cert label) into iCertLabel[:HBufC]
	    assert(!iCertLabel);
	    iCertLabel = HBufC::NewMaxL(aLabel.Length());
	    TPtr theLabel(iCertLabel->Des());
	    theLabel.FillZ();
	    theLabel.Copy(aLabel);

    //	Checks subject key ID with certificate data, and sets up key filter
    //	which is used later to determine whether there is a key with the
    //	appropriate subject and thus, if it is OK to add the certificate	
	    ComputeAndCheckSubjectKeyIdL();

    //	Is keystore checking required? Only if a user certificate
    if (EUserCertificate==aCertificateOwnerType)
		{
        	InitialiseKeyStoreL(EInitKeyStoreForAdd);
		}
    else
		{
        iState = EAdd;
        
        // try new method first
        iWritableCertStore->Add( *iCertLabel,			// call new method
        						 iFormat,
        						 iCertificateOwnerType,
                                 iSubjectKeyId,
                                 iIssuerKeyId,
                                 *iCertificate,
                                 iDeletable,			// with deletable param
                                 iStatus );                    
        SetActive();
		}
	}
Example #7
0
TPtrC8 CMD4Impl::Hash(const TDesC8& aMessage)
	{
	DoUpdate(aMessage.Ptr(),aMessage.Size());
	StoreState();
	DoFinal();
	RestoreState();
	return iHash;
	}		
// --------------------------------------------------------------------------------------
// Appends given string to output buffer. If the serializer's 
// output type is file, the output buffer is released to the output stream 
// after reaching a specified threshold and the output buffer is cleared.
// --------------------------------------------------------------------------------------
//
void CXmlEngSerializerXOP::BufferedWriteL(const TDesC8& aString, TBool aFlush)
	{
	if(aFlush)
		{
		if(iOutputBufferPtr->Size() > 0)
			{
			if( iTmpOutputStream->Write(iOutputBuffer->Des()) == -1)
				{
				User::Leave(iTmpOutputStream->CheckError());
				}
			iOutputBufferPtr->Delete(0, iOutputBufferPtr->Size());							
			}
		if( iTmpOutputStream->Write(aString) == -1)
			{
			User::Leave(iTmpOutputStream->CheckError());
			}												
		iDataWritten += aString.Size();
		return;			
		}

	// first, check if data is in the buffer and added string will not fit
	// -> flush buffer
	if(iOutputBufferPtr->Size() > 0 &&
	   iOutputBufferPtr->Size() + aString.Size() > iOutputBufferPtr->MaxSize())
		{
		if( iTmpOutputStream->Write(iOutputBuffer->Des()) == -1)
			{
			User::Leave(iTmpOutputStream->CheckError());
			}
		iOutputBufferPtr->Delete(0, iOutputBufferPtr->Size());
		}
	// if string alone doesn't fit in the buffer -> save string
	if(aString.Size() > iOutputBufferPtr->MaxSize())
		{
		if( iTmpOutputStream->Write(aString) == -1)
			{
			User::Leave(iTmpOutputStream->CheckError());
			}
		}
	// if string fits into the buffer -> append it
	else
		{
		iOutputBufferPtr->Append(aString);
		}
	iDataWritten += aString.Size();					
	}
// -----------------------------------------------------------------------------
// CG711PayloadFormatRead::ConfigurePayloadFormatL
// Configure payload decoding parameters.
// -----------------------------------------------------------------------------
//
void CG711PayloadFormatRead::ConfigurePayloadFormatL( const TDesC8& aConfigParams )
{
    DP_G711_READ( "CG711PayloadFormatRead::ConfigurePayloadFormatL" );

    __ASSERT_ALWAYS( aConfigParams.Size() == sizeof( TMccCodecInfo ),
                     User::Leave( KErrArgument ) );

    TMccCodecInfoBuffer infoBuffer;
    infoBuffer.Copy( aConfigParams );

    if ( !infoBuffer() .iIsUpdate )
    {
        iCInfo = infoBuffer();
        // Calculates frames/packet, frame size and frame time interval
        iFramesPerPacket = TInt8( iCInfo.iMaxPtime / iCInfo.iHwFrameTime );
        iCInfo.iFrameSize =
            static_cast<TUint>( KDefaultSampleRateInkHz * iCInfo.iHwFrameTime );
        iFrameTimeInterval = TInt64( iCInfo.iHwFrameTime );

        // Create two frame buffers used in data transfer with datapath.
        // Space for two byte additional header needed by HW codec is reserved.
        iFrameBufferOne =
            CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength );
        iFrameBufferTwo =
            CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength );

        // PayloadBuffer contains data received from network
        TInt plSize = iCInfo.iFrameSize * iFramesPerPacket;
        DP_G711_READ3( "CG711PayloadFormatRead::ConfigurePayloadFormatL \
FramesPerPacket: %d, FrameSize: %d" , iFramesPerPacket, iCInfo.iFrameSize );

        if ( EGenRedUsed == iCInfo.iAlgoUsed )
        {
            DP_G711_READ2( "CG711PayloadFormatRead::ConfigurePayloadFormatL, RED LEVEL: %d",
                           iCInfo.iRedundancyCount );

            if ( iCInfo.iRedundancyCount )
            {
                plSize *= iCInfo.iRedundancyCount;
            }

            CPayloadFormatRead* redDecoder
                = static_cast<CPayloadFormatRead*>( iClip );

            TMccRedPayloadReadConfig config;
            config.iRedBlockCount = iCInfo.iRedundancyCount;
            config.iMaxPayloadSize = iCInfo.iFrameSize * iFramesPerPacket;
            config.iNumOfEncodings = 1;
            config.iRedPayloadType = iCInfo.iRedundantPayload;
            config.InitPayloadTypes();
            config.iEncPayloadTypes[0] = iCInfo.iPayloadType;
            TMccRedPayloadReadPckg pckg( config );
            redDecoder->ConfigurePayloadFormatL( pckg );
        }

        iSourceBuffer = CreateClipBufferL( plSize, iSourceBufOwnership );
    }
Example #10
0
TInt RFileX::Write(const TDesC8& aDes)
//
// Write and update the file pos
//
	{

	TheCurrentBase+=aDes.Size();
	return(RFile::Write(aDes));
	}
TInt CTestFileOutputStream::Write(const TDesC8 &aBuffer)
	{
	TRAP(iError,WriteL(aBuffer));
	if(iError)
	    {
    	return -1;
	    }
	return aBuffer.Size();
	};
Example #12
0
TPtrC8 CMD4Impl::Final(const TDesC8& aMessage)
	{
	if (aMessage!=KNullDesC8())
		{
		DoUpdate(aMessage.Ptr(),aMessage.Size());			
		}
	DoFinal();
	Reset();
	return iHash;
	}
Example #13
0
TPtrC8 CMD5Impl::Hash(const TDesC8& aMessage)
	{
	
	TPtrC8 ptr(KNullDesC8());
	DoUpdate(aMessage.Ptr(),aMessage.Size());
	StoreState();
	DoFinal();
	ptr.Set(iHash);
	RestoreState();
	return ptr;
	}		
// -----------------------------------------------------------------------------
// CAmrPayloadDecoder::CompareBuffers
// Compares contents of two buffers.
// -----------------------------------------------------------------------------
//
TBool CAmrPayloadDecoder::CompareBuffers( const TDesC8& aBuffer,
                                          const TAmrFrame& aFrameToCmp, 
                                          TInt aOctetsToCmp ) const
    {
    DP_AMR_DECODE( "CAmrPayloadDecoder::CompareBuffers" );

    TBool isSame( ETrue );
    if ( EAmrFrameNoData == aFrameToCmp.iFrameType )
        {
        if ( aBuffer.Size() )
            {
            return EFalse;
            }
        else
            {
            return ETrue;
            }
        }
    else
        {
        if ( 0 == aBuffer.Size() )
            {
            return EFalse;
            }
        }        

    TStreamDecoder decoder;
    decoder.Initialize( aFrameToCmp.iFrameData, 0, aFrameToCmp.iBitIndex );
    
    TInt octetsToCmp = aOctetsToCmp < aBuffer.Size() ? aOctetsToCmp : aBuffer.Size();
    for ( TInt i = 0; i < octetsToCmp && isSame; i++ )
        {
        TUint8 val = TUint8( decoder.Decode( KBitsIn1Byte ) );
        if ( aBuffer[i] != val )
            {
            isSame = EFalse;
            }
        }
       
    return isSame;
    }
Example #15
0
TPtrC8 CMD5Impl::Final(const TDesC8& aMessage)
	{
	TPtrC8 ptr(KNullDesC8());
	if (aMessage!=KNullDesC8())
		{
		DoUpdate(aMessage.Ptr(),aMessage.Size());			
		}
	DoFinal();
	ptr.Set(iHash);
	Reset();
	return ptr;
	}
void XQAccessPointManagerPrivate::asciiToHex(const TDesC8& aSource, 
                                               HBufC8*& aDest)
{
    _LIT(hex, "0123456789ABCDEF");
    TInt size = aSource.Size();
    TPtr8 ptr = aDest->Des();
    for (TInt ii = 0; ii < size; ii++) {
        TText8 ch = aSource[ii];
        ptr.Append( hex()[(ch/16)&0x0f] );
        ptr.Append( hex()[ch&0x0f] );
    }
}
// -----------------------------------------------------------------------------
// CRemConKeyEvent::ConstructL
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CRemConKeyEvent::ConstructL( const TRemConKeyEventData& aKeyEvent, 
    const TUid& aInterfaceUID,
    const TUint& aOperationID,
    TDesC8& aParameter )
    {
    COM_TRACE_2( "[AccFW:RemConConverter] CRemConKeyEvent::ConstructL( %d, %d )", aKeyEvent, aOperationID );

	iKeyEvent = aKeyEvent;
    iInterfaceUID = aInterfaceUID;
    iOperationID = aOperationID;
    iParameter = HBufC8::NewL( aParameter.Size() );
    iParameter->Des().Copy( aParameter );
    }
// -----------------------------------------------------------------------------
// CUpnpHttpFileAccess::SaveL
//
// -----------------------------------------------------------------------------
//
TInt CUpnpHttpFileAccess::SaveL( TDesC8& aBuffer )
{
    LOGS1( "%i, CUpnpHttpFileAccess::SaveL()", this );
    if ( iIsDeleted )
    {
        LOGS( "file closed" );
        return KErrGeneral;
    }
    LOGS( "file not closed" );
    TInt toWrite = (EncodingMode( )|| (TransferTotal( ) == KErrNotFound ) )
                   ? aBuffer.Length( ) : (TransferTotal( )- iBytesWritten);

    if ( aBuffer.Size( ) < toWrite )
    {
        toWrite = aBuffer.Size( );
    }

    if ( UpnpFileUtil::CheckDiskSpaceShortL( iFileToServe->Des( ), toWrite,
            iFsSession ) )
    {
        DeleteFile( );
        return EHttpInsufficientStorage;
    }

    TInt error = KErrNone;

    // At first time iPosInFile == 0 or range offset, see ConstructL, and the next time
    // saving will continue at stopped point.

    error = iFile.Write( iPosInFile, aBuffer.Right( toWrite ) );
    if ( error != KErrNone )
    {
        return error;
    }
    iPosInFile += toWrite;
    iBytesWritten += toWrite;
    return KErrNone;

}
Example #19
0
EXPORT_C TBool TBtreeInlineLeafOrg::Insert(TAny *aNode,TInt aPos,const TDesC8& anEntry) const
	{
	SNode* const pn=Node(aNode);
	__ASSERT_DEBUG(aPos<=pn->iHead.iCount,Panic(EBadEntryPos));
	if (pn->iHead.iCount==iMaxEntries)
		return EFalse;
	TUint8* pe=Entry(pn,aPos);
	Mem::Copy(pe+iEntrySize,pe,iEntrySize*(pn->iHead.iCount-aPos));
	TInt size=anEntry.Size();
	__ASSERT_ALWAYS(size<=iEntrySize,Panic(EBadEntrySize));
	Mem::Copy(pe,anEntry.Ptr(),size);
	++pn->iHead.iCount;
	return ETrue;
	}
Example #20
0
/**
    Write data to the media through the directory cache.
    
    @param  aPos    linear media position to start writing with
    @param  aDes    data to write
*/
void CMediaWTCache::WriteL(TInt64 aPos,const TDesC8& aDes)
    {

#ifdef _DEBUG
    if(iCacheDisabled)
        {//-- cache is disabled for debug purposes
        User::LeaveIfError(iDrive.WriteCritical(aPos,aDes));
        return;
        }
#endif //_DEBUG

          TUint32 dataLen = aDes.Size();
    const TUint8* pData   = aDes.Ptr();
    const TUint32 PageSz  = PageSize(); //-- cache page size

    //-- find out if aPos is in cache. If not, find a spare page and read data there
    TInt nPage = FindOrGrabReadPageL(aPos);
    CWTCachePage* pPage = iPages[nPage];

    const TUint32 bytesToPageEnd = (TUint32)(pPage->iStartPos+PageSize() - aPos); //-- number of bytes from aPos to the end of the page
//    __PRINT5(_L("CMediaWTCache::WriteL: aPos=%lx, aLength=%x, page:%lx, pageSz:%x, bytesToPageEnd=%x"), aPos, dataLen, pPage->iStartPos, PageSz, bytesToPageEnd);
    if(dataLen <= bytesToPageEnd)
        {//-- data section completely fits to the cache page
        Mem::Copy(pPage->PtrInCachePage(aPos), pData, dataLen);   //-- update cache

        //-- make small write a multiple of a write granularity size (if it is used at all)
        //-- this is not the best way to use write granularity, but we would need to refactor cache pages code to make it normal
        TPtrC8 desBlock(aDes);
        
        if(iWrGranularityLog2)
            {//-- write granularity is used
            const TInt64  newPos = (aPos >> iWrGranularityLog2) << iWrGranularityLog2; //-- round position down to the write granularity size
            TUint32 newLen = (TUint32)(aPos - newPos)+dataLen;  //-- round block size up to the write granularity size
            newLen = RoundUp(newLen, iWrGranularityLog2);
       
            const TUint8* pd = pPage->PtrInCachePage(newPos);
            desBlock.Set(pd, newLen);
            aPos = newPos;
            }


        //-- write data to the media
        const TInt nErr = iDrive.WriteCritical(aPos, desBlock); 
        if(nErr != KErrNone)
            {//-- some serious problem occured during writing, invalidate cache.
            InvalidateCache();
            User::Leave(nErr);
            }

        }
void CHWRMVibraCommonService::ProcessResponseL( TInt /* aCommandId */,  TUint8 aTransId, TDesC8& aData, TBool aTimeout)
#endif
    {
    COMPONENT_TRACE4(_L( "HWRM Server - CHWRMVibraCommonService::ProcessResponseL(0x%x, 0x%x, <data>, 0x%x)" ), aCommandId, aTransId, aTimeout );

    TInt pluginErr(KErrNone);  // Error came from plugin as data (or timeout). Used to complete RMessage.
    TInt contextErr(KErrNone);  // Error in context, i.e. bad handle or descriptor. Used to leave.

    // Unpack the package. All vibra messages contain only possible error code
    // in return package.
    if ( !aTimeout && aData.Size() != sizeof(TInt) )
        {
        COMPONENT_TRACE3(_L( "HWRM Server - CHWRMVibraCommonService::ProcessResponseL - Data size mismatch, expected: 0x%x, got 0x%x" ), sizeof(TInt), aData.Size() );
        contextErr = KErrBadDescriptor;
        pluginErr = KErrBadDescriptor;
        }      
    else
        {        
        // If response was caused by timeout, set that as the error.
        // Timeout handled this way instead of just returning KErrTimeout in aData because
        // aData format is not known in plugin handler and in theoretically some new commands
        // may also return different response than just error code in future.
        if ( aTimeout )
            {
            pluginErr = KErrTimedOut;            
            }
        else
            {
            HWRMVibraCommand::TErrorCodeResponsePackage errPckg;
            errPckg.Copy(aData);
            pluginErr = errPckg();
            }

        if ( pluginErr != KErrNone )
            {
            COMPONENT_TRACE2(_L( "HWRM Server - CHWRMVibraCommonService::ProcessResponseL - Error: %d" ), pluginErr );
            }

        // It is on each service's responsibility to update vibra status p&s keys
        }
        
    // Complete request and remove delete transaction
    contextErr = CompleteRequest(aTransId, pluginErr);    

    // Leave if there is error in context    
    User::LeaveIfError(contextErr);

    COMPONENT_TRACE1(_L( "HWRM Server - CHWRMVibraCommonService::ProcessResponseL - return" ) );
    }
/**
This method is a callback that sends the binary content of the element.
@param				aBytes is the raw binary content data for the element. 
@param				aErrorCode is the error code.
					If this is not KErrNone then special action may be required.
*/
void CTestHandler::OnBinaryContentL(const TDesC8& aBytes, const TDesC8& aCid, TInt aErrorCode)
{
/*
	//use this part of the code if you want to save binary data to MSWord format
	RFs fs;
	CleanupClosePushL(fs);
	User::LeaveIfError(fs.Connect());
	RFile f;
	CleanupClosePushL(f);
	TInt err = f.Replace(fs, _L("c:\\xmlengine\\deserializer\\output\\bin.doc"), EFileWrite);
	err = f.Write(aBytes);
	CleanupStack::PopAndDestroy(2); //f fs
*/
	aCid.Size(); // eliminate compilation warning
	_LIT8(KOnContentFuncName,"OnBinaryContent()\r\n");
	_LIT8(KInfoOnContent,"\tBinary content of element: %S \r\n");
	_LIT8(KInfoOnError,"Error occurs %d \r\n");
	
	HBufC8* info = HBufC8::NewL(aBytes.Size() + 50);
	TPtr8 infoPtr = info->Des();

	iLog.Write(KOnContentFuncName);

	if (aErrorCode == KErrNone)
	{
		infoPtr.Format(KInfoOnContent, &aBytes);
		iLog.Write(infoPtr);
	}
	else
	{
		TBuf8<KShortInfoSize> info;
		info.Format(KInfoOnError,aErrorCode);
		iLog.Write(info);
	}
	delete info;
}
Example #23
0
// -----------------------------------------------------------------------------
// CRoapParser::ConvertRoapStatus
// -----------------------------------------------------------------------------
//
TRoapStatus CRoapParser::ConvertRoapStatus(
    const TDesC8& aStatus)
    {
    TInt i;
    TRoapStatus r = EUnknownStatus;

    for (i = 0; r == EUnknownStatus && i < ELEMENT_COUNT(KStatusValues); i++)
        {
        if (aStatus.Compare(TPtrC8(KStatusValues[i].iString,
            aStatus.Size())) == 0)
            {
            r = static_cast<TRoapStatus>(KStatusValues[i].iNumber);
            }
        }
    return r;
    }
// ------------------------------------------------------------------------------------------------
EXPORT_C void CWBXMLGenerator::BeginDocumentL( TUint8 aVersion, TInt32 aPublicId, TUint32 aCharset, const TDesC8& aStringTbl )
	{
	Workspace()->WriteL(aVersion);

	if( aPublicId <= 0 )
		{
		Workspace()->WriteL(0);
		WriteMUint32L(-aPublicId);
		}
	else
		{
		WriteMUint32L(aPublicId);
		}
	WriteMUint32L(aCharset);
	WriteMUint32L(aStringTbl.Size());
	Workspace()->WriteL(aStringTbl);
	}
Example #25
0
EXPORT_C void TBtreeInlineIndexOrg::Concatenate(TAny *aLeftNode,const TAny *aRightNode,const TDesC8& aPivot) const
//
// Join LeftNode and RightNode together in LeftNode
// contract says that it will fit
//
	{
	SNode* const pl=Node(aLeftNode);
	const SNode* const pr=Node(aRightNode);
	TInt rCount=pr->iHead.iCount;
	TInt lCount=pl->iHead.iCount;
	__ASSERT_DEBUG(lCount+rCount+1<=iMaxEntries,Panic(ECannotConcatenate));
	TInt pSize=aPivot.Size();
	__ASSERT_DEBUG(pSize<=KeySize(),Panic(EBadEntrySize));
	TUint8* pp=Mem::Copy(Entry(pl,lCount)->iKey,aPivot.Ptr(),pSize);
	Mem::Copy(pp,pr->iEntries,rCount*iEntrySize+sizeof(TPageRef));
	pl->iHead.iCount+=rCount+1;
	}
Example #26
0
void CWsListen::HandleMessage(const TDesC8& aData)
	{
	if (aData[0]==KListenerInfoSig)
		Mem::Copy(iReq, aData.Ptr(), aData.Size());
	//The if-statement allows to call QueryPlugin() in HandleMessage() only once to reproduce the defect INC094118.
	//Otherwise HandleMessage() will behave as normal. 
	if (iTestFlag)
		{
	    TListenerInfo aInfo;
		QueryPlugin(aInfo) ;
		iTestFlag = EFalse;
		}
	else
		{
		iCallBack.CallBack();
		}
	}
Example #27
0
TInt CTlsEncrypt::EncryptL(const TDesC8& aInput,HBufC8*& aOutput,
                           TInt64& aSeqNumber,TRecordProtocol& aType)
{
    if(!aInput.Length())
        return KErrBadDescriptor;

    TBuf8<128> Macbuf;

    TLSPROV_LOG2(_L("Before Encryption...RecordType: %d"),(TInt)aType)

    TLSPROV_LOG_HEX(aInput.Ptr(),aInput.Size() )

    ComputeMacL(Macbuf,aInput,EFalse,aSeqNumber,aType);


    HBufC8* TempInput = HBufC8::NewLC(Macbuf.Length()  + aInput.Length());
    TPtr8 InputPtr = TempInput->Des();

    InputPtr.Append(aInput);
    InputPtr.Append(Macbuf);

    TInt nAlloc = iCryptos.iEncryptor->MaxFinalOutputLength(InputPtr.Length());
    if ( !aOutput || aOutput->Des().MaxLength() < nAlloc )
    {
        delete aOutput;
        aOutput = NULL;
        aOutput = HBufC8::NewL( nAlloc );
    }
    TPtr8 Output = aOutput->Des();
    Output.Zero();

    iCryptos.iEncryptor->ProcessFinalL(InputPtr,Output);

    TLSPROV_LOG(_L("After Encryption with mac"))
    TLSPROV_LOG_HEX(aOutput->Ptr(),aOutput->Size() )

    CleanupStack::PopAndDestroy(TempInput);
    return KErrNone;

}
// -----------------------------------------------------------------------------
// RDRMRightsClient::UnwrapMacAndRek
// -----------------------------------------------------------------------------
//
EXPORT_C TInt RDRMRightsClient::UnwrapMacAndRek( const TDesC8& aMacAndRek,
                                                 TKeyTransportScheme aTransportScheme,
                                                 const TDesC8& aRightsIssuerId,
                                                 const TDesC8& aDomainId ) const
    {
    HBufC8* data = NULL;
    TPtr8 dataPtr( NULL, 0 );
    TInt err = KErrNone;

    data = HBufC8::New( 1 + aMacAndRek.Size() );

    if ( data )
        {
        dataPtr.Set( data->Des() );
        dataPtr.SetLength( 1 );
        dataPtr[0] = aTransportScheme;
        dataPtr.Append( aMacAndRek );

        if( aDomainId.Length() )
            {
            err = SendReceive( DRMEngine::EUnwrapDomainMacAndRek, TIpcArgs( &dataPtr,
                                                                  &aRightsIssuerId,
                                                                  &aDomainId ) );
            }
        else
            {
            err = SendReceive( DRMEngine::EUnwrapDeviceMacAndRek, TIpcArgs( &dataPtr,
                                                                  &aRightsIssuerId,
                                                                  NULL ) );
            }
        delete data;
        data = NULL;
        }
    else
        {
        err = KErrNoMemory;
        }

    return err;
    }
void CEapSimIsaInterface::QueryKcAndSRESL(const TDesC8& aRand)
{
	EAP_TRACE_BEGIN(m_am_tools, TRACE_FLAGS_DEFAULT);
	EAP_TRACE_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("CEapSimIsaInterface::QueryKcAndSRESL()\n")));
	EAP_TRACE_RETURN_STRING(m_am_tools, "returns: CEapSimIsaInterface::QueryKcAndSRESL()");

	iQueryId = EQuerySRESandKC;

	EAP_TRACE_DATA_DEBUG(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("RAND"),
			aRand.Ptr(),
			aRand.Size()));

	// Rand must be 16 bytes
	if (static_cast<u16_t>(aRand.Length()) != SIM_RAND_LENGTH)
	{
		EAP_TRACE_ERROR(m_am_tools, TRACE_FLAGS_DEFAULT, (EAPL("ISA interface: Illegal RAND - Incorrect length.\n")));
		User::Leave(KErrArgument);
	}
	
	// Create MMETEL connection.
	User::LeaveIfError( CreateMMETelConnectionL() );
	
	// Open CustomAPI.
	User::LeaveIfError( iCustomAPI.Open(iPhone) );		
	
	iEAPSim.iRandomParameters.Copy( aRand ); //Copy the rand to iEAPSim

	//Pack iEAPSim to iAuthenticationData for passing it to the custom API.
	iAuthenticationData = new (ELeave) RMmCustomAPI::TSimDataPckg( iEAPSim );
	
    iCustomAPI.GetWlanSimAuthenticationData( iStatus, *iAuthenticationData );	
	
	if( !IsActive() )
	{
		SetActive();
	}  

	EAP_TRACE_END(m_am_tools, TRACE_FLAGS_DEFAULT);
}
Example #30
0
////////////////////////////////////////////////////////////////////////////////////////
//	Base64 encoding function using buffers allocated by the caller
////////////////////////////////////////////////////////////////////////////////////////
EXPORT_C TInt TBase64Codec::Base64Encode(const TDesC8 &aRawData, const TDes8 &aEncodedData)
{
	TInt i;
	TInt j;
	TInt datalen;
	TUint8 block[3];
	const TUint8 *fromPtr;
	TUint8 *toPtr;
	TUint count = 0;
	TInt lengthIncludingLinebreaks;
	TInt lengthWithoutLinebreaks;


	i=0;
	fromPtr = aRawData.Ptr();
	toPtr = CONST_CAST(TUint8*, aEncodedData.Ptr());
	datalen = aRawData.Size();
	lengthWithoutLinebreaks = ((datalen + 3)/ 3) * 4;
	lengthIncludingLinebreaks = lengthWithoutLinebreaks + (lengthWithoutLinebreaks) / MAXLINELEN - ((lengthWithoutLinebreaks % MAXLINELEN)?0:1); 
	if(aEncodedData.MaxLength() < lengthIncludingLinebreaks)
		return KErrArgument;

	for (j=0;j<datalen;j+=3)
	{
		/* 11111100>>2 */
		/* 00000011<<4 + 11110000>>4 */
		/*               00001111<<2 + 11000000>>6 */
		/*                             00111111    */
		Mem::FillZ(block, 3);
		Mem::Copy(block, &fromPtr[j], datalen-j<3?datalen-j:3);
		toPtr[i++] = Kb64[(block[0]&0xfc)>>2]; 
		toPtr[i++] = Kb64[((block[0]&0x03)<<4)+(block[1]>>4)];
		if (datalen-j>1)
		{
			toPtr[i++] = Kb64[((block[1]&0x0f)<<2)+(block[2]>>6)]; 
		}
		else
		{