IBR-DTNSuite  0.10
BundleAuthenticationBlock.h
Go to the documentation of this file.
1 /*
2  * BundleAuthenticationBlock.h
3  *
4  * Copyright (C) 2011 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21 
22 #ifndef BUNDLE_AUTHENTICATION_BLOCK_H_
23 #define BUNDLE_AUTHENTICATION_BLOCK_H_
24 
28 #include "ibrdtn/data/EID.h"
29 #include "ibrdtn/data/Bundle.h"
30 
31 namespace dtn
32 {
33  namespace security
34  {
45  {
49  friend class dtn::data::Bundle;
50  public:
52  {
53  public:
54  Factory() : dtn::data::ExtensionBlock::Factory(BundleAuthenticationBlock::BLOCK_TYPE) {};
55  virtual ~Factory() {};
56  virtual dtn::data::Block* create();
57  };
58 
61 
66 
72  static void auth(dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key);
73 
81  static void verify(const dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key) throw (ibrcommon::Exception);
82 
88  static void strip(dtn::data::Bundle &bundle, const dtn::security::SecurityKey &key);
89 
94  static void strip(dtn::data::Bundle &bundle);
95 
96  protected:
104 
116  static std::string calcMAC(const dtn::data::Bundle& bundle, const dtn::security::SecurityKey &key, const bool with_correlator = false, const dtn::data::Number &correlator = 0);
117 
129  static void verify(const dtn::data::Bundle& bundle, const dtn::security::SecurityKey &key, dtn::data::Number &correlator) throw (ibrcommon::Exception);
130 
137  };
138 
142  static BundleAuthenticationBlock::Factory __BundleAuthenticationBlockFactory__;
143  }
144 }
145 
146 #endif /* BUNDLE_AUTHENTICATION_BLOCK_H_ */