當前位置: 首頁>>代碼示例>>C++>>正文


C++ BlockSize函數代碼示例

本文整理匯總了C++中BlockSize函數的典型用法代碼示例。如果您正苦於以下問題:C++ BlockSize函數的具體用法?C++ BlockSize怎麽用?C++ BlockSize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了BlockSize函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: assert

void CTR_ModePolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
{
	assert(m_cipher->IsForwardTransformation());	// CTR mode needs the "encrypt" direction of the underlying block cipher, even to decrypt
	unsigned int maxBlocks = m_cipher->OptimalNumberOfParallelBlocks();
	if (maxBlocks == 1)
	{
		unsigned int sizeIncrement = BlockSize();
		while (iterationCount)
		{
			m_cipher->ProcessAndXorBlock(m_counterArray, input, output);
			IncrementCounterByOne(m_counterArray, sizeIncrement);
			output += sizeIncrement;
			input += sizeIncrement;
			iterationCount -= 1;
		}
	}
	else
	{
		unsigned int sizeIncrement = maxBlocks * BlockSize();
		while (iterationCount >= maxBlocks)
		{
			ProcessMultipleBlocks(output, input, maxBlocks);
			output += sizeIncrement;
			input += sizeIncrement;
			iterationCount -= maxBlocks;
		}
		if (iterationCount > 0)
			ProcessMultipleBlocks(output, input, iterationCount);
	}
}
開發者ID:0xmono,項目名稱:miranda-ng,代碼行數:30,代碼來源:modes.cpp

示例2: Allocate

//=========================================================================
// Allocate
void EpetraExt_BlockDiagMatrix::Allocate(){

  int DataSize=0, NumBlocks=NumMyBlocks();
  Pivots_=new int[NumMyUnknowns()];
  int *ElementSize=new int[NumBlocks];
  
  for(int i=0;i<NumBlocks;i++) {
    ElementSize[i]=BlockSize(i)*BlockSize(i);
    DataSize+=ElementSize[i];
  }
  
#ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
  if(Map().GlobalIndicesInt()) {
    DataMap_=new Epetra_BlockMap(-1,Map().NumMyElements(),Map().MyGlobalElements(),ElementSize,0,Map().Comm());
  }
  else
#endif
#ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
  if(Map().GlobalIndicesLongLong()) {
    DataMap_=new Epetra_BlockMap((long long) -1,Map().NumMyElements(),Map().MyGlobalElements64(),ElementSize,0,Map().Comm());
  }
  else
#endif
    throw "EpetraExt_BlockDiagMatrix::Allocate: GlobalIndices type unknown";

  Values_=new double[DataSize];  
  delete [] ElementSize;
}
開發者ID:rorypeck,項目名稱:trilinos,代碼行數:30,代碼來源:EpetraExt_BlockDiagMatrix.cpp

示例3: CheckHeap

VOID CheckHeap(VOID)
{
USHORT usSel;
BYTE _huge * pHeapStart;
BYTE _huge * pHeapEnd;
BYTE _huge * pWork;
ULONG ulTotal = 0;

   for (usSel = 0; usSel < MAX_SELECTORS; usSel++)
      {
      pHeapStart = rgpSegment[usSel];
      if (!pHeapStart)
         continue;

      pHeapEnd = pHeapStart + HEAP_SIZE;
      pWork = pHeapStart;
      while (pWork < pHeapEnd)
         {
         if (!IsBlockFree(pWork))
            ulTotal += BlockSize(pWork);

         pWork += BlockSize(pWork) + sizeof (ULONG);
         }
      if (pWork != pHeapEnd)
         errmsg("Heap corruption found!");
      }
   if (ulTotal != ulMem)
      {
      fflush(stdout);
      errmsg("Memory lost! %lu %lu %s", ulMem, ulTotal, szLast);
      }


}
開發者ID:OS2World,項目名稱:DRV-FAT32,代碼行數:34,代碼來源:memtest.c

