Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b2dbdbf
add boot transparency support
danbia Dec 9, 2025
d31a7ff
update documentation
danbia Dec 9, 2025
2f42c9d
tyding
danbia Dec 9, 2025
8623013
address PR comments
danbia Dec 10, 2025
bd2b1ed
replace online/offline nomenclature
danbia Dec 10, 2025
40b0cbd
move back transparency code to a dedicated pkg, add btCmd under cmd/a…
danbia Dec 10, 2025
fd40723
tyding
danbia Dec 11, 2025
117a3dc
add to bt validation artifacts hash check
danbia Dec 15, 2025
b2f1ea2
improves godoc and comments
danbia Dec 15, 2025
8602fe6
tyding
danbia Dec 15, 2025
10733ef
fix per-entry path construction
danbia Dec 15, 2025
fa75081
remove uneccessary const type + improve godoc comments
danbia Dec 15, 2025
9169926
tyding
danbia Dec 15, 2025
83de386
uses idiomatic errors where applicable
danbia Dec 15, 2025
6e41fb7
use path.Join to assemble configuration paths
danbia Dec 15, 2025
dca10be
better usage of BtStatus type
danbia Dec 15, 2025
a9b37f2
move configuration loading to transparency.go
danbia Dec 15, 2025
2227596
better code organization in cmd/linux and add configuration methods
danbia Dec 16, 2025
3fca8d7
improves configuration path construction
danbia Dec 17, 2025
13cfbf8
define BootEntry type for better code organization
danbia Dec 17, 2025
ead2d21
tyding
danbia Dec 17, 2025
d293f00
more idiomatic code re-organization
danbia Dec 17, 2025
2afa5f2
more consistent proof hash validation names
danbia Dec 18, 2025
07720d1
fix code repetition in load config
danbia Dec 19, 2025
b7bad2a
add support for external pkg usage
danbia Dec 20, 2025
967e784
automatically detect if operating externally to a UEFI bootloader
danbia Dec 20, 2025
518e7be
tyding
danbia Dec 20, 2025
6f43b79
tyding
danbia Dec 20, 2025
299e394
add protections against invalid hash and root fs
danbia Dec 20, 2025
33f0ce0
add test files for transparency pkg
danbia Dec 20, 2025
a182d68
fix Offline vs Online tests
danbia Dec 21, 2025
ae5685b
returns error if online mode is selected and network is unavailable
danbia Jan 8, 2026
9ea8cae
improve cmd help consistency
danbia Jan 8, 2026
a67ce20
limit returns in the bt config function
danbia Jan 8, 2026
bc17134
documentation tyiding
danbia Jan 8, 2026
b67c30e
moves btValidate function to auth.go
danbia Jan 8, 2026
cc56a74
better usage of const to store test values
danbia Jan 8, 2026
efb36e8
avoid func definition on *BootEntry -> use BootEntry
danbia Jan 8, 2026
6a2fee3
moves entirely btValidate function to auth.go btValidateLinux
danbia Jan 12, 2026
7a0b4ed
tyding
danbia Jan 15, 2026
107027d
function renaming hasValidHash -> validHash
danbia Jan 15, 2026
7697446
makes engine a Config property and align the codebase to the latest b…
danbia Jan 19, 2026
5ead986
improves error messages
danbia Jan 19, 2026
82b9a5b
revert cmd/auth.go
danbia Jan 19, 2026
2146afe
move hash validation function comment
danbia Jan 19, 2026
a79b5a8
fix error detection boot_entry test
danbia Jan 19, 2026
a26554b
updates SetKey to use []byte as argument
danbia Jan 20, 2026
a771b1a
improve comments on config key fields
danbia Jan 20, 2026
a69663b
improve comments and error messages
danbia Jan 20, 2026
bba9774
uses fmt.Errorf instead of errors.New as fmt is already imported
danbia Jan 20, 2026
7f3e20c
more idomatic error check
danbia Jan 20, 2026
03b54ae
improves error checks
danbia Jan 26, 2026
74c8947
change Status code resolution function name Resove -> String
danbia Jan 26, 2026
2e16529
simplifies error message on bt validation
danbia Jan 26, 2026
cccd427
change Hash(*[]byte) (string) -> Sum(b []byte) ([]byte)
danbia Jan 26, 2026
cbc5c14
align test files to Sum()
danbia Jan 26, 2026
a83ab5a
uses artifact.Sum() and artifact.HashSize const from boot-transparenc…
danbia Jan 27, 2026
766688e
moves artifact hash verification to boot-transparency library
danbia Mar 11, 2026
3f6cef2
Merge branch 'development' into boot-transparency
danbia Mar 11, 2026
447c09d
update dependencies
danbia Mar 11, 2026
a9a68ea
replace UEFI specific loading code
danbia Mar 11, 2026
83d80ce
tyding
danbia Mar 12, 2026
775721e
exports PathPrefix to allow configuring the asset store directory
danbia Mar 12, 2026
9d9e1f8
expand testcases
danbia Mar 12, 2026
e5f5144
removes Metadata from BootArtifact until they will be fully supported
danbia Mar 12, 2026
4b86329
exports default path prefix
danbia Mar 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ initializing console (text)
go-boot • tamago/amd64 (go1.24.1) • UEFI x64

