diff --git a/Makefile b/Makefile index f79e80b..d66fef8 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,57 @@ -EXEC=bin/crypto.ex +BIN_PATH=./bin +LIB_PATH=./lib +OBJ_PATH=./obj + +EXEC=$(BIN_PATH)/cryptomain.ex SRC=main.cpp +JSON_CPP=$(OBJ_PATH)/jsoncpp.o -main: main.cpp jsoncpp.o +# merge crypt and decrypt binary into cryptomain +cryptomain.ex: +$(EXEC): $(SRC) $(JSON_CPP) @echo "compilation de aes" - @g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) obj/jsoncpp.o -lcrypto --std=c++14 + @g++ -Wall -Wextra -ggdb -o $(EXEC) $(SRC) $(JSON_CPP) -lcrypto --std=c++14 -obj/jsoncpp.o: jsoncpp.cpp json/json.h json/json-forwards.h +$(JSON_CPP): $(LIB_PATH)/jsoncpp.cpp $(LIB_PATH)/json/json.h $(LIB_PATH)/json/json-forwards.h @echo "compilation de jsoncpp" - @g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb jsoncpp.cpp -o obj/jsoncpp.o + @g++ -I ../lib/jsoncpp-master/include/ -Wall -Wextra -std=c++11 -c -ggdb $(LIB_PATH)/jsoncpp.cpp -o $(JSON_CPP) -run2: - @./bin/crypt.ex data/file && ./bin/decrypt.ex data/file.enc data/aesKey.key +run: $(EXEC) + @./$(EXEC) data/cryptomain/file -run: - @./$(EXEC) file +# separate crypt and decrypt binary +EXEC_DECRYPT=$(BIN_PATH)/decrypt.ex +EXEC_CRYPT=$(BIN_PATH)/crypt.ex +SRC_CRYPT=mainCrypt.cpp +SRC_DECRYPT=mainDecrypt.cpp -decrypt.ex: mainDecrypt.cpp obj/jsoncpp.o aes.hpp - @echo "compilation de decrypt.ex" - @g++ -Wall -Wextra -ggdb -o bin/decrypt.ex mainDecrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14 - -crypt.ex: mainCrypt.cpp jsoncpp.o aes.hpp +crypt.ex: +$(EXEC_CRYPT): $(SRC_CRYPT) $(JSON_CPP) aes.hpp @echo "compilation de crypt.ex" - @g++ -Wall -Wextra -ggdb -o bin/crypt.ex mainCrypt.cpp obj/jsoncpp.o -lcrypto --std=c++14 + @g++ -Wall -Wextra -ggdb -o $(EXEC_CRYPT) $(SRC_CRYPT) $(JSON_CPP) -lcrypto --std=c++14 +decrypt.ex: +$(EXEC_DECRYPT): $(SRC_DECRYPT) $(JSON_CPP) aes.hpp + @echo "compilation de decrypt.ex" + @g++ -Wall -Wextra -ggdb -o $(EXEC_DECRYPT) $(SRC_DECRYPT) $(JSON_CPP) -lcrypto --std=c++14 + +run2: $(EXEC_CRYPT) $(EXEC_DECRYPT) + @./$(EXEC_CRYPT) data/crypt_decrypt/file && ./$(EXEC_DECRYPT) data/crypt_decrypt/file.enc data/crypt_decrypt/file.key + +# debug target valgrind: @valgrind --leak-check=full --track-origins=yes ./$(EXEC) file +# clean target clean: cleanO cleanB cleanO: - @rm -rf obj/*.o + @rm -rf $(OBJ_PATH)/*.o cleanB: - @rm -rf bin/*.ex + @rm -rf $(BIN_PATH)/*.ex cleanD: - @/bin/rm -f data/*.enc - @/bin/rm -f data/*.dec - @/bin/rm -f data/*.key + @rm -f data/*.enc + @rm -f data/*.dec + @rm -f data/*.key diff --git a/data/aesKey.key b/data/aesKey.key deleted file mode 100644 index 16f9179..0000000 --- a/data/aesKey.key +++ /dev/null @@ -1,4 +0,0 @@ -{ - "IV" : "e|-}:庿@3g\u0002\u0006/қU", - "key" : "|\u0006[QGuaJnf'g\u0011/n`\u0015dd/" -} \ No newline at end of file diff --git a/data/crypt_decrypt/file b/data/crypt_decrypt/file new file mode 100644 index 0000000..6419cbd --- /dev/null +++ b/data/crypt_decrypt/file @@ -0,0 +1,2 @@ +toto +test crypt_decrypt diff --git a/data/crypt_decrypt/file.dec b/data/crypt_decrypt/file.dec new file mode 100644 index 0000000..6419cbd --- /dev/null +++ b/data/crypt_decrypt/file.dec @@ -0,0 +1,2 @@ +toto +test crypt_decrypt diff --git a/data/crypt_decrypt/file.enc b/data/crypt_decrypt/file.enc new file mode 100644 index 0000000..77c569b --- /dev/null +++ b/data/crypt_decrypt/file.enc @@ -0,0 +1 @@ +HNt ]U-*e \ No newline at end of file diff --git a/data/crypt_decrypt/file.key b/data/crypt_decrypt/file.key new file mode 100644 index 0000000..d97177a --- /dev/null +++ b/data/crypt_decrypt/file.key @@ -0,0 +1,4 @@ +{ + "IV" : "\u0018FM,Ӯ5\u0006\u0005\u0014u\u000E/\u0004N4s(C", + "key" : "\u0018cqo\fd2޶7Bifw\u000E\u001F" +} \ No newline at end of file diff --git a/data/file b/data/cryptomain/file similarity index 100% rename from data/file rename to data/cryptomain/file diff --git a/data/file.dec b/data/cryptomain/file.dec similarity index 100% rename from data/file.dec rename to data/cryptomain/file.dec diff --git a/data/cryptomain/file.enc b/data/cryptomain/file.enc new file mode 100644 index 0000000..b70a8ff --- /dev/null +++ b/data/cryptomain/file.enc @@ -0,0 +1 @@ +yۤA] \ No newline at end of file diff --git a/data/cryptomain/file.key b/data/cryptomain/file.key new file mode 100644 index 0000000..fdbc7ed --- /dev/null +++ b/data/cryptomain/file.key @@ -0,0 +1,4 @@ +{ + "IV" : ":=\u001AڠNK$zz1\u001Ft\u0016\u0011P\tEO\u0016", + "key" : "Z%ͱ{\u0013\u0019Qc\u0004Ĕ|󔕨n" +} \ No newline at end of file diff --git a/data/file.enc b/data/file.enc deleted file mode 100644 index 958a5c9..0000000 --- a/data/file.enc +++ /dev/null @@ -1 +0,0 @@ -e֗0?Γma \ No newline at end of file diff --git a/data/file.key b/data/file.key deleted file mode 100644 index c8e663a..0000000 --- a/data/file.key +++ /dev/null @@ -1,4 +0,0 @@ -{ - "IV" : "9魔\u0016FC6\u0001\"QX4QkU", - "key" : "\u0002\u0014\u0005\u0019=\u0006RxCIe\u0018Lczsz" -} \ No newline at end of file