1
0
Fork 0
forked from forgejo/forgejo

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>
This commit is contained in:
zeripath 2023-02-22 19:21:46 +00:00 committed by GitHub
parent eb5a55785d
commit 1319ba6742
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 33 additions and 24 deletions

View file

@ -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"
)

View file

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

View file

@ -7,10 +7,11 @@
package identicon
import (
"crypto/sha256"
"fmt"
"image"
"image/color"
"github.com/minio/sha256-simd"
)
const minImageSize = 16

View file

@ -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.

View file

@ -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"
)

View file

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

View file

@ -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 (

View file

@ -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 (

View file

@ -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.

View file

@ -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"
)