Class BouncyCastle
- Namespace
- ZeroInstall.Store.Trust
- Assembly
- ZeroInstall.Store.dll
Provides access to the OpenPGP signature functions of Bouncy Castle.
public class BouncyCastle : IOpenPgp
- Inheritance
-
BouncyCastle
- Implements
- Inherited Members
- Extension Methods
Constructors
BouncyCastle(string)
Provides access to the OpenPGP signature functions of Bouncy Castle.
public BouncyCastle(string homeDir)
Parameters
homeDir
stringThe GnuPG home dir to use.
Methods
ExportKey(IKeyIDContainer)
Exports the public key for a specific key in the keyring.
public string ExportKey(IKeyIDContainer keyIDContainer)
Parameters
keyIDContainer
IKeyIDContainerAn object containing the key ID of the public key to export.
Returns
- string
The public key in ASCII Armored format. Always uses Unix-style linebreaks.
Exceptions
- KeyNotFoundException
The specified
keyIDContainer
could not be found in the keyring.
ImportKey(ArraySegment<byte>)
Imports a public key into the keyring.
public void ImportKey(ArraySegment<byte> data)
Parameters
data
ArraySegment<byte>The public key in binary or ASCII Armored format.
Exceptions
- InvalidDataException
data
does not contain a valid public key.
ListSecretKeys()
Returns a list of secret keys in the keyring.
public IEnumerable<OpenPgpSecretKey> ListSecretKeys()
Returns
Sign(ArraySegment<byte>, OpenPgpSecretKey, string?)
Creates a detached OpenPGP signature using a specific secret key.
public byte[] Sign(ArraySegment<byte> data, OpenPgpSecretKey secretKey, string? passphrase = null)
Parameters
data
ArraySegment<byte>The data to sign.
secretKey
OpenPgpSecretKeyThe secret key to use for signing.
passphrase
stringThe passphrase to use to unlock the secret key.
Returns
- byte[]
The signature in binary format.
Exceptions
- KeyNotFoundException
The specified
secretKey
could not be found in the keyring.- WrongPassphraseException
passphrase
was incorrect.
Verify(ArraySegment<byte>, byte[])
Verifies a detached OpenPGP signature.
public IEnumerable<OpenPgpSignature> Verify(ArraySegment<byte> data, byte[] signature)
Parameters
data
ArraySegment<byte>The data the signature is for.
signature
byte[]The signature in binary format.
Returns
- IEnumerable<OpenPgpSignature>
A list of signatures found, both valid and invalid. MissingKeySignature results indicate you need to use ImportKey(ArraySegment<byte>).
Exceptions
- SignatureException
signature
does not contain syntactically correct signature data.