edu.harvard.deas.hyperenc.vsat
Class FileRandomSource

java.lang.Object
  extended by edu.harvard.deas.hyperenc.vsat.TrueRandomSource
      extended by edu.harvard.deas.hyperenc.vsat.FileRandomSource

public class FileRandomSource
extends TrueRandomSource

FileRandomSource (FRS) traverses the file system collecting random data. Then, it encrypts, compresses and then xor's the resulting pages to produce a final page to hand to the PSN


Field Summary
static int NUM_PAGES
          Number of random pages to combine into the final random page
 
Fields inherited from class edu.harvard.deas.hyperenc.vsat.TrueRandomSource
DATA_LENGTH
 
Constructor Summary
FileRandomSource()
          Simple constructor to initialize components
 
Method Summary
 byte[] compressPage(byte[] page)
          Returns the result of compressing the given page or null if we hit problems XXX Remove the temporary hack of zero-padding
 byte[] encryptPage(byte[] page)
          Returns the result of encrypting the given page using a random key with Triple DES, or null if it encounters an error
 boolean genFileData(File startNode)
          Function to gather random data from the file system Randomly selects a target depth and then calls fileSearch to do the actual descent
 byte[] genRandomness()
          Pieces everything together: Gathers file data and then encrypts, compresses and xor's pages to return a page of random data Returns null if it encounters an error
 byte[] xor(byte[] page1, byte[] page2)
          Computes the byte-wise xor of page1 and page2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUM_PAGES

public static final int NUM_PAGES
Number of random pages to combine into the final random page

See Also:
Constant Field Values
Constructor Detail

FileRandomSource

public FileRandomSource()
Simple constructor to initialize components

Method Detail

genRandomness

public byte[] genRandomness()
Pieces everything together: Gathers file data and then encrypts, compresses and xor's pages to return a page of random data Returns null if it encounters an error

Specified by:
genRandomness in class TrueRandomSource

xor

public byte[] xor(byte[] page1,
                  byte[] page2)
Computes the byte-wise xor of page1 and page2


encryptPage

public byte[] encryptPage(byte[] page)
Returns the result of encrypting the given page using a random key with Triple DES, or null if it encounters an error

Parameters:
page - The array of bytes to be encrypted

compressPage

public byte[] compressPage(byte[] page)
Returns the result of compressing the given page or null if we hit problems XXX Remove the temporary hack of zero-padding

Parameters:
page - An array of FILE_READ_SIZE bytes to be compressed
Returns:
The compressed data, with zeros appended to make the length FILE_READ_SIZE bytes

genFileData

public boolean genFileData(File startNode)
Function to gather random data from the file system Randomly selects a target depth and then calls fileSearch to do the actual descent