Table of Contents

Class PgpEncryptedDataGenerator

Namespace
Org.BouncyCastle.Bcpg.OpenPgp
Assembly
BouncyCastle.Cryptography.dll
public class PgpEncryptedDataGenerator : IStreamGenerator
Inheritance
PgpEncryptedDataGenerator
Implements
Inherited Members

Remarks

Generator for encrypted objects.

Constructors

PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag)

public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm)

Parameters

encAlgorithm SymmetricKeyAlgorithmTag

PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, SecureRandom)

Existing SecureRandom constructor.

public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom random)

Parameters

encAlgorithm SymmetricKeyAlgorithmTag

The symmetric algorithm to use.

random SecureRandom

Source of randomness.

PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, SecureRandom, bool)

Base constructor.

public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom random, bool oldFormat)

Parameters

encAlgorithm SymmetricKeyAlgorithmTag

The symmetric algorithm to use.

random SecureRandom

Source of randomness.

oldFormat bool

PGP 2.6.x compatibility required.

PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, bool)

public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket)

Parameters

encAlgorithm SymmetricKeyAlgorithmTag
withIntegrityPacket bool

PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, bool, SecureRandom)

Creates a cipher stream which will have an integrity packet associated with it.

public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket, SecureRandom random)

Parameters

encAlgorithm SymmetricKeyAlgorithmTag
withIntegrityPacket bool
random SecureRandom

Methods

AddMethod(PgpPublicKey)

Add a public key encrypted session key to the encrypted object.

public void AddMethod(PgpPublicKey key)

Parameters

key PgpPublicKey

AddMethod(PgpPublicKey, bool)

public void AddMethod(PgpPublicKey key, bool sessionKeyObfuscation)

Parameters

key PgpPublicKey
sessionKeyObfuscation bool

AddMethod(char[], HashAlgorithmTag)

Add a PBE encryption method to the encrypted object.

public void AddMethod(char[] passPhrase, HashAlgorithmTag s2kDigest)

Parameters

passPhrase char[]
s2kDigest HashAlgorithmTag

Remarks

Conversion of the passphrase characters to bytes is performed using Convert.ToByte(), which is the historical behaviour of the library (1.7 and earlier).

AddMethodRaw(byte[], HashAlgorithmTag)

Add a PBE encryption method to the encrypted object.

public void AddMethodRaw(byte[] rawPassPhrase, HashAlgorithmTag s2kDigest)

Parameters

rawPassPhrase byte[]
s2kDigest HashAlgorithmTag

Remarks

Allows the caller to handle the encoding of the passphrase to bytes.

AddMethodUtf8(char[], HashAlgorithmTag)

Add a PBE encryption method to the encrypted object.

public void AddMethodUtf8(char[] passPhrase, HashAlgorithmTag s2kDigest)

Parameters

passPhrase char[]
s2kDigest HashAlgorithmTag

Remarks

The passphrase is encoded to bytes using UTF8 (Encoding.UTF8.GetBytes).

Close()

[Obsolete("Dispose any opened Stream directly")]
public void Close()

Open(Stream, byte[])

Return an output stream which will encrypt the data as it is written to it. The stream will be written out in chunks according to the size of the passed in buffer.

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 Stream parameter outStr.

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.

public Stream Open(Stream outStr, byte[] buffer)

Parameters

outStr Stream
buffer byte[]

Returns

Stream

Open(Stream, long)

Return an output stream which will encrypt the data as it is written to it.

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 Stream parameter outStr.

public Stream Open(Stream outStr, long length)

Parameters

outStr Stream
length long

Returns

Stream