add support for crypting l0dables in Makefile

This commit is contained in:
Stefan `Sec` Zehl 2011-08-11 10:16:55 +02:00
parent de02a6ccbc
commit 35f875eb6c
1 changed files with 12 additions and 2 deletions

View File

@ -24,9 +24,13 @@ LDSRCFILE=ram.ld
LDFILE=loadable.ld LDFILE=loadable.ld
CFLAGS+=-mlong-calls -fno-toplevel-reorder CFLAGS+=-mlong-calls -fno-toplevel-reorder
CRYPT=cp DOCRYPT=0
CRYPT=../../tools/crypto/xxtea
CRYPTFLAGS=-p CRYPTFLAGS=-p
skey=`cd .. && ./getkey.pl l0dable_sign`
ekey=`cd .. && ./getkey.pl l0dable_crypt`
all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int all: $(OBJS) $(ELFS) $(BINS) $(CODS) $(NIKS) 1boot.int debug.int
$(LDFILE): $(LDFILE):
@ -47,7 +51,13 @@ $(LDFILE):
$(OBJCOPY) $(OCFLAGS) -O binary $< $@ $(OBJCOPY) $(OCFLAGS) -O binary $< $@
%.c0d: %.bin %.c0d: %.bin
$(CRYPT) $(CRYPTFLAGS) $< $@ ifeq "$(DOCRYPT)" "1"
$(CRYPT) -e -k $(ekey) -o $<.tmp $<
$(CRYPT) -s -k $(skey) -o $@ $<.tmp
rm -f $<.tmp
else
cp $< $@
endif
%.nik: .PHONY %.nik: .PHONY
@a=$@;a=nick_$${a%.nik}.c0d;echo mv $$a $@;mv $$a $@ @a=$@;a=nick_$${a%.nik}.c0d;echo mv $$a $@;mv $$a $@