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