$ show bcgit/bc-csharp
Bouncy Castle for .NET is a comprehensive, production-grade cryptographic library providing implementations of a vast range of symmetric and asymmetric ciphers, hash functions, message authentication codes, digital signatures, key agreement protocols, key encapsulation mechanisms (including post-quantum schemes like ML-KEM, ML-DSA, SLH-DSA), secure random number generation (NIST SP 800-90A DRBG), and ASN.1 encoding/decoding (DER, BER, DL). It supports high-level protocol implementations for TLS/DTLS (client and server, including PSK, SRP, and post-quantum key exchange), OpenPGP (RFC 4880/9580), CMS (Cryptographic Message Syntax), CMP, CRMF, OCSP, TSP, and X.509 certificate generation and validation. The library is designed as a class library with a monolithic architecture organized into namespaces (Org.BouncyCastle.Crypto, .Asn1, .Tls, .Bcpg, .Cms, etc.), exposing both low-level primitives and high-level builders. It targets multiple .NET runtimes with conditional compilation for hardware intrinsics (AES-NI, PCLMULQDQ, SSE/AVX) and Span<T> support. The codebase is actively maintained, with ongoing migration from older algorithm names (e.g., Dilithium → ML-DSA) and extensive use of factory patterns and interface-based abstractions, making it a solid foundation for secure application development.
The LLM identified 4 files worth highlighting for reuse:
Implements X25519 key agreement (RFC 7748) with constant-time scalar multiplication over Curve25519. Self-contained, uses only internal field arithmetic (X25519Field) and Pack utilities. Demonstrates side-channel-resistant implementation and can be extracted as a standalone X25519 library.
Implements Ed25519 signature scheme (RFC 8032) with constant-time operations. Self-contained, uses internal Scalar25519 and field arithmetic. Provides signing, verification, and key generation. Reusable as a standalone Ed25519 implementation.
Static utility class providing generic parsing methods for ASN.1 sequences (Read, ReadOptional, ReadContextTagged, GetOptional, GetTagged). Encapsulates the common pattern of reading typed elements from an Asn1Sequence with validation. Highly reusable across any ASN.1 code that needs to parse tagged or optional elements.
Provides big-endian and little-endian byte/unsigned integer pack/unpack operations used throughout the library for encoding cryptographic values. Self-contained with no dependencies beyond System namespace. Reusable in any C# project requiring efficient endian conversion.