Commit 82aac4f
feat: range decryption API on top of the fee package
Adds DecryptRange / DecryptRangeWithCEK to the root fee package, so a caller
can decrypt one plaintext byte range of a stored FEE blob without fetching or
decrypting the whole object — and without reaching into fee/aesstream or the
COSE/wrap sub-packages to do it.
The range path reuses the envelope-decode and recipient-unwrap logic that
Decrypt uses (matchRecipient, RecipientUnwrapper.unwrap), which is why it lives
inside the fee package rather than a sub-package, and adds only the range piece:
locating the chunk-aligned ciphertext span and handing it to aesstream's range
primitive instead of the whole stream.
- RangeReader exposes Len (the clamped range length) and Size (the whole
object's plaintext size), so an HTTP consumer can fill in Content-Length and
Content-Range before any ciphertext is read, plus CiphertextSpan so a
remote-backed caller can prefetch the span in a single range request.
- PlaintextSize answers an object's decrypted size from the envelope header
alone, with no key material — for HEAD responses and suffix ranges.
- The envelope header is located by probing a small prefix with cose.Decode,
which reports its exact encoded length; the probe grows only for unusually
large envelopes and is bounded at 1 MiB.
- When the envelope records a chunk count, it is cross-checked against the
geometry the blob size implies (ErrSizeMismatch), catching a stale or wrong
size before any plaintext is served. The count is unprotected metadata, so
this is an operational check, not an integrity guarantee — documented as such.
openStream's body-header validation is extracted into a shared validateBody
helper so the whole-object and range paths accept exactly the same envelopes and
report the same errors. No behavior change on the existing path.
Every chunk a range overlaps is authenticated, so a tampered chunk fails rather
than yielding corrupt plaintext; chunks outside the range are never fetched and
so never checked, which the docs spell out along with the trust placed in the
supplied blob size.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CF6S9hmvMkpTkDyRvYopeN1 parent 7feb6d1 commit 82aac4f
5 files changed
Lines changed: 1231 additions & 74 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
| 49 | + | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
257 | | - | |
258 | | - | |
259 | | - | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
263 | | - | |
264 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
265 | 269 | | |
266 | 270 | | |
267 | | - | |
268 | | - | |
269 | 271 | | |
270 | 272 | | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
292 | 276 | | |
293 | | - | |
| 277 | + | |
294 | 278 | | |
295 | 279 | | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
303 | 285 | | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
| 286 | + | |
| 287 | + | |
317 | 288 | | |
318 | 289 | | |
319 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
320 | 305 | | |
321 | | - | |
322 | | - | |
323 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
324 | 314 | | |
325 | 315 | | |
326 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
65 | 75 | | |
66 | 76 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 77 | + | |
71 | 78 | | |
72 | 79 | | |
73 | 80 | | |
| |||
476 | 483 | | |
477 | 484 | | |
478 | 485 | | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
479 | 520 | | |
480 | 521 | | |
481 | | - | |
| 522 | + | |
482 | 523 | | |
483 | 524 | | |
484 | | - | |
| 525 | + | |
485 | 526 | | |
486 | 527 | | |
487 | 528 | | |
488 | 529 | | |
489 | | - | |
| 530 | + | |
490 | 531 | | |
491 | 532 | | |
492 | 533 | | |
| |||
497 | 538 | | |
498 | 539 | | |
499 | 540 | | |
500 | | - | |
| 541 | + | |
501 | 542 | | |
502 | 543 | | |
503 | 544 | | |
504 | 545 | | |
505 | | - | |
| 546 | + | |
506 | 547 | | |
507 | 548 | | |
508 | 549 | | |
| |||
511 | 552 | | |
512 | 553 | | |
513 | 554 | | |
514 | | - | |
| 555 | + | |
515 | 556 | | |
516 | 557 | | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
525 | | - | |
526 | | - | |
| 558 | + | |
527 | 559 | | |
528 | 560 | | |
529 | 561 | | |
| |||
0 commit comments