org.bouncycastle.openpgp

Class PGPUtil

public class PGPUtil extends Object implements HashAlgorithmTags

Basic utility class
Method Summary
static InputStreamgetDecoderStream(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 StringgetDefaultProvider()
Return the provider that will be used by factory classes in situations where a provider must be determined on the fly.
static SecretKeymakeKeyFromPassPhrase(int algorithm, char[] passPhrase, String provider)
static SecretKeymakeKeyFromPassPhrase(int algorithm, S2K s2k, char[] passPhrase, String provider)
static SecretKeymakeRandomKey(int algorithm, SecureRandom random)
static voidsetDefaultProvider(String provider)
Set the provider to be used by the package when it is necessary to find one on the fly.
static voidwriteFileToLiteralData(OutputStream out, char fileType, File file)
write out the passed in file as a literal data packet.
static voidwriteFileToLiteralData(OutputStream out, char fileType, File file, byte[] buffer)
write out the passed in file as a literal data packet in partial packet format.

Method Detail

getDecoderStream

public 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.

Parameters: in the stream to be wrapped

Returns: a BCPGInputStream

Throws: IOException

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)

makeKeyFromPassPhrase

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

makeRandomKey

public static SecretKey makeRandomKey(int algorithm, SecureRandom random)

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)
write out the passed in file as a literal data packet.

Parameters: out fileType the LiteralData type for the file. file

Throws: IOException

writeFileToLiteralData

public 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.

Parameters: out fileType the LiteralData type for the file. file buffer buffer to be used to chunk the file into partial packets.

Throws: IOException