本文整理汇总了C++中dtn::data::Bundle::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ Bundle::remove方法的具体用法?C++ Bundle::remove怎么用?C++ Bundle::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dtn::data::Bundle
的用法示例。
在下文中一共展示了Bundle::remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: decrypt
void PayloadConfidentialBlock::decrypt(dtn::data::Bundle& bundle, const dtn::security::SecurityKey &long_key)
{
// list of block to delete if the process is successful
std::list<const dtn::data::Block*> erasure_list;
// load the RSA key
RSA *rsa_key = long_key.getRSA();
try {
// array for the current symmetric AES key
unsigned char key[ibrcommon::AES128Stream::key_size_in_bytes];
// correlator of the first PCB
dtn::data::Number correlator = 0;
bool decrypt_related = false;
// iterate through all blocks
for (dtn::data::Bundle::iterator it = bundle.begin(); it != bundle.end(); ++it)
{
try {
dynamic_cast<const PayloadIntegrityBlock&>(**it);
// add this block to the erasure list for later deletion
erasure_list.push_back(&**it);
} catch (const std::bad_cast&) { };
try {
const PayloadConfidentialBlock &pcb = dynamic_cast<const PayloadConfidentialBlock&>(**it);
// get salt and key
uint32_t salt = getSalt(pcb._ciphersuite_params);
// decrypt related blocks
if (decrypt_related)
{
// try to decrypt the block
try {
decryptBlock(bundle, it, salt, key);
// success! add this block to the erasue list
erasure_list.push_back(&**it);
} catch (const ibrcommon::Exception&) {
IBRCOMMON_LOGGER_TAG("PayloadConfidentialBlock", critical) << "tag verfication failed, reversing decryption..." << IBRCOMMON_LOGGER_ENDL;
decryptBlock(bundle, it, salt, key);
// abort the decryption and discard the bundle?
throw ibrcommon::Exception("decrypt of correlated block reversed, tag verfication failed");
}
}
// if security destination does match the key, then try to decrypt the payload
else if (pcb.isSecurityDestination(bundle, long_key.reference) &&
(pcb._ciphersuite_id == SecurityBlock::PCB_RSA_AES128_PAYLOAD_PIB_PCB))
{
// try to decrypt the symmetric AES key
if (!getKey(pcb._ciphersuite_params, key, ibrcommon::AES128Stream::key_size_in_bytes, rsa_key))
{
IBRCOMMON_LOGGER_TAG("PayloadConfidentialBlock", critical) << "could not get symmetric key decrypted" << IBRCOMMON_LOGGER_ENDL;
throw ibrcommon::Exception("decrypt failed - could not get symmetric key decrypted");
}
// try to decrypt the payload
if (!decryptPayload(bundle, key, salt))
{
// reverse decryption
IBRCOMMON_LOGGER_TAG("PayloadConfidentialBlock", critical) << "tag verfication failed, reversing decryption..." << IBRCOMMON_LOGGER_ENDL;
decryptPayload(bundle, key, salt);
throw ibrcommon::Exception("decrypt reversed - tag verfication failed");
}
// success! add this block to the erasue list
erasure_list.push_back(&**it);
// check if first PCB has a correlator
if (pcb._ciphersuite_flags & CONTAINS_CORRELATOR)
{
// ... and decrypt all correlated block with the same key
decrypt_related = true;
// store the correlator
correlator = pcb._correlator;
}
else
{
// no correlated blocks should exists
// stop here with decryption
break;
}
}
else
{
// exit here, because we can not decrypt the first PCB.
throw ibrcommon::Exception("unable to decrypt the first PCB");
}
} catch (const std::bad_cast&) { };
}
// delete all block in the erasure list
for (std::list<const dtn::data::Block* >::const_iterator it = erasure_list.begin(); it != erasure_list.end(); ++it)
{
bundle.remove(**it);
//.........这里部分代码省略.........