Skip to content

Commit

Permalink
[#380] Support changes in signature schemes
Browse files Browse the repository at this point in the history
Support new `SignatureRFC6979` message. Make `refs.ECDSA_SHA512` to be
default scheme.

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
  • Loading branch information
Leonard Lyubich authored and alexvanin committed Mar 2, 2022
1 parent f4fd28e commit d065453
Show file tree
Hide file tree
Showing 9 changed files with 468 additions and 366 deletions.
37 changes: 27 additions & 10 deletions container/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,26 @@ func (c *Container) FromGRPCMessage(m grpc.Message) error {
return nil
}

func toSignatureRFC6979(s *refs.Signature) *refsGRPC.SignatureRFC6979 {
var res *refsGRPC.SignatureRFC6979

if s != nil {
res = new(refsGRPC.SignatureRFC6979)
res.SetKey(s.GetKey())
res.SetSign(s.GetSign())
}

return res
}

func (r *PutRequestBody) ToGRPCMessage() grpc.Message {
var m *container.PutRequest_Body

if r != nil {
m = new(container.PutRequest_Body)

m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container))
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetSignature(toSignatureRFC6979(r.sig))
}

return m
Expand Down Expand Up @@ -195,7 +207,8 @@ func (r *PutRequestBody) FromGRPCMessage(m grpc.Message) error {
r.sig = new(refs.Signature)
}

err = r.sig.FromGRPCMessage(sig)
r.sig.SetKey(sig.GetKey())
r.sig.SetSign(sig.GetSign())
}

return err
Expand Down Expand Up @@ -391,7 +404,7 @@ func (r *GetResponseBody) ToGRPCMessage() grpc.Message {

m.SetContainer(r.cnr.ToGRPCMessage().(*container.Container))
m.SetSessionToken(r.token.ToGRPCMessage().(*sessionGRPC.SessionToken))
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetSignature(toSignatureRFC6979(r.sig))
}

return m
Expand Down Expand Up @@ -424,7 +437,8 @@ func (r *GetResponseBody) FromGRPCMessage(m grpc.Message) error {
r.sig = new(refs.Signature)
}

err = r.sig.FromGRPCMessage(sig)
r.sig.SetKey(sig.GetKey())
r.sig.SetSign(sig.GetSign())
}

token := v.GetSessionToken()
Expand Down Expand Up @@ -486,7 +500,7 @@ func (r *DeleteRequestBody) ToGRPCMessage() grpc.Message {
m = new(container.DeleteRequest_Body)

m.SetContainerId(r.cid.ToGRPCMessage().(*refsGRPC.ContainerID))
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetSignature(toSignatureRFC6979(r.sig))
}

return m
Expand Down Expand Up @@ -522,7 +536,8 @@ func (r *DeleteRequestBody) FromGRPCMessage(m grpc.Message) error {
r.sig = new(refs.Signature)
}

err = r.sig.FromGRPCMessage(sig)
r.sig.SetKey(sig.GetKey())
r.sig.SetSign(sig.GetSign())
}

return err
Expand Down Expand Up @@ -765,7 +780,7 @@ func (r *SetExtendedACLRequestBody) ToGRPCMessage() grpc.Message {
m = new(container.SetExtendedACLRequest_Body)

m.SetEacl(r.eacl.ToGRPCMessage().(*aclGRPC.EACLTable))
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetSignature(toSignatureRFC6979(r.sig))
}

return m
Expand Down Expand Up @@ -801,7 +816,8 @@ func (r *SetExtendedACLRequestBody) FromGRPCMessage(m grpc.Message) error {
r.sig = new(refs.Signature)
}

err = r.sig.FromGRPCMessage(sig)
r.sig.SetKey(sig.GetKey())
r.sig.SetSign(sig.GetSign())
}

return err
Expand Down Expand Up @@ -981,7 +997,7 @@ func (r *GetExtendedACLResponseBody) ToGRPCMessage() grpc.Message {
m = new(container.GetExtendedACLResponse_Body)

m.SetEacl(r.eacl.ToGRPCMessage().(*aclGRPC.EACLTable))
m.SetSignature(r.sig.ToGRPCMessage().(*refsGRPC.Signature))
m.SetSignature(toSignatureRFC6979(r.sig))
m.SetSessionToken(r.token.ToGRPCMessage().(*sessionGRPC.SessionToken))
}

Expand Down Expand Up @@ -1018,7 +1034,8 @@ func (r *GetExtendedACLResponseBody) FromGRPCMessage(m grpc.Message) error {
r.sig = new(refs.Signature)
}

err = r.sig.FromGRPCMessage(sig)
r.sig.SetKey(sig.GetKey())
r.sig.SetSign(sig.GetSign())
}

token := v.GetSessionToken()
Expand Down
16 changes: 8 additions & 8 deletions container/grpc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func (m *PutRequest_Body) SetContainer(v *Container) {
}

// SetSignature sets signature of the container structure.
func (m *PutRequest_Body) SetSignature(v *refs.Signature) {
func (m *PutRequest_Body) SetSignature(v *refs.SignatureRFC6979) {
if m != nil {
m.Signature = v
}
Expand Down Expand Up @@ -77,7 +77,7 @@ func (m *DeleteRequest_Body) SetContainerId(v *refs.ContainerID) {
}

// SetSignature sets signature of the container identifier.
func (m *DeleteRequest_Body) SetSignature(v *refs.Signature) {
func (m *DeleteRequest_Body) SetSignature(v *refs.SignatureRFC6979) {
if m != nil {
m.Signature = v
}
Expand Down Expand Up @@ -166,8 +166,8 @@ func (m *GetResponse_Body) SetSessionToken(v *session.SessionToken) {
}
}

// SetSignature sets signature of the requested container.
func (m *GetResponse_Body) SetSignature(v *refs.Signature) {
// SetSignature sets signature of the container structure.
func (m *GetResponse_Body) SetSignature(v *refs.SignatureRFC6979) {
if m != nil {
m.Signature = v
}
Expand Down Expand Up @@ -257,8 +257,8 @@ func (m *SetExtendedACLRequest_Body) SetEacl(v *acl.EACLTable) {
}
}

// SetSignature sets signature of the eACL table.
func (m *SetExtendedACLRequest_Body) SetSignature(v *refs.Signature) {
// SetSignature sets signature of the eACL table structure.
func (m *SetExtendedACLRequest_Body) SetSignature(v *refs.SignatureRFC6979) {
if m != nil {
m.Signature = v
}
Expand Down Expand Up @@ -341,8 +341,8 @@ func (m *GetExtendedACLResponse_Body) SetEacl(v *acl.EACLTable) {
}
}

// SetSignature sets signature of the eACL table.
func (m *GetExtendedACLResponse_Body) SetSignature(v *refs.Signature) {
// SetSignature sets signature of the eACL table structure.
func (m *GetExtendedACLResponse_Body) SetSignature(v *refs.SignatureRFC6979) {
if m != nil {
m.Signature = v
}
Expand Down

0 comments on commit d065453

Please sign in to comment.