-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This completes the offline flow: ```shell tuf payload root.json > /tmp/root.json.payload tuf sign-payload --role=root /tmp/root.json.payload > /tmp/root.json.sigs tuf add-signatures --signatures /tmp/root.json.sigs root.json ``` Additional changes: - rename `add-signature` to `add-signatures` - `add-signatures` expects JSON (from `sign-payload`) rather than hex bytes
- Loading branch information
Showing
5 changed files
with
106 additions
and
41 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
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,43 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/flynn/go-docopt" | ||
tuf "github.com/theupdateframework/go-tuf" | ||
tufdata "github.com/theupdateframework/go-tuf/data" | ||
) | ||
|
||
func init() { | ||
register("sign-payload", cmdSignPayload, ` | ||
usage: tuf sign-payload --role=<role> <path> | ||
Sign a file (not necessarily in the TUF repo) using keys for the given role. | ||
Typically, this will be the output of "tuf payload". | ||
`) | ||
} | ||
|
||
func cmdSignPayload(args *docopt.Args, repo *tuf.Repo) error { | ||
payload, err := os.ReadFile(args.String["<path>"]) | ||
if err != nil { | ||
return err | ||
} | ||
signed := tufdata.Signed{Signed: payload, Signatures: make([]tufdata.Signature, 0)} | ||
|
||
numKeys, err := repo.SignPayload(args.String["--role"], &signed) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
bytes, err := json.Marshal(signed.Signatures) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Print(string(bytes)) | ||
|
||
fmt.Fprintln(os.Stderr, "tuf: signed with", numKeys, "key(s)") | ||
return nil | ||
} |
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