示例4: BlockSize

void CTR_ModePolicy::OperateKeystream(KeystreamOperation operation, byte *output, const byte *input, size_t iterationCount)
{
	unsigned int maxBlocks = m_cipher->OptimalNumberOfParallelBlocks();
	if (maxBlocks == 1)
	{
		unsigned int sizeIncrement = BlockSize();
		while (iterationCount)
		{
			m_cipher->ProcessAndXorBlock(m_counterArray, input, output);
			IncrementCounterByOne(m_counterArray, sizeIncrement);
			output += sizeIncrement;
			input += sizeIncrement;
			iterationCount -= 1;
		}
	}
	else
	{
		unsigned int sizeIncrement = maxBlocks * BlockSize();
		while (iterationCount >= maxBlocks)
		{
			ProcessMultipleBlocks(output, input, maxBlocks);
			output += sizeIncrement;
			input += sizeIncrement;
			iterationCount -= maxBlocks;
		}
		if (iterationCount > 0)
			ProcessMultipleBlocks(output, input, iterationCount);
	}
}
開發者ID:gogo40,項目名稱:GoGo40-keygen,代碼行數:29,代碼來源:modes.cpp

示例5:

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);
		}
	}
開發者ID:cdaffara,項目名稱:symbiandump-os2,代碼行數:10,代碼來源:padding.cpp

示例6: if

//=========================================================================
//! Computes the inverse / factorization if such is set on the list
int EpetraExt_BlockDiagMatrix::Compute(){
  int info;

  if(ApplyMode_==AM_MULTIPLY)
    // Multiply mode - noop    
    return 0;
  else {
    // Factorization - Needed for both 'factor' and 'invert' modes
    int NumBlocks=NumMyBlocks();
    for(int i=0;i<NumBlocks;i++){
      int Nb=BlockSize(i);
      if(Nb==1) {
        // Optimize for Block Size 1        
        Values_[DataMap_->FirstPointInElement(i)]=1.0/Values_[DataMap_->FirstPointInElement(i)];
      }
      else if(Nb==2) {
        // Optimize for Block Size 2
        double * v=&Values_[DataMap_->FirstPointInElement(i)];          
        double d=1/(v[0]*v[3]-v[1]*v[2]);
        double v0old=v[0];
        v[0]=v[3]*d;
        v[1]=-v[1]*d;
        v[2]=-v[2]*d;
        v[3]=v0old*d;
      }
      else{
        // "Large" Block - Use LAPACK
        LAPACK.GETRF(Nb,Nb,&Values_[DataMap_->FirstPointInElement(i)],Nb,&Pivots_[Map().FirstPointInElement(i)],&info);
        if(info) EPETRA_CHK_ERR(-2);
      }
    }
    
    if(ApplyMode_==AM_INVERT){
      // Invert - Use the factorization and invert the blocks in-place
      int lwork=3*DataMap_->MaxMyElementSize();
      std::vector<double> work(lwork);
      for(int i=0;i<NumBlocks;i++){
        int Nb=BlockSize(i);
        if(Nb==1 || Nb==2){
          // Optimize for Block Size 1 and 2
          // No need to do anything - factorization has already inverted the value
        }
        else{
          // "Large" Block - Use LAPACK
          LAPACK.GETRI(Nb,&Values_[DataMap_->FirstPointInElement(i)],Nb,&Pivots_[Map().FirstPointInElement(i)],&work[0],&lwork,&info);
          if(info) EPETRA_CHK_ERR(-3);
        }
      }
    }      
  }
  HasComputed_=true;
  return 0;
}
開發者ID:rorypeck,項目名稱:trilinos,代碼行數:55,代碼來源:EpetraExt_BlockDiagMatrix.cpp

示例7: CRYPTOPP_ASSERT

