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
encAlgorithmSymmetricKeyAlgorithmTag
PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, SecureRandom)
Existing SecureRandom constructor.
public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom random)
Parameters
encAlgorithmSymmetricKeyAlgorithmTagThe symmetric algorithm to use.
randomSecureRandomSource of randomness.
PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, SecureRandom, bool)
Base constructor.
public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, SecureRandom random, bool oldFormat)
Parameters
encAlgorithmSymmetricKeyAlgorithmTagThe symmetric algorithm to use.
randomSecureRandomSource of randomness.
oldFormatboolPGP 2.6.x compatibility required.
PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag, bool)
public PgpEncryptedDataGenerator(SymmetricKeyAlgorithmTag encAlgorithm, bool withIntegrityPacket)
Parameters
encAlgorithmSymmetricKeyAlgorithmTagwithIntegrityPacketbool
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
encAlgorithmSymmetricKeyAlgorithmTagwithIntegrityPacketboolrandomSecureRandom
Methods
AddMethod(PgpPublicKey)
Add a public key encrypted session key to the encrypted object.
public void AddMethod(PgpPublicKey key)
Parameters
keyPgpPublicKey
AddMethod(PgpPublicKey, bool)
public void AddMethod(PgpPublicKey key, bool sessionKeyObfuscation)
Parameters
keyPgpPublicKeysessionKeyObfuscationbool
AddMethod(char[], HashAlgorithmTag)
Add a PBE encryption method to the encrypted object.
public void AddMethod(char[] passPhrase, HashAlgorithmTag s2kDigest)
Parameters
passPhrasechar[]s2kDigestHashAlgorithmTag
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
rawPassPhrasebyte[]s2kDigestHashAlgorithmTag
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
passPhrasechar[]s2kDigestHashAlgorithmTag
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
Returns
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)