aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2023-02-22 19:21:46 +0000
committerGitHub <noreply@github.com>2023-02-22 14:21:46 -0500
commit1319ba6742a8562453646763adad22379674bab5 (patch)
treefe62dccd8bc7d8fb33f882257a53a2ce4eab1ccf /modules
parenteb5a55785de39ae7162911f553b132c03ae7b424 (diff)
downloadgitea-1319ba6742a8562453646763adad22379674bab5.tar.gz
gitea-1319ba6742a8562453646763adad22379674bab5.zip
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 <art27@cantab.net> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/password/hash/pbkdf2.go2
-rw-r--r--modules/avatar/hash.go3
-rw-r--r--modules/avatar/identicon/identicon.go3
-rw-r--r--modules/base/tool.go2
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/git/last_commit_cache.go3
-rw-r--r--modules/lfs/content_store.go3
-rw-r--r--modules/lfs/pointer.go3
-rw-r--r--modules/secret/secret.go3
-rw-r--r--modules/util/keypair_test.go2
10 files changed, 16 insertions, 10 deletions
diff --git a/modules/auth/password/hash/pbkdf2.go b/modules/auth/password/hash/pbkdf2.go
index 27382fedb8..9ff6d162fc 100644
--- a/modules/auth/password/hash/pbkdf2.go
+++ b/modules/auth/password/hash/pbkdf2.go
@@ -4,12 +4,12 @@
package hash
import (
- "crypto/sha256"
"encoding/hex"
"strings"
"code.gitea.io/gitea/modules/log"
+ "github.com/minio/sha256-simd"
"golang.org/x/crypto/pbkdf2"
)
diff --git a/modules/avatar/hash.go b/modules/avatar/hash.go
index 50db9c1943..4fc28a7739 100644
--- a/modules/avatar/hash.go
+++ b/modules/avatar/hash.go
@@ -4,9 +4,10 @@
package avatar
import (
- "crypto/sha256"
"encoding/hex"
"strconv"
+
+ "github.com/minio/sha256-simd"
)
// HashAvatar will generate a unique string, which ensures that when there's a
diff --git a/modules/avatar/identicon/identicon.go b/modules/avatar/identicon/identicon.go
index 63926d5f19..9b7a2faf05 100644
--- a/modules/avatar/identicon/identicon.go
+++ b/modules/avatar/identicon/identicon.go
@@ -7,10 +7,11 @@
package identicon
import (
- "crypto/sha256"
"fmt"
"image"
"image/color"
+
+ "github.com/minio/sha256-simd"
)
const minImageSize = 16
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 994e58ac3c..94f19576b4 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -6,7 +6,6 @@ package base
import (
"crypto/md5"
"crypto/sha1"
- "crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
@@ -26,6 +25,7 @@ import (
"code.gitea.io/gitea/modules/util"
"github.com/dustin/go-humanize"
+ "github.com/minio/sha256-simd"
)
// EncodeMD5 encodes string to md5 hex value.
diff --git a/modules/context/context.go b/modules/context/context.go
index a2088217ff..0c8d7411ed 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -6,7 +6,6 @@ package context
import (
"context"
- "crypto/sha256"
"encoding/hex"
"errors"
"fmt"
@@ -40,6 +39,7 @@ import (
"gitea.com/go-chi/cache"
"gitea.com/go-chi/session"
chi "github.com/go-chi/chi/v5"
+ "github.com/minio/sha256-simd"
"github.com/unrolled/render"
"golang.org/x/crypto/pbkdf2"
)
diff --git a/modules/git/last_commit_cache.go b/modules/git/last_commit_cache.go
index ec8f1cce62..984561b2c6 100644
--- a/modules/git/last_commit_cache.go
+++ b/modules/git/last_commit_cache.go
@@ -4,11 +4,12 @@
package git
import (
- "crypto/sha256"
"fmt"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
+
+ "github.com/minio/sha256-simd"
)
// Cache represents a caching interface
diff --git a/modules/lfs/content_store.go b/modules/lfs/content_store.go
index 94277a6b8e..a4ae21bfd6 100644
--- a/modules/lfs/content_store.go
+++ b/modules/lfs/content_store.go
@@ -4,7 +4,6 @@
package lfs
import (
- "crypto/sha256"
"encoding/hex"
"errors"
"hash"
@@ -13,6 +12,8 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/storage"
+
+ "github.com/minio/sha256-simd"
)
var (
diff --git a/modules/lfs/pointer.go b/modules/lfs/pointer.go
index b5e13d56a3..f7f225bf1c 100644
--- a/modules/lfs/pointer.go
+++ b/modules/lfs/pointer.go
@@ -4,7 +4,6 @@
package lfs
import (
- "crypto/sha256"
"encoding/hex"
"errors"
"fmt"
@@ -15,6 +14,8 @@ import (
"strings"
"code.gitea.io/gitea/modules/log"
+
+ "github.com/minio/sha256-simd"
)
const (
diff --git a/modules/secret/secret.go b/modules/secret/secret.go
index b84d1cfea8..628ae505a5 100644
--- a/modules/secret/secret.go
+++ b/modules/secret/secret.go
@@ -7,11 +7,12 @@ import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
- "crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
"io"
+
+ "github.com/minio/sha256-simd"
)
// AesEncrypt encrypts text and given key with AES.
diff --git a/modules/util/keypair_test.go b/modules/util/keypair_test.go
index c6f68c845a..c9925f7988 100644
--- a/modules/util/keypair_test.go
+++ b/modules/util/keypair_test.go
@@ -7,12 +7,12 @@ import (
"crypto"
"crypto/rand"
"crypto/rsa"
- "crypto/sha256"
"crypto/x509"
"encoding/pem"
"regexp"
"testing"
+ "github.com/minio/sha256-simd"
"github.com/stretchr/testify/assert"
)