cryptix.provider.cipher

Class SPEED

Implemented Interfaces:
Parameterized, SymmetricCipher

public final class SPEED
extends Cipher
implements SymmetricCipher

SPEED is a block cipher with variable key size, data block size and number of rounds (in the style of RC5).

These parameters are set as follows:

These are recommended settings for 'adequate' security:

    +--------------------------------------------------+
    |   block size   |   key length   |     rounds     |
    |==================================================|
    |       8        |      >= 8      |     >= 64      |
    |--------------------------------------------------|
    |      16        |      >= 8      |     >= 48      |
    |--------------------------------------------------|
    |      32        |      >= 8      |     >= 48      |
    +--------------------------------------------------+
 

SPEED was designed by Yuliang Zheng, and is in the public domain.

References:

  1. Y. Zheng "The SPEED Cipher," Proceedings of Financial Cryptography 97, Springer-Verlag (forthcoming). FC97 held at Anguilla, BWI, 24-28 February 1997.

Copyright © 1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.6 $

Authors:
Systemics Ltd
David Hopwood
Since:
Cryptix 2.2.2

Field Summary

Fields inherited from class xjava.security.Cipher

DECRYPT, ENCRYPT, UNINITIALIZED

Fields inherited from class xjava.security.IJCE_Traceable

tracing

Constructor Summary

SPEED()
Constructs a SPEED cipher object, in the UNINITIALIZED state.

Method Summary

protected void
blockDecrypt(in[] , int in_offset, out[] , int out_offset)
Decrypts a block.
protected void
blockEncrypt(in[] , int in_offset, out[] , int out_offset)
Encrypts a block.
Object
clone()
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).
(package private) void
dump()
protected int
engineBlockSize()
SPI: Return the data block length of this cipher.
protected Object
engineGetParameter(String param)
SPI: Gets the value of the specified algorithm parameter.
void
engineInitDecrypt(Key key)
SPI: Initializes this cipher for decryption, using the specified key.
void
engineInitEncrypt(Key key)
SPI: Initializes this cipher for encryption, using the specified key.
protected void
engineSetParameter(String param, Object value)
SPI: Sets the specified algorithm parameter to the specified value.
protected int
engineUpdate(byte[] in, int inOffset, int inLen, byte[] out, int outOffset)
SPI: This is the main engine method for updating data.
protected void
finalize()
Cleans up resources used by this instance, if necessary.
static LinkStatus
getLinkStatus()
Gets an object representing the native linking status of this class.
int
getRounds()
Returns the currently set number of rounds for this instance.
static void
main(argv[] )
Entry point for self_test.
static void
self_test(PrintWriter out, argv[] )
Runs algorithm through test data, including certification data provided in paper.
void
setBlockSize(int blocksize)
Sets the block size in bytes for this cipher.
void
setRounds(int rounds)
Sets the number of rounds for this cipher.

Methods inherited from class xjava.security.Cipher

blockSize, clone, crypt, crypt, crypt, doFinal, doFinal, doFinal, doFinal, engineBlockSize, engineCiphertextBlockSize, engineCrypt, engineGetParameter, engineInBufferSize, engineInitDecrypt, engineInitEncrypt, engineOutBufferSize, enginePlaintextBlockSize, engineSetPaddingScheme, engineSetParameter, engineUpdate, getAlgorithm, getAlgorithms, getAlgorithms, getCiphertextBlockSize, getInputBlockSize, getInstance, getInstance, getInstance, getMode, getOutputBlockSize, getPadding, getPaddingScheme, getParameter, getPlaintextBlockSize, getProvider, getState, inBufferSize, inBufferSizeFinal, initDecrypt, initEncrypt, isPaddingBlockCipher, outBufferSize, outBufferSizeFinal, setParameter, toString, update, update, update, update

Methods inherited from class xjava.security.IJCE_Traceable

disableTracing, enableTracing, traceMethod, traceResult, traceResult, traceVoidMethod

Constructor Details

SPEED

public SPEED()
Constructs a SPEED cipher object, in the UNINITIALIZED state. This calls the Cipher constructor with implBuffering false, implPadding false and the provider set to "Cryptix".

Method Details

blockDecrypt

protected void blockDecrypt(in[] ,
                            int in_offset,
                            out[] ,
                            int out_offset)
Decrypts a block. The in and out buffers can be the same.
Parameters:
in_offset - The start of data within the in buffer.
out_offset - The start of data within the out buffer.

blockEncrypt

protected void blockEncrypt(in[] ,
                            int in_offset,
                            out[] ,
                            int out_offset)
Encrypts a block. The in and out buffers can be the same.
Parameters:
in_offset - The start of data within the in buffer.
out_offset - The start of data within the out buffer.

clone

public final Object clone()
            throws CloneNotSupportedException
Always throws a CloneNotSupportedException (cloning of ciphers is not supported for security reasons).
Overrides:
clone in interface Cipher

dump

(package private)  void dump()

engineBlockSize

protected int engineBlockSize()
SPI: Return the data block length of this cipher. Default (8 bytes) is returned before instantiation, actual length used by object returned after instantiation.
Overrides:
engineBlockSize in interface Cipher
Returns:
the block length in bytes.

engineGetParameter

protected Object engineGetParameter(String param)
            throws NoSuchParameterException,
                   InvalidParameterException
SPI: Gets the value of the specified algorithm parameter.

SPEED has two parameters:

  • "rounds", which specifies the number of rounds for this instance as a decimal String.
  • "blockSize", which specifies the block size for this instance, also as a decimal String.
Overrides:
engineGetParameter in interface Cipher
Parameters:
param - the string name of the parameter.
Returns:
the object that represents the parameter value, or null if there is none.

engineInitDecrypt

public void engineInitDecrypt(Key key)
            throws InvalidKeyException,
                   CryptixException
SPI: Initializes this cipher for decryption, using the specified key.
Overrides:
engineInitDecrypt in interface Cipher
Parameters:
key - the key to use for decryption.

engineInitEncrypt

public void engineInitEncrypt(Key key)
            throws InvalidKeyException
SPI: Initializes this cipher for encryption, using the specified key.
Overrides:
engineInitEncrypt in interface Cipher
Parameters:
key - the key to use for encryption.

engineSetParameter

protected void engineSetParameter(String param,
                                  Object value)
            throws NoSuchParameterException,
                   InvalidParameterException,
                   InvalidParameterTypeException
SPI: Sets the specified algorithm parameter to the specified value.

SPEED has two parameters:

  • "rounds", which specifies the number of rounds for this instance as a decimal String.
  • "blockSize", which specifies the block size for this instance, also as a decimal String.
Overrides:
engineSetParameter in interface Cipher
Parameters:
param - the string name of the parameter.
value - the parameter value.
Throws:
InvalidParameterTypeException - if value is of the wrong type.

engineUpdate

protected int engineUpdate(byte[] in,
                           int inOffset,
                           int inLen,
                           byte[] out,
                           int outOffset)
SPI: This is the main engine method for updating data.

in and out may be the same array, and the input and output regions may overlap.

Overrides:
engineUpdate in interface Cipher
Parameters:
in - the input data.
inOffset - the offset into in specifying where the data starts.
inLen - the length of the subarray.
out - the output array.
outOffset - the offset indicating where to start writing into the out array.
Returns:
the number of bytes written.

finalize

protected final void finalize()
Cleans up resources used by this instance, if necessary.

getLinkStatus

public static LinkStatus getLinkStatus()
Gets an object representing the native linking status of this class.

getRounds

public int getRounds()
Returns the currently set number of rounds for this instance.
Returns:
the number of rounds.

main

public static final void main(argv[] )
Entry point for self_test.

self_test

public static void self_test(PrintWriter out,
                             argv[] )
            throws Exception
Runs algorithm through test data, including certification data provided in paper.

setBlockSize

public void setBlockSize(int blocksize)
Sets the block size in bytes for this cipher. Allowed only when this cipher is in the UNINITIALIZED state; otherwise an exception is thrown.

If the specified number is invalid, an IllegalArgumentException is thrown.

Parameters:
blocksize - the desired block size in bytes: 8, 16 or 32

setRounds

public void setRounds(int rounds)
Sets the number of rounds for this cipher. Allowed only when this cipher is in the UNINITIALIZED state; otherwise an exception is thrown.

If the specified number is invalid, an IllegalArgumentException is thrown.

Parameters:
rounds - the desired number of rounds: >= 32, multiple of 4