Top Description Fields Constructors Methods
org.bouncycastle.crypto.general

pack-priv Class Shacal2Engine

extends Object
implements BlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.internal.BlockCipher
Imports
org.bouncycastle.crypto.internal.BlockCipher, .CipherParameters, .DataLengthException, .OutputLengthException, org.bouncycastle.crypto.internal.params.KeyParameter

Block cipher Shacal2, designed by Helena Handschuh and David Naccache, based on hash function SHA-256, using SHA-256-Initialization-Values as data and SHA-256-Data as key.

A description of Shacal can be found at: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.4066 Best known cryptanalytic (Wikipedia 11.2013): Related-key rectangle attack on 44-rounds (Jiqiang Lu, Jongsung Kim). Comments are related to SHA-256-Naming as described in FIPS PUB 180-2

Field Summary

Modifier and TypeField and Description
private static final int
private boolean
private static final int[]
K

private static final int
private int[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
byteBlockToInts(byte[] bytes, int[] block, int bytesPos, int blockPos)

private void
bytes2ints(byte[] bytes, int[] block, int bytesPos, int blockPos)

private void
decryptBlock(byte[] in, int inOffset, byte[] out, int outOffset)

private void
encryptBlock(byte[] in, int inOffset, byte[] out, int outOffset)

public String
getAlgorithmName()

Implements org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.
public int
getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
public void
init(boolean
if true the cipher is initialised for encryption, if false for decryption.
_forEncryption
,
CipherParameters
the key and other data required by the cipher.
params
)

Implements org.bouncycastle.crypto.internal.BlockCipher.init.

Initialise the cipher.
private void
ints2bytes(int[] block, byte[] out, int pos)

public int
processBlock(byte[]
the array containing the input data.
in
,
int
offset into the in array the data starts at.
inOffset
,
byte[]
the array the output data will be copied into.
out
,
int
the offset into the out array the output will start at.
outOffset
)

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.
public void
public void
setKey(byte[] kb)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_SIZEback to summary
private static final int BLOCK_SIZE
forEncryptionback to summary
private boolean forEncryption
Kback to summary
private static final int[] K
ROUNDSback to summary
private static final int ROUNDS
workingKeyback to summary
private int[] workingKey

Constructor Detail

Shacal2Engineback to summary
public Shacal2Engine()

Method Detail

byteBlockToIntsback to summary
private void byteBlockToInts(byte[] bytes, int[] block, int bytesPos, int blockPos)
bytes2intsback to summary
private void bytes2ints(byte[] bytes, int[] block, int bytesPos, int blockPos)
decryptBlockback to summary
private void decryptBlock(byte[] in, int inOffset, byte[] out, int outOffset)
encryptBlockback to summary
private void encryptBlock(byte[] in, int inOffset, byte[] out, int outOffset)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.internal.BlockCipher.getAlgorithmName.

Return the name of the algorithm the cipher implements.

Returns:String

the name of the algorithm the cipher implements.

getBlockSizeback to summary
public int getBlockSize()

Implements org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Doc from org.bouncycastle.crypto.internal.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).

Returns:int

the block size for this cipher in bytes.

initback to summary
public void init(boolean _forEncryption, CipherParameters params) throws IllegalArgumentException

Implements org.bouncycastle.crypto.internal.BlockCipher.init.

Doc from org.bouncycastle.crypto.internal.BlockCipher.init.

Initialise the cipher.

Parameters
_forEncryption:boolean

if true the cipher is initialised for encryption, if false for decryption.

params:CipherParameters

the key and other data required by the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
ints2bytesback to summary
private void ints2bytes(int[] block, byte[] out, int pos)
processBlockback to summary
public int processBlock(byte[] in, int inOffset, byte[] out, int outOffset) throws DataLengthException, IllegalStateException

Implements org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Doc from org.bouncycastle.crypto.internal.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.

Parameters
in:byte[]

the array containing the input data.

inOffset:int

offset into the in array the data starts at.

out:byte[]

the array the output data will be copied into.

outOffset:int

the offset into the out array the output will start at.

Returns:int

the number of bytes processed and produced.

Exceptions
DataLengthException:
if there isn't enough data in in, or space in out.
IllegalStateException:
if the cipher isn't initialised.
resetback to summary
public void reset()

Implements org.bouncycastle.crypto.internal.BlockCipher.reset.

Doc from org.bouncycastle.crypto.internal.BlockCipher.reset.

Reset the cipher. After resetting the cipher is in the same state as it was after the last init (if there was one).

setKeyback to summary
public void setKey(byte[] kb)