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 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 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; +} 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