public class PGPEncryptedDataGenerator extends java.lang.Object implements SymmetricKeyAlgorithmTags
Modifier and Type | Field and Description |
---|---|
static int |
S2K_SHA1
Specifier for SHA-1 S2K PBE generator.
|
static int |
S2K_SHA224
Specifier for SHA-224 S2K PBE generator.
|
static int |
S2K_SHA256
Specifier for SHA-256 S2K PBE generator.
|
static int |
S2K_SHA384
Specifier for SHA-384 S2K PBE generator.
|
static int |
S2K_SHA512
Specifier for SHA-512 S2K PBE generator.
|
Constructor and Description |
---|
PGPEncryptedDataGenerator(int encAlgorithm,
boolean withIntegrityPacket,
java.security.SecureRandom rand,
java.security.Provider provider)
Deprecated.
use constructor that takes a PGPDataEncryptorBuilder
|
PGPEncryptedDataGenerator(int encAlgorithm,
boolean withIntegrityPacket,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use constructor that takes a PGPDataEncryptorBuilder
|
PGPEncryptedDataGenerator(int encAlgorithm,
java.security.SecureRandom rand,
boolean oldFormat,
java.security.Provider provider)
Deprecated.
use constructor that takes a PGPDataEncryptorBuilder
|
PGPEncryptedDataGenerator(int encAlgorithm,
java.security.SecureRandom rand,
boolean oldFormat,
java.lang.String provider)
Deprecated.
use constructor that takes a PGPDataEncryptorBuilder
|
PGPEncryptedDataGenerator(int encAlgorithm,
java.security.SecureRandom rand,
java.security.Provider provider)
Deprecated.
use constructor that takes a PGPDataEncryptorBuilder
|
PGPEncryptedDataGenerator(int encAlgorithm,
java.security.SecureRandom rand,
java.lang.String provider)
Deprecated.
use constructor that takes a PGPDataEncryptor
|
PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder)
Base constructor.
|
PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder,
boolean oldFormat)
Base constructor with the option to turn on formatting for PGP 2.6.x compatibility.
|
Modifier and Type | Method and Description |
---|---|
void |
addMethod(char[] passPhrase)
Deprecated.
use addMethod that takes PGPKeyEncryptionMethodGenerator
|
void |
addMethod(char[] passPhrase,
int s2kDigest)
Deprecated.
use addMethod that takes PGPKeyEncryptionMethodGenerator
|
void |
addMethod(PGPKeyEncryptionMethodGenerator method)
Added a key encryption method to be used to encrypt the session data associated
with this encrypted data.
|
void |
addMethod(PGPPublicKey key)
Deprecated.
use addMethod that takes PGPKeyEncryptionMethodGenerator
|
void |
close()
Close off the encrypted object - this is equivalent to calling close on the stream
returned by the open() method.
|
java.io.OutputStream |
open(java.io.OutputStream out,
byte[] buffer)
Return an outputstream which will encrypt the data as it is written
to it.
|
java.io.OutputStream |
open(java.io.OutputStream out,
long length)
Return an outputstream which will encrypt the data as it is written
to it.
|
public static final int S2K_SHA1
public static final int S2K_SHA224
public static final int S2K_SHA256
public static final int S2K_SHA384
public static final int S2K_SHA512
public PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.lang.String provider)
encAlgorithm
- the symmetric algorithm to use.rand
- source of randomnessprovider
- the provider name to use for encryption algorithms.public PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, java.security.Provider provider)
encAlgorithm
- the symmetric algorithm to use.rand
- source of randomnessprovider
- the provider to use for encryption algorithms.public PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, java.security.SecureRandom rand, java.lang.String provider)
encAlgorithm
- withIntegrityPacket
- rand
- provider
- public PGPEncryptedDataGenerator(int encAlgorithm, boolean withIntegrityPacket, java.security.SecureRandom rand, java.security.Provider provider)
encAlgorithm
- withIntegrityPacket
- rand
- provider
- public PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.lang.String provider)
encAlgorithm
- the symmetric algorithm to use.rand
- source of randomnessoldFormat
- PGP 2.6.x compatibility required.provider
- the provider to use for encryption algorithms.public PGPEncryptedDataGenerator(int encAlgorithm, java.security.SecureRandom rand, boolean oldFormat, java.security.Provider provider)
encAlgorithm
- the symmetric algorithm to use.rand
- source of randomnessoldFormat
- PGP 2.6.x compatibility required.provider
- the provider to use for encryption algorithms.public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder)
encryptorBuilder
- builder to create actual data encryptor.public PGPEncryptedDataGenerator(PGPDataEncryptorBuilder encryptorBuilder, boolean oldFormat)
encryptorBuilder
- builder to create actual data encryptor.oldFormat
- PGP 2.6.x compatibility required.public void addMethod(char[] passPhrase) throws java.security.NoSuchProviderException, PGPException
passPhrase
- java.security.NoSuchProviderException
PGPException
public void addMethod(char[] passPhrase, int s2kDigest) throws java.security.NoSuchProviderException, PGPException
passPhrase
- passphrase to use to generate key.s2kDigest
- digest algorithm to use for S2K calculationjava.security.NoSuchProviderException
PGPException
public void addMethod(PGPPublicKey key) throws java.security.NoSuchProviderException, PGPException
key
- java.security.NoSuchProviderException
PGPException
public void addMethod(PGPKeyEncryptionMethodGenerator method)
method
- key encryption method to use.public java.io.OutputStream open(java.io.OutputStream out, long length) throws java.io.IOException, PGPException
The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.
out
- length
- java.io.IOException
PGPException
public java.io.OutputStream open(java.io.OutputStream out, byte[] buffer) throws java.io.IOException, PGPException
The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.
Note: if the buffer is not a power of 2 in length only the largest power of 2 bytes worth of the buffer will be used.
out
- buffer
- the buffer to use.java.io.IOException
PGPException
public void close() throws java.io.IOException
Note: This does not close the underlying output stream, only the stream on top of it created by the open() method.
java.io.IOException