TARGET       = tests
CONFIG       = release
SOURCES      = ASN1.cpp main.cpp


include ../../Makefile.inc


test-report.txt: mykey.pub $(TARGET_BINARY) decrypt.txt
	@echo -n "ReadKey Test: " >> test-report.txt
	@./$(TARGET_BINARY) mykey.pub >> test-report.txt
	@echo -n "Decryption Test: " >> test-report.txt
	@if diff -du message.txt decrypt.txt ; then echo "PASS" ; else echo "FAIL" ; fi >> test-report.txt

decrypt.txt: mykey.pub crypt.bin
	@openssl rsautl -verify -pubin -inkey mykey.pub -in crypt.bin -out decrypt.txt

crypt.bin: message.txt
	@openssl rsautl -sign -inkey mykey.pem -in message.txt -out crypt.bin

message.txt:
	@echo "This is my text.\nLet's make it secret.\n" > message.txt

mykey.pub: mykey.pem
	@openssl rsa -in mykey.pem -pubout -out mykey.pub

mykey.pem:
	@openssl genrsa -out mykey.pem 2048

