00001 /* 00002 * Distributed under the OpenDDS License. 00003 * See: http://www.OpenDDS.org/license.html 00004 */ 00005 00006 #ifndef OPENDDS_SECURITY_SSL_PRIVATEKEY_H 00007 #define OPENDDS_SECURITY_SSL_PRIVATEKEY_H 00008 00009 #include "dds/DCPS/security/DdsSecurity_Export.h" 00010 #include "dds/DCPS/unique_ptr.h" 00011 #include "dds/DdsDcpsCoreC.h" 00012 #include <string> 00013 #include <vector> 00014 #include <openssl/evp.h> 00015 00016 namespace OpenDDS { 00017 namespace Security { 00018 namespace SSL { 00019 00020 class DdsSecurity_Export PrivateKey 00021 { 00022 public: 00023 typedef DCPS::unique_ptr<PrivateKey> unique_ptr; 00024 00025 friend DdsSecurity_Export bool operator==(const PrivateKey& lhs, 00026 const PrivateKey& rhs); 00027 00028 PrivateKey(const std::string& uri, const std::string password = ""); 00029 00030 PrivateKey(); 00031 00032 PrivateKey(const PrivateKey& other); 00033 00034 virtual ~PrivateKey(); 00035 00036 PrivateKey& operator=(const PrivateKey& rhs); 00037 00038 void load(const std::string& uri, const std::string& password = ""); 00039 00040 int sign(const std::vector<const DDS::OctetSeq*>& src, 00041 DDS::OctetSeq& dst) const; 00042 00043 private: 00044 static EVP_PKEY* EVP_PKEY_from_pem(const std::string& path, 00045 const std::string& password = ""); 00046 00047 static EVP_PKEY* EVP_PKEY_from_pem_data(const std::string& data, 00048 const std::string& password); 00049 00050 EVP_PKEY* k_; 00051 }; 00052 00053 DdsSecurity_Export bool operator==(const PrivateKey& lhs, 00054 const PrivateKey& rhs); 00055 00056 } // namespace SSL 00057 } // namespace Security 00058 } // namespace OpenDDS 00059 00060 #endif