aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-28 14:56:38 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-10-28 14:56:38 +0100
commitffe6e49220648a0b847e47e1072cf0b8d1b1f803 (patch)
tree52949a55f3d8b1ad1f214aa6e408c194ecf1eaba
parentcaca215c9516e8dc236a8510a6a5467c267d2331 (diff)
go fmt
-rw-r--r--handler.go6
-rw-r--r--instance.go2
-rw-r--r--reqres.go4
-rw-r--r--server/main.go2
-rw-r--r--type.go48
-rw-r--r--x509.go6
6 files changed, 33 insertions, 35 deletions
diff --git a/handler.go b/handler.go
index 119f65c..8f36e50 100644
--- a/handler.go
+++ b/handler.go
@@ -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"
diff --git a/reqres.go b/reqres.go
index d0257ab..d66ca4b 100644
--- a/reqres.go
+++ b/reqres.go
@@ -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() {
diff --git a/type.go b/type.go
index 729f54f..663ae3d 100644
--- a/type.go
+++ b/type.go
@@ -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,
},
}
diff --git a/x509.go b/x509.go
index 841b477..04b3534 100644
--- a/x509.go
+++ b/x509.go
@@ -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))