Skip to content

Commit f79c9e8

Browse files
authored
Use crypto/sha256 (#29386)
Go 1.21 improved the performance of `crypto/sha256`. It's now similar to `minio/sha256-simd`, so we should just use the standard libs. https://go.dev/doc/go1.21#crypto/sha256 https://go-review.googlesource.com/c/go/+/408795 multiformats/go-multihash#173
1 parent ad0a34b commit f79c9e8

File tree

22 files changed

+22
-32
lines changed

22 files changed

+22
-32
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ require (
7878
github.com/mholt/archiver/v3 v3.5.1
7979
github.com/microcosm-cc/bluemonday v1.0.26
8080
github.com/minio/minio-go/v7 v7.0.66
81-
github.com/minio/sha256-simd v1.0.1
8281
github.com/msteinert/pam v1.2.0
8382
github.com/nektos/act v0.2.52
8483
github.com/niklasfasching/go-org v1.7.0
@@ -230,6 +229,7 @@ require (
230229
github.com/mholt/acmez v1.2.0 // indirect
231230
github.com/miekg/dns v1.1.58 // indirect
232231
github.com/minio/md5-simd v1.1.2 // indirect
232+
github.com/minio/sha256-simd v1.0.1 // indirect
233233
github.com/mitchellh/copystructure v1.2.0 // indirect
234234
github.com/mitchellh/mapstructure v1.5.0 // indirect
235235
github.com/mitchellh/reflectwalk v1.0.2 // indirect

models/auth/twofactor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package auth
66
import (
77
"context"
88
"crypto/md5"
9+
"crypto/sha256"
910
"crypto/subtle"
1011
"encoding/base32"
1112
"encoding/base64"
@@ -18,7 +19,6 @@ import (
1819
"code.gitea.io/gitea/modules/timeutil"
1920
"code.gitea.io/gitea/modules/util"
2021

21-
"github.com/minio/sha256-simd"
2222
"github.com/pquerna/otp/totp"
2323
"golang.org/x/crypto/pbkdf2"
2424
)

models/migrations/base/hash.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package base
55

66
import (
7+
"crypto/sha256"
78
"encoding/hex"
89

9-
"github.com/minio/sha256-simd"
1010
"golang.org/x/crypto/pbkdf2"
1111
)
1212

models/migrations/v1_14/v166.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
package v1_14 //nolint
55

66
import (
7+
"crypto/sha256"
78
"encoding/hex"
89

9-
"github.com/minio/sha256-simd"
1010
"golang.org/x/crypto/argon2"
1111
"golang.org/x/crypto/bcrypt"
1212
"golang.org/x/crypto/pbkdf2"

modules/auth/password/hash/pbkdf2.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
package hash
55

66
import (
7+
"crypto/sha256"
78
"encoding/hex"
89
"strings"
910

1011
"code.gitea.io/gitea/modules/log"
1112

12-
"github.com/minio/sha256-simd"
1313
"golang.org/x/crypto/pbkdf2"
1414
)
1515

modules/avatar/hash.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
package avatar
55

66
import (
7+
"crypto/sha256"
78
"encoding/hex"
89
"strconv"
9-
10-
"github.com/minio/sha256-simd"
1110
)
1211

1312
// HashAvatar will generate a unique string, which ensures that when there's a

modules/avatar/identicon/identicon.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
package identicon
88

99
import (
10+
"crypto/sha256"
1011
"fmt"
1112
"image"
1213
"image/color"
13-
14-
"github.com/minio/sha256-simd"
1514
)
1615

1716
const minImageSize = 16

modules/base/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package base
55

66
import (
77
"crypto/sha1"
8+
"crypto/sha256"
89
"encoding/base64"
910
"encoding/hex"
1011
"errors"
@@ -22,7 +23,6 @@ import (
2223
"code.gitea.io/gitea/modules/setting"
2324

2425
"github.com/dustin/go-humanize"
25-
"github.com/minio/sha256-simd"
2626
)
2727

2828
// EncodeSha1 string to sha1 hex value.

modules/git/last_commit_cache.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
package git
55

66
import (
7+
"crypto/sha256"
78
"fmt"
89

910
"code.gitea.io/gitea/modules/log"
1011
"code.gitea.io/gitea/modules/setting"
11-
12-
"github.com/minio/sha256-simd"
1312
)
1413

1514
// Cache represents a caching interface

modules/lfs/content_store.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package lfs
55

66
import (
7+
"crypto/sha256"
78
"encoding/hex"
89
"errors"
910
"hash"
@@ -12,8 +13,6 @@ import (
1213

1314
"code.gitea.io/gitea/modules/log"
1415
"code.gitea.io/gitea/modules/storage"
15-
16-
"github.com/minio/sha256-simd"
1716
)
1817

1918
var (

0 commit comments

Comments
 (0)