diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/.gitignore b/librocksdb-sys/rocksdb/plugin/ippcp/.gitignore new file mode 100644 index 0000000..f772ac3 --- /dev/null +++ b/librocksdb-sys/rocksdb/plugin/ippcp/.gitignore @@ -0,0 +1 @@ +ippcp_example diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples/ippcp_example b/librocksdb-sys/rocksdb/plugin/ippcp/examples/ippcp_example deleted file mode 100755 index d830b46..0000000 Binary files a/librocksdb-sys/rocksdb/plugin/ippcp/examples/ippcp_example and /dev/null differ diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example b/librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example deleted file mode 100755 index 3ed6d67..0000000 Binary files a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example and /dev/null differ diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/ippcp.mk b/librocksdb-sys/rocksdb/plugin/ippcp/ippcp.mk index c30049b..fc1d09c 100644 --- a/librocksdb-sys/rocksdb/plugin/ippcp/ippcp.mk +++ b/librocksdb-sys/rocksdb/plugin/ippcp/ippcp.mk @@ -1,4 +1,4 @@ ippcp_SOURCES = ippcp_provider.cc ippcp_HEADERS = ippcp_provider.h -ippcp_LDFLAGS = -lippcp -ippcp_CXXFLAGS = -Iplugin/ippcp/library/include \ No newline at end of file +ippcp_LDFLAGS = -lippcp -Lplugin/ippcp/library/linux/lib +ippcp_CXXFLAGS = -Iplugin/ippcp/library/include diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/library/linux/lib/libippcp.a b/librocksdb-sys/rocksdb/plugin/ippcp/library/linux/lib/libippcp.a new file mode 100644 index 0000000..c78b5eb Binary files /dev/null and b/librocksdb-sys/rocksdb/plugin/ippcp/library/linux/lib/libippcp.a differ diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/library/lib/libippcp.a b/librocksdb-sys/rocksdb/plugin/ippcp/library/macos/lib/libippcp.a similarity index 100% rename from librocksdb-sys/rocksdb/plugin/ippcp/library/lib/libippcp.a rename to librocksdb-sys/rocksdb/plugin/ippcp/library/macos/lib/libippcp.a diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/library/src/sources/dispatcher/__pycache__/gen_disp_common.cpython-39.pyc b/librocksdb-sys/rocksdb/plugin/ippcp/library/src/sources/dispatcher/__pycache__/gen_disp_common.cpython-39.pyc deleted file mode 100644 index 9b53757..0000000 Binary files a/librocksdb-sys/rocksdb/plugin/ippcp/library/src/sources/dispatcher/__pycache__/gen_disp_common.cpython-39.pyc and /dev/null differ diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples/Makefile b/librocksdb-sys/rocksdb/plugin/ippcp/test_linux/Makefile similarity index 97% rename from librocksdb-sys/rocksdb/plugin/ippcp/examples/Makefile rename to librocksdb-sys/rocksdb/plugin/ippcp/test_linux/Makefile index 81226b5..cdf756f 100644 --- a/librocksdb-sys/rocksdb/plugin/ippcp/examples/Makefile +++ b/librocksdb-sys/rocksdb/plugin/ippcp/test_linux/Makefile @@ -1,6 +1,6 @@ include ../../../make_config.mk -PLATFORM_LDFLAGS += -lrocksdb -lippcp -L../../.. -L../library/lib +PLATFORM_LDFLAGS += -lrocksdb -lippcp -L../../.. -L../library/linux/lib .PHONY: clean all: ippcp_example diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/test_linux/ippcp_example.cc b/librocksdb-sys/rocksdb/plugin/ippcp/test_linux/ippcp_example.cc new file mode 100644 index 0000000..9218ac4 --- /dev/null +++ b/librocksdb-sys/rocksdb/plugin/ippcp/test_linux/ippcp_example.cc @@ -0,0 +1,69 @@ +// Copyright (c) 2011-present, Facebook, Inc. All rights reserved. +// Copyright (c) 2020 Intel Corporation +// This source code is licensed under both the GPLv2 (found in the +// COPYING file in the root directory) and Apache 2.0 License +// (found in the LICENSE.Apache file in the root directory). + +#include +#include +#include +#include +#include +#include + +#include + +#include "../ippcp_provider.h" + +using namespace ROCKSDB_NAMESPACE; + +std::string kDBPath = "/tmp/ipp_aes_example_linux"; + +int main() { + DB* db; + Options options; + options.create_if_missing = true; + + std::shared_ptr provider; + Status status = EncryptionProvider::CreateFromString( + ConfigOptions(), IppcpProvider::kName(), &provider); + + assert(status.ok()); + + status = + provider->AddCipher("", "a6d2ae2816157e2b3c4fcf098815f7xb", 32, false); + assert(status.ok()); + + options.env = NewEncryptedEnv(Env::Default(), provider); + + status = DB::Open(options, kDBPath, &db); + assert(status.ok()); + + setbuf(stdout, NULL); + printf("writing 1M records..."); + WriteOptions w_opts; + for (int i = 0; i < 1000000; ++i) { + status = db->Put(w_opts, std::to_string(i), std::to_string(i)); + assert(status.ok()); + } + db->Flush(FlushOptions()); + printf("done.\n"); + + printf("reading 1M records..."); + std::string value; + ReadOptions r_opts; + for (int i = 0; i < 1000000; ++i) { + status = db->Get(r_opts, std::to_string(i), &value); + assert(status.ok()); + assert(value == std::to_string(i)); + } + printf("done.\n"); + + // Close database + status = db->Close(); + assert(status.ok()); + //status = DestroyDB(kDBPath, options); + //assert(status.ok()); + + return 0; +} diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/test_macos/Makefile b/librocksdb-sys/rocksdb/plugin/ippcp/test_macos/Makefile new file mode 100644 index 0000000..1b52534 --- /dev/null +++ b/librocksdb-sys/rocksdb/plugin/ippcp/test_macos/Makefile @@ -0,0 +1,12 @@ +include ../../../make_config.mk + +PLATFORM_LDFLAGS += -lrocksdb -lippcp -L../../.. -L../library/macos/lib +.PHONY: clean + +all: ippcp_example + +ippcp_example: ippcp_example.cc + $(CXX) $(CXXFLAGS) $@.cc -o$@ -I../../../include -O2 $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) -I../library/include + +clean: + rm -rf ./ippcp_example diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples/ippcp_example.cc b/librocksdb-sys/rocksdb/plugin/ippcp/test_macos/ippcp_example.cc similarity index 100% rename from librocksdb-sys/rocksdb/plugin/ippcp/examples/ippcp_example.cc rename to librocksdb-sys/rocksdb/plugin/ippcp/test_macos/ippcp_example.cc diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/Makefile b/librocksdb-sys/rocksdb/plugin/ippcp/test_plain/Makefile similarity index 97% rename from librocksdb-sys/rocksdb/plugin/ippcp/examples2/Makefile rename to librocksdb-sys/rocksdb/plugin/ippcp/test_plain/Makefile index 81226b5..cdf756f 100644 --- a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/Makefile +++ b/librocksdb-sys/rocksdb/plugin/ippcp/test_plain/Makefile @@ -1,6 +1,6 @@ include ../../../make_config.mk -PLATFORM_LDFLAGS += -lrocksdb -lippcp -L../../.. -L../library/lib +PLATFORM_LDFLAGS += -lrocksdb -lippcp -L../../.. -L../library/linux/lib .PHONY: clean all: ippcp_example diff --git a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example.cc b/librocksdb-sys/rocksdb/plugin/ippcp/test_plain/ippcp_example.cc similarity index 93% rename from librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example.cc rename to librocksdb-sys/rocksdb/plugin/ippcp/test_plain/ippcp_example.cc index 75b2e10..2c0a4ae 100644 --- a/librocksdb-sys/rocksdb/plugin/ippcp/examples2/ippcp_example.cc +++ b/librocksdb-sys/rocksdb/plugin/ippcp/test_plain/ippcp_example.cc @@ -17,7 +17,7 @@ using namespace ROCKSDB_NAMESPACE; -std::string kDBPath = "/tmp/ipp_aes_example2"; +std::string kDBPath = "/tmp/ipp_aes_example3"; int main() { DB* db; @@ -32,6 +32,8 @@ int main() { // status = // provider->AddCipher("", "a6d2ae2816157e2b3c4fcf098815f7xb", 32, false); // assert(status.ok()); + + // options.env = NewEncryptedEnv(Env::Default(), provider); Status status = DB::Open(options, kDBPath, &db); assert(status.ok());