#! /bin/make

test: maa
	# standard tests vectors specified in Annex A of ISO-8731-2:1992
	./maa -t

	# test vector specified in Annex E.3 of ISO-8730:1990
	# compute the MAC of order-*-3 using key J = E6A12F07, K = 9D15C437
	# the correct MAC result should be DE006773
	./maa Tests/order-iso-8730-annex-E-3 E6A12F07 9D15C437 DE006773

	# test vector specified in Annex E.4 of ISO-8730:1990
	# compute the MAC of order-*-4 using key J = E6A12F07, K = 9D15C437
	# the correct MAC result should be C6E3D000
	./maa Tests/order-iso-8730-annex-E-4 E6A12F07 9D15C437 C6E3D000

	# test vector added by INRIA Grenoble
	# compute the MAC of maa_original using key J = 1F619C6D, K = 2C196A9F
	# the correct MAC result should be FDA371B8
	./maa Tests/maa_original 1F619C6D 2C196A9F FDA371B8

maa: main.c maa.h
	# compile the C code generated by Caesar.adt
	$(CADP)/src/com/cadp_cc -g -I$(CADP)/incl main.c -L$(CADP)/bin.`$(CADP)/com/arch` -lcaesar -lcaesar_plug -lm -o maa
	@echo ''

maa.h: maa.lotos
	# translate the LOTOS code to C code using Caesar.adt
	caesar.adt -english -silent maa.lotos
	@echo ''

maa.lotos: BLOCK.lnt BLOCKVALUES.lnt maa.lnt maa.fnt
	# translate the LNT to LOTOS code using LNT2LOTOS
	lnt.open -main null maa.lnt -
	@echo ''

clean:
	@rm -f *.err *.BAK
	@rm -f BIT.lib BIT.f BIT.t
	@rm -f OCTET.lib OCTET.f OCTET.t
	@rm -f OCTETVALUES.lib OCTETVALUES.f OCTETVALUES.t
	@rm -f BLOCK.lib BLOCK.f BLOCK.t
	@rm -f BLOCKVALUES.lib BLOCKVALUES.f BLOCKVALUES.t
	@rm -f maa.lotos maa.t maa.f maa.h
	@$(CADP)/src/com/cadp_rm maa

