本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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
}
示例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);
}
示例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);
}
示例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!");
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}