Skip to content

Commit

Permalink
Remove private_key from Tree, and key_spec from `CreateTreeRequ…
Browse files Browse the repository at this point in the history
…est`.

Part of #2450.
  • Loading branch information
pphaneuf committed Apr 21, 2021
1 parent b2b728e commit 455184a
Show file tree
Hide file tree
Showing 32 changed files with 146 additions and 1,311 deletions.
65 changes: 0 additions & 65 deletions cmd/createtree/keys/registry.go

This file was deleted.

31 changes: 6 additions & 25 deletions cmd/createtree/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
// automated scripts.
//
// Several flags are provided to configure the create tree, most of which try to
// assume reasonable defaults. Multiple types of private keys may be supported;
// one has only to set the appropriate --private_key_format value and supply the
// corresponding flags for the chosen key type.
// assume reasonable defaults.
package main

import (
Expand All @@ -40,8 +38,6 @@ import (
"github.com/google/trillian/client"
"github.com/google/trillian/client/rpcflags"
"github.com/google/trillian/cmd"
"github.com/google/trillian/cmd/createtree/keys"
"github.com/google/trillian/crypto/keyspb"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/durationpb"
)
Expand All @@ -50,12 +46,11 @@ var (
adminServerAddr = flag.String("admin_server", "", "Address of the gRPC Trillian Admin Server (host:port)")
rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "Deadline for RPC requests")

treeState = flag.String("tree_state", trillian.TreeState_ACTIVE.String(), "State of the new tree")
treeType = flag.String("tree_type", trillian.TreeType_LOG.String(), "Type of the new tree")
displayName = flag.String("display_name", "", "Display name of the new tree")
description = flag.String("description", "", "Description of the new tree")
maxRootDuration = flag.Duration("max_root_duration", time.Hour, "Interval after which a new signed root is produced despite no submissions; zero means never")
privateKeyFormat = flag.String("private_key_format", "", "Type of protobuf message to send the key as (PrivateKey, PEMKeyFile, or PKCS11ConfigFile). If empty, a key will be generated for you by Trillian.")
treeState = flag.String("tree_state", trillian.TreeState_ACTIVE.String(), "State of the new tree")
treeType = flag.String("tree_type", trillian.TreeType_LOG.String(), "Type of the new tree")
displayName = flag.String("display_name", "", "Display name of the new tree")
description = flag.String("description", "", "Description of the new tree")
maxRootDuration = flag.Duration("max_root_duration", time.Hour, "Interval after which a new signed root is produced despite no submissions; zero means never")

configFile = flag.String("config", "", "Config file containing flags, file contents can be overridden by command line flags")

Expand Down Expand Up @@ -110,20 +105,6 @@ func newRequest() (*trillian.CreateTreeRequest, error) {
}}
glog.Infof("Creating tree %+v", ctr.Tree)

if *privateKeyFormat != "" {
pk, err := keys.New(*privateKeyFormat)
if err != nil {
return nil, err
}
ctr.Tree.PrivateKey = pk
} else {
ctr.KeySpec = &keyspb.Specification{
Params: &keyspb.Specification_EcdsaParams{
EcdsaParams: &keyspb.Specification_ECDSA{},
},
}
}

return ctr, nil
}

Expand Down
17 changes: 0 additions & 17 deletions cmd/createtree/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/emptypb"
)

// defaultTree reflects all flag defaults with the addition of a valid private key.
var defaultTree = &trillian.Tree{
TreeState: trillian.TreeState_ACTIVE,
TreeType: trillian.TreeType_LOG,
PrivateKey: mustMarshalAny(&emptypb.Empty{}),
MaxRootDuration: durationpb.New(0 * time.Millisecond),
}

Expand All @@ -50,14 +47,6 @@ type testCase struct {
wantTree *trillian.Tree
}

func mustMarshalAny(p proto.Message) *anypb.Any {
anyKey, err := anypb.New(p)
if err != nil {
panic(err)
}
return anyKey
}

func TestCreateTree(t *testing.T) {
nonDefaultTree := proto.Clone(defaultTree).(*trillian.Tree)
nonDefaultTree.TreeType = trillian.TreeType_LOG
Expand Down Expand Up @@ -98,12 +87,6 @@ func TestCreateTree(t *testing.T) {
validateErr: errors.New("unknown TreeType"),
wantErr: true,
},
{
desc: "invalidKeyTypeOpts",
setFlags: func() { *privateKeyFormat = "LLAMA!!" },
validateErr: errors.New("key protobuf must be one of"),
wantErr: true,
},
{
desc: "createErr",
createErr: status.Errorf(codes.Unavailable, "create tree failed"),
Expand Down
69 changes: 0 additions & 69 deletions cmd/createtree/pem.go

This file was deleted.

119 changes: 0 additions & 119 deletions cmd/createtree/pem_test.go

This file was deleted.

Loading

0 comments on commit 455184a

Please sign in to comment.