Top Description Fields Constructors Methods
org.bouncycastle.jcajce.provider.asymmetric.rsa

pack-priv Class CustomPKCS1Encoding

extends Object
implements AsymmetricBlockCipher
Class Inheritance
All Implemented Interfaces
org.bouncycastle.crypto.AsymmetricBlockCipher
Imports
java.security.SecureRandom, org.bouncycastle.crypto.AsymmetricBlockCipher, .CipherParameters, .CryptoServicesRegistrar, .InvalidCipherTextException, org.bouncycastle.crypto.encodings.PKCS1Encoding, org.bouncycastle.crypto.params.AsymmetricKeyParameter, .ParametersWithRandom, org.bouncycastle.util.Arrays, .Properties

this does your basic PKCS 1 v1.5 padding - whether or not you should be using this depends on your application - see PKCS1 Version 2 for details.

Field Summary

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

Constructor Summary

AccessConstructor and Description
pack-priv
CustomPKCS1Encoding(AsymmetricBlockCipher cipher)

Basic constructor.

Method Summary

Modifier and TypeMethod and Description
private static int
checkPkcs1Encoding1(byte[] buf)

Check the argument is a valid encoding with type 1.

private static int
checkPkcs1Encoding2(byte[] buf)

Check the argument is a valid encoding with type 2.

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

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

public int
getInputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getInputBlockSize.

returns the largest size an input block can be.
public int
getOutputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

returns the maximum size of the block produced by this cipher.
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.
private boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockBufferback to summary
private byte[] blockBuffer
engineback to summary
private AsymmetricBlockCipher engine
forEncryptionback to summary
private boolean forEncryption
forPrivateKeyback to summary
private boolean forPrivateKey
HEADER_LENGTHback to summary
private static final int HEADER_LENGTH
randomback to summary
private SecureRandom random
useStrictLengthback to summary
private boolean useStrictLength

Constructor Detail

CustomPKCS1Encodingback to summary
pack-priv CustomPKCS1Encoding(AsymmetricBlockCipher cipher)

Basic constructor.

Method Detail

checkPkcs1Encoding1back to summary
private static int checkPkcs1Encoding1(byte[] buf)

Check the argument is a valid encoding with type 1. Returns the plaintext length if valid, or -1 if invalid.

checkPkcs1Encoding2back to summary
private static int checkPkcs1Encoding2(byte[] buf)

Check the argument is a valid encoding with type 2. Returns the plaintext length if valid, or -1 if invalid.

decodeBlockback to summary
private byte[] decodeBlock(byte[] in, int inOff, int inLen) throws InvalidCipherTextException
Exceptions
InvalidCipherTextException:
if the decrypted block is not in PKCS1 format.
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.

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

returns the largest size an input block can be.

Returns:int

maximum size for an input block.

getOutputBlockSizeback to summary
public int getOutputBlockSize()

Implements org.bouncycastle.crypto.AsymmetricBlockCipher.getOutputBlockSize.

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

returns the maximum size of the block produced by this cipher.

Returns:int

maximum size of the output block produced by the cipher.

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.
useStrictback to summary
private boolean useStrict()