Skip to content

Commit 29931c1

Browse files
committed
Remove port auto-detect on macos, getting rid of CGO
With CGO out of the way the make-release-builds.sh script can build binaries for all OSs & architectures reproducibly in a container. Also create a Macos univeral binary. Commit checksums of all tkey-verification binaries (of the next version that is expected to be released), which the script checks after building. Signed-off-by: Daniel Lublin <[email protected]>
1 parent 3c52912 commit 29931c1

File tree

16 files changed

+227
-73
lines changed

16 files changed

+227
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/gotools/golangci-lint
22
/gotools/certstrap
3+
/gotools/lipo
34
/show-pubkey
45
/tkey-verification

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ clean:
3333
.PHONY: lint
3434
lint:
3535
$(MAKE) -C gotools golangci-lint
36-
./gotools/golangci-lint run
36+
GOOS=linux ./gotools/golangci-lint run
37+
GOOS=windows ./gotools/golangci-lint run
38+
GOOS=darwin ./gotools/golangci-lint run
3739

3840
.PHONY: certs
3941
certs:

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,18 @@ produced by [Tillitis](https://tillitis.se/) (the vendor).
66

77
If you own a TKey and want make sure it's genuine you can follow
88
[these
9-
instructions](https://tillitis.se/app/tkey-device-verification/) (On
9+
instructions](https://tillitis.se/app/tkey-device-verification/) (on
1010
Tillitis' web). Or just download a release of the tool right away:
1111
https://github.com/tillitis/tkey-verification/releases
1212

13+
The published binaries can be reproduced by running
14+
`./make-release-builds.sh` with the wanted version (for example
15+
"0.0.2"). The [release-builds](release-builds) directory contains
16+
checksums of released versions (since we got reproducibility in
17+
place), which the script verifies after building. Running the script
18+
requires a rootless podman setup. On Ubuntu 22.10, running `apt
19+
install podman rootlesskit slirp4netns` should be enough.
20+
1321
## Terminology
1422

1523
- "device under verification": The device the vendor is provisioning
@@ -276,3 +284,25 @@ Example file content:
276284
"signature": "db4e7a72b720b33f6d4887df0f9dcdd6988ca8adb6b0042d8e8c92b5be3e4e39d908f166d093f3ab20880102d43a2b0c8e31178ab7cdb59977dcf7204116cc0c"
277285
}
278286
```
287+
288+
## Making releases of tkey-verification
289+
290+
Make the new release binaries for the expected version:
291+
292+
./make-release-builds 0.0.42
293+
294+
Generate and commit the new checksums:
295+
296+
./gen-release-checksums 0.0.42
297+
git add release-builds/*_0.0.42_*.sha512
298+
git commit -m "Release 0.0.42"
299+
300+
Then tag a new version and push it all:
301+
302+
git tag -a v0.0.42 -m v0.0.42
303+
git push origin main v0.0.42
304+
305+
Publish the new release at
306+
https://github.com/tillitis/tkey-verification/releases and upload the
307+
binaries and checksum files. For MacOS we'll provide only the
308+
universal binary.

build-appbin-in-container.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ cname="tkey-build"
5555

5656
podman run -it --name "$cname" \
5757
--mount type=bind,source="$(pwd)",target=/contrib \
58-
ghcr.io/tillitis/tkey-builder:1 \
58+
ghcr.io/tillitis/tkey-builder:2 \
5959
/bin/bash /contrib/containerbuild "$tag" "$appsrepotag"
6060

6161
podman cp "$cname":/tkey-verification/apps/verisigner/app.bin "$destd/$destf"

cmd/tkey-verification/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ Known firmwares:
8787
desc := fmt.Sprintf(`Usage: %s command [flags...]
8888
8989
Commands:
90-
serve-signer TODO write...
90+
serve-signer Run the server that offers an API for creating vendor signatures.
9191
92-
remote-sign TODO write...
92+
remote-sign Call the remote signing server to sign for a local TKey.
9393
9494
verify Verify that a TKey is genuine by extracting the TKey UDI and using it
9595
to fetch the verification data, including tag and signature from the

cmd/tkey-verification/verify.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func verify(devPath string, verbose bool, showURLOnly bool, baseDir string, veri
128128
func verificationFromURL(verifyURL string) (Verification, error) {
129129
var verification Verification
130130

131-
le.Printf("Fetching %s ...\n", verifyURL)
131+
le.Printf("Fetching verification data from %s ...\n", verifyURL)
132132
client := http.Client{Timeout: 10 * time.Second}
133133
resp, err := client.Get(verifyURL) // #nosec G107
134134
if err != nil {
@@ -155,7 +155,7 @@ func verificationFromURL(verifyURL string) (Verification, error) {
155155
func verificationFromFile(fn string) (Verification, error) {
156156
var verification Verification
157157

158-
le.Printf("Reading %s ...\n", fn)
158+
le.Printf("Reading verification data from file %s ...\n", fn)
159159
verificationJSON, err := os.ReadFile(fn)
160160
if err != nil {
161161
return verification, fmt.Errorf("ReadFile failed: %w", err)

gen-release-checksums

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh -e
2+
3+
if ! hash 2>/dev/null sha512sum; then
4+
sha512sum() {
5+
shasum -a 512 "$@"
6+
}
7+
fi
8+
9+
version="$1"
10+
if [ -z "$version" ]; then
11+
printf "give me a version number\n"
12+
exit 1
13+
fi
14+
shift
15+
16+
cd release-builds
17+
18+
any=
19+
for file in *_"$version"_*; do
20+
[ -e "$file" ] || continue
21+
[ "${file##*.}" != "sha512" ] || continue
22+
hashf="$file.sha512"
23+
if [ -e "$hashf" ]; then
24+
printf "%s already exists, bailing out\n" "$hashf"
25+
exit 1
26+
fi
27+
sha512sum >"$hashf" "$file"
28+
printf "wrote %s\n" "$hashf"
29+
any=any
30+
done
31+
32+
if [ -z "$any" ]; then
33+
printf "no binaries in release-builds/ with that version?\n"
34+
fi

gotools/Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ certstrap:
1515
go mod download github.com/square/certstrap
1616
go mod tidy
1717
go build github.com/square/certstrap
18+
19+
# .PHONY to let go-build handle deps and rebuilds
20+
.PHONY: lipo
21+
lipo:
22+
go mod download github.com/konoui/lipo
23+
go mod tidy
24+
go build github.com/konoui/lipo

gotools/go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.19
44

55
require (
66
github.com/golangci/golangci-lint v1.51.0
7+
github.com/konoui/lipo v0.4.1
78
github.com/square/certstrap v1.3.0
89
)
910

@@ -87,6 +88,7 @@ require (
8788
github.com/kisielk/errcheck v1.6.3 // indirect
8889
github.com/kisielk/gotool v1.0.0 // indirect
8990
github.com/kkHAIKE/contextcheck v1.1.3 // indirect
91+
github.com/konoui/go-qsort v0.0.1 // indirect
9092
github.com/kulti/thelper v0.6.3 // indirect
9193
github.com/kunwardeep/paralleltest v1.0.6 // indirect
9294
github.com/kyoh86/exportloopref v0.1.11 // indirect

gotools/go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
330330
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
331331
github.com/kkHAIKE/contextcheck v1.1.3 h1:l4pNvrb8JSwRd51ojtcOxOeHJzHek+MtOyXbaR0uvmw=
332332
github.com/kkHAIKE/contextcheck v1.1.3/go.mod h1:PG/cwd6c0705/LM0KTr1acO2gORUxkSVWyLJOFW5qoo=
333+
github.com/konoui/go-qsort v0.0.1 h1:7scLI7DAKynqS6enK0vnpwoiw7L38pBI49ofIahb9rc=
334+
github.com/konoui/go-qsort v0.0.1/go.mod h1:UOsvdDPBzyQDk9Tb21hETK6KYXGYQTnoZB5qeKA1ARs=
335+
github.com/konoui/lipo v0.4.1 h1:DbaBYvafcdXx2DMlmMtwVugO8GywlFgywR7qZGMxP1E=
336+
github.com/konoui/lipo v0.4.1/go.mod h1:PpyG5pH3dW3h7QSsAu69JZIBZ4V5e9fg/H67azfQ1f8=
333337
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
334338
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
335339
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=

0 commit comments

Comments
 (0)