From afe96d991c820d89b861eb29e2fd6a12184dffc0 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 19 Apr 2023 14:25:45 +0300 Subject: [PATCH] BLAKE3 --- README | 4 ++-- go.mod | 8 ++++---- go.sum | 16 ++++++++-------- main.go | 9 +++------ 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/README b/README index 4f2abcb..8c3a529 100644 --- 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 d6fc3aa..645d583 100644 --- 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 43b2021..bca4816 100644 --- 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 fa2c20e..adc3c77 100644 --- 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:
 $ 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
 

@@ -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 { -- 2.44.0