IBR-DTNSuite  0.8
ibrdtn/ibrdtn/security/BundleAuthenticationBlock.h
Go to the documentation of this file.
00001 #ifndef BUNDLE_AUTHENTICATION_BLOCK_H_
00002 #define BUNDLE_AUTHENTICATION_BLOCK_H_
00003 
00004 #include "ibrdtn/security/SecurityBlock.h"
00005 #include "ibrdtn/security/SecurityKey.h"
00006 #include "ibrdtn/data/ExtensionBlock.h"
00007 #include "ibrdtn/data/EID.h"
00008 #include "ibrdtn/data/Bundle.h"
00009 
00010 namespace dtn
00011 {
00012         namespace security
00013         {
00023                 class BundleAuthenticationBlock : public SecurityBlock
00024                 {
00028                         friend class dtn::data::Bundle;
00029                         public:
00030                                 class Factory : public dtn::data::ExtensionBlock::Factory
00031                                 {
00032                                 public:
00033                                         Factory() : dtn::data::ExtensionBlock::Factory(BundleAuthenticationBlock::BLOCK_TYPE) {};
00034                                         virtual ~Factory() {};
00035                                         virtual dtn::data::Block* create();
00036                                 };
00037 
00039                                 static const char BLOCK_TYPE = SecurityBlock::BUNDLE_AUTHENTICATION_BLOCK;
00040 
00044                                 virtual ~BundleAuthenticationBlock();
00045 
00051                                 static void auth(dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key);
00052 
00060                                 static void verify(const dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key) throw (ibrcommon::Exception);
00061 
00067                                 static void strip(dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key);
00068 
00073                                 static void strip(dtn::data::Bundle &bundle);
00074 
00075                         protected:
00082                                 BundleAuthenticationBlock();
00083 
00095                                 static std::string calcMAC(const dtn::data::Bundle& bundle, const dtn::security::SecurityKey &key, const bool with_correlator = false, const u_int64_t correlator = 0);
00096 
00108                                 static void verify(const dtn::data::Bundle& bundle, const dtn::security::SecurityKey &key, u_int64_t &correlator) throw (ibrcommon::Exception);
00109 
00115                                 virtual size_t getSecurityResultSize() const;
00116                 };
00117 
00121                 static BundleAuthenticationBlock::Factory __BundleAuthenticationBlockFactory__;
00122         }
00123 }
00124 
00125 #endif /* BUNDLE_AUTHENTICATION_BLOCK_H_ */