Class PGPPadding


  • public class PGPPadding
    extends java.lang.Object
    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 Detail

      • MIN_PADDING_LEN

        public static final int MIN_PADDING_LEN
        Minimum random padding length in octets. Chosen totally arbitrarily.
        See Also:
        Constant Field Values
    • Constructor Detail

      • PGPPadding

        public PGPPadding​(BCPGInputStream in)
                   throws java.io.IOException
        Default constructor.
        Parameters:
        in - packet input stream
        Throws:
        java.io.IOException
      • PGPPadding

        public PGPPadding​(java.security.SecureRandom random)
        Generate a new, random PGPPadding object. The padding consists of n random bytes, where n is a number between (inclusive) MIN_PADDING_LEN and MAX_PADDING_LEN.
        Parameters:
        random - random number generator instance
      • PGPPadding

        public PGPPadding​(int len)
        Generate a new, random PGPPadding object. The padding consists of len random bytes.
      • PGPPadding

        public PGPPadding​(int len,
                          java.security.SecureRandom random)
        Generate a new, random PGPPadding object. The padding consists of len random bytes.
        Parameters:
        len - number of random octets
        random - random number generator instance
    • Method Detail

      • getPadding

        public byte[] getPadding()
        Return the padding octets as a byte array.
        Returns:
        padding octets
      • encode

        public void encode​(java.io.OutputStream outStream)
                    throws java.io.IOException
        Throws:
        java.io.IOException
      • getEncoded

        public byte[] getEncoded()
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • getEncoded

        public byte[] getEncoded​(PacketFormat format)
                          throws java.io.IOException
        Throws:
        java.io.IOException