Class PKCS1Encoding
java.lang.Object
org.gudy.bouncycastle.crypto.encodings.PKCS1Encoding
- All Implemented Interfaces:
AsymmetricBlockCipher
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
FieldsModifier and TypeFieldDescriptionprivate AsymmetricBlockCipher
private boolean
private boolean
private static int
private SecureRandom
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate byte[]
decodeBlock
(byte[] in, int inOff, int inLen) private byte[]
encodeBlock
(byte[] in, int inOff, int inLen) int
returns the largest size an input block can be.int
returns the maximum size of the block produced by this cipher.void
init
(boolean forEncryption, CipherParameters param) initialise the cipher.byte[]
processBlock
(byte[] in, int inOff, int inLen) process the block of len bytes stored in in from offset inOff.
-
Field Details
-
HEADER_LENGTH
private static int HEADER_LENGTH -
random
-
engine
-
forEncryption
private boolean forEncryption -
forPrivateKey
private boolean forPrivateKey
-
-
Constructor Details
-
PKCS1Encoding
-
-
Method Details
-
getUnderlyingCipher
-
init
Description copied from interface:AsymmetricBlockCipher
initialise the cipher.- Specified by:
init
in interfaceAsymmetricBlockCipher
- 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()Description copied from interface:AsymmetricBlockCipher
returns the largest size an input block can be.- Specified by:
getInputBlockSize
in interfaceAsymmetricBlockCipher
- Returns:
- maximum size for an input block.
-
getOutputBlockSize
public int getOutputBlockSize()Description copied from interface:AsymmetricBlockCipher
returns the maximum size of the block produced by this cipher.- Specified by:
getOutputBlockSize
in interfaceAsymmetricBlockCipher
- Returns:
- maximum size of the output block produced by the cipher.
-
processBlock
Description copied from interface:AsymmetricBlockCipher
process the block of len bytes stored in in from offset inOff.- Specified by:
processBlock
in interfaceAsymmetricBlockCipher
- Parameters:
in
- the input datainOff
- offset into the in array where the data startsinLen
- the length of the block to be processed.- Returns:
- the resulting byte array of the encryption/decryption process.
- Throws:
InvalidCipherTextException
- data decrypts improperly.
-
encodeBlock
- Throws:
InvalidCipherTextException
-
decodeBlock
- Throws:
InvalidCipherTextException
- if the decrypted block is not in PKCS1 format.
-