forked from TrueCloudLab/frostfs-node
01ed366e99
Add `WithEncryption` option that passes ECDSA key to the persistent session storage. It uses 32 bytes from marshalled ECDSA key in ASN.1 DER from in AES-256 algorithm encryption in Galois/Counter Mode. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
28 lines
568 B
Go
28 lines
568 B
Go
package persistent
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestPack(t *testing.T) {
|
|
key, err := keys.NewPrivateKey()
|
|
require.NoError(t, err)
|
|
|
|
ts := new(TokenStore)
|
|
|
|
const exp = 12345
|
|
|
|
raw, err := ts.packToken(exp, &key.PrivateKey)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, uint64(exp), epochFromToken(raw))
|
|
|
|
unpacked, err := ts.unpackToken(raw)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, uint64(exp), unpacked.ExpiredAt())
|
|
require.Equal(t, true, key.Equal(unpacked.SessionKey()))
|
|
}
|