public class PKCS5Padding
extends java.lang.Object
An application wishing to use PKCS5Padding, specifies this in the transformation string when instantiating the Cipher class, e.g.:
Cipher des_cipher = Cipher.getInstance("DES/CBC/PKCS5Padding");
Modifier and Type | Field and Description |
---|---|
protected int |
blockSize_ |
protected static int |
DEFAULTBLOCKSIZE |
protected java.security.SecureRandom |
random_ |
Constructor and Description |
---|
PKCS5Padding() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.String |
getName()
Return the name of this padding.
|
byte[] |
pad(byte[] in,
int off,
int len)
Pads the specified sub-array of the given byte array.
|
protected byte[] |
padFinal(byte[] data,
int offset,
int length)
Finalize padding and return all padded bytes.
|
protected void |
setBlockSize(int blockSize) |
protected void |
setRandom(java.security.SecureRandom random)
Sets the random generator to be used (if required).
|
byte[] |
unpad(byte[] in,
int off,
int len)
Removes any padding bytes from the given padded message.
|
protected byte[] |
unpadFinal(byte[] data,
int offset,
int length)
Finalize unpadding and return all unpadded bytes.
|
protected static int DEFAULTBLOCKSIZE
protected int blockSize_
protected java.security.SecureRandom random_
public byte[] pad(byte[] in, int off, int len)
in
- - the byte array holding the message to be padded, big enough to
hold the padding string.off
- - the offset within the given byte array,
indicating the start position of the message to be paddedlen
- - the length of the message to be paddedpublic byte[] unpad(byte[] in, int off, int len)
in
- - the byte array holding the message to be unpadded.off
- - the offset within the given byte array,
indicating the start position of the padded messagelen
- - the length of the padded messageprotected byte[] padFinal(byte[] data, int offset, int length) throws javax.crypto.BadPaddingException, javax.crypto.IllegalBlockSizeException
data
- the final bytes to be padded, may be nulljavax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
protected byte[] unpadFinal(byte[] data, int offset, int length) throws javax.crypto.BadPaddingException, javax.crypto.IllegalBlockSizeException
data
- the final bytes to be unpadded, may be nulljavax.crypto.BadPaddingException
javax.crypto.IllegalBlockSizeException
protected java.lang.String getName()
protected void setBlockSize(int blockSize)
protected void setRandom(java.security.SecureRandom random)
random
- the random generator to be usedIAIK JavaSecurity Website https://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2023 IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved. Version 1.9.4