IBR-DTNSuite  0.10
SecurityKeyManager.h
Go to the documentation of this file.
1 /*
2  * SecurityKeyManager.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 SECURITYKEYMANAGER_H_
23 #define SECURITYKEYMANAGER_H_
24 
25 #include "Configuration.h"
27 #include <ibrdtn/data/EID.h>
28 #include <ibrdtn/data/DTNTime.h>
30 #include <ibrdtn/data/SDNV.h>
31 #include <ibrcommon/data/File.h>
32 #include <iostream>
33 
34 #include <openssl/rsa.h>
35 
36 namespace dtn
37 {
38  namespace security
39  {
41  {
42  public:
44  {
45  public:
46  KeyNotFoundException(std::string what = "Requested key not found.") : ibrcommon::Exception(what)
47  {};
48 
49  virtual ~KeyNotFoundException() throw() {};
50  };
51 
52  static const std::string TAG;
53 
55 
56  virtual ~SecurityKeyManager();
57 
61  virtual void onConfigurationChanged(const dtn::daemon::Configuration &conf) throw ();
62 
65  void store(const dtn::data::EID &ref, const std::string &data, const dtn::security::SecurityKey::KeyType type = dtn::security::SecurityKey::KEY_UNSPEC);
66 
67  private:
69 
77  static int read_private_key(const ibrcommon::File &file, RSA ** rsa);
78 
86  static int read_public_key(const ibrcommon::File &file, RSA ** rsa);
87 
88 
89  static const std::string hash(const dtn::data::EID &eid);
90 
91  ibrcommon::File _path;
92  ibrcommon::File _ca;
93  ibrcommon::File _key;
94  };
95  }
96 }
97 
98 #endif /* SECURITYKEYMANAGER_H_ */