IBR-DTNSuite  0.10
PayloadConfidentialBlock.h
Go to the documentation of this file.
1 /*
2  * PayloadConfidentialBlock.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 _PAYLOAD_CONFIDENTIAL_BLOCK_H_
23 #define _PAYLOAD_CONFIDENTIAL_BLOCK_H_
28 
29 namespace dtn
30 {
31  namespace security
32  {
47  {
52  friend class dtn::data::Bundle;
53  public:
55  {
56  public:
57  Factory() : dtn::data::ExtensionBlock::Factory(PayloadConfidentialBlock::BLOCK_TYPE) {};
58  virtual ~Factory() {};
59  virtual dtn::data::Block* create();
60  };
61 
64 
66  virtual ~PayloadConfidentialBlock();
67 
75  static void encrypt(dtn::data::Bundle& bundle, const dtn::security::SecurityKey &long_key, const dtn::data::EID& source);
76 
88  static void decrypt(dtn::data::Bundle& bundle, const dtn::security::SecurityKey &long_key);
89 
90  protected:
96 
104  static bool decryptPayload(dtn::data::Bundle& bundle, const unsigned char ephemeral_key[ibrcommon::AES128Stream::key_size_in_bytes], const uint32_t salt);
105  };
106 
110  static PayloadConfidentialBlock::Factory __PayloadConfidentialBlockFactory__;
111  }
112 }
113 
114 #endif