TrueZIP 6.8.3

de.schlichtherle.crypto.modes
Class SICSeekableBlockCipher

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

public class SICSeekableBlockCipher
extends Object
implements SeekableBlockCipher

Implements the Segmented Integer Counter (SIC) alias Counter (CTR) mode on top of a simple block cipher. This code is based on the SICBlockCipher class (as of version 1.30 of Bouncy Castle's Lightweight API for JDK 1.4), but also allows random access to a block.

Since:
TrueZIP 3.1
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[] counter
           
private  byte[] counterOut
           
private  byte[] IV
           
 
Constructor Summary
SICSeekableBlockCipher(BlockCipher c)
          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()
          return the underlying blockCounter cipher that we are wrapping.
 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

counter

private final byte[] counter

blockCounter

private long blockCounter

counterOut

private final byte[] counterOut
Constructor Detail

SICSeekableBlockCipher

public SICSeekableBlockCipher(BlockCipher c)
Basic constructor.

Parameters:
c - the blockCounter cipher to be used.
Method Detail

getUnderlyingCipher

public BlockCipher getUnderlyingCipher()
return the underlying blockCounter cipher that we are wrapping.

Returns:
the underlying blockCounter cipher that we are wrapping.

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 final 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 6.8.3

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