IBR-DTN  1.0.0
DHProtocol.h
Go to the documentation of this file.
1 /*
2  * DHProtocol.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 DHPROTOCOL_H_
24 #define DHPROTOCOL_H_
25 
28 #include <openssl/dh.h>
29 #include <openssl/bn.h>
30 #include <iostream>
31 
32 namespace dtn
33 {
34  namespace security
35  {
37  {
38  static const std::string TAG;
39 
40  public:
42  virtual ~DHProtocol();
43 
44  virtual KeyExchangeSession* createSession(const dtn::data::EID &peer, unsigned int uniqueId);
45 
46  virtual void initialize();
47 
48  virtual void begin(KeyExchangeSession &session, KeyExchangeData &data);
49  virtual void step(KeyExchangeSession &session, KeyExchangeData &data);
50 
51  private:
53  {
54  public:
55  DHState();
56  virtual ~DHState();
57  DH* dh;
58  std::string secret;
59  };
60 
61  static void write(std::ostream &stream, const BIGNUM* bn);
62  static void read(std::istream &stream, BIGNUM **bn);
63 
64  void generate_params();
65 
66  ibrcommon::File _dh_params_file;
67  DH* _dh_params;
68  bool _auto_generate_params;
69  };
70  } /* namespace security */
71 } /* namespace dtn */
72 
73 #endif /* DHPROTOCOL_H_ */
virtual void initialize()
Definition: DHProtocol.cpp:115
virtual void begin(KeyExchangeSession &session, KeyExchangeData &data)
Definition: DHProtocol.cpp:133
virtual KeyExchangeSession * createSession(const dtn::data::EID &peer, unsigned int uniqueId)
Definition: DHProtocol.cpp:128
virtual void step(KeyExchangeSession &session, KeyExchangeData &data)
Definition: DHProtocol.cpp:169
DHProtocol(KeyExchangeManager &manager)
Definition: DHProtocol.cpp:52