本文整理汇总了C++中MemoryRegion::size方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryRegion::size方法的具体用法?C++ MemoryRegion::size怎么用?C++ MemoryRegion::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryRegion
的用法示例。
在下文中一共展示了MemoryRegion::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: emitSectionData
uint64_t NyuziGNULDBackend::emitSectionData(const LDSection& pSection,
MemoryRegion& pRegion) const
{
assert(pRegion.size() && "Size of MemoryRegion is zero!");
return pRegion.size();
}
示例2: Encoding_Error
/*
* EMSA1 BSI Encode Operation
*/
SecureVector<byte> EMSA1_BSI::encoding_of(const MemoryRegion<byte>& msg,
u32bit output_bits,
RandomNumberGenerator&)
{
if(msg.size() != hash_ptr()->OUTPUT_LENGTH)
throw Encoding_Error("EMSA1_BSI::encoding_of: Invalid size for input");
if(8*msg.size() <= output_bits)
return msg;
throw Encoding_Error("EMSA1_BSI::encoding_of: max key input size exceeded");
}
示例3: read_handshake
/*
* Split up and process handshake messages
*/
void TLS_Server::read_handshake(byte rec_type,
const MemoryRegion<byte>& rec_buf)
{
if(rec_type == HANDSHAKE)
{
if(!state)
state = new Handshake_State;
state->queue.write(&rec_buf[0], rec_buf.size());
}
while(true)
{
Handshake_Type type = HANDSHAKE_NONE;
SecureVector<byte> contents;
if(rec_type == HANDSHAKE)
{
if(state->queue.size() >= 4)
{
byte head[4] = { 0 };
state->queue.peek(head, 4);
const size_t length = make_u32bit(0, head[1], head[2], head[3]);
if(state->queue.size() >= length + 4)
{
type = static_cast<Handshake_Type>(head[0]);
contents.resize(length);
state->queue.read(head, 4);
state->queue.read(&contents[0], contents.size());
}
}
}
else if(rec_type == CHANGE_CIPHER_SPEC)
{
if(state->queue.size() == 0 && rec_buf.size() == 1 && rec_buf[0] == 1)
type = HANDSHAKE_CCS;
else
throw Decoding_Error("Malformed ChangeCipherSpec message");
}
else
throw Decoding_Error("Unknown message type in handshake processing");
if(type == HANDSHAKE_NONE)
break;
process_handshake_msg(type, contents);
if(type == HANDSHAKE_CCS || !state)
break;
}
}
示例4: generate_sbox
/*
* Generate one of the Sboxes
*/
void Blowfish::generate_sbox(MemoryRegion<u32bit>& box,
u32bit& L, u32bit& R,
const byte salt[16],
size_t salt_off) const
{
const u32bit* S1 = &S[0];
const u32bit* S2 = &S[256];
const u32bit* S3 = &S[512];
const u32bit* S4 = &S[768];
for(size_t i = 0; i != box.size(); i += 2)
{
L ^= load_be<u32bit>(salt, (i + salt_off) % 4);
R ^= load_be<u32bit>(salt, (i + salt_off + 1) % 4);
for(size_t j = 0; j != 16; j += 2)
{
L ^= P[j];
R ^= ((S1[get_byte(0, L)] + S2[get_byte(1, L)]) ^
S3[get_byte(2, L)]) + S4[get_byte(3, L)];
R ^= P[j+1];
L ^= ((S1[get_byte(0, R)] + S2[get_byte(1, R)]) ^
S3[get_byte(2, R)]) + S4[get_byte(3, R)];
}
u32bit T = R; R = L ^ P[16]; L = T ^ P[17];
box[i] = L;
box[i+1] = R;
}
}
示例5: invalid_argument
SecureVector<byte> rfc3394_keyunwrap(const MemoryRegion<byte>& key,
const SymmetricKey& kek,
Algorithm_Factory& af)
{
if(key.size() < 16 || key.size() % 8 != 0)
throw std::invalid_argument("Bad input key size for NIST key unwrap");
std::auto_ptr<BlockCipher> aes(make_aes(kek.length(), af));
aes->set_key(kek);
const size_t n = (key.size() - 8) / 8;
SecureVector<byte> R(n * 8);
SecureVector<byte> A(16);
for(size_t i = 0; i != 8; ++i)
A[i] = key[i];
copy_mem(&R[0], key.begin() + 8, key.size() - 8);
for(size_t j = 0; j <= 5; ++j)
{
for(size_t i = n; i != 0; --i)
{
const u32bit t = (5 - j) * n + i;
byte t_buf[4] = { 0 };
store_be(t, t_buf);
xor_buf(&A[4], &t_buf[0], 4);
copy_mem(&A[8], &R[8*(i-1)], 8);
aes->decrypt(&A[0]);
copy_mem(&R[8*(i-1)], &A[8], 8);
}
}
if(load_be<u64bit>(&A[0], 0) != 0xA6A6A6A6A6A6A6A6)
throw Integrity_Failure("NIST key unwrap failed");
return R;
}
示例6: emitSectionData
uint64_t ARMGNULDBackend::emitSectionData(const Output& pOutput,
const LDSection& pSection,
const MCLDInfo& pInfo,
MemoryRegion& pRegion) const
{
assert(pRegion.size() && "Size of MemoryRegion is zero!");
ELFFileFormat* file_format = getOutputFormat(pOutput);
if (&pSection == m_pAttributes) {
// FIXME: Currently Emitting .ARM.attributes directly from the input file.
const llvm::MCSectionData* sect_data = pSection.getSectionData();
assert(sect_data &&
"Emit .ARM.attribute failed, MCSectionData doesn't exist!");
uint8_t* start =
llvm::cast<MCRegionFragment>(
sect_data->getFragmentList().front()).getRegion().start();
memcpy(pRegion.start(), start, pRegion.size());
return pRegion.size();
}
if (&pSection == &(file_format->getPLT())) {
assert(NULL != m_pPLT && "emitSectionData failed, m_pPLT is NULL!");
uint64_t result = m_pPLT->emit(pRegion);
return result;
}
if (&pSection == &(file_format->getGOT())) {
assert(NULL != m_pGOT && "emitSectionData failed, m_pGOT is NULL!");
uint64_t result = m_pGOT->emit(pRegion);
return result;
}
llvm::report_fatal_error(llvm::Twine("Unable to emit section `") +
pSection.name() +
llvm::Twine("'.\n"));
return 0x0;
}
示例7: if
uint64_t X86GNULDBackend::emitSectionData(const LDSection& pSection,
MemoryRegion& pRegion) const
{
assert(pRegion.size() && "Size of MemoryRegion is zero!");
const ELFFileFormat* FileFormat = getOutputFormat();
assert(FileFormat &&
"ELFFileFormat is NULL in X86GNULDBackend::emitSectionData!");
unsigned int EntrySize = 0;
uint64_t RegionSize = 0;
if (&pSection == &(FileFormat->getPLT())) {
assert(m_pPLT && "emitSectionData failed, m_pPLT is NULL!");
unsigned char* buffer = pRegion.getBuffer();
m_pPLT->applyPLT0();
m_pPLT->applyPLT1();
X86PLT::iterator it = m_pPLT->begin();
unsigned int plt0_size = llvm::cast<PLTEntryBase>((*it)).size();
memcpy(buffer, llvm::cast<PLTEntryBase>((*it)).getValue(), plt0_size);
RegionSize += plt0_size;
++it;
PLTEntryBase* plt1 = 0;
X86PLT::iterator ie = m_pPLT->end();
while (it != ie) {
plt1 = &(llvm::cast<PLTEntryBase>(*it));
EntrySize = plt1->size();
memcpy(buffer + RegionSize, plt1->getValue(), EntrySize);
RegionSize += EntrySize;
++it;
}
}
else if (&pSection == &(FileFormat->getGOT())) {
RegionSize += emitGOTSectionData(pRegion);
}
else if (&pSection == &(FileFormat->getGOTPLT())) {
RegionSize += emitGOTPLTSectionData(pRegion, FileFormat);
}
else {
fatal(diag::unrecognized_output_sectoin)
<< pSection.name()
<< "[email protected]";
}
return RegionSize;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_frameworks_compile_mclinker,代码行数:52,代码来源:X86LDBackend.cpp
示例8: assert
uint64_t AArch64GNULDBackend::emitSectionData(const LDSection& pSection,
MemoryRegion& pRegion) const {
assert(pRegion.size() && "Size of MemoryRegion is zero!");
const ELFFileFormat* file_format = getOutputFormat();
if (file_format->hasPLT() && (&pSection == &(file_format->getPLT()))) {
uint64_t result = m_pPLT->emit(pRegion);
return result;
}
if (file_format->hasGOT() && (&pSection == &(file_format->getGOT()))) {
uint64_t result = m_pGOT->emit(pRegion);
return result;
}
if (file_format->hasGOTPLT() && (&pSection == &(file_format->getGOTPLT()))) {
uint64_t result = m_pGOT->emit(pRegion);
return result;
}
return pRegion.size();
}
示例9: emit
/// emit
void ELFDynamic::emit(const LDSection& pSection, MemoryRegion& pRegion) const
{
if (pRegion.size() < pSection.size()) {
llvm::report_fatal_error(llvm::Twine("the given memory is smaller") +
llvm::Twine(" than the section's demaind.\n"));
}
uint8_t* address = (uint8_t*)pRegion.begin();
EntryListType::const_iterator entry, entryEnd = m_NeedList.end();
for (entry = m_NeedList.begin(); entry != entryEnd; ++entry)
address += (*entry)->emit(address);
entryEnd = m_EntryList.end();
for (entry = m_EntryList.begin(); entry != entryEnd; ++entry)
address += (*entry)->emit(address);
}
示例10: emitSectionData
uint64_t MipsGNULDBackend::emitSectionData(const LDSection& pSection,
MemoryRegion& pRegion) const {
assert(pRegion.size() && "Size of MemoryRegion is zero!");
const ELFFileFormat* file_format = getOutputFormat();
if (file_format->hasGOT() && (&pSection == &(file_format->getGOT()))) {
return m_pGOT->emit(pRegion);
}
if (file_format->hasPLT() && (&pSection == &(file_format->getPLT()))) {
return m_pPLT->emit(pRegion);
}
if (file_format->hasGOTPLT() && (&pSection == &(file_format->getGOTPLT()))) {
return m_pGOTPLT->emit(pRegion);
}
fatal(diag::unrecognized_output_sectoin) << pSection.name()
<< "[email protected]";
return 0;
}
示例11: pad
/*
* Encode a message
*/
SecureVector<byte> EME::encode(const MemoryRegion<byte>& msg,
size_t key_bits,
RandomNumberGenerator& rng) const
{
return pad(&msg[0], msg.size(), key_bits, rng);
}
示例12: decode
/*************************************************
* Decode a BigInt *
*************************************************/
BigInt BigInt::decode(const MemoryRegion<byte>& buf, Base base)
{
return BigInt::decode(buf, buf.size(), base);
}
示例13: update
virtual void update(const MemoryRegion &in)
{
if(!in.isSecure())
secure = false;
md5_append(&md5, (const md5_byte_t *)in.data(), in.size());
}
示例14: process_msg
/*
* Process a full message at once
*/
void Pipe::process_msg(const MemoryRegion<byte>& input)
{
process_msg(input.begin(), input.size());
}
示例15: write
/*
* Write into a Pipe
*/
void Pipe::write(const MemoryRegion<byte>& input)
{
write(&input[0], input.size());
}