// ----------------------------------------------------------------------------- // 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(); }
inline void CPppMsChap::ChallengeResponseL(const TDesC8& aChallenge, TDes8& aPaddablePasswordHash, TDes8& aResponse) /** Computes the Challenge Response. @param aChallenge [in] A MS-CHAP Challenge (8 octets). @param aPaddablePasswordHash [in/out] The hash of the password in a paddable buffer (16 octets in a buffer with at least 21 octets maximum length). @param aResponse [out] The Challenge Response (24 octets). @note This function implements the ChallengeResponse routine specified in RFC 2433. @internalComponent */ { ASSERT(aChallenge.Length()==KPppMsChapChallengeSize); ASSERT(aPaddablePasswordHash.Length()==KPppMsChapHashSize && aPaddablePasswordHash.MaxLength() >= KPppMsChapPaddedHashSize); ASSERT(aResponse.Length() == KPppMsChapNTResponseSize); // aPaddablePasswordHash contains the hash of the password (16 octets) // zero-padded to 21 octets // RFC 2433 - ChallengeResponse(): "Set ZPasswordHash to // PasswordHash zero-padded to 21 octets", i.e. 5 octets aPaddablePasswordHash.AppendFill(0, KPppMsChapPaddedHashSize - KPppMsChapHashSize); // The first 8 octets of aResponse TPtr8 responseChunk(const_cast<TUint8*>(aResponse.Ptr()), KPppDESKeySize, KPppDESKeySize); DesEncryptL(aChallenge, aPaddablePasswordHash.Left(KPppMsChapDESKeySize), responseChunk); // The second 8 octets of aResponse responseChunk.Set(const_cast<TUint8*>(aResponse.Ptr()) + KPppDESKeySize, KPppDESKeySize, KPppDESKeySize); DesEncryptL(aChallenge, aPaddablePasswordHash.Mid(KPppMsChapDESKeySize, KPppMsChapDESKeySize), responseChunk); // The third 8 octets of aResponse responseChunk.Set(const_cast<TUint8*>(aResponse.Ptr()) + 2*KPppDESKeySize, KPppDESKeySize, KPppDESKeySize); DesEncryptL(aChallenge, aPaddablePasswordHash.Mid(2*KPppMsChapDESKeySize, KPppMsChapDESKeySize), responseChunk); // Restore the original length of the password hash aPaddablePasswordHash.SetLength(KPppMsChapHashSize); ASSERT(aResponse.Length() == KPppMsChapNTResponseSize); }