Skip to content

Commit

Permalink
Merge pull request #197 from danielinux/tpm2-test-fix
Browse files Browse the repository at this point in the history
Fix regressions in wolfTPM integration and tests
  • Loading branch information
elms authored Apr 11, 2022
2 parents ff2507a + e755700 commit 1c361f1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ static void wolfBoot_verify_signature(struct wolfBoot_image *img, uint8_t *sig)
ret = wc_RsaPublicKeyDecode_ex(KEY_BUFFER, &inOutIdx, KEY_LEN, &n, &nSz, &e,
&eSz);
if (ret < 0)
return -1;
return;

/* Load public key into TPM */
memset(&tpmKey, 0, sizeof(tpmKey));
Expand All @@ -268,7 +268,7 @@ static void wolfBoot_verify_signature(struct wolfBoot_image *img, uint8_t *sig)
errStr = wolfTPM2_GetRCString(ret);
(void)errStr;
#endif
return -1;
return;
}

/* Perform public decrypt and manually un-pad */
Expand Down
41 changes: 21 additions & 20 deletions tools/test.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
TEST_UPDATE_VERSION?=2
WOLFBOOT_VERSION?=0
EXPVER=tools/test-expect-version/test-expect-version /dev/ttyS0
EXPVER=tools/test-expect-version/test-expect-version
EXPVER_CMD=$(EXPVER) /dev/ttyS0
BINASSEMBLE=tools/bin-assemble/bin-assemble
SPI_CHIP=SST25VF080B
SPI_OPTIONS=SPI_FLASH=1 WOLFBOOT_PARTITION_SIZE=0x80000 WOLFBOOT_PARTITION_UPDATE_ADDRESS=0x00000 WOLFBOOT_PARTITION_SWAP_ADDRESS=0x80000
Expand Down Expand Up @@ -199,17 +200,17 @@ test-01-forward-update-no-downgrade: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=4
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=1
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@make clean
@echo TEST PASSED

Expand All @@ -218,17 +219,17 @@ test-02-forward-update-allow-downgrade: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory ALLOW_DOWNGRADE=1
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
@(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=4
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=2
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 2)
@(test `$(EXPVER_CMD)` -eq 2)
@make clean
@echo TEST PASSED

Expand All @@ -237,21 +238,21 @@ test-03-rollback: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
@(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=4
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@echo
@echo Creating and uploading update image...
@make test-update TEST_UPDATE_VERSION=5
@echo Expecting version '5'
@(test `$(EXPVER)` -eq 5)
@(test `$(EXPVER_CMD)` -eq 5)
@echo
@echo Resetting to trigger rollback...
@make test-reset
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@make clean
@echo TEST PASSED

Expand All @@ -274,17 +275,17 @@ test-21-forward-update-no-downgrade-SPI: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory $(SPI_OPTIONS)
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
@(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Creating and uploading update image...
@make test-update-ext TEST_UPDATE_VERSION=4 $(SPI_OPTIONS)
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@echo
@echo Creating and uploading update image...
@make test-update-ext TEST_UPDATE_VERSION=1 $(SPI_OPTIONS)
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@make clean
@echo TEST PASSED

Expand All @@ -293,22 +294,22 @@ test-23-rollback-SPI: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory $(SPI_OPTIONS)
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
@(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Creating and uploading update image...
@make test-update-ext TEST_UPDATE_VERSION=4 $(SPI_OPTIONS)
@echo Expecting version '4'
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@echo
@echo Creating and uploading update image...
@make test-update-ext TEST_UPDATE_VERSION=5 $(SPI_OPTIONS)
@echo Expecting version '5'
@(test `$(EXPVER)` -eq 5)
@(test `$(EXPVER_CMD)` -eq 5)
@echo
@echo Resetting to trigger rollback...
@make test-reset
@sleep 2
@(test `$(EXPVER)` -eq 4)
@(test `$(EXPVER_CMD)` -eq 4)
@make clean
@echo TEST PASSED

Expand All @@ -320,13 +321,13 @@ test-34-forward-self-update: $(EXPVER) FORCE
@echo Creating and uploading factory image...
@make test-factory WOLFBOOT_VERSION=1 RAM_CODE=1 SIGN=$(SIGN)
@echo Expecting version '1'
@(test `$(EXPVER)` -eq 1)
@(test `$(EXPVER_CMD)` -eq 1)
@echo
@echo Updating keys, firmware, bootloader
@make test-self-update WOLFBOOT_VERSION=4 TEST_UPDATE_VERSION=2 RAM_CODE=1 SIGN=$(SIGN)
@sleep 2
@echo Expecting version '2'
@(test `$(EXPVER)` -eq 2)
@(test `$(EXPVER_CMD)` -eq 2)
@make clean
@echo TEST PASSED

Expand Down

0 comments on commit 1c361f1

Please sign in to comment.