aboutsummaryrefslogtreecommitdiff
path: root/client/client.go
diff options
context:
space:
mode:
authorRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 10:44:37 +0100
committerRasmus Dahlberg <rasmus.dahlberg@kau.se>2020-11-05 10:44:37 +0100
commitaa0c2f3fc07e3c52e62c570ee9108e4602b3ddbf (patch)
treeb60aeb847ae698dadacb017b7ecf06d51c6c4866 /client/client.go
parent53ad91c63c2788a83d0e80985ffa89ce7cdf203f (diff)
simplified encoding and decoding
Go's "encoding/json" already takes care of encoding and decoding byte slices as base64. As such, it need not be done explicitly by us.
Diffstat (limited to 'client/client.go')
-rw-r--r--client/client.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/client/client.go b/client/client.go
index 864afb4..54f75de 100644
--- a/client/client.go
+++ b/client/client.go
@@ -78,10 +78,10 @@ func (c *Client) AddEntry(ctx context.Context, name, checksum []byte) (*stfe.StI
return nil, fmt.Errorf("failed marshaling StItem: %v", err)
}
data, err := json.Marshal(stfe.AddEntryRequest{
- Item: base64.StdEncoding.EncodeToString(leaf),
- Signature: base64.StdEncoding.EncodeToString(ed25519.Sign(*c.PrivateKey, leaf)),
+ Item: leaf,
+ Signature: ed25519.Sign(*c.PrivateKey, leaf),
SignatureScheme: uint16(tls.Ed25519),
- Chain: c.b64Chain(),
+ Chain: c.chain(),
})
if err != nil {
return nil, fmt.Errorf("failed creating post data: %v", err)
@@ -189,10 +189,10 @@ func (c *Client) GetAnchors(ctx context.Context, start, end uint64) ([]*x509.Cer
return nil, fmt.Errorf("TODO: Client.GetAnchors()")
}
-func (c *Client) b64Chain() []string {
- chain := make([]string, 0, len(c.Chain))
+func (c *Client) chain() [][]byte {
+ chain := make([][]byte, 0, len(c.Chain))
for _, cert := range c.Chain {
- chain = append(chain, base64.StdEncoding.EncodeToString(cert.Raw))
+ chain = append(chain, cert.Raw)
}
return chain
}