Package org.bouncycastle.openpgp
Class PGPPadding
java.lang.Object
org.bouncycastle.openpgp.PGPPadding
The PGPPadding contains random data, and can be used to defend against traffic analysis on version 2 SEIPD messages
and Transferable Public Keys.
Such a padding packet MUST be ignored when received.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Maximum random padding length.static final int
Minimum random padding length in octets. -
Constructor Summary
ConstructorDescriptionGenerate a new, randomPGPPadding
object.PGPPadding
(int len) Generate a new, randomPGPPadding
object.PGPPadding
(int len, SecureRandom random) Generate a new, randomPGPPadding
object.PGPPadding
(SecureRandom random) Generate a new, randomPGPPadding
object.Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
encode
(OutputStream outStream) byte[]
byte[]
getEncoded
(PacketFormat format) byte[]
Return the padding octets as a byte array.
-
Field Details
-
MIN_PADDING_LEN
public static final int MIN_PADDING_LENMinimum random padding length in octets. Chosen totally arbitrarily.- See Also:
-
MAX_PADDING_LEN
public static final int MAX_PADDING_LENMaximum random padding length. Chosen somewhat arbitrarily, as SSH also uses max 255 bytes for random padding.- See Also:
-
-
Constructor Details
-
PGPPadding
Default constructor.- Parameters:
in
- packet input stream- Throws:
IOException
-
PGPPadding
public PGPPadding()Generate a new, randomPGPPadding
object. The padding consists of n random bytes, where n is a number between (inclusive)MIN_PADDING_LEN
andMAX_PADDING_LEN
. -
PGPPadding
Generate a new, randomPGPPadding
object. The padding consists of n random bytes, where n is a number between (inclusive)MIN_PADDING_LEN
andMAX_PADDING_LEN
.- Parameters:
random
- random number generator instance
-
PGPPadding
public PGPPadding(int len) Generate a new, randomPGPPadding
object. The padding consists oflen
random bytes. -
PGPPadding
Generate a new, randomPGPPadding
object. The padding consists oflen
random bytes.- Parameters:
len
- number of random octetsrandom
- random number generator instance
-
-
Method Details
-
getPadding
public byte[] getPadding()Return the padding octets as a byte array.- Returns:
- padding octets
-
encode
- Throws:
IOException
-
getEncoded
- Throws:
IOException
-
getEncoded
- Throws:
IOException
-