Skip to content

Commit 892f414

Browse files
authored
Merge pull request #32 from wolfSSL/test-rsa-tpm
Added test cases for RSA and TPM
2 parents b203c02 + 8e24b47 commit 892f414

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

hal/spi/spi_drv_stm32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static void spi_pins_release(void)
112112

113113
/* Release CS */
114114
SPI_PIO_CS_MODE &= ~ (0x03 << (SPI_CS_FLASH * 2));
115-
SPI_PIO_CS_PUPD &= ~ (0x03 << (SPI_CS_TPM * 2));
115+
SPI_PIO_CS_PUPD &= ~ (0x03 << (SPI_CS_FLASH * 2));
116116

117117
}
118118

lib/wolfssl

Submodule wolfssl updated 192 files

tools/test-expect-version/test-expect-version.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ int main(int argc, char** argv)
8787
tty.c_cc[VTIME] = 5;
8888
tcsetattr(serialfd, TCSANOW, &tty);
8989

90-
alarm(30);
90+
alarm(60);
9191

9292
while (i >= 0) {
9393
char c;

tools/test.mk

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,33 @@ ifeq ($(SIGN),ECC256)
1414
SIGN_TOOL=tools/keytools/sign.py --ecc256
1515
endif
1616

17+
ifeq ($(SIGN),RSA2048)
18+
SIGN_TOOL=tools/keytools/sign.py --rsa2048
19+
endif
20+
1721

1822
$(EXPVER):
1923
make -C tools/test-expect-version
2024

2125
# Testbed actions
2226
#
2327
#
28+
#
29+
testbed-on: FORCE
30+
@if ! (test -d /sys/class/gpio/gpio4); then echo "4" > /sys/class/gpio/export || true; fi
31+
@echo "out" >/sys/class/gpio/gpio4/direction
32+
@echo "0" >/sys/class/gpio/gpio4/value || true
33+
@echo "Testbed on."
34+
35+
testbed-off: FORCE
36+
@if ! (test -d /sys/class/gpio/gpio4); then echo "4" > /sys/class/gpio/export || true; fi
37+
@echo "out" >/sys/class/gpio/gpio4/direction
38+
@echo "1" >/sys/class/gpio/gpio4/value || true
39+
@echo "Testbed off."
2440

2541
test-spi-on: FORCE
42+
@make testbed-off
43+
@echo "7" >/sys/class/gpio/unexport || true
2644
@echo "8" >/sys/class/gpio/unexport || true
2745
@echo "9" >/sys/class/gpio/unexport || true
2846
@echo "10" >/sys/class/gpio/unexport || true
@@ -33,6 +51,7 @@ test-spi-on: FORCE
3351
test-spi-off: FORCE
3452
@rmmod spi_bcm2835
3553
@rmmod spidev
54+
@echo "7" >/sys/class/gpio/export
3655
@echo "8" >/sys/class/gpio/export
3756
@echo "9" >/sys/class/gpio/export
3857
@echo "10" >/sys/class/gpio/export
@@ -41,6 +60,16 @@ test-spi-off: FORCE
4160
@echo "in" >/sys/class/gpio/gpio9/direction
4261
@echo "in" >/sys/class/gpio/gpio10/direction
4362
@echo "in" >/sys/class/gpio/gpio11/direction
63+
@make testbed-on
64+
65+
test-tpm-off: FORCE
66+
@if ! (test -d /sys/class/gpio/gpio7); then echo "7" > /sys/class/gpio/export || true; fi
67+
@echo "out" >/sys/class/gpio/gpio7/direction
68+
@echo "1" >/sys/class/gpio/gpio7/value || true
69+
70+
test-tpm-on: FORCE
71+
@echo "7" >/sys/class/gpio/unexport || true
72+
4473

4574
test-update: test-app/image.bin FORCE
4675
@dd if=/dev/zero bs=131067 count=1 2>/dev/null | tr "\000" "\377" > test-update.bin
@@ -78,6 +107,7 @@ test-update-ext: test-app/image.bin FORCE
78107
@make test-spi-on
79108
flashrom -c $(SPI_CHIP) -p linux_spi:dev=/dev/spidev0.0 -w test-update.rom
80109
@make test-spi-off
110+
@make test-tpm-off
81111
@make test-reset
82112
@sleep 2
83113
@make clean
@@ -93,18 +123,22 @@ test-erase-ext: FORCE
93123
@echo Mass-erasing the external SPI flash:
94124
flashrom -c $(SPI_CHIP) -p linux_spi:dev=/dev/spidev0.0 -E
95125
@make test-spi-off
126+
@make test-tpm-off
96127

97128

98129
test-factory: factory.bin
99130
@make test-reset
100131
@sleep 2
101132
@st-flash --reset write factory.bin 0x08000000 || \
102-
(make test-reset && sleep 1 && st-flash --reset write factory.bin 0x08000000) || \
103-
(make test-reset && sleep 1 && st-flash --reset write factory.bin 0x08000000)
133+
((make test-reset && sleep 1 && st-flash --reset write factory.bin 0x08000000) || \
134+
(make test-reset && sleep 1 && st-flash --reset write factory.bin 0x08000000))&
104135

105-
test-reset: FORCE
136+
test-resetold: FORCE
106137
@$$(sleep 1 && st-info --reset) &
107138

139+
test-reset: FORCE
140+
@$$(sleep 1 && make testbed-off && sleep 1 && make testbed-on) &
141+
108142

109143

110144
## Test cases:
@@ -237,8 +271,28 @@ test-34-forward-self-update: $(EXPVER) FORCE
237271
test-44-forward-self-update-ECC: $(EXPVER) FORCE
238272
@make test-34-forward-self-update SIGN=ECC256
239273

274+
test-51-forward-update-no-downgrade-RSA: $(EXPVER) FORCE
275+
@make test-01-forward-update-no-downgrade SIGN=RSA2048
276+
277+
test-53-rollback-RSA: $(EXPVER) FORCE
278+
@make test-03-rollback SIGN=RSA2048
279+
280+
test-61-forward-update-no-downgrade-TPM: $(EXPVER) FORCE
281+
@make test-tpm-on
282+
@make test-01-forward-update-no-downgrade SIGN=ECC256 WOLFTPM=1
283+
@make test-tpm-off
284+
285+
test-63-rollback-TPM: $(EXPVER) FORCE
286+
@make test-tpm-on
287+
@make test-03-rollback SIGN=ECC256 WOLFTPM=1
288+
@make test-tpm-off
289+
240290

241291
test-all: clean test-01-forward-update-no-downgrade test-02-forward-update-allow-downgrade test-03-rollback \
242292
test-11-forward-update-no-downgrade-ECC test-13-rollback-ECC test-21-forward-update-no-downgrade-SPI test-23-rollback-SPI \
243293
test-34-forward-self-update \
244-
test-44-forward-self-update-ECC
294+
test-44-forward-self-update-ECC \
295+
test-51-forward-update-no-downgrade-RSA \
296+
test-53-rollback-RSA \
297+
test-61-forward-update-no-downgrade-TPM \
298+
test-63-rollback-TPM

0 commit comments

Comments
 (0)