88 "github.com/filecoin-project/go-fee/aesstream"
99)
1010
11- // ErrIncompleteDescriptor means a [BodyDescriptor] is missing a field, or carries
11+ // ErrInvalidDescriptor means a [BodyDescriptor] is missing a field, or carries
1212// one that cannot describe a FEE body — a value that could not decrypt anything.
13- var ErrIncompleteDescriptor = errors .New ("fee: incomplete body descriptor" )
13+ var ErrInvalidDescriptor = errors .New ("fee: invalid body descriptor" )
1414
1515// BodyDescriptor is everything a range decrypt needs from a FEE envelope, so a
1616// caller that cached it can serve a byte range without fetching or decoding the
@@ -64,22 +64,22 @@ type BodyDescriptor struct {
6464// range read could use.
6565//
6666// [DecryptRangeWithCEK] calls it when desc is non-nil, so a bad value fails
67- // there with [ErrIncompleteDescriptor ] rather than as an authentication error
67+ // there with [ErrInvalidDescriptor ] rather than as an authentication error
6868// further down.
6969func (m BodyDescriptor ) Validate () error {
7070 if m .HeaderLen <= 0 {
71- return fmt .Errorf ("%w: header length %d is not positive" , ErrIncompleteDescriptor , m .HeaderLen )
71+ return fmt .Errorf ("%w: header length %d is not positive" , ErrInvalidDescriptor , m .HeaderLen )
7272 }
7373 if len (m .BaseNonce ) != aesstream .BaseNonceSize {
7474 return fmt .Errorf ("%w: base nonce is %d bytes, want %d" ,
75- ErrIncompleteDescriptor , len (m .BaseNonce ), aesstream .BaseNonceSize )
75+ ErrInvalidDescriptor , len (m .BaseNonce ), aesstream .BaseNonceSize )
7676 }
7777 if m .ChunkSize < aesstream .MinChunkSize || m .ChunkSize > aesstream .MaxChunkSize {
7878 return fmt .Errorf ("%w: chunk size %d out of range [%d, %d]" ,
79- ErrIncompleteDescriptor , m .ChunkSize , aesstream .MinChunkSize , aesstream .MaxChunkSize )
79+ ErrInvalidDescriptor , m .ChunkSize , aesstream .MinChunkSize , aesstream .MaxChunkSize )
8080 }
8181 if len (m .AAD ) == 0 {
82- return fmt .Errorf ("%w: missing AAD" , ErrIncompleteDescriptor )
82+ return fmt .Errorf ("%w: missing AAD" , ErrInvalidDescriptor )
8383 }
8484 return nil
8585}
@@ -90,7 +90,7 @@ func (m BodyDescriptor) Validate() error {
9090// suffix range ("bytes=-N" is off = size-N) from cached metadata alone.
9191//
9292// blobSize is the whole stored object, envelope included, exactly as passed to
93- // [DecryptRangeWithCEK] when desc is non-nil. It reports [ErrIncompleteDescriptor ]
93+ // [DecryptRangeWithCEK] when desc is non-nil. It reports [ErrInvalidDescriptor ]
9494// for an unusable m, and [aesstream.ErrCiphertextSize] if blobSize cannot
9595// describe a FEE blob at this header length and chunk size.
9696func (m BodyDescriptor ) PlaintextSize (blobSize int64 ) (int64 , error ) {
0 commit comments