com.kirkwarez.kirkpack.io.eoa.wdysv
Class WDYSVOutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byjava.io.FilterOutputStream
          extended bycom.kirkwarez.kirkpack.io.eoa.wdysv.WDYSVOutputStream

public class WDYSVOutputStream
extends FilterOutputStream

This stream streams in plain input data and streams out MYST V encrypted data. Note that a length attribute is required upon construction. This is because the WDYSV header requires the length of the unencrypted data to be set, and it cannot be determined from the stream. The encryption requires blocks of 16 bytes to work, and any padding will be done with zeroes.

Since:
3.00
Version:
3.00
Author:
Berend "Kirk" Wouda

Field Summary
protected static int BLOCKSIZE
          The blocksize.
private static byte[] KEY
          The key.
protected  int length
          The length of the unencrypted data.
protected  int total
          The amount of bytes written out.
static int WDYSV_HEADER
          The WDYSV header.
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
WDYSVOutputStream(OutputStream output, int length)
          Creates a stream over the given stream.
 
Method Summary
 int getLength()
          Returns the length of the unencrypted data, as written to the fileheader.
protected  void setLength(int length)
          Sets the length of the unencrypted data, as written to the fileheader.
 void write(byte[] buffer, int offset, int length)
          Writes the given byte array to the underlying steam using the given subselection.
 void write(int value)
          Writes the given byte (well, int) to the underlying steam.
protected  void writePadding()
          Writes out padding to fill up the blocksize.
 
Methods inherited from class java.io.FilterOutputStream
close, flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

protected int length
The length of the unencrypted data.


total

protected int total
The amount of bytes written out.


KEY

private static byte[] KEY
The key. Ssh!


BLOCKSIZE

protected static final int BLOCKSIZE
The blocksize.

See Also:
Constant Field Values

WDYSV_HEADER

public static final int WDYSV_HEADER
The WDYSV header.

See Also:
Constant Field Values
Constructor Detail

WDYSVOutputStream

public WDYSVOutputStream(OutputStream output,
                         int length)
                  throws IOException
Creates a stream over the given stream.

Parameters:
output - The stream to write to.
length - The length of the data that will be written into this stream (needed for the header, and also for padding).
Throws:
IOException - When the given stream does not cooperate (we need to write the header and the length attribute).
Method Detail

write

public void write(int value)
           throws IOException
Writes the given byte (well, int) to the underlying steam. When the length indicated at construction time is reached, no more bytes are written out.

Parameters:
value - An int that represents a byte to be written out.
Throws:
IOException - When, you know, IO stuff.
See Also:
OutputStream.write(int)

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws IOException
Writes the given byte array to the underlying steam using the given subselection. When the length indicated at construction time is reached, no more bytes are written out.

Parameters:
buffer - The byte buffer with data.
offset - The starting point of where to start getting the data.
length - The amount of data to write, taken from offset on.
Throws:
IOException
See Also:
OutputStream.write(byte[], int, int)

writePadding

protected void writePadding()
                     throws IOException
Writes out padding to fill up the blocksize. The blocksize is 16 bytes.

Throws:
IOException - When writing fails and stuff.

getLength

public int getLength()
Returns the length of the unencrypted data, as written to the fileheader.

Returns:
length The length of the unencrypted data.

setLength

protected void setLength(int length)
Sets the length of the unencrypted data, as written to the fileheader.

Parameters:
length - The length of the unencrypted data.