diff options
-rw-r--r-- | handler.go | 6 | ||||
-rw-r--r-- | instance.go | 2 | ||||
-rw-r--r-- | reqres.go | 4 | ||||
-rw-r--r-- | server/main.go | 2 | ||||
-rw-r--r-- | type.go | 48 | ||||
-rw-r--r-- | x509.go | 6 |
6 files changed, 33 insertions, 35 deletions
@@ -180,8 +180,8 @@ func getConsistencyProof(ctx context.Context, i *Instance, w http.ResponseWriter } // request can be decoded and is valid trillianRequest := trillian.GetConsistencyProofRequest{ - LogId: i.LogParameters.TreeId, - FirstTreeSize: int64(request.First), + LogId: i.LogParameters.TreeId, + FirstTreeSize: int64(request.First), SecondTreeSize: int64(request.Second), } trillianResponse, err := i.Client.GetConsistencyProof(ctx, &trillianRequest) @@ -220,7 +220,7 @@ func getSth(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Req return http.StatusInternalServerError, fmt.Errorf("failed unmarshaling tree head: %v", err) } - th := NewTreeHeadV1(uint64(lr.TimestampNanos / 1000 / 1000), uint64(lr.TreeSize), lr.RootHash) + th := NewTreeHeadV1(uint64(lr.TimestampNanos/1000/1000), uint64(lr.TreeSize), lr.RootHash) sth, err := GenV1STH(i.LogParameters, th) if err != nil { return http.StatusInternalServerError, fmt.Errorf("failed creating signed tree head: %v", err) diff --git a/instance.go b/instance.go index 8914a4b..46fcaa9 100644 --- a/instance.go +++ b/instance.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "crypto/x509" "crypto/sha256" + "crypto/x509" "encoding/base64" "net/http" @@ -36,7 +36,7 @@ type GetProofByHashRequest struct { // GetConsistencyProofRequest is a collection of get-consistency-proof input // parameters type GetConsistencyProofRequest struct { - First int64 `json:"first"` + First int64 `json:"first"` Second int64 `json:"second"` } @@ -156,7 +156,7 @@ func NewGetConsistencyProofRequest(httpRequest *http.Request) (GetConsistencyPro return GetConsistencyProofRequest{}, fmt.Errorf("bad parameters: second(%v) must be larger than first(%v)", first, second) } - return GetConsistencyProofRequest{ First: first, Second: second}, nil + return GetConsistencyProofRequest{First: first, Second: second}, nil } // NewAddEntryResponse assembles an add-entry response from an SDI diff --git a/server/main.go b/server/main.go index 924cfc9..f5403d4 100644 --- a/server/main.go +++ b/server/main.go @@ -20,7 +20,7 @@ var ( trillianID = flag.Int64("trillian_id", 5991359069696313945, "log identifier in the Trillian database") rpcDeadline = flag.Duration("rpc_deadline", time.Second*10, "deadline for backend RPC requests") anchorPath = flag.String("anchor_path", "testdata/chain/rgdd-root.pem", "path to a file containing PEM-encoded X.509 root certificates") - keyPath = flag.String("key_path", "testdata/chain/stfe.key", "path to a PEM-encoded ed25519 signing key") + keyPath = flag.String("key_path", "testdata/chain/stfe.key", "path to a PEM-encoded ed25519 signing key") ) func main() { @@ -25,32 +25,32 @@ const ( // StItem references a versioned item based on a given format specifier. type StItem struct { - Format StFormat `tls:"maxval:65535"` - SignedTreeHeadV1 *SignedTreeHeadV1 `tls:"selector:Format,val:1"` - SignedDebugInfoV1 *SignedDebugInfoV1 `tls:"selector:Format,val:2"` + Format StFormat `tls:"maxval:65535"` + SignedTreeHeadV1 *SignedTreeHeadV1 `tls:"selector:Format,val:1"` + SignedDebugInfoV1 *SignedDebugInfoV1 `tls:"selector:Format,val:2"` ConsistencyProofV1 *ConsistencyProofV1 `tls:"selector:Format,val:3"` - InclusionProofV1 *InclusionProofV1 `tls:"selector:Format,val:4"` - ChecksumV1 *ChecksumV1 `tls:"selector:Format,val:5"` + InclusionProofV1 *InclusionProofV1 `tls:"selector:Format,val:4"` + ChecksumV1 *ChecksumV1 `tls:"selector:Format,val:5"` } type ConsistencyProofV1 struct { - LogId []byte `tls:"minlen:2,maxlen:127"` - TreeSize1 uint64 - TreeSize2 uint64 + LogId []byte `tls:"minlen:2,maxlen:127"` + TreeSize1 uint64 + TreeSize2 uint64 ConsistencyPath []NodeHash `tls:"minlen:1,maxlen:65535"` } type SignedTreeHeadV1 struct { - LogId []byte `tls:"minlen:2,maxlen:127"` - TreeHead TreeHeadV1 `tls:minlen:0, maxlen:65535` // what should maxlen be? - Signature []byte `tls:"minlen:0,maxlen:65535"` + LogId []byte `tls:"minlen:2,maxlen:127"` + TreeHead TreeHeadV1 `tls:minlen:0, maxlen:65535` // what should maxlen be? + Signature []byte `tls:"minlen:0,maxlen:65535"` } type TreeHeadV1 struct { Timestamp uint64 - TreeSize uint64 - RootHash NodeHash `tls:minlen:32,maxlen:255` - Extension []byte `tls:"minlen:0,maxlen:65535"` + TreeSize uint64 + RootHash NodeHash `tls:minlen:32,maxlen:255` + Extension []byte `tls:"minlen:0,maxlen:65535"` } // ChecksumV1 associates a package name with an arbitrary checksum value @@ -72,8 +72,8 @@ type InclusionProofV1 struct { // TODO: double-check that crypto/ed25519 encodes signature as in RFC 8032 // TODO: need to think about signature format, then update markdown/api.md type SignedDebugInfoV1 struct { - LogId []byte `tls:"minlen:32,maxlen:127"` - Message []byte `tls:"minlen:0,maxlen:65535"` + LogId []byte `tls:"minlen:32,maxlen:127"` + Message []byte `tls:"minlen:0,maxlen:65535"` Signature []byte `tls:"minlen:0,maxlen:65535"` // defined in RFC 8032 } @@ -86,8 +86,8 @@ func NewSignedTreeHeadV1(th TreeHeadV1, logId, signature []byte) StItem { return StItem{ Format: StFormatSignedTreeHeadV1, SignedTreeHeadV1: &SignedTreeHeadV1{ - LogId: logId, - TreeHead: th, + LogId: logId, + TreeHead: th, Signature: signature, }, } @@ -96,7 +96,7 @@ func NewSignedTreeHeadV1(th TreeHeadV1, logId, signature []byte) StItem { func NewTreeHeadV1(timestamp, treeSize uint64, rootHash []byte) TreeHeadV1 { return TreeHeadV1{ Timestamp: timestamp, - TreeSize: treeSize, + TreeSize: treeSize, RootHash: NodeHash{ Data: rootHash, }, @@ -108,8 +108,8 @@ func NewSignedDebugInfoV1(logId, message, signature []byte) StItem { return StItem{ Format: StFormatSignedDebugInfoV1, SignedDebugInfoV1: &SignedDebugInfoV1{ - LogId: logId, - Message: message, + LogId: logId, + Message: message, Signature: signature, }, } @@ -153,9 +153,9 @@ func NewConsistencyProofV1(logId []byte, first, second int64, proof *trillian.Pr return StItem{ Format: StFormatConsistencyProofV1, ConsistencyProofV1: &ConsistencyProofV1{ - LogId: logId, - TreeSize1: uint64(first), - TreeSize2: uint64(second), + LogId: logId, + TreeSize1: uint64(first), + TreeSize2: uint64(second), ConsistencyPath: path, }, } @@ -4,9 +4,9 @@ import ( "fmt" "crypto" - "crypto/rand" - "crypto/ed25519" "crypto/ecdsa" + "crypto/ed25519" + "crypto/rand" "crypto/rsa" "crypto/x509" "encoding/pem" @@ -49,7 +49,6 @@ func LoadTrustAnchors(path string) ([]*x509.Certificate, *x509.CertPool, error) return anchors, pool, nil } - func LoadEd25519SigningKey(path string) (ed25519.PrivateKey, error) { data, err := ioutil.ReadFile(path) if err != nil { @@ -114,7 +113,6 @@ func VerifySignature(leaf, signature []byte, certificate *x509.Certificate) erro return nil } - func GenV1SDI(ld *LogParameters, leaf []byte) (StItem, error) { // Note that ed25519 does not use the passed io.Reader sig, err := ld.Signer.Sign(rand.Reader, leaf, crypto.Hash(0)) |