org.bouncycastle.crypto.encodings
Class ISO9796d1Encoding
java.lang.Object
|
+--org.bouncycastle.crypto.encodings.ISO9796d1Encoding
- All Implemented Interfaces:
- AsymmetricBlockCipher
- public class ISO9796d1Encoding
- extends java.lang.Object
- implements AsymmetricBlockCipher
ISO 9796-1 padding. Note in the light of recent results you should
only use this with RSA (rather than the "simpler" Rabin keys) and you
should never use it with anything other than a hash (ie. even if the
message is small don't sign the message, sign it's hash) or some "random"
value. See your favorite search engine for details.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ISO9796d1Encoding
public ISO9796d1Encoding(AsymmetricBlockCipher cipher)
getUnderlyingCipher
public AsymmetricBlockCipher getUnderlyingCipher()
init
public void init(boolean forEncryption,
CipherParameters param)
- Description copied from interface:
AsymmetricBlockCipher
- initialise the cipher.
- Specified by:
init
in interface AsymmetricBlockCipher
- Following copied from interface:
org.bouncycastle.crypto.AsymmetricBlockCipher
- Parameters:
forEncryption
- if true the cipher is initialised for
encryption, if false for decryption.param
- the key and other data required by the cipher.
getInputBlockSize
public int getInputBlockSize()
- return the input block size. The largest message we can process
is (key_size_in_bits + 3)/16, which in our world comes to
key_size_in_bytes / 2.
- Specified by:
getInputBlockSize
in interface AsymmetricBlockCipher
- Following copied from interface:
org.bouncycastle.crypto.AsymmetricBlockCipher
- Returns:
- maximum size for an input block.
getOutputBlockSize
public int getOutputBlockSize()
- return the maximum possible size for the output.
- Specified by:
getOutputBlockSize
in interface AsymmetricBlockCipher
- Following copied from interface:
org.bouncycastle.crypto.AsymmetricBlockCipher
- Returns:
- maximum size of the output block produced by the cipher.
setPadBits
public void setPadBits(int padBits)
- set the number of bits in the next message to be treated as
pad bits.
getPadBits
public int getPadBits()
- retrieve the number of pad bits in the last decoded message.
processBlock
public byte[] processBlock(byte[] in,
int inOff,
int inLen)
throws InvalidCipherTextException
- Description copied from interface:
AsymmetricBlockCipher
- process the block of len bytes stored in in from offset inOff.
- Specified by:
processBlock
in interface AsymmetricBlockCipher
- Following copied from interface:
org.bouncycastle.crypto.AsymmetricBlockCipher
- Parameters:
in
- the input datainOff
- offset into the in array where the data startslen
- the length of the block to be processed.- Returns:
- the resulting byte array of the encryption/decryption process.
- Throws:
InvalidCipherTextException
- data decrypts improperly.DataLengthException
- the input data is too large for the cipher.