aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/tls/openssl/OpenSSLInitializer.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-12-29 09:02:12 +0000
committerVincent Richard <[email protected]>2013-12-29 09:02:12 +0000
commit152c6bed75598a6ca5efb7914701157270155833 (patch)
tree8faced1d75a45c819630323da256248415992ed0 /src/net/tls/openssl/OpenSSLInitializer.cpp
parentMerge branch 'master' of https://github.com/kisli/vmime (diff)
downloadvmime-152c6bed75598a6ca5efb7914701157270155833.tar.gz
vmime-152c6bed75598a6ca5efb7914701157270155833.zip
Merged source and header files in directory structure. Got rid of SConstruct build.
Diffstat (limited to 'src/net/tls/openssl/OpenSSLInitializer.cpp')
-rw-r--r--src/net/tls/openssl/OpenSSLInitializer.cpp142
1 files changed, 0 insertions, 142 deletions
diff --git a/src/net/tls/openssl/OpenSSLInitializer.cpp b/src/net/tls/openssl/OpenSSLInitializer.cpp
deleted file mode 100644
index 1bbb9ee5..00000000
--- a/src/net/tls/openssl/OpenSSLInitializer.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "vmime/config.hpp"
-
-
-#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_TLS_SUPPORT && VMIME_TLS_SUPPORT_LIB_IS_OPENSSL
-
-
-#include "vmime/net/tls/openssl/OpenSSLInitializer.hpp"
-
-#include "vmime/utility/sync/autoLock.hpp"
-#include "vmime/utility/sync/criticalSection.hpp"
-
-#include "vmime/platform.hpp"
-
-#include <openssl/ssl.h>
-#include <openssl/rand.h>
-#include <openssl/crypto.h>
-#include <openssl/err.h>
-
-#if OPENSSL_VERSION_NUMBER >= 0x0907000L
-# include <openssl/conf.h>
-#endif
-
-
-namespace vmime {
-namespace net {
-namespace tls {
-
-
-shared_ptr <vmime::utility::sync::criticalSection >* OpenSSLInitializer::sm_mutexes;
-
-
-OpenSSLInitializer::autoInitializer::autoInitializer()
-{
- // The construction of this unique 'oneTimeInitializer' object will be triggered
- // by the 'autoInitializer' objects from the other translation units
- static OpenSSLInitializer::oneTimeInitializer oneTimeInitializer;
-}
-
-
-OpenSSLInitializer::autoInitializer::~autoInitializer()
-{
-}
-
-
-OpenSSLInitializer::oneTimeInitializer::oneTimeInitializer()
-{
- initialize();
-}
-
-
-OpenSSLInitializer::oneTimeInitializer::~oneTimeInitializer()
-{
- uninitialize();
-}
-
-
-// static
-void OpenSSLInitializer::initialize()
-{
-#if OPENSSL_VERSION_NUMBER >= 0x0907000L
- OPENSSL_config(NULL);
-#endif
-
- SSL_load_error_strings();
- SSL_library_init();
- OpenSSL_add_all_algorithms();
-
- unsigned char seed[SEEDSIZE];
- vmime::platform::getHandler()->generateRandomBytes(seed, SEEDSIZE);
- RAND_seed(seed, SEEDSIZE);
-
- int numMutexes = CRYPTO_num_locks();
- sm_mutexes = new shared_ptr <vmime::utility::sync::criticalSection>[numMutexes];
-
- for (int i = 0 ; i < numMutexes ; ++i)
- sm_mutexes[i] = vmime::platform::getHandler()->createCriticalSection();
-
- CRYPTO_set_locking_callback(&OpenSSLInitializer::lock);
- CRYPTO_set_id_callback(&OpenSSLInitializer::id);
-}
-
-
-// static
-void OpenSSLInitializer::uninitialize()
-{
- EVP_cleanup();
- ERR_free_strings();
-
- CRYPTO_set_locking_callback(NULL);
- CRYPTO_set_id_callback(NULL);
-
- delete [] sm_mutexes;
-}
-
-
-// static
-void OpenSSLInitializer::lock(int mode, int n, const char* /* file */, int /* line */)
-{
- if (mode & CRYPTO_LOCK)
- sm_mutexes[n]->lock();
- else
- sm_mutexes[n]->unlock();
-}
-
-
-// static
-unsigned long OpenSSLInitializer::id()
-{
- return vmime::platform::getHandler()->getThreadId();
-}
-
-
-} // tls
-} // net
-} // vmime
-
-
-#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_TLS_SUPPORT && VMIME_TLS_SUPPORT_LIB_IS_OPENSSL
-