void CBC_Encryption::ProcessData(byte *outString, const byte *inString, size_t length)
{
	if (!length)
		return;
	CRYPTOPP_ASSERT(length%BlockSize()==0);

	unsigned int blockSize = BlockSize();
	m_cipher->AdvancedProcessBlocks(inString, m_register, outString, blockSize, BlockTransformation::BT_XorInput);
	if (length > blockSize)
		m_cipher->AdvancedProcessBlocks(inString+blockSize, outString, outString+blockSize, length-blockSize, BlockTransformation::BT_XorInput);
	memcpy(m_register, outString + length - blockSize, blockSize);
}
開發者ID:superbitcoin,項目名稱:SuperBitcoin,代碼行數:12,代碼來源:modes.cpp

示例8: PadLastBlock

void TTMAC_Base::TruncatedFinal(byte *hash, size_t size)
{
	PadLastBlock(BlockSize() - 2*sizeof(HashWordType));
	CorrectEndianess(m_data, m_data, BlockSize() - 2*sizeof(HashWordType));

	m_data[m_data.size()-2] = GetBitCountLo();
	m_data[m_data.size()-1] = GetBitCountHi();

	Transform(m_digest, m_data, true);

	word32 t2 = m_digest[2];
	word32 t3 = m_digest[3];
	if (size != DIGESTSIZE)
	{
		switch (size)
		{
			case 16:
				m_digest[3] += m_digest[1] + m_digest[4];

			case 12:
				m_digest[2] += m_digest[0] + t3;

			case 8:
				m_digest[0] += m_digest[1] + t3;
				m_digest[1] += m_digest[4] + t2;
				break;

			case 4:
				m_digest[0] +=
						m_digest[1] +
						m_digest[2] +
						m_digest[3] +
						m_digest[4];
				break;

			case 0:
				// Used by HashTransformation::Restart()
				break;

			default:
				throw InvalidArgument("TTMAC_Base: can't truncate a Two-Track-MAC 20 byte digest to " + IntToString(size) + " bytes");
				break;
		}
	}

	CorrectEndianess(m_digest, m_digest, size);
	memcpy(hash, m_digest, size);

	Restart();		// reinit for next use
}
開發者ID:0xmono,項目名稱:miranda-ng,代碼行數:50,代碼來源:ttmac.cpp

示例9: BlockSize

EXPORT_C void CPadding::PadL(const TDesC8& aInput, TDes8& aOutput)
	{
	// Check that the input is small enough to fit inside one padded block
	// Won't leave if input text is equal to blocksize. Let DoPadL handle such situations
	if(aInput.Length() > BlockSize() - MinPaddingLength()
			&& aInput.Length() != BlockSize()) 	
		User::Leave(KErrArgument);
	
	// Check that the output descriptor supplied is large enough to store the result
	if(aOutput.MaxLength() < MaxPaddedLength(aInput.Length())) 	
		User::Leave(KErrOverflow);

	// Call the virtual function, implemented by derived classes
	DoPadL(aInput, aOutput);
	}
開發者ID:cdaffara,項目名稱:symbiandump-os2,代碼行數:15,代碼來源:padding.cpp

示例10: BlockSize

void CTR_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv)
{
	unsigned int s = BlockSize();
	CopyOrZero(m_register, iv, s);
	m_counterArray.New(s * m_cipher->OptimalNumberOfParallelBlocks());
	CopyOrZero(m_counterArray, iv, s);
}
開發者ID:0xmono,項目名稱:miranda-ng,代碼行數:7,代碼來源:modes.cpp

示例11: CheckHeap

