IBR-DTNSuite
0.12
|
#include <PayloadConfidentialBlock.h>
Classes | |
class | Factory |
Public Member Functions | |
virtual | ~PayloadConfidentialBlock () |
Public Member Functions inherited from dtn::security::SecurityBlock | |
virtual | ~SecurityBlock ()=0 |
virtual dtn::data::Length | getLength () const |
virtual dtn::data::Length | getLength_mutable () const |
virtual std::ostream & | serialize (std::ostream &stream, dtn::data::Length &length) const |
virtual std::ostream & | serialize_strict (std::ostream &stream, dtn::data::Length &length) const |
virtual std::istream & | deserialize (std::istream &stream, const dtn::data::Length &length) |
const dtn::data::EID | getSecuritySource () const |
const dtn::data::EID | getSecurityDestination () const |
void | setSecuritySource (const dtn::data::EID &source) |
void | setSecurityDestination (const dtn::data::EID &destination) |
bool | isSecuritySource (const dtn::data::Bundle &, const dtn::data::EID &) const |
bool | isSecurityDestination (const dtn::data::Bundle &, const dtn::data::EID &) const |
const dtn::data::EID | getSecuritySource (const dtn::data::Bundle &) const |
const dtn::data::EID | getSecurityDestination (const dtn::data::Bundle &) const |
template<class T > | |
T & | encryptBlock (dtn::data::Bundle &bundle, dtn::data::Bundle::iterator &it, uint32_t salt, const unsigned char ephemeral_key[ibrcommon::AES128Stream::key_size_in_bytes]) |
Public Member Functions inherited from dtn::data::Block | |
virtual | ~Block () |
Block & | operator= (const Block &block) |
bool | operator== (const block_t &id) const |
virtual void | addEID (const dtn::data::EID &eid) |
virtual void | clearEIDs () |
virtual const eid_list & | getEIDList () const |
const block_t & | getType () const |
void | set (ProcFlags flag, const bool &value) |
bool | get (ProcFlags flag) const |
const Bitset< ProcFlags > & | getProcessingFlags () const |
virtual Length | getLength_strict () const |
Static Public Member Functions | |
static void | encrypt (dtn::data::Bundle &bundle, const dtn::security::SecurityKey &long_key, const dtn::data::EID &source) |
static void | decrypt (dtn::data::Bundle &bundle, const dtn::security::SecurityKey &long_key) |
Static Public Attributes | |
static const dtn::data::block_t | BLOCK_TYPE = SecurityBlock::PAYLOAD_CONFIDENTIAL_BLOCK |
Protected Member Functions | |
PayloadConfidentialBlock () | |
Protected Member Functions inherited from dtn::security::SecurityBlock | |
void | store_security_references () |
SecurityBlock (const SecurityBlock::BLOCK_TYPES type, const CIPHERSUITE_IDS id) | |
SecurityBlock (const SecurityBlock::BLOCK_TYPES type) | |
void | setCiphersuiteId (const CIPHERSUITE_IDS id) |
void | setCorrelator (const dtn::data::Number &corr) |
virtual MutableSerializer & | serialize_mutable (MutableSerializer &serializer, bool include_security_result=true) const |
virtual dtn::data::Length | getSecurityResultSize () const |
Protected Member Functions inherited from dtn::data::Block | |
Block (block_t blocktype) | |
Static Protected Member Functions | |
static bool | decryptPayload (dtn::data::Bundle &bundle, const unsigned char ephemeral_key[ibrcommon::AES128Stream::key_size_in_bytes], const uint32_t salt) |
Static Protected Member Functions inherited from dtn::security::SecurityBlock | |
static bool | isCorrelatorPresent (const dtn::data::Bundle &bundle, const dtn::data::Number &correlator) |
static dtn::data::Number | createCorrelatorValue (const dtn::data::Bundle &bundle) |
static void | createSaltAndKey (uint32_t &salt, unsigned char *key, dtn::data::Length key_size) |
static void | addKey (TLVList &security_parameter, unsigned char const *const key, dtn::data::Length key_size, RSA *rsa) |
static bool | getKey (const TLVList &security_parameter, unsigned char *key, dtn::data::Length key_size, RSA *rsa) |
static void | addSalt (TLVList &security_parameters, const uint32_t &salt) |
static uint32_t | getSalt (const TLVList &security_parameters) |
static void | copyEID (const dtn::data::Block &from, dtn::data::Block &to, dtn::data::Length skip=0) |
template<class T > | |
static T & | encryptBlock (dtn::data::Bundle &bundle, dtn::data::Bundle::iterator &it, uint32_t salt, const unsigned char ephemeral_key[ibrcommon::AES128Stream::key_size_in_bytes]) |
static void | decryptBlock (dtn::data::Bundle &bundle, dtn::data::Bundle::iterator &it, uint32_t salt, const unsigned char key[ibrcommon::AES128Stream::key_size_in_bytes]) |
static void | addFragmentRange (TLVList &ciphersuite_params, const dtn::data::Number &fragmentoffset, const dtn::data::Number &payload_length) |
Friends | |
class | dtn::data::Bundle |
The PayloadConfidentialBlock encrypts the payload, PayloadConfidentialBlocks, which are already there and PayloadIntegrityBlocks, which are already there. Payload Confidential or Integrity Blocks are encrypted because they can contain e.g. signatures which make guessing the plaintext easier. You can instantiate a factory, which will take care of everything. The factory can be given a rsa key and the corresponding node. You may wish to add more keys using addDestination(), so one or more nodes are able to recover the payload. For each destination a PayloadConfidentialBlock is placed in the bundle, when calling encrypt(). Be sure, that no other PayloadConfidentialBlocks or PayloadIntegrityBlocks are inside this bundle if using encryption with more than one key.
Definition at line 46 of file PayloadConfidentialBlock.h.
|
virtual |
does nothing
Definition at line 56 of file PayloadConfidentialBlock.cpp.
|
protected |
Creates an empty PayloadConfidentialBlock. With ciphersuite_id set to PCB_RSA_AES128_PAYLOAD_PIB_PCB
Definition at line 51 of file PayloadConfidentialBlock.cpp.
Referenced by dtn::security::PayloadConfidentialBlock::Factory::create().
|
static |
Decrypts the Payload inside this Bundle. All correlated Blocks, which are found, will be decrypted, too, placed at the position, where their PayloadConfidentialBlock was, which contained them. After a matching PayloadConfidentialBlock with key information is searched by looking after the security destination. If the payload has been decrypted successfully, the correlated blocks will be decrypted. If one block fails to decrypt, it will be deleted.
bundle | the bundle with the to be decrypted payload |
Definition at line 156 of file PayloadConfidentialBlock.cpp.
References dtn::security::SecurityBlock::_ciphersuite_flags, dtn::security::SecurityBlock::_ciphersuite_id, dtn::security::SecurityBlock::_ciphersuite_params, dtn::security::SecurityBlock::_correlator, dtn::data::Bundle::begin(), dtn::security::SecurityBlock::CONTAINS_CORRELATOR, ibrcommon::LogLevel::critical, dtn::security::SecurityBlock::decryptBlock(), decryptPayload(), dtn::data::Bundle::end(), dtn::security::SecurityKey::free(), dtn::security::SecurityBlock::getKey(), dtn::security::SecurityKey::getRSA(), dtn::security::SecurityBlock::getSalt(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::security::SecurityBlock::isSecurityDestination(), ibrcommon::AES128Stream::key_size_in_bytes, dtn::security::SecurityBlock::PCB_RSA_AES128_PAYLOAD_PIB_PCB, dtn::security::SecurityKey::reference, dtn::data::Bundle::remove(), and dtn::security::SecurityBlock::salt.
Referenced by dtn::security::SecurityManager::decrypt(), and decryptPayload().
|
staticprotected |
Decrypts the payload using the ephemeral_key and salt.
bundle | the payload containing bundle |
ephemeral_key | the AES key |
salt | the salt |
Definition at line 265 of file PayloadConfidentialBlock.cpp.
References dtn::security::SecurityBlock::_ciphersuite_params, dtn::security::SecurityBlock::_security_result, ibrcommon::CipherStream::CIPHER_DECRYPT, decrypt(), ibrcommon::LogLevel::error, dtn::data::Bundle::find(), dtn::security::SecurityBlock::TLVList::get(), IBRCOMMON_LOGGER_ENDL, IBRCOMMON_LOGGER_TAG, dtn::security::SecurityBlock::initialization_vector, ibrcommon::BLOB::Reference::iostream(), ibrcommon::AES128Stream::iv_len, dtn::security::SecurityBlock::PCB_integrity_check_value, ibrcommon::AES128Stream::tag_len, and ibrcommon::AES128Stream::verify().
Referenced by decrypt().
|
static |
Encrypts the Payload inside this Bundle. If PIBs or PCBs are found, they will be encrypted, too, with a correlator set. The encrypted blocks will be each placed inside a PayloadConfidentialBlock, which will be inserted at the same place, except for the payload, which be encrypted in place.
bundle | the bundle with the to be encrypted payload |
Definition at line 60 of file PayloadConfidentialBlock.cpp.
References dtn::security::SecurityBlock::_ciphersuite_flags, dtn::security::SecurityBlock::_ciphersuite_params, dtn::security::SecurityBlock::_security_result, dtn::security::SecurityBlock::addFragmentRange(), dtn::security::SecurityBlock::addKey(), dtn::security::SecurityBlock::addSalt(), dtn::data::Bundle::begin(), dtn::security::PayloadIntegrityBlock::BLOCK_TYPE, BLOCK_TYPE, ibrcommon::CipherStream::CIPHER_ENCRYPT, dtn::security::SecurityBlock::CONTAINS_CIPHERSUITE_PARAMS, dtn::security::SecurityBlock::CONTAINS_SECURITY_RESULT, dtn::security::SecurityBlock::createCorrelatorValue(), dtn::security::SecurityBlock::createSaltAndKey(), dtn::data::PrimaryBlock::destination, dtn::data::Bundle::end(), dtn::data::Bundle::find(), dtn::data::PrimaryBlock::FRAGMENT, dtn::data::BundleID::fragmentoffset, dtn::security::SecurityKey::free(), dtn::data::PrimaryBlock::get(), dtn::data::PayloadBlock::getBLOB(), ibrcommon::AES128Stream::getIV(), dtn::security::SecurityKey::getRSA(), ibrcommon::AES128Stream::getTag(), dtn::security::SecurityBlock::initialization_vector, ibrcommon::BLOB::iostream::iostream(), ibrcommon::AES128Stream::iv_len, ibrcommon::AES128Stream::key_size_in_bytes, dtn::security::SecurityBlock::PCB_integrity_check_value, dtn::data::Bundle::push_front(), dtn::security::SecurityKey::reference, dtn::data::Block::REPLICATE_IN_EVERY_FRAGMENT, dtn::security::SecurityBlock::salt, dtn::data::EID::sameHost(), dtn::data::Block::set(), dtn::security::SecurityBlock::TLVList::set(), dtn::security::SecurityBlock::setCorrelator(), dtn::security::SecurityBlock::setSecurityDestination(), dtn::security::SecurityBlock::setSecuritySource(), ibrcommon::BLOB::iostream::size(), dtn::data::BundleID::source, and ibrcommon::AES128Stream::tag_len.
Referenced by dtn::security::SecurityManager::encrypt().
|
friend |
This class is allowed to call the parameterless contructor and the constructor with a bundle as argument.
Definition at line 52 of file PayloadConfidentialBlock.h.
|
static |
The block type of this class.
Definition at line 63 of file PayloadConfidentialBlock.h.
Referenced by dtn::security::SecurityManager::decrypt(), encrypt(), dtn::security::SecurityManager::fastverify(), dtn::core::BundleCore::processBlocks(), and dtn::security::SecurityManager::verifyPIB().