org.bouncycastle.openpgp

Class PGPUtil

Implemented Interfaces:
HashAlgorithmTags

public class PGPUtil
extends java.lang.Object
implements HashAlgorithmTags

Basic utility class

Fields inherited from interface org.bouncycastle.bcpg.HashAlgorithmTags

DOUBLE_SHA, HAVAL_5_160, MD2, MD5, RIPEMD160, SHA1, SHA224, SHA256, SHA384, SHA512, TIGER_192

Method Summary

static InputStream
getDecoderStream(InputStream in)
Return either an ArmoredInputStream or a BCPGInputStream based on whether the initial characters of the stream are binary PGP encodings or not.
static String
getDefaultProvider()
Return the provider that will be used by factory classes in situations where a provider must be determined on the fly.
static SecretKey
makeKeyFromPassPhrase(int algorithm, char[] passPhrase, String provider)
static SecretKey
makeKeyFromPassPhrase(int algorithm, S2K s2k, char[] passPhrase, String provider)
static SecretKey
makeRandomKey(int algorithm, SecureRandom random)
static void
setDefaultProvider(String provider)
Set the provider to be used by the package when it is necessary to find one on the fly.
static void
writeFileToLiteralData(OutputStream out, char fileType, File file)
write out the passed in file as a literal data packet.
static void
writeFileToLiteralData(OutputStream out, char fileType, File file, byte[] buffer)
write out the passed in file as a literal data packet in partial packet format.

Method Details

getDecoderStream

public static InputStream getDecoderStream(InputStream in)
            throws IOException
Return either an ArmoredInputStream or a BCPGInputStream based on whether the initial characters of the stream are binary PGP encodings or not.
Parameters:
in - the stream to be wrapped
Returns:
a BCPGInputStream

getDefaultProvider

public static String getDefaultProvider()
Return the provider that will be used by factory classes in situations where a provider must be determined on the fly.
Returns:
String

makeKeyFromPassPhrase

public static SecretKey makeKeyFromPassPhrase(int algorithm,
                                              char[] passPhrase,
                                              String provider)
            throws NoSuchProviderException,
                   PGPException

makeKeyFromPassPhrase

public static SecretKey makeKeyFromPassPhrase(int algorithm,
                                              S2K s2k,
                                              char[] passPhrase,
                                              String provider)
            throws PGPException,
                   NoSuchProviderException

makeRandomKey

public static SecretKey makeRandomKey(int algorithm,
                                      SecureRandom random)
            throws PGPException

setDefaultProvider

public static void setDefaultProvider(String provider)
Set the provider to be used by the package when it is necessary to find one on the fly.
Parameters:
provider -

writeFileToLiteralData

public static void writeFileToLiteralData(OutputStream out,
                                          char fileType,
                                          File file)
            throws IOException
write out the passed in file as a literal data packet.
Parameters:
out -
fileType - the LiteralData type for the file.
file -

writeFileToLiteralData

public static void writeFileToLiteralData(OutputStream out,
                                          char fileType,
                                          File file,
                                          byte[] buffer)
            throws IOException
write out the passed in file as a literal data packet in partial packet format.
Parameters:
out -
fileType - the LiteralData type for the file.
file -
buffer - buffer to be used to chunk the file into partial packets.