This avoids doing it in a global constructor.
Signed-off-by: Tommi Virtanen <tommi.virtanen@dreamhost.com>
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
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);
/*
* 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:
#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;