inline void CPppMsChap2::HashNtPasswordHashL( const TDesC8& aPasswordHash, TDes8& aPasswordHashHash) /** Computes the hash of the hash of the Microsoft Windows NT password using MD4. @param aPasswordHash [in] The hash of the Microsoft Windows NT password (16 octets). @param aPasswordHashHash [out] The hash of the hash of the Microsoft Windows NT password, computed using MD4 (16 octets). @note This function implements the HashNtPasswordHash routine specified in RFC 2759. @internalComponent */ { ASSERT(aPasswordHash.Length()==KPppMsChap2HashSize); ASSERT(aPasswordHashHash.Length()==KPppMsChap2HashSize); CMd4* md4 = CMd4::NewL(); CleanupStack::PushL(md4); // aPasswordHashHash.Copy(md4.Final(aPasswordHash)); md4->Input(aPasswordHash); md4->Output(aPasswordHashHash); CleanupStack::PopAndDestroy(md4); ASSERT(aPasswordHashHash.Length()==KPppMsChap2HashSize); }
inline void CPppMsChap::NTChallengeResponseL(const TDesC8& aChallenge, const TDesC16& aPassword, TDes8& aResponse) /** Computes a MS-CHAP Windows NT compatible Challenge Response. @param aChallenge [in] A MS-CHAP Challenge (8 octets). @param aPassword [in] The Microsoft Windows NT password (0 to 256 Unicode char). @param aResponse [out] The MS-CHAP Windows NT compatible Challenge Response (24 octets). @note This function implements the NTChallengeResponse routine specified in RFC 2433. @internalComponent */ { ASSERT(aChallenge.Length() == KPppMsChapChallengeSize); ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength); ASSERT(aResponse.Length() == KPppMsChapNTResponseSize); HBufC8* paddedPasswordHashBuf = HBufC8::NewLC(KPppMsChapPaddedHashSize); TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des()); paddablePasswordHash.SetLength(KPppMsChapHashSize); NtPasswordHashL(aPassword, paddablePasswordHash); ChallengeResponseL(aChallenge, paddablePasswordHash, aResponse); CleanupStack::PopAndDestroy(paddedPasswordHashBuf); ASSERT(aResponse.Length() == KPppMsChapNTResponseSize); }
TUint TInputManager::ReadString(TDes8& aStr) { TKeyCode key; aStr.Zero(); while( (key = iConsole.Getch()) != EKeyEnter) { if (aStr.Length() == aStr.MaxLength()) return aStr.MaxLength(); if (key == EKeyBackspace) { if (aStr.Length() > 0) { aStr.Delete(aStr.Length()-1, 1); ConsoleBackspace(1); } } else { TUint8 keyChar(key); aStr.Append(keyChar); iConsole.Printf(_L("%c"), keyChar); } } iConsole.Printf(_L("\n")); return aStr.Length(); }
// NB The use of the LAN Manager compatible challenge response has // been deprecated according to RFC 2433. inline void CPppMsChap::LmChallengeResponseL(const TDesC8& aChallenge, const TDesC8& aPassword, TDes8& aResponse) /** Computes a MS-CHAP LAN Manager compatible Challenge Response. @param aChallenge [in] A MS-CHAP Challenge (8 octets). @param aPassword [in] The LAN Manager password (0 to 14 OEM char). @param aResponse [out] The MS-CHAP LAN Manager compatible Challenge Response (24 octets). @note This function implements the LmChallengeResponse routine specified in RFC 2433. @note The use of the LAN Manager compatible Challenge Response has been deprecated according to RFC 2433. @internalComponent */ { ASSERT(aChallenge.Length() == KPppMsChapChallengeSize); ASSERT(aPassword.Length() <= KPppMsChapMaxLANManagerPasswordLength); ASSERT(aResponse.Length() == KPppMsChapLanManResponseSize); HBufC8* paddedPasswordHashBuf = HBufC8::NewLC(KPppMsChapPaddedHashSize); TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des()); paddablePasswordHash.SetLength(KPppMsChapHashSize); LmPasswordHashL(aPassword, paddablePasswordHash); ChallengeResponseL(aChallenge, paddablePasswordHash, aResponse); CleanupStack::PopAndDestroy(paddedPasswordHashBuf); ASSERT(aResponse.Length() == KPppMsChapLanManResponseSize); }
// ----------------------------------------------------------------------------- // CUpnpHttpChunkParser::ParseL // Decoding the chunked-encoded buffer // ----------------------------------------------------------------------------- // TBool CUpnpHttpChunkParser::ParseExtension( TDes8& aBuffer, TInt& aPos ) { if ( IsEmpty( aBuffer, aPos ) ) { return ETrue; } //if '\r\n' exists TInt lineFeed = aBuffer.Right( aBuffer.Length() - aPos ).FindF( UpnpString::KLineFeed ); if ( lineFeed != KErrNotFound ) { aBuffer.Delete( aPos, lineFeed + UpnpString::KLineFeed().Length() ); if ( !iChunkSize ) { iContext = ETrailer; return EFalse; } else { iContext = EBody; return EFalse; } } else { //one character left - possible linefeed if ( aPos + 1 < aBuffer.Length() ) { aBuffer.Delete( aPos, aBuffer.Length() - aPos - 1 ); } return ETrue; } }
/** Convert data from the API's form (as we're given it by RemCon) the bearer-specific form. */ TInt CCoreSerialConverter::InterfaceToBearer(TUid aInterfaceUid, TUint aOperationId, const TDesC8& aData, TRemConMessageType aMsgType, TDes8& aBearerData) const { TInt ret = KErrCorrupt; if ( aData.Length() <= 10 ) { if ( aMsgType == ERemConCommand ) { aBearerData.Format(_L8("0x%08x 0x%02x %S %S"), aInterfaceUid, aOperationId, &KCmdText(), &aData); // Pad it up in case aData was less than 4 characters. while ( aBearerData.Length() < KRemConSerialBearerMessageLength ) { aBearerData.Append(_L8(" ")); } ret = KErrNone; } else if ( aMsgType == ERemConResponse ) { aBearerData.Format(_L8("0x%08x 0x%02x %S %S"), aInterfaceUid, aOperationId, &KRspText(), &aData); // Pad it up in case aData was less than 4 characters. while ( aBearerData.Length() < KRemConSerialBearerMessageLength ) { aBearerData.Append(_L8(" ")); } ret = KErrNone; } } return ret; }
TInt RecvLine(RTest &aTest, TDes8 &aBuf, RSocket &aSock) { TInt offset=0; TText ch=0; do { TPtr8 ptr(NULL, 0); TSockXfrLength len; TRequestStatus stat; ptr.Set((TUint8 *)aBuf.Ptr()+offset, aBuf.Length()-offset, aBuf.Length()-offset); aSock.RecvOneOrMore(ptr,0,stat,len); User::WaitForRequest(stat); aTest(stat==KErrNone); TInt length=len(); TInt n=0; while (length--) { ch = *(ptr.Ptr()+n); if (ch=='\r' || ch=='\n') break; ++offset; ++n; } } while (ch!='\r' && ch!='\n' ); aBuf.SetLength(offset); return offset; }
void CPaddingSSLv3::DoPadL(const TDesC8& aInput,TDes8& aOutput) { TInt paddingBytes=BlockSize()-(aInput.Length()%BlockSize()); aOutput.Append(aInput); aOutput.SetLength(aOutput.Length()+paddingBytes); for (TInt i=1;i<=paddingBytes;i++) { aOutput[aOutput.Length()-i]=(TUint8)(paddingBytes-1); } }
inline void CPppMsChap2::GenerateNTResponseL( const TDesC8& aAuthenticatorChallenge, const TDesC8& aPeerChallenge, const TDesC8& aUserName, const TDesC16& aPassword, TDes8& aResponse) /** Generates a MS-CHAP-V2 NT-Response. @param aAuthenticatorChallenge [in] The MS-CHAP-V2 authenticator challenge (16 octets). @param aPeerChallenge [in] The MS-CHAP-V2 peer challenge (16 octets). @param aUserName [in] The Microsoft Windows NT username (0 to 256 char). @param aPassword [in] The Microsoft Windows NT password (0 to 256 unicode char). @param aResponse [out] The MS-CHAP-V2 Challenge Response, NT-Response (24 octets). @note This function implements the GenerateNTResponse routine specified in RFC 2759. @internalComponent */ { ASSERT(aAuthenticatorChallenge.Length() == KPppMsChap2AuthenticatorChallengeSize); ASSERT(aPeerChallenge.Length() == KPppMsChap2PeerChallengeSize); ASSERT(aUserName.Length() <= KPppMsChapMaxNTUserNameLength); ASSERT(aPassword.Length() <= KPppMsChapMaxNTPasswordLength); ASSERT(aResponse.Length() == KPppMsChap2NTResponseSize); HBufC8* challengeHashBuf = HBufC8::NewMaxLC(KPppMsChap2ChallengeHashSize); TPtr8 challengeHash(challengeHashBuf->Des()); ChallengeHashL(aPeerChallenge, aAuthenticatorChallenge, aUserName, challengeHash); HBufC8* paddedPasswordHashBuf = HBufC8::NewLC(KPppMsChap2PaddedHashSize); TPtr8 paddablePasswordHash(paddedPasswordHashBuf->Des()); paddablePasswordHash.SetLength(KPppMsChap2HashSize); NtPasswordHashL(aPassword, paddablePasswordHash); ChallengeResponseL(challengeHash, paddablePasswordHash, aResponse); CleanupStack::PopAndDestroy(paddedPasswordHashBuf); CleanupStack::PopAndDestroy(challengeHashBuf); ASSERT(aResponse.Length()==KPppMsChap2NTResponseSize); }
// --------------------------------------------------------- // CNSmlCmdsBase::TrimRightSpaceAndNull // Trims right spaces and zero terminator (NULL) // --------------------------------------------------------- EXPORT_C void CNSmlCmdsBase::TrimRightSpaceAndNull( TDes8& aDes ) const { aDes.TrimRight(); if ( aDes.Length() > 0 ) { if ( aDes[aDes.Length() - 1] == NULL ) { aDes.SetLength( aDes.Length() - 1 ); } } }
void CIpcStreamProvd::GetData(TDes8 &aDesc,TUint /*options*/,TSockAddr* /*anAddr*/) { __ASSERT_DEBUG(iConnection,Panic(EBadWriteCall)); __ASSERT_DEBUG(iSocket,Panic(EBadWriteCall)); CCirBuffer& buf=((CIpcStreamProvd *)iConnection)->iBuffer; __ASSERT_DEBUG(aDesc.Length()<=buf.Count(),Panic(EReadGetTooMuch)); buf.Remove((TUint8 *)aDesc.Ptr(),aDesc.Length()); iConnection->CanSend(); }
////////////////////////////////////////////////////////////////////// // util ////////////////////////////////////////////////////////////////////// void ReplaceUrl(TDes8& aUrl,const TDesC8& aIsRepeatedKStr,const TDesC8& aStr){ HBufC8* tmp=HBufC8::NewL(aUrl.Length()+aStr.Length()+128); int iPos=aUrl.FindF(aIsRepeatedKStr); if(iPos>=0){ tmp->Des().Copy(aUrl.Left(iPos)); //加上前面有用的字符 tmp->Des().Append(aStr); int iStart=iPos+aIsRepeatedKStr.Length(); //要被替换的字符,加上要被替换的字符长度 int iLen2=aUrl.Length()-iStart; tmp->Des().Append(aUrl.Mid(iStart,iLen2)); //加上后面有用的字符 aUrl.Copy(tmp->Des()); } delete tmp; }
void CPppMsChap2::ChallengeHashL(const TDesC8& aPeerChallenge, const TDesC8& aAuthenticatorChallenge, const TDesC8& aUserName, TDes8& aChallengeHash) /** Computes the hash of the Peer Challenge, Authenticator Challenge and username using SHA-1. @param aPeerChallenge [in] The Peer Challenge (16 octets). @param aAuthenticatorChallenge [in] The Authenticator Challenge (16 octets). @param aUserName [in] The Microsoft Windows NT username (0 to 256 char). @param aChallengeHash [out] The hash of the peer challenge, authenticator challenge and username, computed using SHA-1 (8 octets). @note This function implements the ChallengeHash routine specified in RFC 2759. @internalComponent */ { ASSERT(aPeerChallenge.Length() == KPppMsChap2PeerChallengeSize); ASSERT(aAuthenticatorChallenge.Length() == KPppMsChap2AuthenticatorChallengeSize); ASSERT(aUserName.Length() <= KPppMsChapMaxNTUserNameLength); ASSERT(aChallengeHash.Length()==KPppMsChap2ChallengeHashSize); CSHA1* sha1 = CSHA1::NewL(); CleanupStack::PushL(sha1); // RFC 2759: "Only the user name (as presented by the peer and // excluding any prepended domain name)" TPtrC8 userName(aUserName); TInt i = aUserName.Locate('\\'); if (i >= 0 && i < userName.Length() - 1) userName.Set(aUserName.Mid(i + 1)); else if (i >= userName.Length() - 1) User::Leave(KErrGeneral); sha1->Update(aPeerChallenge); sha1->Update(aAuthenticatorChallenge); aChallengeHash.Copy(sha1->Final(userName).Ptr(), KPppMsChap2ChallengeHashSize); CleanupStack::PopAndDestroy(sha1); ASSERT(aChallengeHash.Length()==KPppMsChap2ChallengeHashSize); }
// ----------------------------------------------------------------------------- // UpnpAVCPEngine::RemoveSlashes // ----------------------------------------------------------------------------- // void RemoveSlashes(TDes8& aPath) { if (aPath.Length() > 0 && aPath[0] == '/' ) { aPath.Delete(0,1); } // remove ending '/' TInt length = aPath.Length(); if (length > 0 && aPath[length-1] == '/' ) { aPath.Delete(length-1,1); } }
void CPppMsChap::DesEncryptL(const TDesC8& aClear, const TDesC8& aKey, TDes8& aCypher) /** Encrypts a plaintext into a ciphertext using the DES encryption algorithm in ECB mode. @param aClear [in] A plaintext (8 octets). @param aKey [in] A key (7 octets). @param aCypher [out] The ciphertext (8 octets). @note This function implements the DesEncrypt routine specified in RFC 2433. @internalComponent */ { ASSERT(aClear.Length() == KPppMsChapDESClearTextSize); ASSERT(aKey.Length() == KPppMsChapDESKeySize); ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize); HBufC8* desKeyBuf=HBufC8::NewMaxLC(KPppDESKeySize); TPtr8 desKey(desKeyBuf->Des()); // RFC 2433: "Use the DES encryption algorithm [4] in ECB mode [10] to // encrypt Clear into Cypher such that Cypher can only be decrypted // back to Clear by providing Key. Note that the DES algorithm takes // as input a 64-bit stream where the 8th, 16th, 24th, etc. bits are // parity bits ignored by the encrypting algorithm. Unless you write // your own DES to accept 56-bit input without parity, you will need // to insert the parity bits yourself." MakeDesKey(aKey, desKey); CBlockTransformation* encryptor = CDESEncryptor::NewLC(desKey, EFalse); CPaddingNone* padding = CPaddingNone::NewLC(); CBufferedEncryptor* bufEncryptor = CBufferedEncryptor::NewL(encryptor, padding); CleanupStack::Pop(padding); CleanupStack::Pop(encryptor); CleanupStack::PushL(bufEncryptor); aCypher.Zero(); bufEncryptor->ProcessFinalL(aClear, aCypher); CleanupStack::PopAndDestroy(bufEncryptor); CleanupStack::PopAndDestroy(desKeyBuf); ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize); }
void CUtils::StripSpaces(TDes8& aText) { TInt i; for (i=0; i<aText.Length(); i++) if (aText[i] != ' ') break; if (i) aText.Delete(0,i); for (i=aText.Length()-1; i>=0; i--) if (aText[i] != ' ') break; if (i != aText.Length()-1) aText.Delete(i+1,aText.Length()-1-i); }
TBool TDebugFunctionality::GetStopModeFunctionality(TDes8& aDFBlock) { TUint32 size = GetStopModeFunctionalityBufSize(); if (aDFBlock.MaxLength() < size) { // Insufficient space to contain the debug functionality block return EFalse; } TUint8* ptr = (TUint8*)&size; aDFBlock.SetLength(0); aDFBlock.Append(ptr, 4); TVersion version = TVersion(KStopModeMajorVersionNumber, KStopModeMinorVersionNumber, KStopModePatchVersionNumber); ptr = (TUint8*)&version; aDFBlock.Append(ptr, sizeof(TVersion)); AppendBlock((const TSubBlock&)StopModeFunctionalityCore,aDFBlock); AppendBlock((const TSubBlock&)StopModeFunctionalityFunctions,aDFBlock); AppendBlock((const TSubBlock&)StopModeFunctionalityList,aDFBlock); const TTagHeader& header = StopModeFunctionalityBuffers->iHeader; aDFBlock.Append((TUint8*)&header, sizeof(TTagHeader)); for(TInt i=0; i<EBuffersLast; i++) { TTag tag; TheDBufferManager.GetBufferDetails((TBufferType)i, tag); aDFBlock.Append((TUint8*)&tag, sizeof(TTag)); } if(aDFBlock.Length() != size - 4) { return EFalse; } TUint32* ptr32 = (TUint32*)aDFBlock.Ptr(); TUint32 checksum = 0; for(TInt i=0; i<aDFBlock.Length(); i+=4) { checksum^=*ptr32; ptr32++; } ptr = (TUint8*)&checksum; aDFBlock.Append(ptr, 4); return ETrue; }
TInt CTmsTestStep::ReadNextLineL( RFile &aFile, TDes8 &aLine ) // read a cr/lf limiited line from the file, assumes file is a valid file // and that aLine is of sufficient length to hold the data { aLine.Zero(); TBuf8<1> chr; for (;;) { aFile.Read(chr); if ( chr.Length() == 0 ) { break; } if (chr.CompareF(KRet) == 0) { // got a line, exctract newline as well aFile.Read(chr); break; } else { aLine.Append(chr); } } return aLine.Length(); }
// KErrBadDescriptor, if message length too small // KErrUnderFlow, if message length too big. // KErrCouldNotConnect, if receiver object is out of scope. TInt DISICLTransceiver::ValidateISIMessage( TDes8& aMessage ) { C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage 0x%x>" ), &aMessage ) ); const TUint16 descLength( aMessage.Length() ); TInt msgOk( KErrNone ); msgOk = ( ISI_HEADER_OFFSET_MESSAGEID >= descLength ) ? KErrBadDescriptor : msgOk; TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); // Get ISI message length after known that the descriptor is big enough. const TUint8* msgPtr( aMessage.Ptr() ); const TUint16 isiMsgLength( GET_LENGTH( msgPtr ) + PN_HEADER_SIZE ); // If the descriptor length is less than ISI message length. msgOk = ( ( msgOk == KErrNone && isiMsgLength > descLength ) ? KErrUnderflow : msgOk ); TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); // If the ISI message length is bigger that the largest supported. msgOk = ( ( msgOk == KErrNone && isiMsgLength > KMaxISIMsgSize ) ? KErrUnderflow : msgOk ); TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); // If the ISI message length with PN_HEADER_SIZE is less or equal than ISI_HEADER_OFFSET_MESSAGEID. msgOk = ( ( msgOk == KErrNone && isiMsgLength <= ISI_HEADER_OFFSET_MESSAGEID ) ? KErrUnderflow : msgOk ); TRACE_ASSERT_INFO( msgOk == KErrNone, msgOk ); TRACE_ASSERT_INFO( msgOk == KErrNone, isiMsgLength ); TRACE_ASSERT_INFO( msgOk == KErrNone, descLength ); C_TRACE( ( _T( "DISICLTransceiver::ValidateISIMessage %d<" ), msgOk ) ); return msgOk; }
EXPORT_C int Tbuf8ToWchar(TDes8& aSrc, wchar_t* aDes, int& n_size) { int retval = ESuccess; unsigned int ilen = aSrc.Length(); int minusone = -1; if(0 == ilen) { return EDescriptorNoData; } else if(!aDes) { return EInvalidPointer; } else if(n_size < ilen+1) { n_size = ilen+1; return EInvalidSize; } if(minusone != mbstowcs(aDes, (const char*)aSrc.Ptr(), ilen)) { *(aDes + ilen) = L'\0'; } else { retval = EInvalidMBSSequence; } return retval; }
// Construct a faked event, storing the supplied event parameters into the supplied empty event data buffer. EXPORT_C TLoopbackCommandEvent::TLoopbackCommandEvent(const TDesC8& aHCICommandPacket, TDes8& aEventData) : THCIEventBase(ELoopbackCommandEvent, aEventData.Length(), aEventData) { PutString(aHCICommandPacket, aEventData); iEventData.Set(aEventData); }
// --------------------------------------------------------------------------- // CSensrvDataHandler::GetData // --------------------------------------------------------------------------- // TInt CSensrvDataHandler::GetData( TDes8& aDataPtr ) { COMPONENT_TRACE( ( _L( "Sensrv Client - CSensrvDataHandler::GetData - Start" ) ) ); TInt err( KErrNone ); if( aDataPtr.Length() < iChannelInfo.iDataItemSize ) { // aDataPtr is too small err = KErrOverflow; } else if( iGetDataCount >= iReadBufferCount || !iReadBuffer ) { // data not found. err = KErrNotFound; } else { // set data TUint8* ptr = const_cast<TUint8*>( iReadBuffer->Des().Ptr() ); ptr += ( iGetDataCount * iChannelInfo.iDataItemSize ); aDataPtr.Copy( ptr, iChannelInfo.iDataItemSize ); ++iGetDataCount; } COMPONENT_TRACE( ( _L( "Sensrv Client - CSensrvDataHandler::GetData - Return %d" ), err ) ); return err; }
TInt CTestAgentDrmContent::ReadTUintvarL(TDes8& aBuffer, TInt Offset, TInt& aNumBytes) const { TUint8 byte; TInt Value=0; TBool Continue = ETrue; for(aNumBytes = 0; Continue ; aNumBytes++) { Value <<= 7; if(Offset + aNumBytes == aBuffer.Length()) User::Leave(KErrOverflow); byte = aBuffer[Offset + aNumBytes]; if((byte & 0x80) == 0) { Continue=EFalse; } else { byte &= 0x7F; } Value+=byte; } return Value; }
void CSdpPDUHandler::CompleteOPL(TDes8& aPdu, const TDesC8& aWritePdu, const TInt aMaxAttrCount) /** Verifies the size of the response parameters and writes out correct length for the attributes. @verbatim response descriptor DesC written area (attributes) DesC maximum byte count TInt @endverbatim Method will leave if response is bigger than requested or allowed for. Returns nothing **/ { TUint16 finalLength = (TUint16)aWritePdu.Length(); if (finalLength > aMaxAttrCount) User::Leave(KErrNoMemory); aPdu.SetLength(KRspAttributeCountSize + finalLength + KContStateHeader); BigEndian::Put16(&aPdu[KRspAttrCountOffset], finalLength); // now need to update the DES size if (iDesSize == 3) { BigEndian::Put16(&aPdu[KRspAttributeListOffset+1], (unsigned short)(finalLength-iDesSize)); } else if (iDesSize == 2) { if (finalLength > 0xff) User::Leave(KErrNoMemory); aPdu[KRspAttributeListOffset+1] = (unsigned char)((finalLength&0xff)-iDesSize); } else User::Leave(KErrUnknown); // perhaps this should be a panic aPdu[aPdu.Length()-1] = 0; // FIXME: Put contState here }
TInt CT_DataRGavdp::GAVDP_SecurityControlIndication(TSEID /*aSEID*/, TDes8& aSecurityDataInOut) { INFO_PRINTF1(KLogInfoSecurityControlIndication); //verify CheckEvent(EGAVDP_SecurityControlIndication); HBufC16* securityDataInOut = HBufC16::NewL(aSecurityDataInOut.Length()); securityDataInOut->Des().Copy(aSecurityDataInOut); if (KLogDataFixed().Compare(*securityDataInOut)==0) { INFO_PRINTF1(KLogInfoSecurityDataUnchanged); } else if(KLogDataChange().Compare(*securityDataInOut)==0) { aSecurityDataInOut.Copy(KLogDataChanged()); INFO_PRINTF2(KLogInfoSecurityDataChanged, &KLogDataChanged()); } else { ERR_PRINTF1(KLogErrReceivedSecurityData); SetAsyncError(iCmdIndex, KErrGeneral); } delete securityDataInOut; DecOutstanding(); return KErrNone; }
EXPORT_C void CRtpHandlerBase::SaveReadStatus(TDes8& aClientBuf) { __RTP_LOG1(_L("CRtpHandlerBase [0x%x]::SaveClientStatus"), this); __RTP_LOG2(_L("\taClientBuffer at 0x%x, of Length %d"), aClientBuf.Ptr(), aClientBuf.Length()); ASSERT(iDataObserver); //With out DataObserver the app shouldnot attempt a read iClientDataPtr = &aClientBuf; }
TInt CIPv6Binder::DeleteContext(TDes8& aContextParameters) /** * Deletes a context. As the NIF is responsible for one primary context, * this is equivalent to closing down the NIF. * * @param aContextParameters Parameters of the context to delete * @return KErrArgument if an incorrect structure is passed, otherwise KErrNone */ { OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CIPV6BINDER_DELETECONTEXT_1, "CIPv6Binder::DeleteContext"); if (aContextParameters.Length() != sizeof(TContextParameters)) { return KErrArgument; } TUint8* ptr = CONST_CAST(TUint8*, aContextParameters.Ptr()); TContextParameters* params = REINTERPRET_CAST(TContextParameters*, ptr); if (params->iContextInfo.iContextId != STATIC_CAST(TInt8, GetFlow().GetBcaController()->Nsapi())) { params->iReasonCode = KErrBadName; } else { params->iReasonCode = KErrNone; GetFlow().Stop(KErrNone, MNifIfNotify::EDisconnect); } return KErrNone; }
// NB The use of the LAN Manager compatible challenge response has // been deprecated according to RFC 2433. inline void CPppMsChap::DesHashL(const TDesC8& aClear, TDes8& aCypher) /** Makes aCypher an irreversibly encrypted form of aClear by encrypting known text using aClear as the secret key. The known text consists of the string "KGS!@#$%". @param aClear [in] A plaintext used as the secret key for encryption (7 octets). @param aCypher [out] The ciphertext (8 octets). @note This function implements the DesHash routine specified in RFC 2433. @note The use of the LAN Manager compatible challenge response has been deprecated according to RFC 2433. @internalComponent */ { ASSERT(aClear.Length() == KPppMsChapDESKeySize); ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize); HBufC8* desKeyBuf = HBufC8::NewMaxLC(KPppDESKeySize); TPtr8 desKey(desKeyBuf->Des()); MakeDesKey(aClear, desKey); // A magic string literal specified in RFC 2433 used as clear text for // making aCypher an irreversibly encrypted form of aClear by // encrypting this clear text using aClear as the secret key. _LIT8(KStdText, "KGS!@#$%"); CBlockTransformation* encryptor = CDESEncryptor::NewLC(desKey, EFalse); CPaddingNone* padding = CPaddingNone::NewLC(); CBufferedEncryptor* bufEncryptor = CBufferedEncryptor::NewL(encryptor, padding); CleanupStack::Pop(padding); CleanupStack::Pop(encryptor); CleanupStack::PushL(bufEncryptor); aCypher.Zero(); bufEncryptor->ProcessFinalL(KStdText, aCypher); CleanupStack::PopAndDestroy(bufEncryptor); CleanupStack::PopAndDestroy(desKeyBuf); ASSERT(aCypher.Length() == KPppMsChapDESCipherTextSize); }
void CRandomSetSource::GenerateBytesL(TDes8& aDest) { TInt i=0; //Reverse the string by bytes up to the point of the end of the given string //of "random" bytes. for (i=0; iCounter >= 0 && i< aDest.Length(); ++i,--iCounter) { aDest[i] = iValue[iCounter]; } //Then fill the remaining (if any) bytes in aDest with 0's. This is all to //allow the stuff to work with bigint style integers; we're writing straight //into a RInteger.Ptr() here for(;i<aDest.Length(); ++i) { aDest[i] = 0x00; } }
// ----------------------------------------------------------------------------- // RDRMRightsClient::GetRandomDataL // ----------------------------------------------------------------------------- // EXPORT_C void RDRMRightsClient::GetRandomDataL( TDes8& aRandomData ) const { if( !aRandomData.Length() ) { User::Leave(KErrArgument); } User::LeaveIfError( SendReceive( DRMEngine::EGetRandomData, TIpcArgs( &aRandomData ) ) ); }