## The Bouncy Castle Cryptographic C#® API

### Contents:

1. The Bouncy Castle Cryptographic C#® API
   1. 1. Contents:
      2. License & Contributors:
      3. Features:
      4. How To Build.
      5. The Source:
      6. Documentation:
      7. For first time users.
      8. Notes:
         1. Thursday January 18, 2007
         2. Tuesday Febuary 1, 2005
         3. Sunday December 12, 2004
      9. Trademarks.

### License & Contributors:

See License & Contributors files.

### Features:

- Generation and parsing of Pkcs12 files.
- X.509: Generators and parsers for V1 and V3 certificates, V2 CRLs and attribute certificates.
- PBE algorithms supported by PBEUtil: PBEwithMD2andDES-CBC, PBEwithMD2andRC2-CBC, PBEwithMD5andDES-CBC, PBEwithMD5andRC2-CBC, PBEwithSHA1andDES-CBC, PBEwithSHA1andRC2-CBC, PBEwithSHA-1and128bitRC4, PBEwithSHA-1and40bitRC4, PBEwithSHA-1and3-keyDESEDE-CBC, PBEwithSHA-1and2-keyDESEDE-CBC, PBEwithSHA-1and128bitRC2-CBC, PBEwithSHA-1and40bitRC2-CBC, PBEwithHmacSHA-1, PBEwithHmacSHA-224, PBEwithHmacSHA-256, PBEwithHmacRIPEMD128, PBEwithHmacRIPEMD160, and PBEwithHmacRIPEMD256.
- Signature algorithms supported by SignerUtilities: MD2withRSA, MD4withRSA, MD5withRSA, RIPEMD128withRSA, RIPEMD160withRSA, RIPEMD256withRSA, SHA-1withRSA, SHA-224withRSA, SHA-256withRSAandMGF1, SHA-384withRSAandMGF1, SHA-512withRSAandMGF1, SHA-1withDSA, and SHA-1withECDSA.
- Symmetric key algorithms: AES, Blowfish, Camellia, CAST5, CAST6, DESede, DES, GOST28147, IDEA, NaccacheStern, RC2, RC4, RC5-32, RC5-64, RC6, Rijndael, Serpent, Skipjack, TEA/XTEA, and Twofish.
- Symmetric key modes: CBC, CFB, CTS, GOFB, OFB, OpenPGPCFB, and SIC (or CTR).
- Symmetric key paddings: ISO10126d2, ISO7816d4, Pkcs-5/7, TBC, X.923, and Zero Byte.
- Asymmetric key algorithms: RSA (with blinding), ElGamal, DSA, ECDSA.
- Asymmetric key paddings/encodings: ISO9796d1, OAEP, and Pkcs1.
- Digests: GOST3411, MD2, MD4, MD5, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512, Tiger, and Whirlpool.
- Signer mechanisms: DSA, ECDSA, ECGOST3410, GOST3410, ISO9796d2, PSS, RSA.
- Key Agreement: Diffie-Hellman and EC-DH.
- Macs: CBCBlockCipher, CFBBlockCipher, GOST28147, HMac, and ISO9797 Alg. 3.
- PBE generators: Pkcs-12, and Pkcs 5 - schemes 1 and 2.
- OpenPGP (RFC 2440)
- Cryptographic Message Syntax (CMS, RFC 3852), including streaming API.
- Online Certificate Status Protocol (OCSP, RFC 2560).
- Time Stamp Protocol (TSP, RFC 3161).

Porting notes from the old ASN.1 library For the most part code using the old subset of ASN.1 classes should be easy to transfer, providing the following changes are made:

- DERObject becomes Asn1Object
- DEREncodable becomes Asn1Encodable
- GetDERObject() becomes ToAsn1Object()
- BERConstructedOctetString becomes BerOctetString
- If you were using the older mutable DERConstructedSequence/Set and BERConstructedSequence, use an Asn1EncodableVector in conjunction with DerSequence/Set and BerSequence
- BERInputStream and DERInputStream are replaced with Asn1InputStream
- AsymmetricKeyParameter is now in the Org.Bouncycastle.Crypto namespace

### How To Build.

The BC C# API uses NAnt (http://nant.sourceforge.net) to provide a platform independent build environment. There is also a solution file for Visual Studio, and one for MonoDevelop. The API requires .NET Framework 1.1, and should work fine with .NET 2.0 also. It has been successfully built and tested with Mono versions from 1.1.13 onwards.

Using a command prompt (DOS window), cd into the 'crypto' folder of this distribution.
Use,

- 'nant' without arguments to compile debug code, the tests and run the tests.
- 'nant compile-release' to compile release code.
- 'nant compile-debug' to compile debug code.
- 'nant test' to run the included unit tests (using NUnit; you may need to edit the build file to set the location where NUnit is installed).

Output:
The compiled api can be found in the 'api/bin/release' & 'api/bin/debug' directories.
The compiled tests can be found in the 'test/bin' directory (by default a debug build is used for testing).
Please note that the DLLs depend on the SharpZip compression library, which is included with the release in the 'lib' directory.

### The Source:

Source code can be found in the 'src'directory.

### Documentation:

There is limited documentation available at the moment. Some of the source contains XML comments, but this is a work in progress. We will be working to iumprove this now that 1.0 is out the door.

### For first time users.

Java® heritage,
The Bouncy Castle C# API is a port of the Bouncy Castle Java APIs. Approximately %80 of the functionality in the Java build has now been ported. For the most part, the naming conventions of the .NET platform have been adopted. The C# API is constantly kept uptodate with bug fixes and new test cases from the Java build (and vice versa sometimes), thus benefitting from the large user base and real-world use the Java version has seen.
Please consider.
The Bouncy Castle C# API is a library of transformations that when combined properly will enable developers to create standard conforming cryptographic systems. In order to use this API you must have some knowledge of how to build cryptographic systems, namely what transformations to use and the when, where and why of their use.
Developing good cryptographic systems takes practice and understanding.
There are many resources available online and in book shops please use those to your advantage.

### Notes:

#### Thursday January 18, 2007

This is the 1.0 release of the Bouncy Castle C# API.
Implementations of CMS, OCSP, OpenPGP, and TSP.
Elliptic Curves (F2m and Fp).
A basic TLS client.
PEM file reading and writing.
Symmetric key algorithms: Camellia, GOST28147, NaccacheStern, and TEA/XTEA.
Symmetric key modes: GOFB and OpenPGPCFB.
Symmetric key paddings: ISO7816d4.
Asymmetric key algorithms: RSA blinding.
Digests: GOST3411 and Whirlpool.
Macs: GOST28147 and ISO9797 Alg 3.
Signer mechanisms: ECDSA, ECGOST3410, and GOST3410.
...and many more features, bug fixes, and performance improvements.

#### Tuesday Febuary 1, 2005

This is the second beta release of the Bouncy Castle API C# implementation.
Reliability improvement to ASN1InputStream.
The OID entries in SignerUtilities for RSA signature algorithms for SHA-256,
SHA-384, and SHA-512 were pointing creating the wrong signature objects.

#### Sunday December 12, 2004

This is the first beta release of the Bouncy Castle Cryptographic API C# implementation.
The Legion of the Bouncy Castle would like to extend their thanks to all those who contributed to this api during the alpha stages of its development.
Keep up the good work folks.
Please send any questions, bug reports to dev-crypto-csharp@bouncycastle.org

### Trademarks.

C#, .NET, and MSDN are Registered Trademarks of Microsoft. Microsoft.com
Java is a Registered Trademark of Sun Microsystems. Sun Microsystems
© 2007 Legion of the Bouncy Castle