-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The show-pubkey command outputs the vendor signing pubkey, the app tag, and app hash digest to stdout. The output is in the format used for a line in the vendor-signing-pubkey.txt file, and used to embed another vendor signing key. The command takes takes an argument with the path to the devie app using --app path/to/app.bin
- Loading branch information
1 parent
afab1a7
commit a38666d
Showing
2 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package main | ||
|
||
import ( | ||
"crypto/sha512" | ||
"encoding/hex" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/tillitis/tkey-verification/internal/tkey" | ||
) | ||
|
||
func showPubkey(binPath string, devPath string, verbose bool) { | ||
tk, err := tkey.NewTKey(devPath, verbose) | ||
if err != nil { | ||
le.Printf("Couldn't connect to TKey: %v\n", err) | ||
os.Exit(1) | ||
} | ||
|
||
exit := func(code int) { | ||
tk.Close() | ||
os.Exit(code) | ||
} | ||
|
||
content, err := os.ReadFile(binPath) | ||
if err != nil { | ||
le.Printf("ReadFile: %v", err) | ||
exit(1) | ||
} | ||
|
||
appHash := sha512.Sum512(content) | ||
|
||
pubKey, err := tk.LoadSigner(content) | ||
if err != nil { | ||
le.Printf("LoadSigner: %v\n", err) | ||
exit(1) | ||
} | ||
|
||
tag := strings.TrimSuffix(filepath.Base(binPath), ".bin") | ||
|
||
le.Printf("Public Key, app tag, and app hash for vendor-signing-pubkeys.txt follows on stdout:\n") | ||
fmt.Printf("%s %s %s\n", hex.EncodeToString(pubKey), tag, hex.EncodeToString(appHash[:])) | ||
|
||
exit(0) | ||
} |