Bouncy Castle Cryptography Library 1.45

org.bouncycastle.openpgp
Class PGPUtil

java.lang.Object
  extended by org.bouncycastle.openpgp.PGPUtil
All Implemented Interfaces:
HashAlgorithmTags

public class PGPUtil
extends java.lang.Object
implements HashAlgorithmTags

Basic utility class


Field Summary
 
Fields inherited from interface org.bouncycastle.bcpg.HashAlgorithmTags
DOUBLE_SHA, HAVAL_5_160, MD2, MD5, RIPEMD160, SHA1, SHA224, SHA256, SHA384, SHA512, TIGER_192
 
Constructor Summary
PGPUtil()
           
 
Method Summary
static java.io.InputStream getDecoderStream(java.io.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 java.lang.String getDefaultProvider()
          Return the provider that will be used by factory classes in situations where a provider must be determined on the fly.
static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm, char[] passPhrase, java.lang.String provider)
           
static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm, S2K s2k, char[] passPhrase, java.security.Provider provider)
           
static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm, S2K s2k, char[] passPhrase, java.lang.String provider)
           
static javax.crypto.SecretKey makeRandomKey(int algorithm, java.security.SecureRandom random)
           
static void setDefaultProvider(java.lang.String provider)
          Set the provider to be used by the package when it is necessary to find one on the fly.
static void writeFileToLiteralData(java.io.OutputStream out, char fileType, java.io.File file)
          write out the passed in file as a literal data packet.
static void writeFileToLiteralData(java.io.OutputStream out, char fileType, java.io.File file, byte[] buffer)
          write out the passed in file as a literal data packet in partial packet format.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PGPUtil

public PGPUtil()
Method Detail

getDefaultProvider

public static java.lang.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

setDefaultProvider

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

Parameters:
provider -

makeRandomKey

public static javax.crypto.SecretKey makeRandomKey(int algorithm,
                                                   java.security.SecureRandom random)
                                            throws PGPException
Throws:
PGPException

makeKeyFromPassPhrase

public static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm,
                                                           char[] passPhrase,
                                                           java.lang.String provider)
                                                    throws java.security.NoSuchProviderException,
                                                           PGPException
Throws:
java.security.NoSuchProviderException
PGPException

makeKeyFromPassPhrase

public static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm,
                                                           S2K s2k,
                                                           char[] passPhrase,
                                                           java.lang.String provider)
                                                    throws PGPException,
                                                           java.security.NoSuchProviderException
Throws:
PGPException
java.security.NoSuchProviderException

makeKeyFromPassPhrase

public static javax.crypto.SecretKey makeKeyFromPassPhrase(int algorithm,
                                                           S2K s2k,
                                                           char[] passPhrase,
                                                           java.security.Provider provider)
                                                    throws PGPException,
                                                           java.security.NoSuchProviderException
Throws:
PGPException
java.security.NoSuchProviderException

writeFileToLiteralData

public static void writeFileToLiteralData(java.io.OutputStream out,
                                          char fileType,
                                          java.io.File file)
                                   throws java.io.IOException
write out the passed in file as a literal data packet.

Parameters:
out -
fileType - the LiteralData type for the file.
file -
Throws:
java.io.IOException

writeFileToLiteralData

public static void writeFileToLiteralData(java.io.OutputStream out,
                                          char fileType,
                                          java.io.File file,
                                          byte[] buffer)
                                   throws java.io.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.
Throws:
java.io.IOException

getDecoderStream

public static java.io.InputStream getDecoderStream(java.io.InputStream in)
                                            throws java.io.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
Throws:
java.io.IOException

Bouncy Castle Cryptography Library 1.45