From 27f79fc8e899371905f8f33fb36aaa7627cea3f2 Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Tue, 14 Jun 2011 16:27:02 -0700 Subject: [PATCH] auth: remove CephCryptoManager It doesn't do anything. Signed-off-by: Colin McCabe --- src/auth/Crypto.cc | 13 +++++-------- src/auth/Crypto.h | 8 +------- src/auth/cephx/CephxKeyServer.cc | 2 +- src/test/crypto.cc | 10 +++++----- 4 files changed, 12 insertions(+), 21 deletions(-) diff --git a/src/auth/Crypto.cc b/src/auth/Crypto.cc index c435366fbbffc..dd678c879b798 100644 --- a/src/auth/Crypto.cc +++ b/src/auth/Crypto.cc @@ -324,7 +324,7 @@ decrypt(const bufferptr& secret, const bufferlist& in, bufferlist& out) const static CryptoNone crypto_none; static CryptoAES crypto_aes; -CryptoHandler *CryptoManager::get_crypto(int type) +CryptoHandler *get_crypto_handler(int type) { switch (type) { case CEPH_CRYPTO_NONE: @@ -336,9 +336,6 @@ CryptoHandler *CryptoManager::get_crypto(int type) } } -CryptoManager ceph_crypto_mgr; - - // --------------------------------------------------- int CryptoKey::set_secret(int type, bufferptr& s) @@ -346,7 +343,7 @@ int CryptoKey::set_secret(int type, bufferptr& s) this->type = type; created = g_clock.now(); - CryptoHandler *h = ceph_crypto_mgr.get_crypto(type); + CryptoHandler *h = get_crypto_handler(type); if (!h) return -EOPNOTSUPP; int ret = h->validate_secret(s); @@ -364,7 +361,7 @@ int CryptoKey::create(int t) type = t; created = g_clock.now(); - CryptoHandler *h = ceph_crypto_mgr.get_crypto(type); + CryptoHandler *h = get_crypto_handler(type); if (!h) return -EOPNOTSUPP; return h->create(secret); @@ -372,7 +369,7 @@ int CryptoKey::create(int t) int CryptoKey::encrypt(const bufferlist& in, bufferlist& out) const { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(type); + CryptoHandler *h = get_crypto_handler(type); if (!h) return -EOPNOTSUPP; return h->encrypt(this->secret, in, out); @@ -380,7 +377,7 @@ int CryptoKey::encrypt(const bufferlist& in, bufferlist& out) const int CryptoKey::decrypt(const bufferlist& in, bufferlist& out) const { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(type); + CryptoHandler *h = get_crypto_handler(type); if (!h) return -EOPNOTSUPP; return h->decrypt(this->secret, in, out); diff --git a/src/auth/Crypto.h b/src/auth/Crypto.h index c51a69701ee3b..f3f88532ecda4 100644 --- a/src/auth/Crypto.h +++ b/src/auth/Crypto.h @@ -103,13 +103,7 @@ public: bufferlist& out) const = 0; }; - -class CryptoManager { -public: - CryptoHandler *get_crypto(int type); -}; - -extern CryptoManager ceph_crypto_mgr; +extern CryptoHandler *get_crypto_handler(int type); extern int get_random_bytes(char *buf, int len); diff --git a/src/auth/cephx/CephxKeyServer.cc b/src/auth/cephx/CephxKeyServer.cc index 666094d08a018..c034feb7661ba 100644 --- a/src/auth/cephx/CephxKeyServer.cc +++ b/src/auth/cephx/CephxKeyServer.cc @@ -254,7 +254,7 @@ bool KeyServer::get_service_secret(uint32_t service_id, bool KeyServer::generate_secret(CryptoKey& secret) { bufferptr bp; - CryptoHandler *crypto = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *crypto = get_crypto_handler(CEPH_CRYPTO_AES); if (!crypto) return false; diff --git a/src/test/crypto.cc b/src/test/crypto.cc index 88cab9772c183..5265a02e4f610 100644 --- a/src/test/crypto.cc +++ b/src/test/crypto.cc @@ -17,7 +17,7 @@ public: ::testing::Environment* const crypto_env = ::testing::AddGlobalTestEnvironment(new CryptoEnvironment); TEST(AES, ValidateSecret) { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *h = get_crypto_handler(CEPH_CRYPTO_AES); int l; for (l=0; l<16; l++) { @@ -36,7 +36,7 @@ TEST(AES, ValidateSecret) { } TEST(AES, Encrypt) { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *h = get_crypto_handler(CEPH_CRYPTO_AES); char secret_s[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -76,7 +76,7 @@ TEST(AES, Encrypt) { } TEST(AES, Decrypt) { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *h = get_crypto_handler(CEPH_CRYPTO_AES); char secret_s[] = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, @@ -128,7 +128,7 @@ TEST(AES, Loop) { for (int i=0; i<10000; i++) { bufferlist cipher; { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *h = get_crypto_handler(CEPH_CRYPTO_AES); int success; success = h->encrypt(secret, plaintext, cipher); @@ -137,7 +137,7 @@ TEST(AES, Loop) { plaintext.clear(); { - CryptoHandler *h = ceph_crypto_mgr.get_crypto(CEPH_CRYPTO_AES); + CryptoHandler *h = get_crypto_handler(CEPH_CRYPTO_AES); int err; err = h->decrypt(secret, cipher, plaintext); ASSERT_EQ((int)sizeof(orig_plaintext_s), err); -- 2.39.5