|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
com.kirkwarez.kirkpack.io.uru.wdys.WDYSOutputStream
This stream streams in plain input data and streams out Uru WDYS encrypted data. Note that a length attribute is required upon construction. This is because the WDYS header requires the length of the unencrypted data to be set, and it cannot be determined from the stream. The encryption requires blocks of 2 times 4 bytes to work, and any padding will be done with zeroes.
Field Summary | |
protected byte[] |
block
The xTEA dual block buffer. |
private static int[] |
KEY
The key. |
protected int |
length
The length of the unencrypted data. |
protected int |
total
The amount of bytes written out. |
protected int |
unwritten
How much there's yet to be written to the buffers to make them full. |
static String |
WDYS_HEADER
The WDYS header. |
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary | |
WDYSOutputStream(OutputStream output,
int length)
Creates a stream over the given stream. |
Method Summary | |
protected int |
byteArrayToInt(byte[] bytes)
Makes a byte array of an int. |
protected byte[][] |
encrypt(byte[][] v)
The xTEA encryption algorithm. |
int |
getLength()
Returns the length of the unencrypted data, as written to the fileheader. |
protected byte[] |
intToByteArray(int value)
Makes an int out of a byte array. |
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. |
protected void |
writeToBuffer(byte[] buffer,
int offset,
int length)
Writes length bytes from the given array to the buffers from offset on. |
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 |
protected byte[] block
protected int unwritten
protected int length
protected int total
private static int[] KEY
public static final String WDYS_HEADER
Constructor Detail |
public WDYSOutputStream(OutputStream output, int length) throws IOException
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).
IOException
- When the given stream does not cooperate (we need to write the
header and the length attribute).Method Detail |
public void write(int value) throws IOException
value
- An int that represents a byte to be written out.
IOException
- When, you know, IO stuff.OutputStream.write(int)
public void write(byte[] buffer, int offset, int length) throws IOException
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.
IOException
OutputStream.write(byte[], int, int)
protected void writePadding() throws IOException
IOException
- When writing fails and stuff.protected void writeToBuffer(byte[] buffer, int offset, int length) throws IOException
buffer
- The buffer to write the data from.offset
- The starting offset.length
- The amount of bytes to write.
IOException
- When your HDD explodes.protected byte[][] encrypt(byte[][] v)
v
- The encrypted input blocks.
protected byte[] intToByteArray(int value)
value
- The int to turn into a byte array.
protected int byteArrayToInt(byte[] bytes)
bytes
- The byte array to turn into an int.
public int getLength()
protected void setLength(int length)
length
- The length of the unencrypted data.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |