[#1255] node/session: Add encryption

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>
This commit is contained in:
Pavel Karpy 2022-03-21 14:53:49 +03:00 committed by Alex Vanin
parent a884ad56d9
commit 01ed366e99
6 changed files with 111 additions and 11 deletions

View file

@ -11,14 +11,16 @@ func TestPack(t *testing.T) {
key, err := keys.NewPrivateKey()
require.NoError(t, err)
ts := new(TokenStore)
const exp = 12345
raw, err := packToken(exp, &key.PrivateKey)
raw, err := ts.packToken(exp, &key.PrivateKey)
require.NoError(t, err)
require.Equal(t, uint64(exp), epochFromToken(raw))
unpacked, err := unpackToken(raw)
unpacked, err := ts.unpackToken(raw)
require.NoError(t, err)
require.Equal(t, uint64(exp), unpacked.ExpiredAt())