de.flexiprovider.core.shacal2
Class Shacal2
java.lang.Object
|
+--javax.crypto.CipherSpi
|
+--de.flexiprovider.api.Cipher
|
+--de.flexiprovider.api.BlockCipher
|
+--de.flexiprovider.core.shacal2.Shacal2
- public class Shacal2
- extends BlockCipher
SHACAL-2 is 256-bit symmetric block cipher with a SHA-2 structure, jointly
developed by Helena Handschuh and David Naccache. It supports keys of various
lengths (between 128 and 512 bits). Encrypting and decryption of a block of
data is achieved in 64 rounds.
For more information, see here.
- Author:
- Paul Nguentcheu
|
Field Summary |
static java.lang.String |
ALG_NAME
The algorithm name. |
(package private) int[] |
K
Constant words K0...63
These are the first thirty-two bits of the fractional parts of the cube
roots of the first sixty-four primes. |
|
Method Summary |
protected int |
getCipherBlockSize()
This method returns the blocksize, the algorithm uses. |
int |
getKeySize(Key key)
Returns the key size of the given key object. |
java.lang.String |
getName()
|
protected void |
initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
This method guarantees the AlgorithmParameterSpec compatibility. |
protected void |
initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
This method guarantees the AlgorithmParameterSpec compatibility. |
void |
keySchedule(byte[] key)
This method implements the Shacal2 Key schedule. |
protected void |
singleBlockDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
This method decrypts a single block of data, and may only be called, if
the block cipher is in decrytion mode. |
protected void |
singleBlockEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
This method encrypts a single block of data, and may only be called, if
the block cipher is in encrytion mode. |
| Methods inherited from class de.flexiprovider.api.BlockCipher |
doFinal, doFinal, engineInit, getBlockSize, getIV, getOutputSize, getParameters, initDecrypt, initDecrypt, initDecrypt, initEncrypt, initEncrypt, initEncrypt, initEncrypt, setMode, setPadding, update, update |
| Methods inherited from class de.flexiprovider.api.Cipher |
doFinal, doFinal, engineDoFinal, engineDoFinal, engineGetBlockSize, engineGetIV, engineGetKeySize, engineGetOutputSize, engineGetParameters, engineInit, engineInit, engineSetMode, engineSetPadding, engineUpdate, engineUpdate, update |
| Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ALG_NAME
public static final java.lang.String ALG_NAME
- The algorithm name.
K
int[] K
- Constant words K0...63
These are the first thirty-two bits of the fractional parts of the cube
roots of the first sixty-four primes.
Shacal2
public Shacal2()
getName
public java.lang.String getName()
- Overrides:
getName in class Cipher
- Returns:
- the name of this cipher
getCipherBlockSize
protected int getCipherBlockSize()
- This method returns the blocksize, the algorithm uses. This method will
normaly be called by the padding scheme. It must be assured, that this
method is exclusivly called, when the algorithm is either in encryption
or in decryption mode. The blocksize in Shacal2 is always 32 bytes.
- Overrides:
getCipherBlockSize in class BlockCipher
- Returns:
- the used blocksize
getKeySize
public int getKeySize(Key key)
throws InvalidKeyException
- Returns the key size of the given key object. Checks whether the key
object is an instance of
Shacal2Key or
SecretKeySpec.
- Overrides:
getKeySize in class Cipher
- Parameters:
key - the key object- Returns:
- the key size of the given key object.
- Throws:
InvalidKeyException - if the key is invalid.
keySchedule
public void keySchedule(byte[] key)
- This method implements the Shacal2 Key schedule.
- Parameters:
key - the byte array containing the data for the key.
initCipherEncrypt
protected void initCipherEncrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- This method guarantees the AlgorithmParameterSpec compatibility. As these
are not used here it just calls the origin InitDecrypt method.
- Overrides:
initCipherEncrypt in class BlockCipher
- Parameters:
key - the SecretKey which has to be used to decrypt data.params - algorithmParameterSpec, not used for here- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipher.
initCipherDecrypt
protected void initCipherDecrypt(SecretKey key,
AlgorithmParameterSpec params)
throws InvalidKeyException
- This method guarantees the AlgorithmParameterSpec compatibility. As these
are not used here it just calls the origin InitDecrypt method.
- Overrides:
initCipherDecrypt in class BlockCipher
- Parameters:
key - the SecretKey which has to be used to decrypt data.params - algorithmParameterSpec, not used for here- Throws:
InvalidKeyException - if the given key is inappropriate for initializing this
cipher.
singleBlockDecrypt
protected void singleBlockDecrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
- This method decrypts a single block of data, and may only be called, if
the block cipher is in decrytion mode. It has to be asured that the array
in contains a whole block starting at inOffset and that
out is large enough to hold an decrypted block starting at
outOffset
- Overrides:
singleBlockDecrypt in class BlockCipher
- Parameters:
input - array of bytes which contains the ciphertext to be decryptedinOff - index in array in, where the ciphertext block startsoutput - array of bytes which will contain the plaintext starting at
outOffsetoutOff - index in array out, where the plaintext block will start
singleBlockEncrypt
protected void singleBlockEncrypt(byte[] input,
int inOff,
byte[] output,
int outOff)
- This method encrypts a single block of data, and may only be called, if
the block cipher is in encrytion mode. It has to be asured that the array
in contains a whole block starting at inOffset and that
out is large enough to hold an encrypted block starting at
outOffset
- Overrides:
singleBlockEncrypt in class BlockCipher
- Parameters:
input - array of bytes which contains the plaintext to be encryptedinOff - index in array in, where the plaintext block startsoutput - array of bytes which will contain the ciphertext startig at
outOffsetoutOff - index in array out, where the ciphertext block will start