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

@ -9,7 +9,6 @@ import (
"crypto/elliptic"
"crypto/rand"
"crypto/rsa"
"crypto/sha256"
"crypto/x509"
"encoding/base64"
"encoding/pem"
@ -25,6 +24,7 @@ import (
"code.gitea.io/gitea/modules/util"
"github.com/golang-jwt/jwt/v4"
"github.com/minio/sha256-simd"
ini "gopkg.in/ini.v1"
)

View file

@ -5,7 +5,6 @@ package lfs
import (
stdCtx "context"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
"errors"
@ -32,6 +31,7 @@ import (
"code.gitea.io/gitea/modules/storage"
"github.com/golang-jwt/jwt/v4"
"github.com/minio/sha256-simd"
)
// requestContext contain variables from the HTTP request.

View file

@ -6,13 +6,14 @@ package token
import (
"context"
crypto_hmac "crypto/hmac"
"crypto/sha256"
"encoding/base32"
"fmt"
"time"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/util"
"github.com/minio/sha256-simd"
)
// A token is a verifiable container describing an action.

View file

@ -7,7 +7,6 @@ import (
"context"
"crypto/hmac"
"crypto/sha1"
"crypto/sha256"
"crypto/tls"
"encoding/hex"
"fmt"
@ -29,6 +28,7 @@ import (
webhook_module "code.gitea.io/gitea/modules/webhook"
"github.com/gobwas/glob"
"github.com/minio/sha256-simd"
)
// Deliver deliver hook task