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
FieldsModifier and TypeFieldDescriptionstatic final intMaximum random padding length.static final intMinimum random padding length in octets. -
Constructor Summary
ConstructorsConstructorDescriptionGenerate a new, randomPGPPaddingobject.PGPPadding(int len) Generate a new, randomPGPPaddingobject.PGPPadding(int len, SecureRandom random) Generate a new, randomPGPPaddingobject.PGPPadding(SecureRandom random) Generate a new, randomPGPPaddingobject.Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidencode(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, randomPGPPaddingobject. The padding consists of n random bytes, where n is a number between (inclusive)MIN_PADDING_LENandMAX_PADDING_LEN. -
PGPPadding
Generate a new, randomPGPPaddingobject. The padding consists of n random bytes, where n is a number between (inclusive)MIN_PADDING_LENandMAX_PADDING_LEN.- Parameters:
random- random number generator instance
-
PGPPadding
public PGPPadding(int len) Generate a new, randomPGPPaddingobject. The padding consists oflen
random bytes. -
PGPPadding
Generate a new, randomPGPPaddingobject. 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
-