Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog for NeoFS Node
### Added

### Fixed
- SNs do not support objects signed with N3 scheme via session v2 feature (#4259)

### Changed

Expand Down
24 changes: 14 additions & 10 deletions internal/crypto/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"

"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
isessions "github.com/nspcc-dev/neofs-node/internal/sessions"
versioncore "github.com/nspcc-dev/neofs-node/pkg/core/version"
neofscrypto "github.com/nspcc-dev/neofs-sdk-go/crypto"
Expand Down Expand Up @@ -73,21 +74,24 @@ func AuthenticateObject(obj object.Object, fsChain HistoricN3ScriptRunner, sToke
return errors.New("different object owner and session issuer")
}
}
var signer = obj.Owner()
if sessionTokenV2 != nil {
// NOTE: update this place for non-ECDSA schemes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cthulhu-rider do you understand this comment? can it be dropped now? is it about this PR? something else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, can be dropped

if ecdsaPub != nil {
nodeUser := user.NewFromECDSAPublicKey(*ecdsaPub)
ok, err := sessionTokenV2.AssertAuthority(nodeUser, resolver)
if err != nil {
return fmt.Errorf("assert session v2 authority: %w", err)
}
if !ok { // same format for all ECDSA schemes
return errors.New("session v2 token is not for object's signer")
}
signer = user.NewFromECDSAPublicKey(*ecdsaPub)
} else {
signer = user.NewFromScriptHash(hash.Hash160(verifScript))
}
ok, err := sessionTokenV2.AssertAuthority(signer, resolver)
if err != nil {
return fmt.Errorf("assert session v2 authority: %w", err)
}
if !ok { // same format for all ECDSA schemes
return errors.New("session v2 token is not for object's signer")
}

k := sha256.Sum256(sessionTokenV2.Marshal())
_, err := sTokenCache.AuthenticateTokenV2(k, func() (sessionv2.Token, error) {
_, err = sTokenCache.AuthenticateTokenV2(k, func() (sessionv2.Token, error) {
if err := AuthenticateTokenV2(sessionTokenV2, fsChain); err != nil {
return sessionv2.Token{}, fmt.Errorf("session token v2: %w", err)
}
Expand All @@ -114,7 +118,7 @@ func AuthenticateObject(obj object.Object, fsChain HistoricN3ScriptRunner, sToke
return errors.New("owner mismatches signature")
}
case neofscrypto.N3:
if err := verifyN3ScriptsAtEpoch(fsChain, obj.CreationEpoch(), obj.Owner().ScriptHash(), invocScript, verifScript, func() [sha256.Size]byte {
if err := verifyN3ScriptsAtEpoch(fsChain, obj.CreationEpoch(), signer.ScriptHash(), invocScript, verifScript, func() [sha256.Size]byte {
return sha256.Sum256(obj.SignedData())
}); err != nil {
return err
Expand Down
Loading