Skip to content

Commit

Permalink
Verify applet using FT (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Oct 12, 2023
1 parent 56df399 commit 6ff848b
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 86 deletions.
60 changes: 24 additions & 36 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ BUILD_EPOCH := $(shell /bin/date -u "+%s")
BUILD_TAGS = linkramsize,linkramstart,disable_fr_auth,linkprintk
BUILD = ${BUILD_USER}@${BUILD_HOST} on ${BUILD_DATE}
REV = $(shell git rev-parse --short HEAD 2> /dev/null)
DEV_LOG_ORIGIN ?= "DEV.armoredwitness.transparency.dev/${USER}"
LOG_ORIGIN ?= "DEV.armoredwitness.transparency.dev/${USER}"
GIT_SEMVER_TAG ?= $(shell (git describe --tags --exact-match --match 'v*.*.*' 2>/dev/null || git describe --match 'v*.*.*' --tags 2>/dev/null || git describe --tags 2>/dev/null || echo -n 'v0.0.0+'`git rev-parse HEAD`) | tail -c +2 )

PROTOC ?= /usr/bin/protoc
Expand All @@ -30,9 +30,6 @@ ifeq ("${DEBUG}","1")
BUILD_TAGS := ${BUILD_TAGS},debug
endif

SIGN = $(shell type -p signify || type -p signify-openbsd || type -p minisign)
SIGN_PWD ?= "armored-witness"

APP := ""
TEXT_START = 0x80010000 # ramStart (defined in mem.go under relevant tamago/soc package) + 0x10000

Expand All @@ -50,42 +47,33 @@ QEMU ?= qemu-system-arm -machine mcimx6ul-evk -cpu cortex-a7 -m 512M \

ARCH = "arm"

GOFLAGS = -tags ${BUILD_TAGS} -trimpath -ldflags "-s -w -T ${TEXT_START} -E ${ENTRY_POINT} -R 0x1000 -X 'main.Build=${BUILD}' -X 'main.Revision=${REV}' -X 'main.Version=${BUILD_EPOCH}' -X 'main.PublicKey=$(shell test ${APPLET_PUBLIC_KEY} && cat ${APPLET_PUBLIC_KEY} | tail -n 1)'"
GOFLAGS = -tags ${BUILD_TAGS} -trimpath \
-ldflags "-s -w -T ${TEXT_START} -E ${ENTRY_POINT} -R 0x1000 \
-X 'main.Build=${BUILD}' \
-X 'main.Revision=${REV}' \
-X 'main.Version=${BUILD_EPOCH}' \
-X 'main.AppletLogVerifier=$(shell test ${LOG_PUBLIC_KEY} && cat ${LOG_PUBLIC_KEY})' \
-X 'main.AppletLogOrigin=${LOG_ORIGIN}' \
-X 'main.AppletManifestVerifier=$(shell test ${APPLET_PUBLIC_KEY} && cat ${APPLET_PUBLIC_KEY})'"

.PHONY: clean qemu qemu-gdb

#### primary targets ####

all: trusted_os_embedded_applet_signed witnessctl
all: trusted_os_embedded_applet witnessctl

# This target is only used for dev builds, since the proto definitions may
# change in development and require re-compilation of protos.
trusted_os: APP=trusted_os
trusted_os: DIR=$(CURDIR)/trusted_os
trusted_os: create_dummy_applet proto elf manifest

trusted_os_signed: trusted_os
echo "signing Trusted OS"
@if [ "${SIGN_PWD}" != "" ]; then \
echo -e "${SIGN_PWD}\n" | ${SIGN} -S -s ${OS_PRIVATE_KEY1} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig1; \
echo -e "${SIGN_PWD}\n" | ${SIGN} -S -s ${OS_PRIVATE_KEY2} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig2; \
else \
${SIGN} -S -s ${OS_PRIVATE_KEY1} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig1; \
${SIGN} -S -s ${OS_PRIVATE_KEY2} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig2; \
fi

trusted_os_embedded_applet_signed: APP=trusted_os
trusted_os_embedded_applet_signed: DIR=$(CURDIR)/trusted_os
trusted_os_embedded_applet_signed: check_os_env copy_applet proto elf manifest imx
trusted_os_embedded_applet_signed:
echo "signing Trusted OS"
@if [ "${SIGN_PWD}" != "" ]; then \
echo -e "${SIGN_PWD}\n" | ${SIGN} -S -s ${OS_PRIVATE_KEY1} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig1; \
echo -e "${SIGN_PWD}\n" | ${SIGN} -S -s ${OS_PRIVATE_KEY2} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig2; \
else \
${SIGN} -S -s ${OS_PRIVATE_KEY1} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig1; \
${SIGN} -S -s ${OS_PRIVATE_KEY2} -m ${CURDIR}/bin/trusted_os.elf -x ${CURDIR}/bin/trusted_os.sig2; \
fi
trusted_os_embedded_applet: APP=trusted_os
trusted_os_embedded_applet: DIR=$(CURDIR)/trusted_os
trusted_os_embedded_applet: check_os_env copy_applet proto elf manifest imx
trusted_os_embedded_applet:
# TODO: fix this
touch ${CURDIR}/bin/trusted_applet.proofbundle

witnessctl: check_tamago
@echo "building armored-witness control tool"
Expand All @@ -106,7 +94,7 @@ log_initialise:
echo "(Re-)initialising log at ${LOG_STORAGE_DIR}"
go run github.com/transparency-dev/serverless-log/cmd/integrate@a56a93b5681e5dc231882ac9de435c21cb340846 \
--storage_dir=${LOG_STORAGE_DIR} \
--origin=${DEV_LOG_ORIGIN} \
--origin=${LOG_ORIGIN} \
--private_key=${LOG_PRIVATE_KEY} \
--public_key=${LOG_PUBLIC_KEY} \
--initialise
Expand All @@ -129,12 +117,12 @@ log_os:
fi
go run github.com/transparency-dev/serverless-log/cmd/sequence@a56a93b5681e5dc231882ac9de435c21cb340846 \
--storage_dir=${LOG_STORAGE_DIR} \
--origin=${DEV_LOG_ORIGIN} \
--origin=${LOG_ORIGIN} \
--public_key=${LOG_PUBLIC_KEY} \
--entries=${CURDIR}/bin/trusted_os_manifest
-go run github.com/transparency-dev/serverless-log/cmd/integrate@a56a93b5681e5dc231882ac9de435c21cb340846 \
--storage_dir=${LOG_STORAGE_DIR} \
--origin=${DEV_LOG_ORIGIN} \
--origin=${LOG_ORIGIN} \
--private_key=${LOG_PRIVATE_KEY} \
--public_key=${LOG_PUBLIC_KEY}
@mkdir -p ${LOG_ARTEFACT_DIR}
Expand Down Expand Up @@ -189,19 +177,19 @@ check_os_env:
exit 1; \
fi
@if [ "${APPLET_PATH}" == "" ]; then \
echo 'You need to set the APPLET_PATH variable to a valid path for the directory holding applet elf and signature files (e.g. path to armored-witness-applet/bin)'; \
echo 'You need to set the APPLET_PATH variable to a valid path for the directory holding applet elf and proof bundle files (e.g. path to armored-witness-applet/bin)'; \
exit 1; \
fi

copy_applet:
mkdir -p ${CURDIR}/trusted_os/assets
cp ${APPLET_PATH}/trusted_applet.elf ${CURDIR}/trusted_os/assets/
cp ${APPLET_PATH}/trusted_applet.sig ${CURDIR}/trusted_os/assets/
cp ${APPLET_PATH}/trusted_applet.proofbundle ${CURDIR}/trusted_os/assets/

create_dummy_applet:
mkdir -p $(DIR)/assets
rm -f $(DIR)/assets/trusted_applet.elf && touch $(DIR)/assets/trusted_applet.elf
rm -f $(DIR)/assets/trusted_applet.sig && touch $(DIR)/assets/trusted_applet.sig
rm -f $(DIR)/assets/trusted_applet.proofbundle && touch $(DIR)/assets/trusted_applet.proofbundle

check_tamago:
@if [ "${TAMAGO}" == "" ] || [ ! -f "${TAMAGO}" ]; then \
Expand All @@ -215,12 +203,12 @@ dcd:
clean:
@rm -fr $(CURDIR)/bin/* $(CURDIR)/trusted_os/assets/* $(CURDIR)/qemu.dtb

qemu: trusted_os_embedded_applet_signed
qemu: trusted_os_embedded_applet
$(QEMU) -kernel $(CURDIR)/bin/trusted_os.elf

qemu-gdb: GOFLAGS := $(GOFLAGS:-w=)
qemu-gdb: GOFLAGS := $(GOFLAGS:-s=)
qemu-gdb: trusted_os_embedded_applet_signed
qemu-gdb: trusted_os_embedded_applet
$(QEMU) -kernel $(CURDIR)/bin/trusted_os.elf -S -s

#### application target ####
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,23 @@ require (
github.com/flynn/u2f v0.0.0-20180613185708-15554eb68e5d
github.com/gsora/fidati v0.0.0-20220824075547-eeb0a5f7d6c3
github.com/transparency-dev/armored-witness-boot v0.0.0-20230904140406-e2e16c7665b7
github.com/transparency-dev/armored-witness-common v0.0.0-20231012085018-f5e62744cd3e
github.com/usbarmory/GoTEE v0.0.0-20230914094934-f4f769daa5a9
github.com/usbarmory/armory-boot v0.0.0-20230922092524-e66d926bc36c
github.com/usbarmory/crucible v0.0.0-20230721112227-63d5e1f2db77
github.com/usbarmory/imx-usbnet v0.0.0-20230626092818-ef791923688e
github.com/usbarmory/imx-usbserial v0.0.0-20230503192150-40b6298b31f8
github.com/usbarmory/tamago v0.0.0-20230922151120-1f76695abebe
golang.org/x/crypto v0.14.0
golang.org/x/mod v0.13.0
google.golang.org/protobuf v1.31.0
gvisor.dev/gvisor v0.0.0-20230614190805-57027c7d31f8
)

require (
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/dsoprea/go-ext4 v0.0.0-20190528173430-c13b09fc0ff8 // indirect
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
Expand All @@ -35,8 +34,9 @@ require (
github.com/pierrec/lz4/v4 v4.1.14 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/stretchr/testify v1.8.2 // indirect
github.com/transparency-dev/formats v0.0.0-20230920083814-0f75b1d4e813 // indirect
github.com/transparency-dev/merkle v0.0.2 // indirect
github.com/u-root/u-root v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
Expand Down
23 changes: 9 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dsoprea/go-ext4 v0.0.0-20190528173430-c13b09fc0ff8 h1:e3CYZInWqO0a3MWfD0WW/11Ki0qo3Fc1ZAHx0+whlhY=
github.com/dsoprea/go-ext4 v0.0.0-20190528173430-c13b09fc0ff8/go.mod h1:UBig4B62vBWtudYo4RJPwdV5Lqo+oeh7AtSCmRIkRPc=
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd h1:l+vLbuxptsC6VQyQsfD7NnEC8BZuFpz45PgY+pH8YTg=
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs=
github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw=
github.com/flynn/hid v0.0.0-20190502022136-f1b9b6cc019a h1:fsyWnwbywFpHJS4T55vDW+UUeWP2WomJbB45/jf4If4=
Expand All @@ -20,9 +16,6 @@ github.com/flynn/u2f v0.0.0-20180613185708-15554eb68e5d h1:2D6Rp/MRcrKnRFr7kfgBO
github.com/flynn/u2f v0.0.0-20180613185708-15554eb68e5d/go.mod h1:shcCQPgKtaJz4obqb6Si031WgtSrW+Tj+ZLq/mRNrM8=
github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
Expand Down Expand Up @@ -61,8 +54,15 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/transparency-dev/armored-witness-applet v0.0.0-20230918140527-29dcafed830b h1:d8bLTgqLrvH1VJyNUTAzLyY/Ux13s7QHb19vEcTum7E=
github.com/transparency-dev/armored-witness-boot v0.0.0-20230904140406-e2e16c7665b7 h1:3xrmiN4hwWi3nxvDo9asUWrNCjaPYBhF+rHpW97Fde0=
github.com/transparency-dev/armored-witness-boot v0.0.0-20230904140406-e2e16c7665b7/go.mod h1:GTj2zM9nwFe7G7gaXzIbkKJ/PkZfvVq4TdNiA6CBsdo=
github.com/transparency-dev/armored-witness-common v0.0.0-20231012085018-f5e62744cd3e h1:xfRW77mjLPStON23m0cRHtkMhy/Hyc9LefW/MhFCZ2s=
github.com/transparency-dev/armored-witness-common v0.0.0-20231012085018-f5e62744cd3e/go.mod h1:6M39UQVYzzFdzXGrJFjRC+G9D5f0icxOVkcX/yaWZss=
github.com/transparency-dev/formats v0.0.0-20230920083814-0f75b1d4e813 h1:PHklaeYyhPsbhWt+MnKpBvJrsJGkPEaU1JutMj4wNqM=
github.com/transparency-dev/formats v0.0.0-20230920083814-0f75b1d4e813/go.mod h1:J2NdDb6IhKIvF6MwCvKikz9/QStRylEtS2mv+En+jBg=
github.com/transparency-dev/merkle v0.0.2 h1:Q9nBoQcZcgPamMkGn7ghV8XiTZ/kRxn1yCG81+twTK4=
github.com/transparency-dev/merkle v0.0.2/go.mod h1:pqSy+OXefQ1EDUVmAJ8MUhHB9TXGuzVAT58PqBoHz1A=
github.com/u-root/u-root v0.11.0 h1:6gCZLOeRyevw7gbTwMj3fKxnr9+yHFlgF3N7udUVNO8=
github.com/u-root/u-root v0.11.0/go.mod h1:DBkDtiZyONk9hzVEdB/PWI9B4TxDkElWlVTHseglrZY=
github.com/usbarmory/GoTEE v0.0.0-20230914094934-f4f769daa5a9 h1:bVjcARGT+mwll/+no7bsCCC1UDldtuNXL00twGtLPGo=
Expand All @@ -78,21 +78,16 @@ github.com/usbarmory/imx-usbserial v0.0.0-20230503192150-40b6298b31f8/go.mod h1:
github.com/usbarmory/tamago v0.0.0-20220823080407-04f05cf2a5a3/go.mod h1:Lok79mjbJnhoBGqhX5cCUsZtSemsQF5FNZW+2R1dRr8=
github.com/usbarmory/tamago v0.0.0-20230922151120-1f76695abebe h1:h3PrTFE6iPJzyYz+/2iyIPCUS5yyuqPHRCMsW2IXk3k=
github.com/usbarmory/tamago v0.0.0-20230922151120-1f76695abebe/go.mod h1:uCPXcPo8SZulhZPz8irfVqzwVlPZ45w7CTJxkfxueGA=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
28 changes: 15 additions & 13 deletions trusted_os/flash.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/usbarmory/tamago/soc/nxp/usdhc"

"github.com/transparency-dev/armored-witness-boot/config"
abconfig "github.com/usbarmory/armory-boot/config"
"github.com/transparency-dev/armored-witness-common/release/firmware"

"github.com/transparency-dev/armored-witness-os/api"
)
Expand Down Expand Up @@ -81,12 +81,12 @@ type Card interface {
Detect() error
}

// read reads the trusted applet and its signature from internal storage, the
// applet and signatures are *not* verified by this function.
func read(card Card) (taELF []byte, taSig []byte, err error) {
// read reads the trusted applet bundle from internal storage, the
// applet and FT proofs are *not* verified by this function.
func read(card Card) (fw *firmware.Bundle, err error) {
blockSize := card.Info().BlockSize
if blockSize != expectedBlockSize {
return nil, nil, fmt.Errorf("h/w invariant error - expected MMC blocksize %d, found %d", expectedBlockSize, blockSize)
return nil, fmt.Errorf("h/w invariant error - expected MMC blocksize %d, found %d", expectedBlockSize, blockSize)
}

buf, err := card.Read(taConfBlock*expectedBlockSize, config.MaxLength)
Expand All @@ -101,12 +101,17 @@ func read(card Card) (taELF []byte, taSig []byte, err error) {
return
}

if len(conf.Signatures) < 1 {
return nil, nil, errors.New("invalid applet signature")
fw = &firmware.Bundle{
Checkpoint: conf.Bundle.Checkpoint,
Index: conf.Bundle.LogIndex,
InclusionProof: conf.Bundle.InclusionProof,
Manifest: conf.Bundle.Manifest,
}

taSig = conf.Signatures[0]
taELF, err = card.Read(conf.Offset, conf.Size)
fw.Firmware, err = card.Read(conf.Offset, conf.Size)
if err != nil {
return nil, fmt.Errorf("failed to read firmware: %v", err)
}

return
}
Expand Down Expand Up @@ -174,10 +179,7 @@ func blinkenLights() (func(), func()) {

// updateApplet verifies an applet update and flashes it to internal storage
func updateApplet(taELF []byte, taSig []byte, pb config.ProofBundle) (err error) {
log.Printf("SM applet verification")
if err = abconfig.Verify(taELF, taSig, PublicKey); err != nil {
return fmt.Errorf("applet verification error: %v", err)
}
// TODO: OS applet verification

return flashFirmware(Firmware_Applet, taELF, [][]byte{taSig}, pb)
}
Expand Down
Loading

0 comments on commit 6ff848b

Please sign in to comment.