This page maps the calls of BouncyCastle for C# that are used most to the OneCrypto call that does the same job. There is no compatibility layer: the shapes differ on purpose. OneCrypto's models are immutable and keep the bytes they were read from, verification returns a report instead of throwing or returning a bool, every time-dependent call takes a reference time, and the algorithm comes from the key and the CryptoPolicy rather than from a name you pass. The BouncyCastle names below come from its public API documentation.
Namespaces: models and the happy path are in RecursiveAI.OneCrypto; primitives in .Primitives; PKCS in .Pkcs; policy in .Policy; OpenPGP in .OpenPgp (package RecursiveAI.OneCrypto.OpenPgp); time-stamp clients in .Online.
Certificates and requests
| Task | BouncyCastle | OneCrypto |
| Read a certificate | X509CertificateParser.ReadCertificate, PemReader.ReadObject | Certificate.Parse(bytes) or Crypto.Load(path) for any file |
| Build a self-signed or CA-issued certificate | X509V3CertificateGenerator with Generate(ISignatureFactory) | CertificateBuilder.CreateSelfSigned(options, signer) / CertificateBuilder.Create(options, issuerCertificate, signer); for a CA, CertificateAuthority.Issue(...) with a CertificateProfile |
| A development CA and a TLS certificate | generator classes, extensions by hand | Pki.CreateCa("Dev CA"), Pki.IssueTlsServer(ca, ["localhost"]) |
| Certificate request | Pkcs10CertificationRequest | Pki.CreateCsr(key, "name", names); layer: CertificateSigningRequestBuilder; read with CertificateSigningRequest.Parse |
| CRL | X509V2CrlGenerator | Pki.Revoke(ca, certificates); layer: CertificateAuthority.IssueCrl, CertificateRevocationList.Parse |
| OCSP | OcspReqGenerator, BasicOcspRespGenerator | OcspRequest, OcspResponse models; OcspResponder handler; OcspClient in .Online |
| Path validation | PkixCertPathBuilder, PkixCertPathValidator | Pki.Validate(certificate, trusted, intermediates); layer: PathValidator.Validate(certificate, ValidationOptions); the report names every rule |
| Key and certificate in a PFX | Pkcs12Store, Pkcs12StoreBuilder | Pkcs12File.Create(...) / Pkcs12File.Parse(...).Open(password); or PkiIdentity.ToPkcs12(password) and PkiIdentity.Load(path, password) |
| PEM and PKCS #8 | PemReader, PemWriter, PrivateKeyInfoFactory | PemCodec, PrivateKeyInfo.Parse/ToPem, EncryptedPrivateKeyInfo, or Crypto.Load |
CMS and time-stamps
| Task | BouncyCastle | OneCrypto |
| Sign, attached or detached | CmsSignedDataGenerator.AddSigner + Generate(content, encapsulate) | Cms.Sign(content, signer), Cms.SignDetached(content, signer); layer: SignedData.Create(content, signers, options) |
| Verify | CmsSignedData.GetSignerInfos().GetSigners() then SignerInformation.Verify per signer | Cms.Verify(message, trusted) or Cms.VerifyDetached(message, content, trusted): a SignedDataReport with a result per signer and per rule, and the signer's chain checked at the reference time |
| Encrypt to certificates | CmsEnvelopedDataGenerator.AddKeyTransRecipient / AddKeyAgreeRecipient + Generate | Cms.Encrypt(content, recipientCertificate): the certificate's key picks the delivery; layer: AuthEnvelopedData.Create / EnvelopedData.Create with CmsRecipient.KeyTransport/KeyAgreement/Kem/Password |
| Decrypt | CmsEnvelopedData.GetRecipientInfos() + RecipientInformation.GetContent(key) | Cms.Decrypt(message, identity); layer: EnvelopedData.Parse(...).Decrypt(CmsDecryptionKey) |
| Streaming | CmsSignedDataStreamGenerator, CmsEnvelopedDataStreamGenerator, CmsEnvelopedDataParser | Stream overloads of Cms.SignDetached, Cms.VerifyDetached, Cms.Encrypt, Cms.Decrypt; layer: SignedData.SignStream, EnvelopedData.EncryptStream and their async twins |
| Time-stamp request and response | TimeStampRequestGenerator, TimeStampResponse, TimeStampToken.Validate | await Tsa.StampAsync(data, url, trustedRoots), Tsa.Verify(token, data, trustedRoots); layer: TimeStampRequest, TsaClient, TimeStampVerifier, TimeStampAuthority for a server |
OpenPGP
| Task | BouncyCastle | OneCrypto |
| Generate a key | PgpKeyRingGenerator | Pgp.GenerateKey("Name <mail>"); layer: PgpKeyGenerator |
| Encrypt | PgpEncryptedDataGenerator + PgpLiteralDataGenerator | Pgp.Encrypt(data, certificate) |
| Decrypt | PgpObjectFactory, PgpPublicKeyEncryptedData.GetDataStream | Pgp.Decrypt(message, secretKey): the plaintext is released only after the integrity check |
| Sign, detached or inline | PgpSignatureGenerator, PgpOnePassSignature | Pgp.SignDetached(data, key), Pgp.Sign(data, key) |
| Verify | PgpSignature.InitVerify / Verify | Pgp.VerifyDetached(data, signature, certificates), Pgp.Verify(message, certificates): a verdict per signature |
| Key rings | PgpPublicKeyRingBundle, PgpSecretKeyRingBundle | PgpCertificate, GnuPGHome, CertDirectory |
Primitives
| Task | BouncyCastle | OneCrypto (RecursiveAI.OneCrypto.Primitives) |
| Ed25519 | Ed25519PrivateKeyParameters, Ed25519Signer | Ed25519PrivateKey.Generate(), TrySign, Ed25519PublicKey.Verify |
| X25519 | X25519Agreement | X25519PrivateKey.Generate(), TryDeriveSharedSecret |
| Argon2, scrypt | Argon2BytesGenerator, SCrypt.Generate | Argon2.DeriveKey(Argon2Type.Argon2id, ...), Scrypt.DeriveKey(...): memory and cost limits are on by default |
| OCB, EAX | OcbBlockCipher, EaxBlockCipher | AesOcb, AesEax: span one-shots |
Post-quantum
| Task | BouncyCastle | OneCrypto |
| ML-KEM | MLKemKeyPairGenerator, MLKemGenerator, MLKemExtractor | MlKemDecapsulationKey.Generate(MlKemSet.MlKem768), key.EncapsulationKey.TryEncapsulate(ciphertext, secret), key.TryDecapsulate(ciphertext, secret) |
| ML-DSA | MLDsaKeyPairGenerator, MLDsaSigner | MlDsaPrivateKey.Generate(MlDsaParameterSet.MlDsa65), TrySign(message, context, signature, out n), key.PublicKey.Verify(message, context, signature) |
| SLH-DSA | SlhDsaKeyPairGenerator, SlhDsaSigner | SlhDsaPrivateKey.Generate(variant); pre-hash and context forms in SlhDsaScheme |
| LMS/HSS, XMSS | LmsKeyPairGenerator, XmssKeyPairGenerator | Lms, Hss, Xmss, XmssMt with a SignatureStateStore that reserves each one-time key before a signature is released |
| Hybrid keys in certificates and CMS | composite classes, by hand | Pki.CreateCa("CA") and Cms.Encrypt(data, certificate) are hybrid under CryptoPolicy.Standard; CryptoPolicy.Cnsa2 makes ML-DSA-87 and ML-KEM-1024 |
OneCrypto's post-quantum code runs on every platform, the browser included, and the platform's own implementation is used only when CryptoPolicy.FipsMode is set or the key lives in an operating-system store, a token or a device.
Differences that matter
- Failure is a report. A bad signature, an untrusted chain or a refused algorithm is a verdict in the result, with the rule and the specification section. Malformed input raises a typed exception (
CmsParseException, X509ParseException, OpenPgpParseException); every parser has a TryParse.
- Nothing reads a hidden clock. Validity questions take a reference time; the happy path takes a
TimeProvider.
- Nothing fetches unless you ask. Revocation, issuers and time-stamps come from data you pass, or from a source you hand the call.
- Policy decides algorithms. SHA-1 and small RSA are refused for new data and flagged on old data; legacy ciphers decrypt but never encrypt; unauthenticated encryption fails closed.