Recursive AI
LibraryC#AvailablePreview

onecrypto

A cryptography library for .NET in C#: CMS and S/MIME, X.509, PKCS#12, PEM and SSH keys, and the primitives .NET lacks, such as Ed25519, X25519 and Argon2. Cryptography, not cryptocurrency.

Not audited. In the project’s words: “This library has not been independently audited.” It is a preview, 0.1.0-preview.1, and the API can change. Its certificate path validator is a preview too: don’t rely on it for trust decisions yet.

dotnet add package RecursiveAI.OneCrypto --prerelease

A quick look

One call loads any key or certificate file, whatever its format. The keys it returns sign, decrypt or agree directly, including the Ed25519 keys .NET can’t load.

Getting started
Program.csC#
using RecursiveAI.OneCrypto;
using RecursiveAI.OneCrypto.Keys;
using LoadedItems file = Crypto.Load("demo.pfx", _ => "demo");
Certificate cert = file.Certificates[0];
ISigningKey key = file.PrivateKeys[0].Signing!;
byte[] data = "hello"u8.ToArray();
byte[] signature = key.Sign(data, key.DefaultSpec);
key.DefaultSpec.Verify(cert.PublicKey, data, signature);   // Status: Valid
What it does

What it does

Any key file, one call

PEM and DER, PKCS#8 plain or encrypted, PKCS#12, legacy RSA and EC PEM, and OpenSSH keys and certificates, read by content. PKCS#12 and OpenSSH keys are written too.

CMS and S/MIME

Signed, enveloped and authenticated-enveloped data with every recipient type, a report for each verification rule, and streaming for large files. Decryption fails closed.

Certificates and issuing

X.509 certificates, requests, CRLs and OCSP read and built, RFC 3161 time-stamps, and a certificate authority, time-stamp authority and OCSP responder as handlers with no I/O.

What .NET lacks

Ed25519, Ed448, X25519 and X448, AES-OCB, EAX and key wrap, Argon2, scrypt and bcrypt-pbkdf, and Camellia, in managed code.

The platform first

RSA, ECDSA, ECDH, AES and hashes come from .NET itself. Where a platform lacks one, only SHA-3, ChaCha20-Poly1305 and RSA and ECDSA verification have a managed fallback; anything else is a typed error naming the platform.

Policy and two-phase signing

Dated rules for SHA-1, MD5 and RSA sizes, with presets. Signatures can be prepared in one process and signed by a key held elsewhere.

Before you rely on it

How it’s checked

Against the RFCs and against OpenSSL, Go, GnuPG and OpenSSH

The primitives run their RFC test vectors, and Wycheproof’s where it has them. The formats are exchanged both ways with OpenSSL 3.5.9: the CMS matrix has 169 passes, 0 failures and 20 cases OpenSSL can’t produce or open. Every parser has a fuzz target, each run for 600 seconds without a finding before this release.

Speed, as OneCrypto’s time ÷ the fastest managed .NET library’s for each row (mostly BouncyCastle 2.7.0), on x64: Ed25519 signing 0.55, X25519 0.76, Argon2 0.36, CMS signing 0.18, PKCS#12 loading 0.25. Three are documented exceptions: Camellia encrypts at about 2.3–2.4× and decrypts at about 1.1×, because it never indexes a table with secret data; AES key wrap on x64 at 1.53×, the platform’s per-call cost; and ECDSA P-256 verification at up to 1.70× on x64, because it calls the platform’s ECDSA. The x64 run is marked load-flagged.

The package

Go further

This project is unaffiliated with other products named OneCrypto.