2021-09-28 06:02:02 +00:00
|
|
|
package internal
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/client"
|
2024-11-07 14:32:10 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/session"
|
2021-09-28 06:02:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// VerifyResponseKeyV2 checks if response is signed with expected key. Returns client.ErrWrongPublicKey if not.
|
|
|
|
func VerifyResponseKeyV2(expectedKey []byte, resp interface {
|
|
|
|
GetVerificationHeader() *session.ResponseVerificationHeader
|
2023-10-31 11:56:55 +00:00
|
|
|
},
|
|
|
|
) error {
|
2021-09-28 06:02:02 +00:00
|
|
|
if !bytes.Equal(resp.GetVerificationHeader().GetBodySignature().GetKey(), expectedKey) {
|
|
|
|
return client.ErrWrongPublicKey
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|