parent
901f70d3c9
commit
7c979aded7
2 changed files with 5 additions and 16 deletions
|
@ -3,10 +3,6 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha512"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
|
@ -1061,10 +1057,9 @@ func makeAuthTokenRequest(ctx context.Context, t *testing.T, bearers []*models.B
|
|||
}
|
||||
|
||||
func signToken(t *testing.T, key *keys.PrivateKey, data []byte) *handlers.BearerToken {
|
||||
h := sha512.Sum512(data)
|
||||
x, y, err := ecdsa.Sign(rand.Reader, &key.PrivateKey, h[:])
|
||||
signer := neofsecdsa.Signer(key.PrivateKey)
|
||||
sign, err := signer.Sign(data)
|
||||
require.NoError(t, err)
|
||||
sign := elliptic.Marshal(elliptic.P256(), x, y)
|
||||
|
||||
return &handlers.BearerToken{
|
||||
Token: base64.StdEncoding.EncodeToString(data),
|
||||
|
|
|
@ -2,9 +2,6 @@ package handlers
|
|||
|
||||
import (
|
||||
"crypto/ecdsa"
|
||||
"crypto/elliptic"
|
||||
"crypto/rand"
|
||||
"crypto/sha512"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"math"
|
||||
|
@ -12,6 +9,7 @@ import (
|
|||
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||
crypto "github.com/nspcc-dev/neofs-crypto"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/gen/models"
|
||||
"github.com/nspcc-dev/neofs-rest-gw/internal/util"
|
||||
"github.com/nspcc-dev/neofs-sdk-go/user"
|
||||
|
@ -54,12 +52,8 @@ func TestSign(t *testing.T) {
|
|||
binaryBearer := v2token.GetBody().StableMarshal(nil)
|
||||
bearerBase64 := base64.StdEncoding.EncodeToString(binaryBearer)
|
||||
|
||||
h := sha512.Sum512(binaryBearer)
|
||||
x, y, err := ecdsa.Sign(rand.Reader, &key.PrivateKey, h[:])
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
signatureData := elliptic.Marshal(elliptic.P256(), x, y)
|
||||
signatureData, err := crypto.Sign(&key.PrivateKey, binaryBearer)
|
||||
require.NoError(t, err)
|
||||
|
||||
bt := &BearerToken{
|
||||
Token: bearerBase64,
|
||||
|
|
Reference in a new issue