]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: add CryptoRandom to CephContext
authorCasey Bodley <cbodley@redhat.com>
Tue, 3 Oct 2017 20:02:44 +0000 (16:02 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 9 Oct 2017 14:42:25 +0000 (10:42 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/auth/Crypto.cc
src/auth/cephx/CephxKeyServer.cc
src/common/ceph_context.cc
src/common/ceph_context.h

index 22a53509d89e847fdc98dd9b111ef29ee78f4982..228a99b34c2b811d048d3b26c49ca6d4f61a928d 100644 (file)
@@ -453,7 +453,7 @@ int CryptoKey::create(CephContext *cct, int t)
     return -EOPNOTSUPP;
   }
   bufferptr s;
-  int r = ch->create(nullptr, s); // fixme
+  int r = ch->create(cct->random(), s);
   delete ch;
   if (r < 0)
     return r;
index db73266b8c96a325ca0badecd48b221252e2b134..b3a9dc8c8e29a59cef913785422df06592b43eb6 100644 (file)
@@ -264,7 +264,7 @@ bool KeyServer::generate_secret(CryptoKey& secret)
   if (!crypto)
     return false;
 
-  if (crypto->create(nullptr, bp) < 0) // fixme
+  if (crypto->create(cct->random(), bp) < 0)
     return false;
 
   secret.set_secret(CEPH_CRYPTO_AES, bp, ceph_clock_now());
index e82a9b2b122c2dc1cdaefd2c32c0b398cd7b137f..2a5cb3be4eefbab5754f7ba0a878c3a9ab669dfd 100644 (file)
@@ -632,6 +632,7 @@ CephContext::CephContext(uint32_t module_type_,
 
   _crypto_none = CryptoHandler::create(CEPH_CRYPTO_NONE);
   _crypto_aes = CryptoHandler::create(CEPH_CRYPTO_AES);
+  _crypto_random.reset(new CryptoRandom());
 
   MempoolObs *mempool_obs = 0;
   lookup_or_create_singleton_object(mempool_obs, "mempool_obs");
index fdbc06cacc58e257570e0ff6330f560b9eb7e0a5..9070cfb72e82e2c3d8a0584b7c9a0723418d62ec 100644 (file)
@@ -16,6 +16,7 @@
 #define CEPH_CEPHCONTEXT_H
 
 #include <set>
+#include <memory>
 #include <mutex>
 #include <atomic>
 
@@ -37,6 +38,7 @@ struct md_config_t;
 class CephContextHook;
 class CephContextObs;
 class CryptoHandler;
+class CryptoRandom;
 
 namespace ceph {
   class PluginRegistry;
@@ -146,6 +148,8 @@ public:
    */
   CryptoHandler *get_crypto_handler(int type);
 
+  CryptoRandom* random() const { return _crypto_random.get(); }
+
   /// check if experimental feature is enable, and emit appropriate warnings
   bool check_experimental_feature_enabled(const std::string& feature);
   bool check_experimental_feature_enabled(const std::string& feature,
@@ -265,6 +269,7 @@ private:
   // crypto
   CryptoHandler *_crypto_none;
   CryptoHandler *_crypto_aes;
+  std::unique_ptr<CryptoRandom> _crypto_random;
 
   // experimental
   CephContextObs *_cct_obs;