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

public Class ISO9796d1Encoding

extends Object
implements AsymmetricBlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.AsymmetricBlockCipher
Imports
java.math.BigInteger, org.bouncycastle.crypto.AsymmetricBlockCipher, .CipherParameters, .InvalidCipherTextException, org.bouncycastle.crypto.params.ParametersWithRandom, .RSAKeyParameters

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.

Field Summary

Modifier and TypeField and Description
private int
private AsymmetricBlockCipher
private boolean
private static byte[]
private BigInteger
private int
private static byte[]
private static final BigInteger
private static final BigInteger

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static byte[]
private byte[]
decodeBlock(byte[] in, int inOff, int inLen)

private byte[]
encodeBlock(byte[] in, int inOff, int inLen)

public int
public int
getOutputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

return the maximum possible size for the output.
public int
getPadBits()

retrieve the number of pad bits in the last decoded message.

public AsymmetricBlockCipher
public void
init(boolean
if true the cipher is initialised for encryption, if false for decryption.
forEncryption
,
CipherParameters
the key and other data required by the cipher.
param
)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.init.

initialise the cipher.
public byte[]
processBlock(byte[]
the input data
in
,
int
offset into the in array where the data starts
inOff
,
int
the length of the block to be processed.
inLen
)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.processBlock.

process the block of len bytes stored in in from offset inOff.
public void
setPadBits(int padBits)

set the number of bits in the next message to be treated as pad bits.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bitSizeback to summary
private int bitSize
engineback to summary
private AsymmetricBlockCipher engine
forEncryptionback to summary
private boolean forEncryption
inverseback to summary
private static byte[] inverse
modulusback to summary
private BigInteger modulus
padBitsback to summary
private int padBits
shadowsback to summary
private static byte[] shadows
SIXback to summary
private static final BigInteger SIX
SIXTEENback to summary
private static final BigInteger SIXTEEN

Constructor Detail

ISO9796d1Encodingback to summary
public ISO9796d1Encoding(AsymmetricBlockCipher cipher)

Method Detail

convertOutputDecryptOnlyback to summary
private static byte[] convertOutputDecryptOnly(BigInteger result)
decodeBlockback to summary
private byte[] decodeBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException
Exceptions
InvalidCipherTextException:
if the decrypted block is not a valid ISO 9796 bit string
encodeBlockback to summary
private byte[] encodeBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException
getInputBlockSizeback to summary
public int getInputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.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.

Returns:int

Doc from org.bouncycastle.crypto.AsymmetricBlockCipher.getInputBlockSize.

maximum size for an input block.

getOutputBlockSizeback to summary
public int getOutputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

return the maximum possible size for the output.

Returns:int

Doc from org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

maximum size of the output block produced by the cipher.

getPadBitsback to summary
public int getPadBits()

retrieve the number of pad bits in the last decoded message.

getUnderlyingCipherback to summary
public AsymmetricBlockCipher getUnderlyingCipher()
initback to summary
public void init(boolean forEncryption, CipherParameters param)

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.init.

Doc from org.bouncycastle.crypto.AsymmetricBlockCipher.init.

initialise the cipher.

Parameters
forEncryption:boolean

if true the cipher is initialised for encryption, if false for decryption.

param:CipherParameters

the key and other data required by the cipher.

processBlockback to summary
public byte[] processBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.processBlock.

Doc from org.bouncycastle.crypto.AsymmetricBlockCipher.processBlock.

process the block of len bytes stored in in from offset inOff.

Parameters
in:byte[]

the input data

inOff:int

offset into the in array where the data starts

inLen:int

the length of the block to be processed.

Returns:byte[]

the resulting byte array of the encryption/decryption process.

Exceptions
InvalidCipherTextException:
data decrypts improperly.
setPadBitsback to summary
public void setPadBits(int padBits)

set the number of bits in the next message to be treated as pad bits.