VOID CheckHeap(VOID)
{
USHORT usSel;
BYTE _huge * pHeapStart;
BYTE _huge * pHeapEnd;
BYTE _huge * pWork;
USHORT rc;

   for (usSel = 0; usSel < MAX_SELECTORS; usSel++)
      {
      pHeapStart = rgpSegment[usSel];
      if (!pHeapStart || pHeapStart == RESERVED_SEGMENT)
         continue;
      rc = MY_PROBEBUF(PB_OPREAD, (PBYTE)pHeapStart, HEAP_SIZE);
      if (rc)
         {
         CritMessage("FAT32: Protection VIOLATION in CheckHeap (SYS%d)", rc);
         Message("FAT32: Protection VIOLATION in CheckHeap (SYS%d)", rc);
         return;
         }
      pHeapEnd = pHeapStart + HEAP_SIZE;
      pWork = pHeapStart;
      while (pWork < pHeapEnd)
         pWork += BlockSize(pWork) + sizeof (ULONG);
      if (pWork != pHeapEnd)
         CritMessage("FAT32: Heap corruption found!");
      }
}
開發者ID:OS2World,項目名稱:DRV-FAT32,代碼行數:28,代碼來源:ifsmem.c

示例12: BlockSize

template <class T, class BASE> byte * IteratedHashBase<T, BASE>::CreateUpdateSpace(size_t &size)
{
	unsigned int blockSize = BlockSize();
	unsigned int num = ModPowerOf2(m_countLo, blockSize);
	size = blockSize - num;
	return (byte *)m_data.begin() + num;
}
開發者ID:hon1nbo,項目名稱:BCTt,代碼行數:7,代碼來源:iterhash.cpp

示例13: OnReadFile

const IStream* FileStorage::ReadFileHelper(const FileEntry& file, FileDataType dataType /*= FileDataType::Binary*/) const
{
	const IStream* resultStream = OnReadFile(file, dataType);
	RETURN_NULL_IF_NULL(resultStream);

	const CoderChain* coderChain = GetFileCoderChain(file);
	if (coderChain != nullptr)
	{
		if (IsWholeFileCoding())
		{
			MemoryStream* tempStream = new MemoryStream(file.OriginalSize(), false);
			coderChain->Decode(*resultStream, *tempStream);
			const auto data = tempStream->CurrentBuffer();
			SAFE_DELETE(tempStream);
			MemoryStream* outputStream = new MemoryStream(data);
			resultStream = outputStream;
		}
		else
		{
			resultStream = new BlockCodeReadStream(*resultStream, BlockSize(), *coderChain, file);
		}
	}

	return resultStream;
}
開發者ID:johndpope,項目名稱:Medusa,代碼行數:25,代碼來源:FileStorage.cpp

示例14: CRYPTOPP_UNUSED

void OFB_ModePolicy::CipherResynchronize(byte *keystreamBuffer, const byte *iv, size_t length)
{
	CRYPTOPP_UNUSED(keystreamBuffer), CRYPTOPP_UNUSED(length);
	CRYPTOPP_ASSERT(length == BlockSize());

	CopyOrZero(m_register, iv, length);
}
開發者ID:superbitcoin,項目名稱:SuperBitcoin,代碼行數:7,代碼來源:modes.cpp

示例15: OnWriteFile

IStream* FileStorage::WriteFileHelper(FileEntry& file, FileOpenMode openMode /*= FileOpenMode::ReadOnly*/, FileDataType dataType /*= FileDataType::Binary*/)
{
	IStream* resultStream = OnWriteFile(file, openMode, dataType);;

	const CoderChain* coderChain = GetFileCoderChain(file);
	if (coderChain != nullptr)
	{
		if (IsWholeFileCoding())
		{
			resultStream = new FileCodeWriteStream(*resultStream, *coderChain, file);
		}
		else
		{
			resultStream = new BlockCodeWriteStream(*resultStream, BlockSize(), *coderChain, file);
		}
	}

	if (Hasher() != HasherType::None)
	{
		resultStream = new HashStream(*resultStream, Hasher(), [&file](StringRef result) {file.SetSignature(result); });

	}

	return resultStream;
}
開發者ID:johndpope,項目名稱:Medusa,代碼行數:25,代碼來源:FileStorage.cpp


注:本文中的BlockSize函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。