Merge lp:~jderose/dmedia/tie-size-to-id into lp:dmedia
Status: | Merged |
---|---|
Approved by: | Jason Gerard DeRose |
Approved revision: | 170 |
Merged at revision: | 167 |
Proposed branch: | lp:~jderose/dmedia/tie-size-to-id |
Merge into: | lp:dmedia |
Diff against target: |
309 lines (+133/-18) 6 files modified
dmedia/downloader.py (+3/-2) dmedia/filestore.py (+83/-9) dmedia/schema.py (+1/-1) dmedia/tests/helpers.py (+2/-2) dmedia/tests/test_downloader.py (+1/-1) dmedia/tests/test_filestore.py (+43/-3) |
To merge this branch: | bzr merge lp:~jderose/dmedia/tie-size-to-id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Gerard DeRose | Approve | ||
David Jordan | Approve | ||
Review via email: mp+50765@code.launchpad.net |
Description of the change
Cryptographically ties doc['bytes'] to doc['_id'].
This allows us to insure that for a given doc['_id'] (the top-hash), the doc['bytes'] and doc['_attachmen
Validating doc['bytes'] is important because we want to be fairly confident about preallocating that much space before starting a file download. Otherwise a malicious peer need do nothing more than start circulating a bogus doc with the wrong doc['bytes'] to wreak all kinds of havoc.
Even though we're still using sha1, I'm doing this is a way that makes sense for when we migrate to Skein. The top-hash of a file whose size is 31415 bytes gets "personalized" like this:
tophash = sha1(b'
With Skein it would work like this:
tophash = skein512(leaves, pers=b'
Ah, also note that leafhash_ personalization () and leafhash() aren't currently being used... just some daydreaming about how I'll do this when we switch to Skein.