本文整理汇总了C++中Section::getBlockCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::getBlockCount方法的具体用法?C++ Section::getBlockCount怎么用?C++ Section::getBlockCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::getBlockCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSectionOffset
//! The boot tag for \a section is taken into account, thus making the
//! result offset point to the first block of the actual section data.
//!
//! \note The offset will only be valid if all encryption keys and all
//! sections have already been added to the image.
uint32_t EncoreBootImage::getSectionOffset(Section * section)
{
// start with boot image headers
uint32_t offset = numberOfCipherBlocks(sizeof(boot_image_header_t)); // header
offset += numberOfCipherBlocks(sizeof(section_header_t)) * sectionCount(); // section table
offset += 2 * keyCount(); // key dictiontary
// add up sections before this one
section_iterator_t it = beginSection();
for (; it != endSection() && *it != section; ++it)
{
Section * thisSection = *it;
// insert padding for section alignment
offset += getPadBlockCountForSection(thisSection, offset);
// add one for boot tag associated with this section
offset++;
// now add the section's contents
offset += thisSection->getBlockCount();
}
// and add padding for this section
offset += getPadBlockCountForSection(section, offset);
// skip over this section's boot tag
offset++;
return offset;
}
示例2: writeToStream
//.........这里部分代码省略.........
if (isEncrypted())
{
key_iterator_t it = beginKeys();
for (i=0; it != endKeys(); ++it, ++i)
{
// write CBC-MAC result for this key, then update SHA-1
RijndaelCBCMAC & mac = (macs.get())[i];
const RijndaelCBCMAC::block_t & macResult = mac.getMAC();
stream.write(reinterpret_cast<const char *>(&macResult), sizeof(RijndaelCBCMAC::block_t));
hash.Update(reinterpret_cast<const uint8_t *>(&macResult), sizeof(RijndaelCBCMAC::block_t));
fileBlocksWritten++;
// encrypt DEK with this key, write it out, and update image digest
Rijndael cipher;
cipher.init(Rijndael::CBC, Rijndael::Encrypt, *it, Rijndael::Key16Bytes, imageHeader.m_iv);
AESKey<128>::key_t wrappedSessionKey;
cipher.blockEncrypt(m_sessionKey, sizeof(AESKey<128>::key_t) * 8, wrappedSessionKey);
stream.write(reinterpret_cast<char *>(&wrappedSessionKey), sizeof(wrappedSessionKey));
hash.Update(reinterpret_cast<uint8_t *>(&wrappedSessionKey), sizeof(wrappedSessionKey));
fileBlocksWritten++;
}
}
// write sections and boot tags
{
section_iterator_t it = beginSection();
for (; it != endSection(); ++it)
{
section_iterator_t itCopy = it;
bool isLastSection = (++itCopy == endSection());
Section * section = *it;
cipher_block_t block;
unsigned blockCount = section->getBlockCount();
unsigned blocksWritten = 0;
Rijndael cipher;
cipher.init(Rijndael::CBC, Rijndael::Encrypt, m_sessionKey, Rijndael::Key16Bytes, imageHeader.m_iv);
// Compute the number of padding blocks needed to align the section. This first
// call to getPadBlockCountForOffset() passes an offset that excludes
// the boot tag for this section.
unsigned paddingBlocks = getPadBlockCountForSection(section, fileBlocksWritten);
// Insert nop commands as padding to align the start of the section, if
// the section has special alignment requirements.
NopCommand nop;
while (paddingBlocks--)
{
blockCount = nop.getBlockCount();
blocksWritten = 0;
while (blocksWritten < blockCount)
{
nop.getBlocks(blocksWritten, 1, &block);
if (isEncrypted())
{
// re-init after encrypt to update IV
cipher.blockEncrypt(block, sizeof(cipher_block_t) * 8, block);
cipher.init(Rijndael::CBC, Rijndael::Encrypt, m_sessionKey, Rijndael::Key16Bytes, block);
}
stream.write(reinterpret_cast<char *>(&block), sizeof(cipher_block_t));
hash.Update(reinterpret_cast<uint8_t *>(&block), sizeof(cipher_block_t));
blocksWritten++;
示例3:
//! The identifier, length, and flags fields are taken from \a section.
//!
//! \todo How does length get set correctly if the length is supposed to include
//! this command?
EncoreBootImage::TagCommand::TagCommand(const Section & section)
{
m_sectionIdentifier = section.getIdentifier();
m_sectionLength = section.getBlockCount();
m_sectionFlags = section.getFlags();
}