TuviPgpLib is a PGP (Pretty Good Privacy) library that provides encryption, signing, import/export, and key management functionality. It uses BouncyCastle for cryptographic operations, providing secure encryption and signing of email and other data.
-
Key Management
- Key Import/Export: Both public and private key import and export are supported. Both ASCII Armored and binary key export are supported.
- External Storage Support: The IKeyStorage interface allows the library to integrate with external key storage to save and load key data.
- Public and Secret Key Ring Support: The library allows importing and exporting PGP public/secret key ring bundles.
-
Key Search and Filtering
- Ability to filter and match keys with email addresses via the IKeyMatcher interface.
- Automatic key selection for encryption and signing based on email address is supported.
-
Data Encryption and Signing
- Support for data and message encryption using PGP, as well as digital signature generation.
- Signature verification and message decryption with data integrity checking.
-
Exception Handling
- Special exceptions for working with keys, including:
- PublicKeyNotFoundException — the key was not found.
- PublicKeyAlreadyExistException — the key already exists.
- ImportPublicKeyException and others — exceptions when importing keys.
- Handling various errors related to cryptographic algorithms and key formats.
- Special exceptions for working with keys, including:
-
Extensibility
- TuviPgpContext — the main context for working with PGP, which can be extended or modified for specific implementations.
- Ability to use various encryption algorithms and standards via the BouncyCastle library.
using (var stream = File.OpenRead("publickey.asc"))
{
pgpContext.ImportPublicKeys(stream, isArmored: true);
}
using (var outputStream = File.Create("privatekey.asc"))
{
pgpContext.ExportSecretKeys("user@example.com", outputStream, isArmored: true);
}
var encryptedMessage = pgpContext.Encrypt("message", recipientEmail);
bool isValid = pgpContext.VerifySignature(signedMessage, senderEmail);
- .NET Standard 2.0
- BouncyCastle for cryptographic operations
WIP
The project is licensed under the Apache License 2.0. See the LICENSE file for details.
We welcome any contributions to the project! If you have suggestions or find a bug, create an issue or submit a pull request.