]> Sergey Matveev's repositories - sgblog.git/commitdiff
BLAKE3 instead of BLAKE2
authorSergey Matveev <stargrave@stargrave.org>
Fri, 28 Jul 2023 18:23:23 +0000 (21:23 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 28 Jul 2023 18:23:23 +0000 (21:23 +0300)
cmd/sgblog/http.go
go.mod
go.sum

index 58515d8de88cb85fd6b4579bb8e7a6002444127a..fd5f7b448ec88bcdb7dc8a15d5b51e01a5575b5a 100644 (file)
@@ -44,7 +44,7 @@ import (
        "github.com/vorlif/spreak"
        "go.stargrave.org/sgblog"
        "go.stargrave.org/sgblog/cmd/sgblog/atom"
-       "golang.org/x/crypto/blake2b"
+       "lukechampine.com/blake3"
 )
 
 const (
@@ -186,10 +186,7 @@ func serveHTTP() {
                makeErr(err, http.StatusBadRequest)
        }
 
-       etagHash, err := blake2b.New256(nil)
-       if err != nil {
-               panic(err)
-       }
+       etagHash := blake3.New(32, nil)
        for _, s := range []string{
                "SGBLOG",
                sgblog.Version,
@@ -435,10 +432,7 @@ func serveHTTP() {
                } else {
                        title = fmt.Sprintf("%s (topic: %s)", cfg.Title, topic)
                }
-               idHasher, err := blake2b.New256(nil)
-               if err != nil {
-                       panic(err)
-               }
+               idHasher := blake3.New(32, nil)
                idHasher.Write([]byte("ATOM POSTS"))
                idHasher.Write([]byte(cfg.AtomId))
                idHasher.Write([]byte(topic))
@@ -522,10 +516,7 @@ func serveHTTP() {
                etagHash.Write([]byte("ATOM COMMENTS"))
                etagHash.Write(commit.Hash[:])
                checkETag(etagHash)
-               idHasher, err := blake2b.New256(nil)
-               if err != nil {
-                       panic(err)
-               }
+               idHasher := blake3.New(32, nil)
                idHasher.Write([]byte("ATOM COMMENTS"))
                idHasher.Write([]byte(cfg.AtomId))
                feed := atom.Feed{
@@ -653,10 +644,7 @@ func serveHTTP() {
                                        body: lines[3:],
                                })
                        }
-                       idHasher, err := blake2b.New256(nil)
-                       if err != nil {
-                               panic(err)
-                       }
+                       idHasher := blake3.New(32, nil)
                        idHasher.Write([]byte("ATOM COMMENTS"))
                        idHasher.Write(commit.Hash[:])
                        feed := atom.Feed{
diff --git a/go.mod b/go.mod
index 36c0eb003fcf0021e08275a89f69ddd020c5beb8..a0f2ccaa0bdba50e4ba29437cf7b62fb2ba066d2 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -7,8 +7,8 @@ require (
        github.com/hjson/hjson-go v3.3.0+incompatible
        github.com/vorlif/spreak v0.4.0
        go.cypherpunks.ru/recfile v0.7.0
-       golang.org/x/crypto v0.7.0
        golang.org/x/text v0.8.0
+       lukechampine.com/blake3 v1.2.1
 )
 
 require (
@@ -22,9 +22,11 @@ require (
        github.com/imdario/mergo v0.3.13 // indirect
        github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
        github.com/kevinburke/ssh_config v1.2.0 // indirect
+       github.com/klauspost/cpuid/v2 v2.0.9 // indirect
        github.com/mitchellh/go-homedir v1.1.0 // indirect
        github.com/sergi/go-diff v1.2.0 // indirect
        github.com/xanzy/ssh-agent v0.3.2 // indirect
+       golang.org/x/crypto v0.7.0 // indirect
        golang.org/x/mod v0.8.0 // indirect
        golang.org/x/net v0.8.0 // indirect
        golang.org/x/sys v0.6.0 // indirect
diff --git a/go.sum b/go.sum
index 68a51aaa1fd5f2fa3728de67646a75afc1de67e6..a3400c49e99a11f442e7821b396d94beedbc90a3 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -49,6 +49,8 @@ github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c
 github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
 github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
 github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
+github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
+github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
 github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
@@ -140,3 +142,5 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
 gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+lukechampine.com/blake3 v1.2.1 h1:YuqqRuaqsGV71BV/nm9xlI0MKUv4QC54jQnBChWbGnI=
+lukechampine.com/blake3 v1.2.1/go.mod h1:0OFRp7fBtAylGVCO40o87sbupkyIGgbpv1+M1k1LM6k=