diff --git a/crypto/data_formats.go b/crypto/data_formats.go index c76f7c76e4..4c98d82073 100644 --- a/crypto/data_formats.go +++ b/crypto/data_formats.go @@ -24,7 +24,6 @@ import ( ) // This file contains struct specific mappings and data structures. -// TODO(gdbelvin): remove data-structure specific operations. // Constants used as map keys when building input for ObjectHash. They must not be changed // as this will change the output of hashRoot() diff --git a/trillian.pb.go b/trillian.pb.go index c350ec15ae..2c4c01798d 100644 --- a/trillian.pb.go +++ b/trillian.pb.go @@ -17,6 +17,52 @@ var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +// LogRootFormat specifies the fields that are covered by the +// SignedLogRoot signature, as well as their ordering and formats. +type LogRootFormat int32 + +const ( + LogRootFormat_LOG_ROOT_FORMAT_UNKNOWN LogRootFormat = 0 + LogRootFormat_LOG_ROOT_FORMAT_V1 LogRootFormat = 1 +) + +var LogRootFormat_name = map[int32]string{ + 0: "LOG_ROOT_FORMAT_UNKNOWN", + 1: "LOG_ROOT_FORMAT_V1", +} +var LogRootFormat_value = map[string]int32{ + "LOG_ROOT_FORMAT_UNKNOWN": 0, + "LOG_ROOT_FORMAT_V1": 1, +} + +func (x LogRootFormat) String() string { + return proto.EnumName(LogRootFormat_name, int32(x)) +} +func (LogRootFormat) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } + +// MapRootFormat specifies the fields that are covered by the +// SignedMapRoot signature, as well as their ordering and formats. +type MapRootFormat int32 + +const ( + MapRootFormat_MAP_ROOT_FORMAT_UNKNOWN MapRootFormat = 0 + MapRootFormat_MAP_ROOT_FORMAT_V1 MapRootFormat = 1 +) + +var MapRootFormat_name = map[int32]string{ + 0: "MAP_ROOT_FORMAT_UNKNOWN", + 1: "MAP_ROOT_FORMAT_V1", +} +var MapRootFormat_value = map[string]int32{ + "MAP_ROOT_FORMAT_UNKNOWN": 0, + "MAP_ROOT_FORMAT_V1": 1, +} + +func (x MapRootFormat) String() string { + return proto.EnumName(MapRootFormat_name, int32(x)) +} +func (MapRootFormat) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } + // Defines the way empty / node / leaf hashes are constructed incorporating // preimage protection, which can be application specific. type HashStrategy int32 @@ -57,7 +103,7 @@ var HashStrategy_value = map[string]int32{ func (x HashStrategy) String() string { return proto.EnumName(HashStrategy_name, int32(x)) } -func (HashStrategy) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{0} } +func (HashStrategy) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{2} } // State of the tree. type TreeState int32 @@ -102,7 +148,7 @@ var TreeState_value = map[string]int32{ func (x TreeState) String() string { return proto.EnumName(TreeState_name, int32(x)) } -func (TreeState) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{1} } +func (TreeState) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{3} } // Type of the tree. type TreeType int32 @@ -137,7 +183,7 @@ var TreeType_value = map[string]int32{ func (x TreeType) String() string { return proto.EnumName(TreeType_name, int32(x)) } -func (TreeType) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{2} } +func (TreeType) EnumDescriptor() ([]byte, []int) { return fileDescriptor3, []int{4} } // Represents a tree, which may be either a verifiable log or map. // Readonly attributes are assigned at tree creation, after which they may not @@ -480,6 +526,8 @@ func init() { proto.RegisterType((*SignedEntryTimestamp)(nil), "trillian.SignedEntryTimestamp") proto.RegisterType((*SignedLogRoot)(nil), "trillian.SignedLogRoot") proto.RegisterType((*SignedMapRoot)(nil), "trillian.SignedMapRoot") + proto.RegisterEnum("trillian.LogRootFormat", LogRootFormat_name, LogRootFormat_value) + proto.RegisterEnum("trillian.MapRootFormat", MapRootFormat_name, MapRootFormat_value) proto.RegisterEnum("trillian.HashStrategy", HashStrategy_name, HashStrategy_value) proto.RegisterEnum("trillian.TreeState", TreeState_name, TreeState_value) proto.RegisterEnum("trillian.TreeType", TreeType_name, TreeType_value) @@ -488,68 +536,72 @@ func init() { func init() { proto.RegisterFile("trillian.proto", fileDescriptor3) } var fileDescriptor3 = []byte{ - // 1008 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5d, 0x6f, 0xe2, 0x46, - 0x17, 0x5e, 0x03, 0x01, 0x73, 0x20, 0xc4, 0x99, 0x7c, 0xac, 0xc3, 0x2b, 0xbd, 0x4b, 0xd3, 0x4a, - 0x4d, 0x73, 0x41, 0xb6, 0xb4, 0x89, 0x54, 0xed, 0x45, 0xe5, 0x04, 0x27, 0x40, 0x12, 0x40, 0x63, - 0xb7, 0xd5, 0xe6, 0xc6, 0x1a, 0xf0, 0xd4, 0x58, 0x6b, 0x63, 0xcb, 0x1e, 0x56, 0xeb, 0xbd, 0xee, - 0x4d, 0xd5, 0xfe, 0xcc, 0xfe, 0x8d, 0x4a, 0xd5, 0x8c, 0x3f, 0x42, 0x92, 0x76, 0x77, 0x55, 0xf5, - 0x26, 0x99, 0xf3, 0x9c, 0xe7, 0x39, 0x73, 0x8e, 0xe7, 0x9c, 0x19, 0xa0, 0xc5, 0x22, 0xd7, 0xf3, - 0x5c, 0xb2, 0xec, 0x86, 0x51, 0xc0, 0x02, 0x24, 0xe7, 0x76, 0xbb, 0x3d, 0x8f, 0x92, 0x90, 0x05, - 0x27, 0x6f, 0x68, 0x12, 0x87, 0xb3, 0xec, 0x5f, 0xca, 0x6a, 0xab, 0x99, 0x2f, 0x76, 0x9d, 0x70, - 0x96, 0xfe, 0xcd, 0x3c, 0x07, 0x4e, 0x10, 0x38, 0x1e, 0x3d, 0x11, 0xd6, 0x6c, 0xf5, 0xf3, 0x09, - 0x59, 0x26, 0x99, 0xeb, 0xff, 0x8f, 0x5d, 0xf6, 0x2a, 0x22, 0xcc, 0x0d, 0xb2, 0xad, 0xdb, 0x2f, - 0x1e, 0xfb, 0x99, 0xeb, 0xd3, 0x98, 0x11, 0x3f, 0x4c, 0x09, 0x87, 0xbf, 0xd6, 0xa0, 0x62, 0x46, - 0x94, 0x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42, 0x13, 0xe4, 0x3e, 0xd6, 0x86, 0xe3, 0xe1, - 0xf8, 0x4a, 0xd9, 0x38, 0xbe, 0x02, 0x39, 0x7f, 0xa5, 0x78, 0xc2, 0x0f, 0x72, 0x31, 0x5f, 0x4f, - 0x79, 0x2a, 0x35, 0x28, 0xdf, 0x4c, 0xae, 0x14, 0x89, 0x2f, 0x6e, 0xb5, 0xa9, 0x52, 0xe2, 0x5f, - 0x67, 0x8a, 0xf5, 0x09, 0xee, 0xeb, 0x58, 0xef, 0x5b, 0xdc, 0x59, 0x3e, 0x1f, 0xc0, 0xc1, 0x3c, - 0xf0, 0xf3, 0x83, 0x78, 0xf8, 0xc3, 0xe0, 0x7c, 0xd3, 0xcc, 0xec, 0x29, 0x37, 0xa7, 0xd2, 0x5d, - 0xdb, 0x71, 0xd9, 0x62, 0x35, 0xeb, 0xce, 0x03, 0xff, 0x24, 0x7b, 0xb9, 0x73, 0xc9, 0xac, 0x2a, - 0x34, 0xdf, 0xfc, 0x15, 0x00, 0x00, 0xff, 0xff, 0x35, 0xfc, 0xf8, 0x8e, 0x5e, 0x08, 0x00, 0x00, + // 1057 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x5b, 0x6f, 0xe2, 0xc6, + 0x17, 0x8f, 0x81, 0x80, 0x39, 0x5c, 0xe2, 0x4c, 0x6e, 0x0e, 0x2b, 0xfd, 0x97, 0x7f, 0x5a, 0xa9, + 0x69, 0x1e, 0xc8, 0x2e, 0x6d, 0x22, 0x55, 0xfb, 0x50, 0x39, 0xc1, 0x09, 0x90, 0x04, 0xd0, 0xd8, + 0xdd, 0x6a, 0xf3, 0x62, 0x0d, 0x78, 0x6a, 0xac, 0xc5, 0xd8, 0xb2, 0x87, 0xd5, 0x7a, 0x9f, 0xfb, + 0x52, 0xb5, 0x1f, 0xb3, 0x5f, 0xa3, 0x52, 0x35, 0x63, 0x9b, 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 0xe2, 0x8b, 0x3b, 0x6d, 0xa4, 0xe4, 0xf8, + 0xd3, 0x19, 0x61, 0x7d, 0x88, 0x3b, 0x3a, 0xd6, 0x3b, 0x16, 0x07, 0xf3, 0x17, 0x5d, 0x38, 0x9c, + 0xf8, 0x5e, 0x36, 0x14, 0x8f, 0x3f, 0x52, 0x2e, 0x6a, 0x66, 0x1a, 0x8f, 0x78, 0x38, 0x92, 0xee, + 0x1b, 0x8e, 0xcb, 0xa6, 0x8b, 0x71, 0x6b, 0xe2, 0x7b, 0xa7, 0xe9, 0x57, 0x44, 0x26, 0x19, 0x17, + 0x85, 0xe6, 0xbb, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x3e, 0xa3, 0xc0, 0x2c, 0xea, 0x08, 0x00, + 0x00, } diff --git a/trillian.proto b/trillian.proto index 8dbc873421..c897cf423a 100644 --- a/trillian.proto +++ b/trillian.proto @@ -27,6 +27,22 @@ import "google/protobuf/any.proto"; import "google/protobuf/duration.proto"; import "google/protobuf/timestamp.proto"; + +// LogRootFormat specifies the fields that are covered by the +// SignedLogRoot signature, as well as their ordering and formats. +enum LogRootFormat { + LOG_ROOT_FORMAT_UNKNOWN = 0; + LOG_ROOT_FORMAT_V1 = 1; +} + +// MapRootFormat specifies the fields that are covered by the +// SignedMapRoot signature, as well as their ordering and formats. +enum MapRootFormat { + MAP_ROOT_FORMAT_UNKNOWN = 0; + MAP_ROOT_FORMAT_V1 = 1; +} + + // What goes in here? // Things which are exposed through the public trillian APIs. diff --git a/types/logroot.go b/types/logroot.go new file mode 100644 index 0000000000..f92112e7c3 --- /dev/null +++ b/types/logroot.go @@ -0,0 +1,87 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package types defines serialization and parsing functions for SignedLogRoot +// and SignedMapRoot fields. +package types + +import ( + "encoding/binary" + "fmt" + + "github.com/google/certificate-transparency-go/tls" + + "github.com/google/trillian" +) + +// LogRootV1 holds the TLS-deserialization of the following structure +// (described in RFC5246 section 4 notation): +// struct { +// uint64 tree_size; +// opaque root_hash<0..128>; +// uint64 timestamp_nanos; +// uint64 revision; +// opaque metadata<0..65535>; +// } LogRootV1; +type LogRootV1 struct { + TreeSize uint64 + RootHash []byte `tls:"minlen:0,maxlen:128"` + TimestampNanos uint64 + Revision uint64 + Metadata []byte `tls:"minlen:0,maxlen:65535"` +} + +// LogRoot holds the TLS-deserialization of the following structure +// (described in RFC5246 section 4 notation): +// enum { v1(1), (65535)} Version; +// struct { +// Version version; +// select(version) { +// case v1: LogRootV1; +// } +// } LogRoot; +type LogRoot struct { + Version tls.Enum `tls:"size:2"` + V1 *LogRootV1 `tls:"selector:Version,val:1"` +} + +// UnmarshalBinary verifies that logRootBytes is a TLS serialized LogRoot, has +// the LOG_ROOT_FORMAT_V1 tag, and populates the caller with the deserialized +// *LogRootV1. +func (l *LogRootV1) UnmarshalBinary(logRootBytes []byte) error { + if logRootBytes == nil { + return fmt.Errorf("nil log root") + } + version := binary.BigEndian.Uint16(logRootBytes) + if version != uint16(trillian.LogRootFormat_LOG_ROOT_FORMAT_V1) { + return fmt.Errorf("invalid LogRoot.Version: %v, want %v", + version, trillian.LogRootFormat_LOG_ROOT_FORMAT_V1) + } + + var logRoot LogRoot + if _, err := tls.Unmarshal(logRootBytes, &logRoot); err != nil { + return err + } + + *l = *logRoot.V1 + return nil +} + +// MarshalBinary returns a canonical TLS serialization of LogRoot. +func (l *LogRootV1) MarshalBinary() ([]byte, error) { + return tls.Marshal(LogRoot{ + Version: tls.Enum(trillian.LogRootFormat_LOG_ROOT_FORMAT_V1), + V1: l, + }) +} diff --git a/types/logroot_test.go b/types/logroot_test.go new file mode 100644 index 0000000000..1d9d9e0960 --- /dev/null +++ b/types/logroot_test.go @@ -0,0 +1,86 @@ +// Copyright 2017 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding" + "reflect" + "testing" +) + +func TestLogRoot(t *testing.T) { + for _, logRoot := range []interface { + encoding.BinaryMarshaler + encoding.BinaryUnmarshaler + }{ + &LogRootV1{ + RootHash: []byte("foo"), + Metadata: []byte{}, + }, + } { + b, err := logRoot.MarshalBinary() + if err != nil { + t.Errorf("%v MarshalBinary(): %v", logRoot, err) + continue + } + var got LogRootV1 + if err := got.UnmarshalBinary(b); err != nil { + t.Errorf("UnmarshalBinary(): %v", err) + continue + } + if !reflect.DeepEqual(&got, logRoot) { + t.Errorf("serialize/parse round trip failed. got %#v, want %#v", got, logRoot) + } + } +} + +func TestUnmarshalLogRoot(t *testing.T) { + for _, tc := range []struct { + logRoot []byte + wantErr bool + }{ + {logRoot: MustMarshalLogRoot(&LogRootV1{})}, + { + logRoot: func() []byte { + b := MustMarshalLogRoot(&LogRootV1{}) + b[0] = 1 // Corrupt the version tag. + return b + }(), + wantErr: true, + }, + { + // Correct type, but junk afterwards. + logRoot: []byte{0, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, + wantErr: true, + }, + {logRoot: []byte("foo"), wantErr: true}, + {logRoot: nil, wantErr: true}, + } { + + var got LogRootV1 + err := got.UnmarshalBinary(tc.logRoot) + if got, want := err != nil, tc.wantErr; got != want { + t.Errorf("UnmarshalBinary(): %v, wantErr %v", err, want) + } + } +} + +func MustMarshalLogRoot(root *LogRootV1) []byte { + b, err := root.MarshalBinary() + if err != nil { + panic(err) + } + return b +} diff --git a/types/maproot.go b/types/maproot.go new file mode 100644 index 0000000000..af09b078d4 --- /dev/null +++ b/types/maproot.go @@ -0,0 +1,80 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding/binary" + "fmt" + + "github.com/google/certificate-transparency-go/tls" + "github.com/google/trillian" +) + +// MapRootV1 holds the TLS-deserialization of the following structure +// (described in RFC5246 section 4 notation): +// struct { +// opaque root_hash<0..128>; +// uint64 timestamp_nanos; +// uint64 revision; +// opaque metadata<0..65535>; +// } MapRootV1; +type MapRootV1 struct { + RootHash []byte `tls:"minlen:0,maxlen:128"` + TimestampNanos uint64 + Revision uint64 + Metadata []byte `tls:"minlen:0,maxlen:65535"` +} + +// MapRoot holds the TLS-deserialization of the following structure +// (described in RFC5246 section 4 notation): +// enum { v1(1), (65535)} Version; +// struct { +// Version version; +// select(version) { +// case v1: MapRootV1; +// } +// } MapRoot; +type MapRoot struct { + Version tls.Enum `tls:"size:2"` + V1 *MapRootV1 `tls:"selector:Version,val:1"` +} + +// UnmarshalBinary verifies that mapRootBytes is a TLS serialized MapRoot, +// has the MAP_ROOT_FORMAT_V1 tag, and returns the deserialized *MapRootV1. +func (m *MapRootV1) UnmarshalBinary(mapRootBytes []byte) error { + if mapRootBytes == nil { + return fmt.Errorf("nil map root") + } + version := binary.BigEndian.Uint16(mapRootBytes) + if version != uint16(trillian.MapRootFormat_MAP_ROOT_FORMAT_V1) { + return fmt.Errorf("invalid MapRoot.Version: %v, want %v", + version, trillian.MapRootFormat_MAP_ROOT_FORMAT_V1) + } + + var mapRoot MapRoot + if _, err := tls.Unmarshal(mapRootBytes, &mapRoot); err != nil { + return err + } + *m = *mapRoot.V1 + return nil +} + +// MarshalBinary returns a canonical TLS serialization of the map root. +func (m *MapRootV1) MarshalBinary() ([]byte, error) { + return tls.Marshal(MapRoot{ + Version: tls.Enum(trillian.MapRootFormat_MAP_ROOT_FORMAT_V1), + V1: m, + }) +} diff --git a/types/maproot_test.go b/types/maproot_test.go new file mode 100644 index 0000000000..5f67ad894a --- /dev/null +++ b/types/maproot_test.go @@ -0,0 +1,89 @@ +// Copyright 2018 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package types + +import ( + "encoding" + "reflect" + "testing" + + _ "github.com/golang/glog" // Don't crash when --logtostderr is supplied +) + +func TestMapRoot(t *testing.T) { + for _, mapRoot := range []interface { + encoding.BinaryMarshaler + encoding.BinaryUnmarshaler + }{ + &MapRootV1{ + RootHash: []byte("foo"), + Metadata: []byte{}, + }, + } { + b, err := mapRoot.MarshalBinary() + if err != nil { + t.Errorf("%v MarshalBinary(): %v", mapRoot, err) + } + var got MapRootV1 + if err := got.UnmarshalBinary(b); err != nil { + t.Errorf("UnmarshalBinary(): %v", err) + } + if !reflect.DeepEqual(&got, mapRoot) { + t.Errorf("serialize/parse round trip failed. got %#v, want %#v", got, mapRoot) + } + } +} + +func MustMarshalMapRoot(root *MapRootV1) []byte { + b, err := root.MarshalBinary() + if err != nil { + panic(err) + } + return b +} + +func TestUnmarshalMapRoot(t *testing.T) { + for _, tc := range []struct { + mapRoot []byte + want MapRootV1 + wantErr bool + }{ + { + mapRoot: MustMarshalMapRoot(&MapRootV1{ + RootHash: []byte("aaa"), + }), + want: MapRootV1{ + RootHash: []byte("aaa"), + Metadata: []byte{}, + }, + }, + { + // Correct type, but junk afterwards. + mapRoot: []byte{0, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, + wantErr: true, + }, + {mapRoot: []byte("foo"), wantErr: true}, + {mapRoot: nil, wantErr: true}, + } { + var r MapRootV1 + err := r.UnmarshalBinary(tc.mapRoot) + if got, want := err != nil, tc.wantErr; got != want { + t.Errorf("UnmarshalBinary(): %v, wantErr: %v", err, want) + } + if got, want := r, tc.want; !reflect.DeepEqual(got, want) { + t.Errorf("UnmarshalBinary(): \n%#v, want: \n%#v", got, want) + } + } +}