. <path> # load and start EFI image
bt (none|offline|online)? # show/set boot-transparency status
build # build information
cat <path> # show file contents
clear # clear screen
Expand Down Expand Up @@ -266,6 +267,16 @@ For a stand-alone AMD SEV-SNP unikernel, based on go-boot code but capable of
terminating EFI Boot Services and using additional network drivers, see
[tamago-sev-example](https://github.com/usbarmory/tamago-sev-example).

Boot transparency
=================

The interaction with a transparency ecosystem for boot loading operations is provided
by the [boot-transparency](https://github.com/usbarmory/boot-transparency) Go library.

The following example demonstrates how to enable, and configure, the boot transparency support:

* [Boot transparency](https://github.com/usbarmory/go-boot/wiki/Boot-Transparency)

License
=======

Expand Down
96 changes: 96 additions & 0 deletions cmd/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// Copyright (c) The go-boot authors. All Rights Reserved.
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.

package cmd

import (
"errors"
"fmt"
"io/fs"
"net"
"regexp"
"strings"

"github.com/usbarmory/go-boot/shell"
"github.com/usbarmory/go-boot/transparency"
"github.com/usbarmory/go-boot/uapi"

"github.com/usbarmory/boot-transparency/artifact"
"github.com/usbarmory/boot-transparency/policy"
_ "github.com/usbarmory/boot-transparency/engine/sigsum"
_ "github.com/usbarmory/boot-transparency/engine/tessera"
bt_transparency "github.com/usbarmory/boot-transparency/transparency"
)

var btConfig transparency.Config

func init() {
shell.Add(shell.Cmd{
Name: "bt",
Args: 2,
Pattern: regexp.MustCompile(`^(?:bt)( none| offline| online)?( sigsum| tessera)?$`),
Syntax: "(none|offline|online)? (sigsum|tessera)?",
Help: "show/change boot-transparency configuration",
Fn: btCmd,
})
}

func btCmd(_ *shell.Interface, arg []string) (res string, err error) {
if len(arg[0]) > 0 {
switch strings.TrimSpace(arg[0]) {
case "none":
btConfig.Status = transparency.None
case "offline":
btConfig.Status = transparency.Offline
case "online":
if net.SocketFunc == nil {
return "", errors.New("network unavailable")
}
btConfig.Status = transparency.Online
}

if btConfig.Status != transparency.None && len(arg[1]) == 0 {
return "", errors.New("invalid transparency engine")
}

if len(arg[1]) > 0 {
e := bt_transparency.EngineCodeFromString[strings.TrimSpace(arg[1])]
if _, err = bt_transparency.GetEngine(e); err != nil {
return "", fmt.Errorf("unable to configure the transparency engine, %v", err)
}
btConfig.Engine = e
}
}

switch btConfig.Status {
case transparency.None:
res = fmt.Sprintf("boot-transparency is disabled\n")
case transparency.Offline, transparency.Online:
res = fmt.Sprintf("boot-transparency is enabled in %s mode, %s engine selected\n", btConfig.Status, btConfig.Engine)
}

return
}

func btValidateLinux(entry *uapi.Entry, root fs.FS) (err error) {
if entry == nil || len(entry.Linux) == 0 {
return errors.New("invalid kernel entry")
}

btConfig.Root = root

btEntry := policy.BootEntry{
policy.BootArtifact{
Category: artifact.LinuxKernel,
Data: entry.Linux,
},
policy.BootArtifact{
Category: artifact.Initrd,
Data: entry.Initrd,
},
}

return transparency.Validate(&btConfig, &btEntry)
}
8 changes: 8 additions & 0 deletions cmd/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/usbarmory/armory-boot/exec"
"github.com/usbarmory/go-boot/shell"
"github.com/usbarmory/go-boot/transparency"
"github.com/usbarmory/go-boot/uapi"
"github.com/usbarmory/go-boot/uefi"
"github.com/usbarmory/go-boot/uefi/x64"
Expand Down Expand Up @@ -245,6 +246,13 @@ func linuxCmd(_ *shell.Interface, arg []string) (res string, err error) {
return "", errors.New("empty kernel entry")
}

// boot transparency validation (if enabled)
if btConfig.Status != transparency.None {
if err = btValidateLinux(entry, root); err != nil {
return "", fmt.Errorf("boot transparency, %v", err)
}
}

image := &exec.LinuxImage{
Kernel: entry.Linux,
InitialRamDisk: entry.Initrd,
Expand Down
22 changes: 20 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b
github.com/u-root/u-root v0.15.0
github.com/usbarmory/armory-boot v0.0.0-20260202115234-edf170b30f66
github.com/usbarmory/boot-transparency v0.0.0-20260311132025-a6323d45a3df
github.com/usbarmory/go-net v0.0.0-20251003201608-93d9ffe808de
github.com/usbarmory/tamago v1.26.1
golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e
Expand All @@ -18,17 +19,34 @@ require (

require (
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/btree v1.1.2 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/klauspost/compress v1.17.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/klauspost/compress v1.18.0 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/therootcompany/xz v1.0.1 // indirect
github.com/transparency-dev/formats v0.0.0-20250421220931-bb8ad4d07c26 // indirect
github.com/transparency-dev/merkle v0.0.2 // indirect
github.com/transparency-dev/tessera v1.0.0 // indirect
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 // indirect
github.com/ulikunitz/xz v0.5.15 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/metric v1.38.0 // indirect
go.opentelemetry.io/otel/trace v1.38.0 // indirect
golang.org/x/crypto v0.42.0 // indirect
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
golang.org/x/mod v0.28.0 // indirect
golang.org/x/net v0.44.0 // indirect
golang.org/x/sync v0.17.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/time v0.7.0 // indirect
golang.org/x/text v0.29.0 // indirect
golang.org/x/time v0.12.0 // indirect
gvisor.dev/gvisor v0.0.0-20250911055229-61a46406f068 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
sigsum.org/sigsum-go v0.11.2 // indirect
)
55 changes: 51 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,47 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/arl/statsviz v0.8.0 h1:O6GjjVxEDxcByAucOSl29HaGYLXsuwA3ujJw8H9E7/U=
github.com/arl/statsviz v0.8.0/go.mod h1:XlrbiT7xYT03xaW9JMMfD8KFUhBOESJwfyNJu83PbB0=
github.com/cenkalti/backoff/v5 v5.0.3 h1:ZN+IMa753KfX5hd8vVaMixjnqRZ3y8CuJKRKj1xcsSM=
github.com/cenkalti/backoff/v5 v5.0.3/go.mod h1:rkhZdG3JZukswDf7f0cwqPNk4K0sa+F97BxZthm/crw=
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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b h1:wDUNC2eKiL35DbLvsDhiblTUXHxcOPwQSCzi7xpQUN4=
github.com/hako/durafmt v0.0.0-20210608085754-5c1018a4e16b/go.mod h1:VzxiSdG6j1pi7rwGm/xYI5RbtpBgM8sARDXlvEvxlu0=
github.com/klauspost/compress v1.17.4 h1:Ej5ixsIri7BrIjBkRZLTo6ghwrEtHFk7ijlczPW4fZ4=
github.com/klauspost/compress v1.17.4/go.mod h1:/dCuZOvVtNoHsyb+cuJD3itjs3NbnF6KH9zAO4BDxPM=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
github.com/therootcompany/xz v1.0.1/go.mod h1:3K3UH1yCKgBneZYhuQUvJ9HPD19UEXEI0BWbMn8qNMY=
github.com/transparency-dev/formats v0.0.0-20250421220931-bb8ad4d07c26 h1:YTbkeFbzcer+42bIgo6Za2194nKwhZPgaZKsP76QffE=
github.com/transparency-dev/formats v0.0.0-20250421220931-bb8ad4d07c26/go.mod h1:ODywn0gGarHMMdSkWT56ULoK8Hk71luOyRseKek9COw=
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/transparency-dev/tessera v1.0.0 h1:4OT1V9xJLa5NnYlFWWlCdZkCm18/o12rdd+bCTje7XE=
github.com/transparency-dev/tessera v1.0.0/go.mod h1:TLvfjlkbmsmKVEJUtzO2eb9Q2IBnK3EJ0dI4G0oxEOU=
github.com/u-root/u-root v0.15.0 h1:8JXfjAA/Vs8EXfZUA2ftvoHbiYYLdaU8umJ461aq+Jw=
github.com/u-root/u-root v0.15.0/go.mod h1:/0Qr7qJeDwWxoKku2xKQ4Szc+SwBE3g9VE8jNiamsmc=
github.com/u-root/uio v0.0.0-20240224005618-d2acac8f3701 h1:pyC9PaHYZFgEKFdlp3G8RaCKgVpHZnecvArXvPXcFkM=
Expand All @@ -28,23 +51,47 @@ github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY=
github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/usbarmory/armory-boot v0.0.0-20260202115234-edf170b30f66 h1:EKfiE4TIqVtO9Nyj7Izg16JPWpg+QaFkg0N3kBzgCZU=
github.com/usbarmory/armory-boot v0.0.0-20260202115234-edf170b30f66/go.mod h1:2cCdG4eUnVtrKyfbCc2A+0SHJl62Cgf4jEXTw/OvlW4=
github.com/usbarmory/boot-transparency v0.0.0-20260311132025-a6323d45a3df h1:pt2+nl2z534UxcBaicQVUlpbyhKOuqI+o/tEVT96/CY=
github.com/usbarmory/boot-transparency v0.0.0-20260311132025-a6323d45a3df/go.mod h1:sRG+Jvx0W7gw7ATXOGPgF93DhjHYZ0I9CnT0myhtdKo=
github.com/usbarmory/go-net v0.0.0-20251003201608-93d9ffe808de h1:5O20CXXbFwjrqyDFtCyFUlxiRLCdc+ksT8MUihbjIDg=
github.com/usbarmory/go-net v0.0.0-20251003201608-93d9ffe808de/go.mod h1:+6WiKCFJtJQZdNM2VpwQsYGo/aBJ39pN7nWx6Td3Z8s=
github.com/usbarmory/tamago v1.26.1 h1:ZJkxM/+qNZTO631bJz5x/flhYb/ww1ura4H2BrZbX5I=
github.com/usbarmory/tamago v1.26.1/go.mod h1:7x0kUe5eE9S1z7Pi/C9RjF8E4JHWzqnE4cKzGl0hyug=
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
golang.org/x/crypto v0.42.0 h1:chiH31gIWm57EkTXpwnqf8qeuMUi0yekh6mT2AvFlqI=
golang.org/x/crypto v0.42.0/go.mod h1:4+rDnOTJhQCx2q7/j6rAN5XDw8kPjeaXEUR2eL94ix8=
golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e h1:G2pNJMnWEb60ip90TMo++m9fpt+d3YIZa0er3buPKRo=
golang.org/x/crypto/x509roots/fallback v0.0.0-20260209214922-2f26647a795e/go.mod h1:MEIPiCnxvQEjA4astfaKItNwEVZA5Ki+3+nyGbJ5N18=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 h1:nDVHiLt8aIbd/VzvPWN6kSOPE7+F/fNFDSXLVYkE/Iw=
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394/go.mod h1:sIifuuw/Yco/y6yb6+bDNfyeQ/MdPUy/hKEMYQV17cM=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
golang.org/x/net v0.44.0 h1:evd8IRDyfNBMBTTY5XRF1vaZlD+EmWx6x8PkhR04H/I=
golang.org/x/net v0.44.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY=
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
golang.org/x/sys v0.41.0 h1:Ivj+2Cp/ylzLiEU89QhWblYnOE9zerudt9Ftecq2C6k=
golang.org/x/sys v0.41.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.40.0 h1:36e4zGLqU4yhjlmxEaagx2KuYbJq3EwY8K943ZsHcvg=
golang.org/x/term v0.40.0/go.mod h1:w2P8uVp06p2iyKKuvXIm7N/y0UCRt3UfJTfZ7oOpglM=
golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ=
golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/text v0.29.0 h1:1neNs90w9YzJ9BocxfsQNHKuAT4pkghyXc4nhZ6sJvk=
golang.org/x/text v0.29.0/go.mod h1:7MhJOA9CD2qZyOKYazxdYMF85OwPdEr9jTtBpO7ydH4=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gvisor.dev/gvisor v0.0.0-20250911055229-61a46406f068 h1:95kdltF/maTDk/Wulj7V81cSLgjB/Mg/6eJmOKsey4U=
gvisor.dev/gvisor v0.0.0-20250911055229-61a46406f068/go.mod h1:K16uJjZ+hSqDVsXhU2Rg2FpMN7kBvjZp/Ibt5BYZJjw=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
sigsum.org/sigsum-go v0.11.2 h1:7HhDPC8gVJzl3wB3gAg3j6gTpO2t0UPHC0ogwhKuNRc=
sigsum.org/sigsum-go v0.11.2/go.mod h1:pGa/r4QsNYom+RqRMkdhcG5E00ty1nlTmALEizdRWPk=
97 changes: 97 additions & 0 deletions transparency/boot_entry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// Copyright (c) The go-boot authors. All Rights Reserved.
//
// Use of this source code is governed by the license
// that can be found in the LICENSE file.

// Package transparency implements an interface to the
// boot-transparency library functions to ease boot bundle
// validation.
package transparency

import (
"fmt"

"github.com/usbarmory/boot-transparency/policy"
"github.com/usbarmory/boot-transparency/transparency"
)

// Validate applies boot-transparency validation (e.g. inclusion proof,
// boot policy and claims consistency) for the argument [Config] representing
// the boot transparency configuration.
// Returns error if the boot artifacts are not passing the validation.
func Validate(c *Config, b *policy.BootEntry) (err error) {
if c.Status == None {
return
}

if len(*b) == 0 {
return fmt.Errorf("invalid boot entry")
}

// Automatically load the configuration from the configured root filesystem.
if c.Root != nil {
entryPath, err := c.Path(b)
if err != nil {
return fmt.Errorf("cannot load boot-transparency configuration, %v", err)
}

if err = c.loadFromRoot(entryPath); err != nil {
return fmt.Errorf("cannot load boot-transparency configuration, %v", err)
}
}

te, err := transparency.GetEngine(c.Engine)
if err != nil {
return fmt.Errorf("unable to get transparency engine, %v", err)
}

if err = te.SetKey(c.LogKey, c.SubmitKey); err != nil {
return fmt.Errorf("unable to set log and submitter keys, %v", err)
}

if err = te.SetWitnessPolicy(c.WitnessPolicy); err != nil {
return fmt.Errorf("unable to set witness policy, %v", err)
}

format, statement, proof, probe, _, err := transparency.ParseProofBundle(c.ProofBundle)
if err != nil {
return fmt.Errorf("unable to parse the proof bundle, %v", err)
}

if format != c.Engine {
return fmt.Errorf("proof bundle format doesn't match the transparency engine.")
}

// If network access is available the inclusion proof verification
// is performed using the proof fetched from the log.
if c.Status == Online {
proof, err = te.GetProof(statement, probe)
if err != nil {
return err
}
}

if err = te.VerifyProof(statement, proof, nil); err != nil {
return err
}

requirements, err := policy.ParseRequirements(c.BootPolicy)
if err != nil {
return
}

claims, err := policy.ParseStatement(statement)
if err != nil {
return
}

// Validate the matching between the logged claims and the policy requirements,
// fot the given set of boot artifacts.
if err = policy.Validate(requirements, claims, b); err != nil {
// The boot bundle is NOT authorized.
return
}

// boot-transparency validation passed, boot bundle is authorized.
return
}
Loading