Recursive AI

Coming from BouncyCastle

All onecrypto docs

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

TaskBouncyCastleOneCrypto
Read a certificateX509CertificateParser.ReadCertificate, PemReader.ReadObjectCertificate.Parse(bytes) or Crypto.Load(path) for any file
Build a self-signed or CA-issued certificateX509V3CertificateGenerator 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 certificategenerator classes, extensions by handPki.CreateCa("Dev CA"), Pki.IssueTlsServer(ca, ["localhost"])
Certificate requestPkcs10CertificationRequestPki.CreateCsr(key, "name", names); layer: CertificateSigningRequestBuilder; read with CertificateSigningRequest.Parse
CRLX509V2CrlGeneratorPki.Revoke(ca, certificates); layer: CertificateAuthority.IssueCrl, CertificateRevocationList.Parse
OCSPOcspReqGenerator, BasicOcspRespGeneratorOcspRequest, OcspResponse models; OcspResponder handler; OcspClient in .Online
Path validationPkixCertPathBuilder, PkixCertPathValidatorPki.Validate(certificate, trusted, intermediates); layer: PathValidator.Validate(certificate, ValidationOptions); the report names every rule
Key and certificate in a PFXPkcs12Store, Pkcs12StoreBuilderPkcs12File.Create(...) / Pkcs12File.Parse(...).Open(password); or PkiIdentity.ToPkcs12(password) and PkiIdentity.Load(path, password)
PEM and PKCS #8PemReader, PemWriter, PrivateKeyInfoFactoryPemCodec, PrivateKeyInfo.Parse/ToPem, EncryptedPrivateKeyInfo, or Crypto.Load

CMS and time-stamps

TaskBouncyCastleOneCrypto
Sign, attached or detachedCmsSignedDataGenerator.AddSigner + Generate(content, encapsulate)Cms.Sign(content, signer), Cms.SignDetached(content, signer); layer: SignedData.Create(content, signers, options)
VerifyCmsSignedData.GetSignerInfos().GetSigners() then SignerInformation.Verify per signerCms.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 certificatesCmsEnvelopedDataGenerator.AddKeyTransRecipient / AddKeyAgreeRecipient + GenerateCms.Encrypt(content, recipientCertificate): the certificate's key picks the delivery; layer: AuthEnvelopedData.Create / EnvelopedData.Create with CmsRecipient.KeyTransport/KeyAgreement/Kem/Password
DecryptCmsEnvelopedData.GetRecipientInfos() + RecipientInformation.GetContent(key)Cms.Decrypt(message, identity); layer: EnvelopedData.Parse(...).Decrypt(CmsDecryptionKey)
StreamingCmsSignedDataStreamGenerator, CmsEnvelopedDataStreamGenerator, CmsEnvelopedDataParserStream overloads of Cms.SignDetached, Cms.VerifyDetached, Cms.Encrypt, Cms.Decrypt; layer: SignedData.SignStream, EnvelopedData.EncryptStream and their async twins
Time-stamp request and responseTimeStampRequestGenerator, TimeStampResponse, TimeStampToken.Validateawait Tsa.StampAsync(data, url, trustedRoots), Tsa.Verify(token, data, trustedRoots); layer: TimeStampRequest, TsaClient, TimeStampVerifier, TimeStampAuthority for a server

OpenPGP

TaskBouncyCastleOneCrypto
Generate a keyPgpKeyRingGeneratorPgp.GenerateKey("Name <mail>"); layer: PgpKeyGenerator
EncryptPgpEncryptedDataGenerator + PgpLiteralDataGeneratorPgp.Encrypt(data, certificate)
DecryptPgpObjectFactory, PgpPublicKeyEncryptedData.GetDataStreamPgp.Decrypt(message, secretKey): the plaintext is released only after the integrity check
Sign, detached or inlinePgpSignatureGenerator, PgpOnePassSignaturePgp.SignDetached(data, key), Pgp.Sign(data, key)
VerifyPgpSignature.InitVerify / VerifyPgp.VerifyDetached(data, signature, certificates), Pgp.Verify(message, certificates): a verdict per signature
Key ringsPgpPublicKeyRingBundle, PgpSecretKeyRingBundlePgpCertificate, GnuPGHome, CertDirectory

Primitives

TaskBouncyCastleOneCrypto (RecursiveAI.OneCrypto.Primitives)
Ed25519Ed25519PrivateKeyParameters, Ed25519SignerEd25519PrivateKey.Generate(), TrySign, Ed25519PublicKey.Verify
X25519X25519AgreementX25519PrivateKey.Generate(), TryDeriveSharedSecret
Argon2, scryptArgon2BytesGenerator, SCrypt.GenerateArgon2.DeriveKey(Argon2Type.Argon2id, ...), Scrypt.DeriveKey(...): memory and cost limits are on by default
OCB, EAXOcbBlockCipher, EaxBlockCipherAesOcb, AesEax: span one-shots

Post-quantum

TaskBouncyCastleOneCrypto
ML-KEMMLKemKeyPairGenerator, MLKemGenerator, MLKemExtractorMlKemDecapsulationKey.Generate(MlKemSet.MlKem768), key.EncapsulationKey.TryEncapsulate(ciphertext, secret), key.TryDecapsulate(ciphertext, secret)
ML-DSAMLDsaKeyPairGenerator, MLDsaSignerMlDsaPrivateKey.Generate(MlDsaParameterSet.MlDsa65), TrySign(message, context, signature, out n), key.PublicKey.Verify(message, context, signature)
SLH-DSASlhDsaKeyPairGenerator, SlhDsaSignerSlhDsaPrivateKey.Generate(variant); pre-hash and context forms in SlhDsaScheme
LMS/HSS, XMSSLmsKeyPairGenerator, XmssKeyPairGeneratorLms, Hss, Xmss, XmssMt with a SignatureStateStore that reserves each one-time key before a signature is released
Hybrid keys in certificates and CMScomposite classes, by handPki.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.