IBR-DTN  1.0.0
KeyExchangeProtocol.h
Go to the documentation of this file.
1 /*
2  * KeyExchangeProtocol.h
3  *
4  * Copyright (C) 2014 IBR, TU Braunschweig
5  *
6  * Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7  * Thomas Schrader <schrader.thomas@gmail.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22 
23 #ifndef KEYEXCHANGEPROTOCOL_H_
24 #define KEYEXCHANGEPROTOCOL_H_
25 
28 #include <map>
29 
30 namespace dtn
31 {
32  namespace security
33  {
35  {
36  public:
37  virtual ~KeyExchangeManager() = 0;
38  virtual void submit(KeyExchangeSession &session, const KeyExchangeData &data) = 0;
39  virtual void finish(KeyExchangeSession &session) = 0;
40  };
41 
43  {
44  public:
46  virtual ~KeyExchangeProtocol();
47 
48  int getProtocol() const;
49 
53  void add(std::map<int, KeyExchangeProtocol*> &list);
54 
58  virtual KeyExchangeSession* createSession(const dtn::data::EID &peer, unsigned int uniqueId);
59 
60  virtual void initialize() {};
61 
62  virtual void begin(KeyExchangeSession &session, KeyExchangeData &data) = 0;
63  virtual void step(KeyExchangeSession &session, KeyExchangeData &data) = 0;
64 
65  static void sha256(std::ostream &stream, const std::string &data);
66  static std::string toHex(const std::string &data);
67 
68  protected:
70 
71  private:
72  const int _protocol_id;
73  };
74  }
75 }
76 
77 #endif /* KEYEXCHANGEPROTOCOL_H_ */
KeyExchangeProtocol(KeyExchangeManager &manager, int protocol_id)
virtual void step(KeyExchangeSession &session, KeyExchangeData &data)=0
virtual void finish(KeyExchangeSession &session)=0
virtual void submit(KeyExchangeSession &session, const KeyExchangeData &data)=0
static std::string toHex(const std::string &data)
void add(std::map< int, KeyExchangeProtocol * > &list)
static void sha256(std::ostream &stream, const std::string &data)
virtual void begin(KeyExchangeSession &session, KeyExchangeData &data)=0
virtual KeyExchangeSession * createSession(const dtn::data::EID &peer, unsigned int uniqueId)