IBR-DTNSuite  0.8
ibrdtn/ibrdtn/security/PayloadConfidentialBlock.h
Go to the documentation of this file.
00001 #ifndef _PAYLOAD_CONFIDENTIAL_BLOCK_H_
00002 #define _PAYLOAD_CONFIDENTIAL_BLOCK_H_
00003 #include "ibrdtn/security/SecurityBlock.h"
00004 #include "ibrdtn/security/SecurityKey.h"
00005 #include "ibrdtn/data/PayloadBlock.h"
00006 #include "ibrdtn/data/ExtensionBlock.h"
00007 
00008 namespace dtn
00009 {
00010         namespace security
00011         {
00025                 class PayloadConfidentialBlock : public SecurityBlock
00026                 {
00031                         friend class dtn::data::Bundle;
00032                         public:
00033                                 class Factory : public dtn::data::ExtensionBlock::Factory
00034                                 {
00035                                 public:
00036                                         Factory() : dtn::data::ExtensionBlock::Factory(PayloadConfidentialBlock::BLOCK_TYPE) {};
00037                                         virtual ~Factory() {};
00038                                         virtual dtn::data::Block* create();
00039                                 };
00040 
00042                                 static const char BLOCK_TYPE = SecurityBlock::PAYLOAD_CONFIDENTIAL_BLOCK;
00043 
00045                                 virtual ~PayloadConfidentialBlock();
00046 
00054                                 static void encrypt(dtn::data::Bundle& bundle, const dtn::security::SecurityKey &long_key, const dtn::data::EID& source);
00055 
00067                                 static void decrypt(dtn::data::Bundle& bundle, const dtn::security::SecurityKey &long_key);
00068 
00069                         protected:
00074                                 PayloadConfidentialBlock();
00075 
00083                                 static bool decryptPayload(dtn::data::Bundle& bundle, const unsigned char ephemeral_key[ibrcommon::AES128Stream::key_size_in_bytes], const u_int32_t salt);
00084                 };
00085 
00089                 static PayloadConfidentialBlock::Factory __PayloadConfidentialBlockFactory__;
00090         }
00091 }
00092 
00093 #endif