diff options
author | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-11-05 11:46:10 +0100 |
---|---|---|
committer | Rasmus Dahlberg <rasmus.dahlberg@kau.se> | 2020-11-05 11:46:10 +0100 |
commit | 8bb721bed66d09e27c9577d88d40cb1e48a8783d (patch) | |
tree | 8a754d85e950bb5f71c27dc055944e468dc90d25 | |
parent | eda3037a9c52596da61d6bb4f06e7cd4d5964756 (diff) |
moved sth and sdi metrics into the signer component
-rw-r--r-- | handler.go | 3 | ||||
-rw-r--r-- | x509.go | 19 |
2 files changed, 10 insertions, 12 deletions
@@ -80,7 +80,6 @@ func addEntry(ctx context.Context, i *Instance, w http.ResponseWriter, r *http.R if err != nil { return http.StatusInternalServerError, err } - lastSdiTimestamp.Set(float64(time.Now().Unix()), i.LogParameters.id()) if err := writeJsonResponse(rsp, w); err != nil { return http.StatusInternalServerError, err } @@ -217,8 +216,6 @@ func getSth(ctx context.Context, i *Instance, w http.ResponseWriter, _ *http.Req if err != nil { return http.StatusInternalServerError, err } - lastSthTimestamp.Set(float64(time.Now().Unix()), i.LogParameters.id()) - lastSthSize.Set(float64(sth.SignedTreeHeadV1.TreeHead.TreeSize), i.LogParameters.id()) if err := writeJsonResponse(rsp, w); err != nil { return http.StatusInternalServerError, err } @@ -2,6 +2,7 @@ package stfe import ( "fmt" + "time" "crypto" "crypto/ed25519" @@ -80,27 +81,27 @@ func ParseEd25519PrivateKey(data []byte) (ed25519.PrivateKey, error) { } } -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)) +func GenV1SDI(lp *LogParameters, serialized []byte) (*StItem, error) { + sig, err := lp.Signer.Sign(rand.Reader, serialized, crypto.Hash(0)) // ed25519 if err != nil { return nil, fmt.Errorf("ed25519 signature failed: %v", err) } - return NewSignedDebugInfoV1(ld.LogId, []byte("reserved"), sig), nil + lastSdiTimestamp.Set(float64(time.Now().Unix()), lp.id()) + return NewSignedDebugInfoV1(lp.LogId, []byte("reserved"), sig), nil } -func GenV1STH(ld *LogParameters, th *TreeHeadV1) (*StItem, error) { +func GenV1STH(lp *LogParameters, th *TreeHeadV1) (*StItem, error) { serialized, err := th.Marshal() if err != nil { return nil, fmt.Errorf("failed tls marshaling tree head: %v", err) } - - // Note that ed25519 does not use the passed io.Reader - sig, err := ld.Signer.Sign(rand.Reader, serialized, crypto.Hash(0)) + sig, err := lp.Signer.Sign(rand.Reader, serialized, crypto.Hash(0)) // ed25519 if err != nil { return nil, fmt.Errorf("ed25519 signature failed: %v", err) } - return NewSignedTreeHeadV1(th, ld.LogId, sig), nil + lastSthTimestamp.Set(float64(time.Now().Unix()), lp.id()) + lastSthSize.Set(float64(th.TreeSize), lp.id()) + return NewSignedTreeHeadV1(th, lp.LogId, sig), nil } // LoadChain loads a PEM-encoded certificate chain from a given path |