Skip to content

Commit 1319ba6

Browse files
zeripathjolheiser
andauthored
Use minio/sha256-simd for accelerated SHA256 (#23052)
minio/sha256-simd provides additional acceleration for SHA256 using AVX512, SHA Extensions for x86 and ARM64 for ARM. It provides a drop-in replacement for crypto/sha256 and if the extensions are not available it falls back to standard crypto/sha256. --------- Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: John Olheiser <[email protected]>
1 parent eb5a557 commit 1319ba6

File tree

24 files changed

+33
-24
lines changed

24 files changed

+33
-24
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ require (
7676
github.com/mholt/archiver/v3 v3.5.1
7777
github.com/microcosm-cc/bluemonday v1.0.21
7878
github.com/minio/minio-go/v7 v7.0.46
79+
github.com/minio/sha256-simd v1.0.0
7980
github.com/msteinert/pam v1.1.0
8081
github.com/nektos/act v0.0.0
8182
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
@@ -220,7 +221,6 @@ require (
220221
github.com/mholt/acmez v1.0.4 // indirect
221222
github.com/miekg/dns v1.1.50 // indirect
222223
github.com/minio/md5-simd v1.1.2 // indirect
223-
github.com/minio/sha256-simd v1.0.0 // indirect
224224
github.com/mitchellh/copystructure v1.2.0 // indirect
225225
github.com/mitchellh/mapstructure v1.5.0 // indirect
226226
github.com/mitchellh/reflectwalk v1.0.2 // indirect

models/auth/oauth2.go

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

66
import (
77
"context"
8-
"crypto/sha256"
98
"encoding/base32"
109
"encoding/base64"
1110
"fmt"
@@ -18,6 +17,7 @@ import (
1817
"code.gitea.io/gitea/modules/util"
1918

2019
uuid "github.com/google/uuid"
20+
"github.com/minio/sha256-simd"
2121
"golang.org/x/crypto/bcrypt"
2222
"xorm.io/builder"
2323
"xorm.io/xorm"

models/auth/twofactor.go

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

66
import (
77
"crypto/md5"
8-
"crypto/sha256"
98
"crypto/subtle"
109
"encoding/base32"
1110
"encoding/base64"
@@ -18,6 +17,7 @@ import (
1817
"code.gitea.io/gitea/modules/timeutil"
1918
"code.gitea.io/gitea/modules/util"
2019

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

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"
87
"encoding/hex"
98

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"
87
"encoding/hex"
98

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"
87
"encoding/hex"
98
"strings"
109

1110
"code.gitea.io/gitea/modules/log"
1211

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

modules/avatar/hash.go

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

66
import (
7-
"crypto/sha256"
87
"encoding/hex"
98
"strconv"
9+
10+
"github.com/minio/sha256-simd"
1011
)
1112

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

modules/avatar/identicon/identicon.go

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

99
import (
10-
"crypto/sha256"
1110
"fmt"
1211
"image"
1312
"image/color"
13+
14+
"github.com/minio/sha256-simd"
1415
)
1516

1617
const minImageSize = 16

modules/base/tool.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package base
66
import (
77
"crypto/md5"
88
"crypto/sha1"
9-
"crypto/sha256"
109
"encoding/base64"
1110
"encoding/hex"
1211
"errors"
@@ -26,6 +25,7 @@ import (
2625
"code.gitea.io/gitea/modules/util"
2726

2827
"github.com/dustin/go-humanize"
28+
"github.com/minio/sha256-simd"
2929
)
3030

3131
// EncodeMD5 encodes string to md5 hex value.

modules/context/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package context
66

77
import (
88
"context"
9-
"crypto/sha256"
109
"encoding/hex"
1110
"errors"
1211
"fmt"
@@ -40,6 +39,7 @@ import (
4039
"gitea.com/go-chi/cache"
4140
"gitea.com/go-chi/session"
4241
chi "github.com/go-chi/chi/v5"
42+
"github.com/minio/sha256-simd"
4343
"github.com/unrolled/render"
4444
"golang.org/x/crypto/pbkdf2"
4545
)

0 commit comments

Comments
 (0)