]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_crypto: add assert_init
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 20 May 2011 22:12:49 +0000 (15:12 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Sat, 21 May 2011 00:57:11 +0000 (17:57 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/auth/Crypto.cc
src/common/ceph_crypto.cc
src/common/ceph_crypto.h

index 757ed791563eeaa1bea32713d551ff26d2cb5093..c435366fbbffccbf23a4a3faa86c96dac5e476e5 100644 (file)
 # include <pk11pub.h>
 #endif
 
-#include "include/ceph_fs.h"
+#include "common/Clock.h"
+#include "common/armor.h"
+#include "common/ceph_crypto.h"
 #include "common/config.h"
 #include "common/debug.h"
-#include "common/armor.h"
-#include "common/Clock.h"
 #include "common/hex.h"
 #include "common/safe_io.h"
+#include "include/ceph_fs.h"
 
 #include <errno.h>
 
@@ -57,7 +58,7 @@ static int get_random_bytes(int len, bufferlist& bl)
 
 class CryptoNone : public CryptoHandler {
 public:
-  CryptoNone() {}
+  CryptoNone() { }
   ~CryptoNone() {}
   int create(bufferptr& secret);
   int validate_secret(bufferptr& secret);
@@ -210,7 +211,7 @@ static int nss_aes_operation(CK_ATTRIBUTE_TYPE op, const bufferptr& secret, cons
 
 class CryptoAES : public CryptoHandler {
 public:
-  CryptoAES() {}
+  CryptoAES() { }
   ~CryptoAES() {}
   int create(bufferptr& secret);
   int validate_secret(bufferptr& secret);
@@ -348,7 +349,6 @@ int CryptoKey::set_secret(int type, bufferptr& s)
   CryptoHandler *h = ceph_crypto_mgr.get_crypto(type);
   if (!h)
     return -EOPNOTSUPP;
-
   int ret = h->validate_secret(s);
 
   if (ret < 0)
index b6520d7087426cc5235396c8038db818eb177b15..5ec492ed8ef9d4282ca7a4cc55335957b4e69b95 100644 (file)
 
 #include <pthread.h>
 
+static bool crypto_init = false;
+
+void ceph::crypto::assert_init() {
+  assert(crypto_init == true);
+}
+
 #ifdef USE_CRYPTOPP
+void ceph::crypto::init() {
+  crypto_init = true;
+}
+
+void ceph::crypto::shutdown() {
+  crypto_init = false;
+}
+
 // nothing
 ceph::crypto::HMACSHA1::~HMACSHA1()
 {
@@ -25,7 +39,6 @@ ceph::crypto::HMACSHA1::~HMACSHA1()
 #elif USE_NSS
 
 static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
-static bool crypto_init = false;
 
 void ceph::crypto::init() {
   pthread_mutex_lock(&lock);
index 48a5f203cc026ab2e1da42164d5dc899e4da8013..23a058997acac922226b593422b476c46fdba2a1 100644 (file)
 # include <cryptopp/hmac.h>
 namespace ceph {
   namespace crypto {
-    static inline void init() {
-      // nothing
-    }
-    static inline void shutdown() {
-      // nothing
-    }
+    void assert_init();
+    void init();
+    void shutdown();
+
     using CryptoPP::Weak::MD5;
     using CryptoPP::SHA1;
     using CryptoPP::SHA256;
@@ -53,6 +51,7 @@ typedef unsigned char byte;
 
 namespace ceph {
   namespace crypto {
+    void assert_init();
     void init();
     void shutdown();
     class Digest {