From 637187c38d57b9b8003bbd33f227b31db44ce7a5 Mon Sep 17 00:00:00 2001 From: Mahmmoud Mahdi Date: Sat, 5 Sep 2020 06:49:49 +0200 Subject: [PATCH 1/4] fix: git certification required --- deps/gtest/download_gtest.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/gtest/download_gtest.sh b/deps/gtest/download_gtest.sh index 6754f5ed..f08740c1 100755 --- a/deps/gtest/download_gtest.sh +++ b/deps/gtest/download_gtest.sh @@ -10,5 +10,5 @@ GTEST_VERSION=googletest-release-${VERSION}.zip GTEST_LINK=https://github.com/google/googletest/archive/release-${VERSION}.zip if [[ ! -f ${GTEST_VERSION} ]]; then - wget -O ${GTEST_VERSION} ${GTEST_LINK} -fi \ No newline at end of file + wget -O ${GTEST_VERSION} ${GTEST_LINK} --no-check-certificate +fi From 8e414da26c375194503827c566793e443edf6007 Mon Sep 17 00:00:00 2001 From: Mahmmoud Mahdi Date: Sat, 5 Sep 2020 12:24:13 +0200 Subject: [PATCH 2/4] replace api.parser.class with parser_class_name Solve bugs zparser.yy: warning: 3 shift/reduce conflicts [-Wconflicts-sr] zparser.yy:42.9-24: error: %define variable 'api.parser.class' is not used %define api.parser.class {Parser} ^^^^^^^^^^^^^^^^ Makefile:64: recipe for target 'zparser.o' failed --- src/zparser.yy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zparser.yy b/src/zparser.yy index bcde1330..f02da829 100644 --- a/src/zparser.yy +++ b/src/zparser.yy @@ -39,7 +39,7 @@ %name-prefix "oabe" /* set the parser's class identifier */ -%define api.parser.class {Parser} +%define parser_class_name {Parser} /* keep track of the current position within the input */ %locations From 2a4bf4284b571bde1daf90ab8cc7482bf872b199 Mon Sep 17 00:00:00 2001 From: Mahmmoud Mahdi Date: Sat, 5 Sep 2020 12:46:22 +0200 Subject: [PATCH 3/4] Create test_1.cpp --- examples/test_1.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 examples/test_1.cpp diff --git a/examples/test_1.cpp b/examples/test_1.cpp new file mode 100644 index 00000000..a8ea49d9 --- /dev/null +++ b/examples/test_1.cpp @@ -0,0 +1,49 @@ +#include +#include +#include +#include +#include + +using namespace std; +using namespace oabe; +using namespace oabe::crypto; + +int main(int argc, char **argv) { + InitializeOpenABE(); + cout << "Testing CP-ABE context" << endl; + + OpenABECryptoContext cpabe("CP-ABE"); + int pid1TEMP=40 ; + // double pid2TEMP=30 ; + int pid1GLUCUSE=100; + // double paid2GLUCUSE=300; + int pid1HR=77; + // double pid2HR=66; + string ct, pt1 = std::to_string(pid1TEMP & pid1GLUCUSE & pid1HR); + string pt2; + + cpabe.generateParams(); + + cpabe.keygen("|doctor|family", "key0"); + + cpabe.encrypt("doctor and family", pt1, ct); + + bool result = cpabe.decrypt("key0", ct, pt2); + + assert(result && pt1 == pt2); + + cout << "Recovered message: " << pt2 << endl; + + ShutdownOpenABE(); + if(pid1TEMP >37.5){ + cout << "patined with id1 has a high temrature"<< endl; + } + if(pid1GLUCUSE >200){ + cout << "patined with id1 has a high galcuse level"<< endl; + } + if(pid1HR >100 or pid1HR <60){ + cout << "patined with id1 has a dangerus heart rate"<< endl; + } + + return 0; +} From fb6c0c1025c0d5f37ae52e088b9b802d8515b40e Mon Sep 17 00:00:00 2001 From: Mahmmoud Mahdi Date: Sat, 5 Sep 2020 12:48:09 +0200 Subject: [PATCH 4/4] Update Makefile --- examples/Makefile | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/examples/Makefile b/examples/Makefile index 72142814..c2058bbd 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -6,25 +6,29 @@ CXXFLAGS := $(CXX11FLAGS)$(OS_CXXFLAGS) -pthread -Wall -g -O2 -DSSL_LIB_INIT -I$ LDFLAGS := -L${ZROOT}/deps/root/lib -L${ZROOT}/root/lib LIBS := -lcrypto -lrelic -lrelic_ec -lopenabe -all: test_kp test_cp test_pk test_km +all: test_kp test_cp test_pk test_km test_1 + +test_1: test_1.o + $(CXX) -o test_1 $(CXXFLAGS) $(LDFLAGS) test_1.cpp $(LIBS) test_kp: test_kp.o - $(CXX) -o test_kp $(CXXFLAGS) $(LDFLAGS) test_kp.cpp $(LIBS) + $(CXX) -o test_kp $(CXXFLAGS) $(LDFLAGS) test_kp.cpp $(LIBS) test_cp: test_cp.o - $(CXX) -o test_cp $(CXXFLAGS) $(LDFLAGS) test_cp.cpp $(LIBS) + $(CXX) -o test_cp $(CXXFLAGS) $(LDFLAGS) test_cp.cpp $(LIBS) test_pk: test_pk.o - $(CXX) -o test_pk $(CXXFLAGS) $(LDFLAGS) test_pk.cpp $(LIBS) + $(CXX) -o test_pk $(CXXFLAGS) $(LDFLAGS) test_pk.cpp $(LIBS) test_km: test_km.o - $(CXX) -o test_km $(CXXFLAGS) $(LDFLAGS) test_km.cpp $(LIBS) + $(CXX) -o test_km $(CXXFLAGS) $(LDFLAGS) test_km.cpp $(LIBS) test: - ./test_kp - ./test_cp - ./test_pk - ./test_km + ./test_kp + ./test_cp + ./test_pk + ./test_km + ./test_1 clean: - rm -rf *.o *.dSYM test_kp test_cp test_pk test_km + rm -rf *.o *.dSYM test_kp test_cp test_pk test_km test_1