C# Class Org.BouncyCastle.Bcpg.OpenPgp.PgpEncryptedDataGenerator

Generator for encrypted objects.
Inheritance: IStreamGenerator
Show file Open project: nonorganic/dssnet Class Usage Examples

Public Methods

Method Description
AddMethod ( PgpPublicKey key ) : void

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

AddMethod ( char passPhrase ) : void

Add a PBE encryption method to the encrypted object using the default algorithm (S2K_SHA1).

AddMethod ( char passPhrase, HashAlgorithmTag s2kDigest ) : void

Add a PBE encryption method to the encrypted object.

Close ( ) : void

Close off the encrypted object - this is equivalent to calling Close() on the stream returned by the Open() method.

Note: This does not close the underlying output stream, only the stream on top of it created by the Open() method.

Open ( Stream outStr, byte buffer ) : Stream

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.

Open ( Stream outStr, long length ) : Stream

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.

PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm ) : System
PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom rand ) : System

Existing SecureRandom constructor.

PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom rand, bool oldFormat ) : System

Base constructor.

PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket ) : System
PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket, SecureRandom rand ) : System

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

Private Methods

Method Description
AddCheckSum ( byte sessionInfo ) : void
CreateSessionInfo ( SymmetricKeyAlgorithmTag algorithm, KeyParameter key ) : byte[]
Open ( Stream outStr, long length, byte buffer ) : Stream

If buffer is non null stream assumed to be partial, otherwise the length will be used to output a fixed length packet.

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.

Method Details

AddMethod() public method

Add a public key encrypted session key to the encrypted object.
public AddMethod ( PgpPublicKey key ) : void
key PgpPublicKey
return void

AddMethod() public method

Add a PBE encryption method to the encrypted object using the default algorithm (S2K_SHA1).
public AddMethod ( char passPhrase ) : void
passPhrase char
return void

AddMethod() public method

Add a PBE encryption method to the encrypted object.
public AddMethod ( char passPhrase, HashAlgorithmTag s2kDigest ) : void
passPhrase char
s2kDigest HashAlgorithmTag
return void

Close() public method

Close off the encrypted object - this is equivalent to calling Close() on the stream returned by the Open() method.

Note: This does not close the underlying output stream, only the stream on top of it created by the Open() method.

public Close ( ) : void
return void

Open() public method

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 Open ( Stream outStr, byte buffer ) : Stream
outStr Stream
buffer byte
return Stream

Open() public method

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 Open ( Stream outStr, long length ) : Stream
outStr Stream
length long
return Stream

PgpEncryptedDataGenerator() public method

public PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm ) : System
encAlgorithm SymmetricKeyAlgorithmTag
return System

PgpEncryptedDataGenerator() public method

Existing SecureRandom constructor.
public PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom rand ) : System
encAlgorithm SymmetricKeyAlgorithmTag The symmetric algorithm to use.
rand Org.BouncyCastle.Security.SecureRandom Source of randomness.
return System

PgpEncryptedDataGenerator() public method

Base constructor.
public PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom rand, bool oldFormat ) : System
encAlgorithm SymmetricKeyAlgorithmTag The symmetric algorithm to use.
rand Org.BouncyCastle.Security.SecureRandom Source of randomness.
oldFormat bool PGP 2.6.x compatibility required.
return System

PgpEncryptedDataGenerator() public method

public PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket ) : System
encAlgorithm SymmetricKeyAlgorithmTag
withIntegrityPacket bool
return System

PgpEncryptedDataGenerator() public method

Creates a cipher stream which will have an integrity packet associated with it.
public PgpEncryptedDataGenerator ( SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket, SecureRandom rand ) : System
encAlgorithm SymmetricKeyAlgorithmTag
withIntegrityPacket bool
rand Org.BouncyCastle.Security.SecureRandom
return System