summaryrefslogtreecommitdiffstats
path: root/src/rgw/rgw_kmip_client.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/rgw/rgw_kmip_client.cc')
-rw-r--r--src/rgw/rgw_kmip_client.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/rgw/rgw_kmip_client.cc b/src/rgw/rgw_kmip_client.cc
new file mode 100644
index 000000000..e801972ea
--- /dev/null
+++ b/src/rgw/rgw_kmip_client.cc
@@ -0,0 +1,82 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab ft=cpp
+
+#include "common/Thread.h"
+#include "include/compat.h"
+#include "common/errno.h"
+#include "rgw_common.h"
+#include "rgw_kmip_client.h"
+
+#include <atomic>
+
+#define dout_context g_ceph_context
+#define dout_subsys ceph_subsys_rgw
+
+RGWKMIPManager *rgw_kmip_manager;
+
+int
+RGWKMIPTransceiver::wait(optional_yield y)
+{
+ if (done)
+ return ret;
+ std::unique_lock l{lock};
+ if (!done)
+ cond.wait(l);
+ if (ret) {
+ lderr(cct) << "kmip process failed, " << ret << dendl;
+ }
+ return ret;
+}
+
+int
+RGWKMIPTransceiver::send()
+{
+ int r = rgw_kmip_manager->add_request(this);
+ if (r < 0) {
+ lderr(cct) << "kmip send failed, " << r << dendl;
+ }
+ return r;
+}
+
+int
+RGWKMIPTransceiver::process(optional_yield y)
+{
+ int r = send();
+ if (r < 0)
+ return r;
+ return wait(y);
+}
+
+RGWKMIPTransceiver::~RGWKMIPTransceiver()
+{
+ int i;
+ if (out)
+ free(out);
+ out = nullptr;
+ if (outlist->strings) {
+ for (i = 0; i < outlist->string_count; ++i) {
+ free(outlist->strings[i]);
+ }
+ free(outlist->strings);
+ outlist->strings = 0;
+ }
+ if (outkey->data) {
+ ::ceph::crypto::zeroize_for_security(outkey->data, outkey->keylen);
+ free(outkey->data);
+ outkey->data = 0;
+ }
+}
+
+void
+rgw_kmip_client_init(RGWKMIPManager &m)
+{
+ rgw_kmip_manager = &m;
+ rgw_kmip_manager->start();
+}
+
+void
+rgw_kmip_client_cleanup()
+{
+ rgw_kmip_manager->stop();
+ delete rgw_kmip_manager;
+}