forked from TrueCloudLab/frostfs-api-go
[#162] sdk/object: Detach header verification functions
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2cc58e36f8
commit
420d956062
1 changed files with 24 additions and 10 deletions
|
@ -124,10 +124,8 @@ func VerifyIDSignature(obj *Object) error {
|
|||
)
|
||||
}
|
||||
|
||||
// SetVerificationFields calculates and sets all verification fields of the object.
|
||||
func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||
CalculateAndSetPayloadChecksum(obj)
|
||||
|
||||
// SetIDWithSignature sets object identifier and signature.
|
||||
func SetIDWithSignature(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||
if err := CalculateAndSetID(obj); err != nil {
|
||||
return errors.Wrap(err, "could not set identifier")
|
||||
}
|
||||
|
@ -139,14 +137,17 @@ func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// CheckVerificationFields checks all verification fields of the object.
|
||||
func CheckVerificationFields(obj *Object) error {
|
||||
if err := VerifyIDSignature(obj); err != nil {
|
||||
return errors.Wrap(err, "invalid signature")
|
||||
// SetVerificationFields calculates and sets all verification fields of the object.
|
||||
func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||
CalculateAndSetPayloadChecksum(obj)
|
||||
|
||||
return SetIDWithSignature(key, obj)
|
||||
}
|
||||
|
||||
if err := VerifyID(obj); err != nil {
|
||||
return errors.Wrap(err, "invalid identifier")
|
||||
// CheckVerificationFields checks all verification fields of the object.
|
||||
func CheckVerificationFields(obj *Object) error {
|
||||
if err := CheckHeaderVerificationFields(obj); err != nil {
|
||||
return errors.Wrap(err, "invalid header structure")
|
||||
}
|
||||
|
||||
if err := VerifyPayloadChecksum(obj); err != nil {
|
||||
|
@ -155,3 +156,16 @@ func CheckVerificationFields(obj *Object) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CheckHeaderVerificationFields checks all verification fields except payload.
|
||||
func CheckHeaderVerificationFields(obj *Object) error {
|
||||
if err := VerifyIDSignature(obj); err != nil {
|
||||
return errors.Wrap(err, "invalid signature")
|
||||
}
|
||||
|
||||
if err := VerifyID(obj); err != nil {
|
||||
return errors.Wrap(err, "invalid identifier")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue