| cryptix.jce.provider.cipher.BlockCipher cryptix.jce.provider.cipher.Blowfish
Blowfish | final public class Blowfish extends BlockCipher (Code) | | This class implements the Blowfish algorithm (standard, 16 round version).
Blowfish is a symmetric block cipher, with a 64-bit blocksize and a variable
key length (between 40 and 448 bits inclusive, in 8-bit increments).
References:
- Bruce Schneier,
"Section 14.3 Blowfish,"
Applied Cryptography, 2nd edition,
John Wiley & Sons, 1996
- Bruce Schneier,
Description of a New Variable-Length Key, 64-Bit Cipher (Blowfish),
Fast Software Encryption Cambridge Security Workshop Proceedings,
Springer-Verlag, 1004, pp 191-204.
-
http://www.counterpane.com/blowfish.html
The implementation is heavily optimized (but we can still do better):
- The P-box and S-box data is encoded in a string to save on
.class-file size
- P-box entries are stored in individual integers Pxx
- The loops have been unrolled
- Encryption & decryption use the same algorithm
Speed optimizations thanks to Peter Hjelt .
Additional speed and size optimizations by gelderen .
version: $Revision: 1.1 $ author: Systemics Ltd. author: David Hopwood author: Jeroen C. van Gelderen (gelderen@cryptix.org) author: Raif S. Naffah (raif@cryptix.org) |
Method Summary | |
protected void | coreCrypt(byte[] in, int inOffset, byte[] out, int outOffset) Encrypt or decrypt a single block of data. | protected void | coreInit(Key key, boolean decrypt) Initialize the object for encryption or decryption, given a Key.
This method expects a key with algorithm 'Blowfish' and
format 'RAW'. |
Blowfish | public Blowfish()(Code) | | |
coreCrypt | protected void coreCrypt(byte[] in, int inOffset, byte[] out, int outOffset)(Code) | | Encrypt or decrypt a single block of data.
Parameters: in - array containing datablock to be encrypted Parameters: inOffset - where the datablock starts Parameters: out - array where the output is to be stored Parameters: outOffset - where the output should start |
coreInit | protected void coreInit(Key key, boolean decrypt) throws InvalidKeyException(Code) | | Initialize the object for encryption or decryption, given a Key.
This method expects a key with algorithm 'Blowfish' and
format 'RAW'. Both are case insensitive.
FIXME: checks need overhaul (or moved out to superclass).
Parameters: key - key Parameters: decrypt - true for decrypt mode, false for encrypt mode throws: InvalidKeyException - when key==null or getAlgorithm()!=Blowfishor getFormat()!=RAW or getEncoded()==null or size<40 orsize>448 |
Methods inherited from cryptix.jce.provider.cipher.BlockCipher | final public Object clone() throws CloneNotSupportedException(Code)(Java Doc) abstract void coreCrypt(byte[] in, int inOffset, byte[] out, int outOffset)(Code)(Java Doc) int coreGetBlockSize()(Code)(Java Doc) abstract void coreInit(Key key, boolean decrypt) throws InvalidKeyException(Code)(Java Doc) final protected int engineDoFinal(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException, IllegalBlockSizeException, BadPaddingException(Code)(Java Doc) final protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen) throws IllegalBlockSizeException, BadPaddingException(Code)(Java Doc) final protected int engineGetBlockSize()(Code)(Java Doc) final protected byte[] engineGetIV()(Code)(Java Doc) protected int engineGetKeySize(Key key) throws InvalidKeyException(Code)(Java Doc) final protected int engineGetOutputSize(int inputLen)(Code)(Java Doc) final protected AlgorithmParameters engineGetParameters()(Code)(Java Doc) final protected void engineInit(int opmode, Key key, SecureRandom random) throws InvalidKeyException(Code)(Java Doc) final protected void engineInit(int opmode, Key key, AlgorithmParameterSpec params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException(Code)(Java Doc) final protected void engineInit(int opmode, Key key, AlgorithmParameters params, SecureRandom random) throws InvalidKeyException, InvalidAlgorithmParameterException(Code)(Java Doc) final protected void engineSetMode(String mode) throws NoSuchAlgorithmException(Code)(Java Doc) final protected void engineSetPadding(String padding) throws NoSuchPaddingException(Code)(Java Doc) final protected int engineUpdate(byte[] input, int inputOffset, int inputLen, byte[] output, int outputOffset) throws ShortBufferException(Code)(Java Doc) final protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)(Code)(Java Doc)
|
|
|