TrueZIP Driver ZIP.RAES (TZP) 7.1

de.schlichtherle.truezip.crypto
Class SICSeekableBlockCipher

java.lang.Object
  extended by de.schlichtherle.truezip.crypto.SICSeekableBlockCipher
All Implemented Interfaces:
SeekableBlockCipher, BlockCipher

public class SICSeekableBlockCipher
extends Object
implements SeekableBlockCipher

Implements Counter (CTR) mode (alias Segmented Integer Counter - SIC). on top of a simple block cipher. This code is based on bouncy castle's SICBlockCipher class, but also allows random access to a block.

Author:
The Legion of the Bouncy Castle (majority of the code), Christian Schlichtherle (optimizations and extension to support seeking)

Field Summary
private  long blockCounter
           
private  int blockSize
           
private  BlockCipher cipher
           
private  byte[] counterIn
           
private  byte[] counterOut
           
private  byte[] IV
           
 
Constructor Summary
SICSeekableBlockCipher(BlockCipher cipher)
          Basic constructor.
 
Method Summary
 String getAlgorithmName()
           
 long getBlockCounter()
          Returns the index of the block, starting at 0, which will be processed next when BlockCipher.processBlock(byte[], int, byte[], int) is called.
 int getBlockSize()
           
 BlockCipher getUnderlyingCipher()
          Returns the underlying block cipher which we are decorating.
 void init(boolean forEncryption, CipherParameters params)
           
 int processBlock(byte[] in, int inOff, byte[] out, int outOff)
           
 void reset()
           
 void setBlockCounter(long block)
          Sets the counter so that the block with the given index, starting at 0, can be processed next.
private  void updateCounter()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cipher

private final BlockCipher cipher

blockSize

private final int blockSize

IV

private final byte[] IV

counterIn

private final byte[] counterIn

blockCounter

private long blockCounter

counterOut

private final byte[] counterOut
Constructor Detail

SICSeekableBlockCipher

public SICSeekableBlockCipher(BlockCipher cipher)
Basic constructor.

Parameters:
cipher - The block cipher to be used.
Method Detail

getUnderlyingCipher

public BlockCipher getUnderlyingCipher()
Returns the underlying block cipher which we are decorating.

Returns:
The underlying block cipher which we are decorating.

init

public void init(boolean forEncryption,
                 CipherParameters params)
          throws IllegalArgumentException
Specified by:
init in interface BlockCipher
Throws:
IllegalArgumentException

getAlgorithmName

public String getAlgorithmName()
Specified by:
getAlgorithmName in interface BlockCipher

getBlockSize

public int getBlockSize()
Specified by:
getBlockSize in interface BlockCipher

processBlock

public int processBlock(byte[] in,
                        int inOff,
                        byte[] out,
                        int outOff)
                 throws DataLengthException,
                        IllegalStateException
Specified by:
processBlock in interface BlockCipher
Throws:
DataLengthException
IllegalStateException

updateCounter

private void updateCounter()

setBlockCounter

public void setBlockCounter(long block)
Description copied from interface: SeekableBlockCipher
Sets the counter so that the block with the given index, starting at 0, can be processed next.

Specified by:
setBlockCounter in interface SeekableBlockCipher
Parameters:
block - The index of the block, starting at 0, which will be processed next when BlockCipher.processBlock(byte[], int, byte[], int) is called.

getBlockCounter

public long getBlockCounter()
Description copied from interface: SeekableBlockCipher
Returns the index of the block, starting at 0, which will be processed next when BlockCipher.processBlock(byte[], int, byte[], int) is called.

Specified by:
getBlockCounter in interface SeekableBlockCipher

reset

public void reset()
Specified by:
reset in interface BlockCipher

TrueZIP Driver ZIP.RAES (TZP) 7.1

Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.