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.
|
// SetIDWithSignature sets object identifier and signature.
|
||||||
func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
func SetIDWithSignature(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||||
CalculateAndSetPayloadChecksum(obj)
|
|
||||||
|
|
||||||
if err := CalculateAndSetID(obj); err != nil {
|
if err := CalculateAndSetID(obj); err != nil {
|
||||||
return errors.Wrap(err, "could not set identifier")
|
return errors.Wrap(err, "could not set identifier")
|
||||||
}
|
}
|
||||||
|
@ -139,14 +137,17 @@ func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetVerificationFields calculates and sets all verification fields of the object.
|
||||||
|
func SetVerificationFields(key *ecdsa.PrivateKey, obj *RawObject) error {
|
||||||
|
CalculateAndSetPayloadChecksum(obj)
|
||||||
|
|
||||||
|
return SetIDWithSignature(key, obj)
|
||||||
|
}
|
||||||
|
|
||||||
// CheckVerificationFields checks all verification fields of the object.
|
// CheckVerificationFields checks all verification fields of the object.
|
||||||
func CheckVerificationFields(obj *Object) error {
|
func CheckVerificationFields(obj *Object) error {
|
||||||
if err := VerifyIDSignature(obj); err != nil {
|
if err := CheckHeaderVerificationFields(obj); err != nil {
|
||||||
return errors.Wrap(err, "invalid signature")
|
return errors.Wrap(err, "invalid header structure")
|
||||||
}
|
|
||||||
|
|
||||||
if err := VerifyID(obj); err != nil {
|
|
||||||
return errors.Wrap(err, "invalid identifier")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := VerifyPayloadChecksum(obj); err != nil {
|
if err := VerifyPayloadChecksum(obj); err != nil {
|
||||||
|
@ -155,3 +156,16 @@ func CheckVerificationFields(obj *Object) error {
|
||||||
|
|
||||||
return nil
|
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