mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 12:54:38 +03:00
This reverts commit bba7c23957.
This commit is contained in:
16
vendor/github.com/golang-jwt/jwt/v4/ed25519.go
generated
vendored
16
vendor/github.com/golang-jwt/jwt/v4/ed25519.go
generated
vendored
@@ -3,9 +3,7 @@ package jwt
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"crypto"
|
||||
"crypto/ed25519"
|
||||
"crypto/rand"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -64,22 +62,20 @@ func (m *SigningMethodEd25519) Verify(signingString, signature string, key inter
|
||||
// Sign implements token signing for the SigningMethod.
|
||||
// For this signing method, key must be an ed25519.PrivateKey
|
||||
func (m *SigningMethodEd25519) Sign(signingString string, key interface{}) (string, error) {
|
||||
var ed25519Key crypto.Signer
|
||||
var ed25519Key ed25519.PrivateKey
|
||||
var ok bool
|
||||
|
||||
if ed25519Key, ok = key.(crypto.Signer); !ok {
|
||||
if ed25519Key, ok = key.(ed25519.PrivateKey); !ok {
|
||||
return "", ErrInvalidKeyType
|
||||
}
|
||||
|
||||
if _, ok := ed25519Key.Public().(ed25519.PublicKey); !ok {
|
||||
// ed25519.Sign panics if private key not equal to ed25519.PrivateKeySize
|
||||
// this allows to avoid recover usage
|
||||
if len(ed25519Key) != ed25519.PrivateKeySize {
|
||||
return "", ErrInvalidKey
|
||||
}
|
||||
|
||||
// Sign the string and return the encoded result
|
||||
// ed25519 performs a two-pass hash as part of its algorithm. Therefore, we need to pass a non-prehashed message into the Sign function, as indicated by crypto.Hash(0)
|
||||
sig, err := ed25519Key.Sign(rand.Reader, []byte(signingString), crypto.Hash(0))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
sig := ed25519.Sign(ed25519Key, []byte(signingString))
|
||||
return EncodeSegment(sig), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user