[tahoe-dev] Random access to files

Shawn Willden shawn-tahoe at willden.org
Mon Jan 26 23:56:45 PST 2009


How hard would it be to add support for random access?

I'm thinking of an API that allows one to request a range of bytes from a file 
(mutable or immutable; I need both).  The implementation would have to figure 
out which sequence of segments contain those bytes, download and decrypt 
those segments and then return the requested byte range.

Actually, it may be better to return the whole sequence of segments and an 
offset to tell the client where its range begins.  That way the client can 
cache segments.

One possible issue that jumps out at me is the encryption:  depending on the 
chaining mode used, it may not be possible to decrypt segments in isolation.  
If I'm reading the code right, though, it looks like the AES decryptor from 
pycryptopp operates in counter mode, AND the underlying CTR_Mode 
implementation from cryptopp provides the SeekToIteration() method.

At least for the immutable files case, which is the only one I've 
investigated, it looks like the change is straightforward:

1.  Modify the pycryptopp AES interface to allow an option CTR parameter, 
    and to call SeekToIteration() if it's present.
2.  Modify CipherTextDownloader and Downloader in download.py to allow
    specification of a byte range, and to have CipherTextDownloader 
    figure out which segments correspond to that range and get only them.
3.  Modify the IDownloader interface to allow specification of a byte


More information about the tahoe-dev mailing list