]> Sergey Matveev's repositories - uploader.git/commitdiff
BLAKE3 v1.5.0
authorSergey Matveev <stargrave@stargrave.org>
Wed, 19 Apr 2023 11:25:45 +0000 (14:25 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Mon, 15 May 2023 07:47:01 +0000 (10:47 +0300)
README
go.mod
go.sum
main.go

diff --git a/README b/README
index 4f2abcba60381b68b0c92b2cfba300426a469233..8c3a52951f71c6b156ffd144395c4919c1e9780f 100644 (file)
--- a/README
+++ b/README
@@ -1,7 +1,7 @@
 Simplest HTTP form file uploader.
 
 It just saves uploaded file from HTML form to the new file on the disk.
-Also it calculates BLAKE2b-512 checksum, replying with it in the answer.
+Also it calculates BLAKE3-256 checksum, replying with it in the answer.
 
 You can upload files with curl:
 
@@ -11,7 +11,7 @@ You can upload files with curl:
 
 and verify integrity locally:
 
-    b2sum somedata.tar.gpg
+    b3sum somedata.tar.gpg
 
 You can enable mail notification with -notify-to and -notify-from options.
 It is advisable to run it under daemontools-like supervisor
diff --git a/go.mod b/go.mod
index d6fc3aa722789bd5e5fbfa3aae8fb95d03a57b48..645d583bd6d4a005c0ac931ea731065e5a86db8c 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,10 +3,10 @@ module go.stargrave.org/uploader
 go 1.17
 
 require (
-       go.cypherpunks.ru/recfile v0.5.1
+       go.cypherpunks.ru/recfile v0.7.0
        go.cypherpunks.ru/tai64n/v2 v2.0.0
-       golang.org/x/crypto v0.1.0
-       golang.org/x/net v0.2.0
+       golang.org/x/net v0.9.0
+       lukechampine.com/blake3 v1.1.7
 )
 
-require golang.org/x/sys v0.2.0 // indirect
+require github.com/klauspost/cpuid/v2 v2.0.9 // indirect
diff --git a/go.sum b/go.sum
index 43b2021d8704eb643608409496542e396b5aa0c3..bca4816707f1f4e2d85c7a8ef21d0b3ca9db6409 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,10 +1,10 @@
-go.cypherpunks.ru/recfile v0.5.1 h1:Sk9Og/7aybvg4PrZdhyFSeEdS6wvcisvd+1oGf8uFyU=
-go.cypherpunks.ru/recfile v0.5.1/go.mod h1:sR+KajB+vzofL3SFVFwKt3Fke0FaCcN1g3YPNAhU3qI=
+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=
+go.cypherpunks.ru/recfile v0.7.0 h1:0R1UnDGKccp7JnC66msslJMlSY02jHx/XkW+ISl0GuY=
+go.cypherpunks.ru/recfile v0.7.0/go.mod h1:sR+KajB+vzofL3SFVFwKt3Fke0FaCcN1g3YPNAhU3qI=
 go.cypherpunks.ru/tai64n/v2 v2.0.0 h1:AlohA1/zRqInhIGK7CVnn7tC5/vt1TaOAEyBgeu5Ruo=
 go.cypherpunks.ru/tai64n/v2 v2.0.0/go.mod h1:9eeXyzoNO/8grf+bw+T1HXRCRjHVXjUsvnIyaUkjS5I=
-golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
-golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
-golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
-golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
-golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A=
-golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
+golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
+lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0=
+lukechampine.com/blake3 v1.1.7/go.mod h1:tkKEOtDkNtklkXtLNEOGNq5tcV90tJiA1vAA12R78LA=
diff --git a/main.go b/main.go
index fa2c20e320f2665078b4be89184557d027b66551..adc3c774bc05d861b0b88f60a2fd9966034e43a6 100644 (file)
--- a/main.go
+++ b/main.go
@@ -39,8 +39,8 @@ import (
 
        "go.cypherpunks.ru/recfile"
        "go.cypherpunks.ru/tai64n/v2"
-       "golang.org/x/crypto/blake2b"
        "golang.org/x/net/netutil"
+       "lukechampine.com/blake3"
 )
 
 const (
@@ -57,7 +57,7 @@ var (
 Example command line usage:
 <pre>
 $ curl -F file=@somedata.tar.gpg [-F comment="optional comment"] http://.../upload/
-$ b2sum somedata.tar.gpg # to verify BLAKE2b-512 checksum
+$ b3sum somedata.tar.gpg # to verify BLAKE3-256 checksum
 </pre>
 <form enctype="multipart/form-data" action="/upload/" method="post">
 <label for="file">File to upload:</label><br/>
@@ -93,10 +93,6 @@ func upload(w http.ResponseWriter, r *http.Request) {
                log.Println(r.RemoteAddr, "non file form field")
                return
        }
-       h, err := blake2b.New512(nil)
-       if err != nil {
-               panic(err)
-       }
        t := time.Now()
        ts := new(tai64n.TAI64N)
        ts.FromTime(t)
@@ -108,6 +104,7 @@ func upload(w http.ResponseWriter, r *http.Request) {
                return
        }
        fdBuf := bufio.NewWriterSize(fd, WriteBufSize)
+       h := blake3.New(32, nil)
        mw := io.MultiWriter(fdBuf, h)
        n, err := io.Copy(mw, p)
        if err != nil {