void uncompress(std::istream &in, std::ostream &out) { while (in) { int32_t uncompress_size = rawReadInt(in); if (uncompress_size == 0) { // empty block rawReadInt(in); continue; } else if (uncompress_size < 0) { // end of file break; } int32_t compress_size = rawReadInt(in); StreamSource ssrc(in, compress_size); StreamSink ssink(out); snappy::Uncompress(&ssrc, &ssink); } }
std::vector<std::uint8_t> cryptoprocess_buffer( const std::vector<std::uint8_t> &buffer, size_t constant_size, const std::string &symmetric_key, const std::array<uint8_t, 12> &initialization_vector){ CryptoPP::PKCS12_PBKDF<CryptoPP::SHA256> derivation; CryptoPP::SecByteBlock key(CryptoPP::Twofish::MAX_KEYLENGTH); derivation.DeriveKey(key.data(), key.size(), 0, (const byte *)symmetric_key.c_str(), symmetric_key.size(), salt, sizeof(salt), 1 << 10, 0); typename T::algo_type e; e.SetKeyWithIV(key, key.size(), initialization_vector.data(), initialization_vector.size()); e.SpecifyDataLengths(0, constant_size, 0); std::string pre, post; pre.resize(buffer.size()); std::copy(buffer.begin(), buffer.end(), pre.begin()); CryptoPP::StringSource ssrc(pre, true, new typename T::filter_type(e, new CryptoPP::StringSink(post))); std::vector<std::uint8_t> ret; ret.resize(post.size()); std::copy(post.begin(), post.end(), ret.begin()); return ret; }
void UT_CRtpSDES::UT_CRtpSDES_GetSdesSsrcL( ) { TInt result( KErrNone ); CRtpSDES* rtpSdes( NULL ); TInt err( KErrNone ); // "" ) ); // "Test description: Get SSRC that does not exist" ) ); // "CRtpSDES::GetSdesSsrc( TRtpSSRC aSSRC )") ); // "CRtpSDES::AddSsrcToSdesL( const TRtpSSRC aSSRC )") ); TRAP( err, rtpSdes = CRtpSDES::NewL() ) if ( err != KErrNone ) { delete rtpSdes; __ASSERT_ALWAYS( err != KErrNoMemory, User::Leave( KErrNoMemory ) ); // "CRtpSDES: ERROR, could not create CRtpSDES object" ) ); EUNIT_ASSERT( EFalse ); } CleanupStack::PushL( rtpSdes ); TRtpSSRC ssrc( 0 ); TBool gotSSRC( rtpSdes->GetSdesSsrc( ssrc ) ); if ( gotSSRC ) { // "ERROR, should not have found SSRC") ); } ssrc = 1; rtpSdes->AddSsrcToSdesL( ssrc ); if ( rtpSdes->iSndSSRCArray->Count() != 1 ) { result = KErrGeneral; // "ERROR, incorrect number of SSRC:s in array (1)") ); } ssrc = 1; rtpSdes->AddSsrcToSdesL( ssrc ); if ( rtpSdes->iSndSSRCArray->Count() != 1 ) { result = KErrGeneral; // "ERROR, incorrect number of SSRC:s in array (2)") ); } ssrc = 2; rtpSdes->AddSsrcToSdesL( ssrc ); if ( rtpSdes->iSndSSRCArray->Count() != 2 ) { result = KErrGeneral; // "ERROR, incorrect number of SSRC:s in array (3)") ); } gotSSRC = rtpSdes->GetSdesSsrc( 3 ); if ( gotSSRC ) { result = KErrGeneral; // "ERROR, should not have found SSRC 3") ); } gotSSRC = rtpSdes->GetSdesSsrc( 1 ); if ( !gotSSRC ) { result = KErrGeneral; // "ERROR, should have found SSRC 1") ); } if ( rtpSdes->iSndSSRCArray->Count() != 2 ) { result = KErrGeneral; // "ERROR, incorrect number of SSRC:s in array (4)") ); } if ( result == KErrNone ) { // "CRtpSDES::GetSdesSsrc - passed" ) ); // "CRtpSDES::AddSsrcToSdesL - passed" ) ); } else { // "CRtpSDES::GetSdesSsrc - FAILED" ) ); // "CRtpSDES::AddSsrcToSdesL - FAILED" ) ); } CleanupStack::PopAndDestroy( rtpSdes ); }