diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/DHParams.cpp | 35 | ||||
-rw-r--r-- | cpp/src/Ice/DHParams.h | 46 | ||||
-rw-r--r-- | cpp/src/Ice/DHParamsF.h | 37 | ||||
-rw-r--r-- | cpp/src/Ice/Makefile | 1 | ||||
-rw-r--r-- | cpp/src/Ice/RSAKeyPair.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/RSAPrivateKey.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/SystemOpenSSL.cpp | 26 | ||||
-rw-r--r-- | cpp/src/Ice/SystemOpenSSL.h | 8 | ||||
-rw-r--r-- | cpp/src/Ice/ice.dsp | 12 |
9 files changed, 161 insertions, 20 deletions
diff --git a/cpp/src/Ice/DHParams.cpp b/cpp/src/Ice/DHParams.cpp new file mode 100644 index 00000000000..c67ade7e5e6 --- /dev/null +++ b/cpp/src/Ice/DHParams.cpp @@ -0,0 +1,35 @@ +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#include <Ice/DHParams.h>
+
+void ::IceInternal::incRef(::IceSSL::OpenSSL::DHParams* p) { p->__incRef(); }
+void ::IceInternal::decRef(::IceSSL::OpenSSL::DHParams* p) { p->__decRef(); }
+
+IceSSL::OpenSSL::DHParams::DHParams(DH* dhParams) :
+ _dhParams(dhParams)
+{
+ assert(_dhParams != 0);
+}
+
+IceSSL::OpenSSL::DHParams::~DHParams()
+{
+ if (_dhParams != 0)
+ {
+ DH_free(_dhParams);
+ }
+}
+
+DH*
+IceSSL::OpenSSL::DHParams::get() const
+{
+ return _dhParams;
+}
+
diff --git a/cpp/src/Ice/DHParams.h b/cpp/src/Ice/DHParams.h new file mode 100644 index 00000000000..f55d7670890 --- /dev/null +++ b/cpp/src/Ice/DHParams.h @@ -0,0 +1,46 @@ +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DH_PARAMS_H
+#define ICE_DH_PARAMS_H
+
+#include <IceUtil/Config.h>
+#include <IceUtil/Shared.h>
+#include <openssl/ssl.h>
+#include <Ice/DHParamsF.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class DHParams : public IceUtil::Shared
+{
+public:
+
+ // Construction from DH Params structure (simple initialization).
+ DHParams(DH*);
+
+ ~DHParams();
+
+ // Get the internal key structure as per the OpenSSL implementation.
+ DH* get() const;
+
+private:
+
+ DH* _dhParams;
+};
+
+}
+
+}
+
+#endif
diff --git a/cpp/src/Ice/DHParamsF.h b/cpp/src/Ice/DHParamsF.h new file mode 100644 index 00000000000..b8b8274ec88 --- /dev/null +++ b/cpp/src/Ice/DHParamsF.h @@ -0,0 +1,37 @@ +// **********************************************************************
+//
+// Copyright (c) 2002
+// MutableRealms, Inc.
+// Huntsville, AL, USA
+//
+// All Rights Reserved
+//
+// **********************************************************************
+
+#ifndef ICE_DH_PARAMS_F_H
+#define ICE_DH_PARAMS_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceSSL
+{
+
+namespace OpenSSL
+{
+
+class DHParams;
+typedef IceInternal::Handle<DHParams> DHParamsPtr;
+
+}
+
+}
+
+namespace IceInternal
+{
+
+void incRef(::IceSSL::OpenSSL::DHParams*);
+void decRef(::IceSSL::OpenSSL::DHParams*);
+
+}
+
+#endif
diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index 92cce94c798..6271fae3bb0 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -104,6 +104,7 @@ OBJS = Initialize.o \ RSAPrivateKey.o \ RSAPublicKey.o \ RSAKeyPair.o \ + DHParams.o \ OpenSSLUtils.o \ DefaultCertificateVerifier.o \ SingleCertificateVerifier.o \ diff --git a/cpp/src/Ice/RSAKeyPair.cpp b/cpp/src/Ice/RSAKeyPair.cpp index 158c0380810..f6ccedff747 100644 --- a/cpp/src/Ice/RSAKeyPair.cpp +++ b/cpp/src/Ice/RSAKeyPair.cpp @@ -70,7 +70,7 @@ IceSSL::OpenSSL::RSAKeyPair::certToByteSeq(ByteSeq& certSeq) RSA*
IceSSL::OpenSSL::RSAKeyPair::getRSAPrivateKey() const
{
- return _privateKey->getRSAPrivateKey();
+ return _privateKey->get();
}
X509*
diff --git a/cpp/src/Ice/RSAPrivateKey.cpp b/cpp/src/Ice/RSAPrivateKey.cpp index fb266301b2b..f91d1cd4d94 100644 --- a/cpp/src/Ice/RSAPrivateKey.cpp +++ b/cpp/src/Ice/RSAPrivateKey.cpp @@ -44,6 +44,12 @@ IceSSL::OpenSSL::RSAPrivateKey::RSAPrivateKey(const ByteSeq& keySeq) byteSeqToKey(keySeq);
}
+IceSSL::OpenSSL::RSAPrivateKey::RSAPrivateKey(RSA* rsa) :
+ _privateKey(rsa)
+{
+ assert(_privateKey != 0);
+}
+
IceSSL::OpenSSL::RSAPrivateKey::~RSAPrivateKey()
{
if (_privateKey != 0)
@@ -83,17 +89,11 @@ IceSSL::OpenSSL::RSAPrivateKey::keyToByteSeq(ByteSeq& keySeq) }
RSA*
-IceSSL::OpenSSL::RSAPrivateKey::getRSAPrivateKey() const
+IceSSL::OpenSSL::RSAPrivateKey::get() const
{
return _privateKey;
}
-IceSSL::OpenSSL::RSAPrivateKey::RSAPrivateKey(RSA* rsa) :
- _privateKey(rsa)
-{
- assert(_privateKey != 0);
-}
-
void
IceSSL::OpenSSL::RSAPrivateKey::byteSeqToKey(const ByteSeq& keySeq)
{
diff --git a/cpp/src/Ice/SystemOpenSSL.cpp b/cpp/src/Ice/SystemOpenSSL.cpp index 0b8822904e8..321ceb68360 100644 --- a/cpp/src/Ice/SystemOpenSSL.cpp +++ b/cpp/src/Ice/SystemOpenSSL.cpp @@ -31,6 +31,9 @@ #include <Ice/OpenSSLJanitors.h> #include <Ice/TraceLevels.h> #include <Ice/Logger.h> +
+#include <Ice/RSAPrivateKey.h>
+#include <Ice/DHParams.h>
#include <openssl/e_os.h> #include <openssl/rand.h> @@ -81,7 +84,8 @@ IceSSL::OpenSSL::System::createConnection(ContextType connectionType, int socket void IceSSL::OpenSSL::System::shutdown() -{ +{
+/* // Free our temporary RSA keys. RSAMap::iterator iRSA = _tempRSAKeys.begin(); RSAMap::iterator eRSA = _tempRSAKeys.end(); @@ -90,7 +94,7 @@ IceSSL::OpenSSL::System::shutdown() { RSA_free((*iRSA).second); iRSA++; - } + }
// Free our temporary DH params. DHMap::iterator iDH = _tempDHKeys.begin(); @@ -101,6 +105,7 @@ IceSSL::OpenSSL::System::shutdown() DH_free((*iDH).second); iDH++; } +*/
} bool @@ -284,7 +289,7 @@ IceSSL::OpenSSL::System::getRSAKey(int isExport, int keyLength) if (retVal != _tempRSAKeys.end()) { // Yes! Use it. - rsa_tmp = (*retVal).second; + rsa_tmp = (*retVal).second->get(); assert(rsa_tmp != 0); } @@ -330,9 +335,12 @@ IceSSL::OpenSSL::System::getRSAKey(int isExport, int keyLength) rsa_tmp = rsaCert; } else - { - RSA_free(rsaCert); - rsaCert = 0; + {
+ if (rsaCert != 0)
+ { + RSA_free(rsaCert); + rsaCert = 0;
+ } } } @@ -345,7 +353,7 @@ IceSSL::OpenSSL::System::getRSAKey(int isExport, int keyLength) // Save in our temporary key cache. if (rsa_tmp != 0) { - _tempRSAKeys[keyLength] = rsa_tmp; + _tempRSAKeys[keyLength] = new RSAPrivateKey(rsa_tmp); } } @@ -365,7 +373,7 @@ IceSSL::OpenSSL::System::getDHParams(int isExport, int keyLength) if (retVal != _tempDHKeys.end()) { // Yes! Use it. - dh_tmp = (*retVal).second; + dh_tmp = (*retVal).second->get(); } else { @@ -382,7 +390,7 @@ IceSSL::OpenSSL::System::getDHParams(int isExport, int keyLength) if (dh_tmp != 0) { - _tempDHKeys[keyLength] = dh_tmp; + _tempDHKeys[keyLength] = new DHParams(dh_tmp); } } } diff --git a/cpp/src/Ice/SystemOpenSSL.h b/cpp/src/Ice/SystemOpenSSL.h index 84d7d16d35a..39758546fa0 100644 --- a/cpp/src/Ice/SystemOpenSSL.h +++ b/cpp/src/Ice/SystemOpenSSL.h @@ -31,6 +31,9 @@ #include <openssl/ssl.h> #include <string> #include <map> +
+#include <Ice/RSAPrivateKeyF.h>
+#include <Ice/DHParamsF.h>
namespace IceSSL { @@ -40,9 +43,8 @@ class GeneralConfig; namespace OpenSSL { -// TODO: Make these map<int, RSAPrivateKeyPtr> and something similar for DH. -typedef std::map<int,RSA*> RSAMap; -typedef std::map<int,DH*> DHMap; +typedef std::map<int,RSAPrivateKeyPtr> RSAMap;
+typedef std::map<int,DHParamsPtr> DHMap;
typedef std::map<int,CertificateDesc> RSACertMap; typedef std::map<int,DiffieHellmanParamsFile> DHParamsMap; diff --git a/cpp/src/Ice/ice.dsp b/cpp/src/Ice/ice.dsp index 9bfea0f2dd2..f5c36a76fc1 100644 --- a/cpp/src/Ice/ice.dsp +++ b/cpp/src/Ice/ice.dsp @@ -184,6 +184,10 @@ SOURCE=.\DefaultCertificateVerifier.cpp # End Source File
# Begin Source File
+SOURCE=.\DHParams.cpp
+# End Source File
+# Begin Source File
+
SOURCE=.\Direct.cpp
# End Source File
# Begin Source File
@@ -576,6 +580,14 @@ SOURCE=.\DefaultCertificateVerifier.h # End Source File
# Begin Source File
+SOURCE=.\DHParams.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\DHParamsF.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\include\Ice\Direct.h
# End Source File
# Begin Source File
|