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

public final Class BlowfishEngine

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

A class that provides Blowfish key encryption operations, such as encoding data and generating keys. All the algorithms herein are from Applied Cryptography and implement a simplified cryptography interface.

Field Summary

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

private static final int
private static final int
private final int[]
private final int[]
private final int[]
private final int[]
private static final int
private byte[]

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
Bits32ToBytes(int in, byte[] b, int offset)

private int
private int
BytesTo32bits(byte[] b, int i)

private void
decryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)

Decrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset.

private void
encryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)

Encrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset.

private int
F(int x)

public String
getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

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

Implements org.bouncycastle.crypto.BlockCipher.getBlockSize.

Return the block size for this cipher (in bytes).
private CryptoServicePurpose
public void
init(boolean
whether or not we are for encryption.
encrypting
,
CipherParameters
the parameters required to set up the cipher.
params
)

Implements org.bouncycastle.crypto.BlockCipher.init.

initialise a Blowfish cipher.
public final int
processBlock(byte[]
the array containing the input data.
in
,
int
offset into the in array the data starts at.
inOff
,
byte[]
the array the output data will be copied into.
out
,
int
the offset into the out array the output will start at.
outOff
)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Process one block of input from the array in and write it to the out array.
private void
processTable(int xl, int xr, int[] table)

apply the encryption cycle to each value pair in the table.

public void
reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Reset the cipher.
private void
setKey(byte[] key)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BLOCK_SIZEback to summary
private static final int BLOCK_SIZE
encryptingback to summary
private boolean encrypting
KPback to summary
private static final int[] KP
KS0back to summary
private static final int[] KS0
KS1back to summary
private static final int[] KS1
KS2back to summary
private static final int[] KS2
KS3back to summary
private static final int[] KS3
Pback to summary
private final int[] P
P_SZback to summary
private static final int P_SZ
ROUNDSback to summary
private static final int ROUNDS
S0back to summary
private final int[] S0
S1back to summary
private final int[] S1
S2back to summary
private final int[] S2
S3back to summary
private final int[] S3
SBOX_SKback to summary
private static final int SBOX_SK
workingKeyback to summary
private byte[] workingKey

Constructor Detail

BlowfishEngineback to summary
public BlowfishEngine()

Method Detail

Bits32ToBytesback to summary
private void Bits32ToBytes(int in, byte[] b, int offset)
bitsOfSecurityback to summary
private int bitsOfSecurity()
BytesTo32bitsback to summary
private int BytesTo32bits(byte[] b, int i)
decryptBlockback to summary
private void decryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)

Decrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. The input will be an exact multiple of our blocksize.

encryptBlockback to summary
private void encryptBlock(byte[] src, int srcIndex, byte[] dst, int dstIndex)

Encrypt the given input starting at the given offset and place the result in the provided buffer starting at the given offset. The input will be an exact multiple of our blocksize.

Fback to summary
private int F(int x)
getAlgorithmNameback to summary
public String getAlgorithmName()

Implements org.bouncycastle.crypto.BlockCipher.getAlgorithmName.

Doc from org.bouncycastle.crypto.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.BlockCipher.getBlockSize.

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

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

Returns:int

the block size for this cipher in bytes.

getPurposeback to summary
private CryptoServicePurpose getPurpose()
initback to summary
public void init(boolean encrypting, CipherParameters params)

Implements org.bouncycastle.crypto.BlockCipher.init.

initialise a Blowfish cipher.

Parameters
encrypting:boolean

whether or not we are for encryption.

params:CipherParameters

the parameters required to set up the cipher.

Exceptions
IllegalArgumentException:
if the params argument is inappropriate.
processBlockback to summary
public final int processBlock(byte[] in, int inOff, byte[] out, int outOff)

Implements org.bouncycastle.crypto.BlockCipher.processBlock.

Doc from org.bouncycastle.crypto.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.

inOff:int

offset into the in array the data starts at.

out:byte[]

the array the output data will be copied into.

outOff:int

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

Returns:int

the number of bytes processed and produced.

processTableback to summary
private void processTable(int xl, int xr, int[] table)

apply the encryption cycle to each value pair in the table.

resetback to summary
public void reset()

Implements org.bouncycastle.crypto.BlockCipher.reset.

Doc from org.bouncycastle.crypto.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
private void setKey(byte[] key)