// ----------------------------------------------------------------------------- // CG711PayloadFormatRead::DecodePayload // Decodes all audio frames from the received RTP payload buffer. Decoded // audio frames are saved to the internal array so that audio frames can be // requested one at a time with GetNextFrame() -method. // No assumption about frame count in RTP packet is done. // ----------------------------------------------------------------------------- // TInt CG711PayloadFormatRead::DecodePayload( TDes8& aSourceBuffer ) { DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload SourceBufSize: %d", aSourceBuffer.Size() ); DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload SourceBufLength: %d", aSourceBuffer.Length() ); iFrameIndex = 0; const TUint8* framePtr = aSourceBuffer.Ptr(); const TUint8* endPtr = aSourceBuffer.Ptr() + aSourceBuffer.Size(); TInt frames = aSourceBuffer.Size() / TInt( iCInfo.iFrameSize ); DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload FrameSize: %d", iCInfo.iFrameSize ); DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload Frames: %d", frames ); // Construct pointers to frames in payload if not in CN mode if ( !iCnFrame ) { while ( frames-- ) { const TPtr8 bufPtr( const_cast<TUint8*>( framePtr ), iCInfo.iFrameSize, iCInfo.iFrameSize ); iFrameArray.Append( bufPtr ); framePtr += iCInfo.iFrameSize; if ( framePtr >= endPtr ) { frames = 0; } } } else if ( aSourceBuffer.Size() && iCnFrame ) { // If it is a CN frame, then we must do special handling. This is // because e.g Cisco kit sends 1 byte CN frames, thus we need to // expand the source buffer with zeroes. TInt targetLen = iCInfo.iFrameSize; targetLen = targetLen - aSourceBuffer.Size(); DP_G711_READ2( "CG711PayloadFormatRead::DecodePayload CN frame size adjust: %d", targetLen ); const TChar zero( '0' ); aSourceBuffer.AppendFill( zero, targetLen ); const TPtr8 bufPtr( const_cast<TUint8*>( framePtr ), iCInfo.iFrameSize, iCInfo.iFrameSize ); iFrameArray.Append( bufPtr ); } return iFrameArray.Count(); }
/** * -Reads in the whole Msg. Header & Body From the WSS stack * (i.e the test Harness) and Creates a Local Copy. * -Copy the Msg. Header & Body to Watcher Buffers: * if the Watcher Buffers are big enough to hold the message, * then the whole Mgs is copied and we Complete with KErrNone. * if the Watcher Buffers are smaller then the Msg is copied * in blocks of size equal to the size of the Watcher Buffers * completing with EMoreData every time until the watcher gets * the whole Msg. At that point there is no more data to be * copied then we complete with KErrNone. */ EXPORT_C void CDummyWSPCLConn::CompleteUnitWaitPushL(TDes8& aBody,TDes8& aHeaders) { TPushID id; id=99; // Only read data from the WSS stack the first call if (iPushHeadersDataOffset == 0 && iPushBodyDataOffset == 0) { __ASSERT_DEBUG(iPushHeadersData == 0, User::Panic(_L("headers != 0"), 0)); __ASSERT_DEBUG(iPushBodyData == 0, User::Panic(_L("body != 0"), 0)); TUint bodySize = aBody.Size(); TUint headersSize =aHeaders.Size(); if (bodySize==0 && headersSize==0) User::Leave(RWSPCLConn::EDataNotAvailable); iPushHeadersData= aHeaders.AllocL(); iPushBodyData= aBody.AllocL(); *iID=id;//**** Generate an Id per Msg, Not Supported in R1 iPushHeadersData->Des().SetLength(headersSize); iPushBodyData->Des().SetLength(bodySize); } TInt clientHeadersSize = iClientHeaders->MaxSize(); TInt clientBodySize = iClientBody->MaxSize(); TInt headersRetSize = Min(clientHeadersSize, (iPushHeadersData->Size() - iPushHeadersDataOffset)); TInt bodyRetSize = Min(clientBodySize, (iPushBodyData->Size() - iPushBodyDataOffset)); iClientHeaders->Append(iPushHeadersData->Mid(iPushHeadersDataOffset, headersRetSize)); iClientBody->Append(iPushBodyData->Mid(iPushBodyDataOffset, bodyRetSize)); iPushHeadersDataOffset += headersRetSize; iPushBodyDataOffset += bodyRetSize; __ASSERT_DEBUG(iPushBodyDataOffset <= iPushBodyData->Size(), User::Panic(_L("Body offset too big"), 0)); __ASSERT_DEBUG(iPushHeadersDataOffset <= iPushHeadersData->Size(), User::Panic(_L("Headers offset too big"), 0)); // Are we done yet? if (iPushHeadersDataOffset == iPushHeadersData->Size() && iPushBodyDataOffset == iPushBodyData->Size() ) { delete iPushHeadersData; delete iPushBodyData; iPushHeadersData = 0; iPushBodyData = 0; iPushHeadersDataOffset = 0; iPushBodyDataOffset = 0; User::RequestComplete(iStatus,KErrNone); } else User::RequestComplete(iStatus,RWAPConn::EMoreData); }
void CRC2Encryptor::Transform(TDes8& aBlock) { assert(aBlock.Size() == KRC2BlockBytes); TUint16 R0, R1, R2, R3; GetBlockLittleEndian((TUint8*)&aBlock[0], R0, R1, R2, R3); TInt i = 0; for (; i < 16; i++) { R0 += (R1 & ~R3) + (R2 & R3) + iK[4*i+0]; R0 = rotlFixed(R0, 1); R1 += (R2 & ~R0) + (R3 & R0) + iK[4*i+1]; R1 = rotlFixed(R1, 2); R2 += (R3 & ~R1) + (R0 & R1) + iK[4*i+2]; R2 = rotlFixed(R2, 3); R3 += (R0 & ~R2) + (R1 & R2) + iK[4*i+3]; R3 = rotlFixed(R3, 5); if (i == 4 || i == 10) { R0 += iK[R3 & 63]; R1 += iK[R0 & 63]; R2 += iK[R1 & 63]; R3 += iK[R2 & 63]; } } PutBlockLittleEndian((TUint8*)&aBlock[0], R0, R1, R2, R3); }
void CRC2Decryptor::Transform(TDes8& aBlock) { assert(aBlock.Size() == KRC2BlockBytes); TUint16 R0, R1, R2, R3; GetBlockLittleEndian((TUint8*)&aBlock[0], R0, R1, R2, R3); TInt i = 15; for (; i >= 0; i--) { if (i == 4 || i == 10) { R3 -= iK[R2 & 63]; R2 -= iK[R1 & 63]; R1 -= iK[R0 & 63]; R0 -= iK[R3 & 63]; } R3 = rotrFixed(R3, 5); R3 -= (R0 & ~R2) + (R1 & R2) + iK[4*i+3]; R2 = rotrFixed(R2, 3); R2 -= (R3 & ~R1) + (R0 & R1) + iK[4*i+2]; R1 = rotrFixed(R1, 2); R1 -= (R2 & ~R0) + (R3 & R0) + iK[4*i+1]; R0 = rotrFixed(R0, 1); R0 -= (R1 & ~R3) + (R2 & R3) + iK[4*i+0]; } PutBlockLittleEndian((TUint8*)&aBlock[0], R0, R1, R2, R3); }
LOCAL_C TInt TranslateCrLf(TDes8 &aDes) // // Search for CR/LF characters in a string and replace them with // '\r' '\n' format. Also replaces unprintable characters with "?" // { TText8 buf[KBlockSize]; TText8 *pS=(TText8*)aDes.Ptr(); TText8 *pSE=pS+aDes.Size(); TText8 *pT=&buf[0]; TText8 *pTMax=pT+(KBlockSize-1); for (; pS<pSE; pS++,pT++) { if (pT>=pTMax) return(KErrTooBig); if (*pS=='\xD'||*pS=='\xA') { *pT++='\\'; *pT=(*pS=='\xD')?'r':'n'; } else if (((TChar)*pS).IsPrint()) *pT=*pS; else *pT='\?'; } *pT=0; if ((pT-&buf[0])>aDes.MaxLength()) return(KErrTooBig); aDes.Copy(&buf[0]); return(KErrNone); }
EXPORT_C void CStreamCipher::Process(const TDesC8& aInput, TDes8& aOutput) { TInt outputIndex = aOutput.Size(); // aOutput may already have outputIndex bytes of data in it // check there will still be enough space to process the result __ASSERT_DEBUG(aOutput.MaxLength() - outputIndex >= MaxOutputLength(aInput.Length()), User::Panic(KCryptoPanic, ECryptoPanicOutputDescriptorOverflow)); aOutput.Append(aInput); TPtr8 transformBuf((TUint8*)(aOutput.Ptr()) + outputIndex, aInput.Size(), aInput.Size()); DoProcess(transformBuf); }
// ----------------------------------------------------------------------------- // ConvertAsciiToHex // ----------------------------------------------------------------------------- // void CHssIapHandler::ConvertAsciiToHex( const TDes8& aSource, HBufC8*& aDest ) { DEBUG("CHssIapHandler::ConvertAsciiToHex"); _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] ); } }