]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
auth: Let common_init (or CephCrypto::init) init auth crypto.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 10 Mar 2011 23:44:01 +0000 (15:44 -0800)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Fri, 11 Mar 2011 21:13:40 +0000 (13:13 -0800)
This avoids doing it in a global constructor.

Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com>
src/Makefile.am
src/auth/Crypto.cc
src/auth/Crypto.h
src/test/crypto.cc

index af3c06faae77ccb82772c8e7bd342d7385cbac90..aadfea0c108b7a5d245876fff98f422d0e598056 100644 (file)
@@ -399,10 +399,10 @@ unittest_bufferlist_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_bufferlist
 
 unittest_crypto_SOURCES = test/crypto.cc
-unittest_crypto_LDFLAGS = -lrt ${AM_LDFLAGS}
-unittest_crypto_LDADD =  libceph.la \
+unittest_crypto_LDFLAGS = -lrt ${CRYPTO_LDFLAGS} ${AM_LDFLAGS}
+unittest_crypto_LDADD =  libceph.la ${CRYPTO_LIBS} \
                        ${UNITTEST_LDADD}
-unittest_crypto_CXXFLAGS = ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
+unittest_crypto_CXXFLAGS = ${CRYPTO_CXXFLAGS} ${AM_CXXFLAGS} ${UNITTEST_CXXFLAGS}
 check_PROGRAMS += unittest_crypto
 
 unittest_ceph_crypto_SOURCES = test/ceph_crypto.cc
index d9b599d5681cc4d4c917780c08cc3ae91330cd8f..4fb3660f6bf677bfef84560f05e87468115689eb 100644 (file)
@@ -206,20 +206,7 @@ static int nss_aes_operation(CK_ATTRIBUTE_TYPE op, bufferptr& secret, const buff
 
 class CryptoAES : public CryptoHandler {
 public:
-  CryptoAES() {
-#ifdef USE_NSS
-    SECStatus ret;
-    ret = NSS_NoDB_Init(NULL);
-    if (ret != SECSuccess) {
-      dout(0) << "initializing NSS crypto library failed (code "
-             << PR_GetError() << "), aborting" << dendl;
-      exit(1);
-    }
-
-    
-#endif
-  }
-
+  CryptoAES() {}
   ~CryptoAES() {}
   int create(bufferptr& secret);
   int validate_secret(bufferptr& secret);
index 641dedba140c24c903f0d1470100a07226d5c1c5..ba478ad3b65e340dbd9155d29601b975aa59f4df 100644 (file)
@@ -87,6 +87,9 @@ static inline ostream& operator<<(ostream& out, const CryptoKey& k)
 
 /*
  * Driver for a particular algorithm
+ *
+ * To use these functions, you need to call ceph::crypto::init(), see
+ * common/ceph_crypto.h. common_init already does this for you.
  */
 class CryptoHandler {
 public:
index e8b577e79379b3116b1960d7a3076fe62db4c46b..90e4807f43b2ef3beed6591bbcfaf7dcbdb9809d 100644 (file)
@@ -3,9 +3,19 @@
 
 #include "include/types.h"
 #include "auth/Crypto.h"
+#include "common/ceph_crypto.h"
 
 #include "gtest/gtest.h"
 
+class CryptoEnvironment: public ::testing::Environment {
+public:
+  void SetUp() {
+    ceph::crypto::init();
+  }
+};
+
+::testing::Environment* const crypto_env = ::testing::AddGlobalTestEnvironment(new CryptoEnvironment);
+
 TEST(AES, ValidateSecret) {
   CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES);
   int l;