Class DataLoader

java.lang.Object
  |
  +--DataLoader

public class DataLoader
extends java.lang.Object

DataLoader is an IO interface used by RSA to read and write clear and encrypted data. Its default is that it is not bufferised, thus each call to a read method results in a disk access. As well for writes.

It was necessary to define a format for blocks of data. In this implementation, clear data is read by blocks of at most 126 bytes, and inserted in a 128 bytes large integer whose first byte is the length of the block of clear data read. This integer is then encrypted using rsa, and can be written to and read from a file. When decrypted and written as clear data to a file, only the number of bytes specified in the first bytes is indeed written to the file.

Author:
E.Lemonnier & E.Nordenstam

Constructor Summary
DataLoader(java.lang.String filein, java.lang.String fileout)
          Create a DataLoader defined by an file from which to read and a file in which to write.
 
Method Summary
 void close()
          Close the streams manipulated by a DataLoader.
 java.math.BigInteger readClearBlock()
          Read a block of data from a clear file.
 java.math.BigInteger readEncryptedBlock()
          Read a block of encrypted data from an encrypted file.
 void writeClearBlock(java.math.BigInteger b)
          Write a block of clear data to a file.
 void writeEncryptedBlock(java.math.BigInteger b)
          Write a block of encrypted data to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataLoader

public DataLoader(java.lang.String filein,
                  java.lang.String fileout)
           throws java.lang.Exception
Create a DataLoader defined by an file from which to read and a file in which to write.

Parameters:
filein - a file from which to read.
fileout - a file in which to write.
Method Detail

close

public void close()
Close the streams manipulated by a DataLoader.

readClearBlock

public java.math.BigInteger readClearBlock()
                                    throws java.io.IOException
Read a block of data from a clear file.

Returns:
the block of data as a big integer of 1024 bits.

readEncryptedBlock

public java.math.BigInteger readEncryptedBlock()
                                        throws java.io.IOException
Read a block of encrypted data from an encrypted file.

Returns:
the block of data as a big integer of 1024 bits.

writeClearBlock

public void writeClearBlock(java.math.BigInteger b)
                     throws java.io.IOException
Write a block of clear data to a file.

Parameters:
b - clear data encapsulated in a 128 bytes integer.

writeEncryptedBlock

public void writeEncryptedBlock(java.math.BigInteger b)
                         throws java.io.IOException
Write a block of encrypted data to a file.

Parameters:
a - 1024 bits integer representing encrypted data.