CryptoHives.Foundation.Security.Cryptography
0.6.101
dotnet add package CryptoHives.Foundation.Security.Cryptography --version 0.6.101
NuGet\Install-Package CryptoHives.Foundation.Security.Cryptography -Version 0.6.101
<PackageReference Include="CryptoHives.Foundation.Security.Cryptography" Version="0.6.101" />
<PackageVersion Include="CryptoHives.Foundation.Security.Cryptography" Version="0.6.101" />
<PackageReference Include="CryptoHives.Foundation.Security.Cryptography" />
paket add CryptoHives.Foundation.Security.Cryptography --version 0.6.101
#r "nuget: CryptoHives.Foundation.Security.Cryptography, 0.6.101"
#:package CryptoHives.Foundation.Security.Cryptography@0.6.101
#addin nuget:?package=CryptoHives.Foundation.Security.Cryptography&version=0.6.101
#tool nuget:?package=CryptoHives.Foundation.Security.Cryptography&version=0.6.101
π‘οΈ CryptoHives Open Source Initiative π
An open, community-driven collection of cryptography and performance libraries for the .NET ecosystem, maintained by The Keepers of the CryptoHives.
π CryptoHives.Foundation.Security.Cryptography
Fully managed, OS-independent implementations of hash, MAC, KDF, cipher, and post-quantum KEM algorithms for .NET, written directly from NIST/RFC/ISO specifications and checked against official test vectors.
No OS crypto dependency means deterministic results on every platform. Where the hardware supports it, intrinsics are used automatically β AES-NI, PCLMULQDQ/VPCLMULQDQ, SSE2, SSSE3, AVX2 and AVX-512 on x86/x64; ARM AES, ARM SHA-1/SHA-2, PMULL and NEON on Arm64.
π₯ Installation
dotnet add package CryptoHives.Foundation.Security.Cryptography
β¨ Key Features
- OS-independent β identical results on Windows, Linux, macOS, and anywhere else .NET runs
- Standards-based β implemented from NIST, RFC, and ISO specifications; validated against official test vectors
- Hardware-accelerated β automatic dispatch across AES-NI/AVX2/AVX-512 and the Arm64 crypto and NEON paths, with a scalar fallback always available
- Allocation-free hot paths β
Span<byte>-based APIs, friendly tostackalloc - XOF streaming β
IExtendableOutput(Absorb/Squeeze/Reset) on all XOF algorithms HashAlgorithmcompatible β drop-in for anything consumingSystem.Security.Cryptography.HashAlgorithm- Broad algorithm coverage β SHA-2/3, Keccak, SHAKE, BLAKE2/3, Ascon, regional ciphers, and more
𧬠Supported Algorithms
| Family | Algorithms |
|---|---|
| SHA-2 | SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256 |
| SHA-3 | SHA3-224, SHA3-256, SHA3-384, SHA3-512 |
| Keccak | Keccak-256, Keccak-384, Keccak-512 (Ethereum-compatible) |
| SHAKE / cSHAKE | SHAKE128, SHAKE256, cSHAKE128, cSHAKE256 |
| TurboSHAKE / KT | TurboSHAKE128, TurboSHAKE256, KT128, KT256 |
| ParallelHash (SP 800-185) | ParallelHash128, ParallelHash256 |
| BLAKE | BLAKE2b, BLAKE2s (SIMD-accelerated), BLAKE3 |
| Ascon | Ascon-Hash256, Ascon-XOF128 (NIST SP 800-232 lightweight) |
| Regional hash | SM3, Streebog, Kupyna, LSH, Whirlpool, RIPEMD-160 |
| Legacy | SHA-1, MD5, HMAC-SHA-1, HMAC-MD5 (backward compatibility only) |
| MAC | HMAC-SHA-256/384/512, HMAC-SHA3-256/384/512, AES-CMAC, AES-GMAC, Poly1305, KMAC128/256, BLAKE2/3 keyed |
| Cipher (AEAD) | AES-GCM (128/192/256), AES-CCM (128/192/256), ChaCha20-Poly1305, XChaCha20-Poly1305, Ascon-AEAD128 |
| Cipher (block/stream) | AES-128/192/256 (ECB/CBC/CTR), ChaCha20 |
| Cipher (regional) | SM4, ARIA, Camellia, Kuznyechik, Kalyna (128/256/512), SEED |
| KDF | HKDF, KBKDF, ConcatKDF, PBKDF2 |
| Post-quantum KEM | ML-KEM-512, ML-KEM-768, ML-KEM-1024 (FIPS 203) |
π‘ Quick Examples
Allocation-Free Hash (Blake3)
using CryptoHives.Foundation.Security.Cryptography.Hash;
using var blake3 = Blake3.Create();
Span<byte> hash = stackalloc byte[32];
blake3.TryComputeHash(data, hash, out _);
XOF Streaming (Shake256)
using CryptoHives.Foundation.Security.Cryptography.Hash;
// Variable-length output via IExtendableOutput
using var shake = Shake256.Create(outputBytes: 64);
shake.Absorb(context);
shake.Absorb(message);
Span<byte> output = stackalloc byte[64];
shake.Squeeze(output);
shake.Reset(); // Reuse the instance
Keyed Hash / MAC (HMAC-SHA-256)
using CryptoHives.Foundation.Security.Cryptography.Mac;
using var hmac = new HmacSha256(key);
Span<byte> tag = stackalloc byte[32];
hmac.Update(message); // call as often as needed
hmac.Finalize(tag); // writes the 32-byte tag
hmac.Reset(); // reuse the instance for the next message
Authenticated Encryption (AES-GCM)
using CryptoHives.Foundation.Security.Cryptography.Cipher;
using System.Security.Cryptography; // for CryptographicException
using var aesGcm = new AesGcm256(key);
// Encrypt
Span<byte> ciphertext = new byte[plaintext.Length];
Span<byte> tag = stackalloc byte[16];
aesGcm.Encrypt(nonce, plaintext, ciphertext, tag, associatedData);
// Decrypt β returns false (and clears `recovered`) if tag verification fails;
// it does not throw. Always check the result before trusting the output.
Span<byte> recovered = new byte[ciphertext.Length];
if (!aesGcm.Decrypt(nonce, ciphertext, tag, recovered, associatedData))
{
throw new CryptographicException("Authentication failed.");
}
Post-Quantum Key Encapsulation (ML-KEM)
MLKem and MLKemAlgorithm carry the same names and the same member signatures as
System.Security.Cryptography.MLKem from .NET 10, so switching to the managed
implementation is a one-line change β swap the using, and everything downstream compiles
unchanged:
-using System.Security.Cryptography; // .NET 10 only, and only where the OS provides ML-KEM
+using CryptoHives.Foundation.Security.Cryptography.Kem;
using CryptoHives.Foundation.Security.Cryptography.Kem;
// MLKem.IsSupported is always true here: no OS or hardware dependency,
// on every target framework down to net462.
using var receiver = MLKem.GenerateKey(MLKemAlgorithm.MLKem768);
byte[] encapsulationKey = receiver.ExportEncapsulationKey();
// Sender: encapsulate a shared secret for the receiver.
using var sender = MLKem.ImportEncapsulationKey(MLKemAlgorithm.MLKem768, encapsulationKey);
sender.Encapsulate(out byte[] ciphertext, out byte[] senderSecret);
// Receiver: recover the same shared secret.
byte[] receiverSecret = receiver.Decapsulate(ciphertext);
Both the allocating overloads above and the allocation-free span overloads
(Encapsulate(Span<byte>, Span<byte>), Decapsulate(ReadOnlySpan<byte>, Span<byte>)) are
available, matching the in-box type.
Keys are validated on import per FIPS 203 Β§7.2/Β§7.3, decapsulation uses constant-time
implicit rejection, and all three parameter sets are verified against the official
NIST ACVP test vectors plus BouncyCastle and .NET 10 MLKem interop tests.
Not yet implemented: the PKCS#8, SubjectPublicKeyInfo and PEM import/export members (
ImportPkcs8PrivateKey,ExportSubjectPublicKeyInfo,ImportFromPem, β¦). Raw key and seed import/export is complete. See the KEM roadmap.
cSHAKE β Domain-Separated XOF
using CryptoHives.Foundation.Security.Cryptography.Hash;
using var cshake = CShake128.Create(
outputBytes: 32,
functionName: "MyApp"u8.ToArray(),
customization: "v1"u8.ToArray());
cshake.Absorb(input);
Span<byte> derived = stackalloc byte[32];
cshake.Squeeze(derived);
π Documentation
| Resource | Link |
|---|---|
| Full package documentation | cryptohives.github.io/Foundation/packages/security/cryptography |
| Hash algorithms guide | cryptohives.github.io/β¦/hash-algorithms |
| Cipher algorithms guide | cryptohives.github.io/β¦/cipher-algorithms |
| XOF mode guide | cryptohives.github.io/β¦/xof-mode |
| Benchmarks (interactive dashboard) | cryptohives.github.io/β¦/benchmarks |
| MAC algorithms guide | cryptohives.github.io/β¦/mac-algorithms |
| API reference | cryptohives.github.io/β¦/api/β¦Cryptography.Hash |
| Source repository | github.com/CryptoHives/Foundation |
π¨ Security Policy
Every algorithm is implemented from its published specification and validated against official test vectors. Public APIs are designed assuming hostile input.
If you discover a vulnerability, please don't open a public issue β follow the process on the CryptoHives Security Page instead.
βοΈ License
MIT β Β© 2026 The Keepers of the CryptoHives
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.Bcl.Memory (>= 10.0.11)
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
- System.Memory (>= 4.6.3)
-
.NETFramework 4.7.2
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.Bcl.Memory (>= 10.0.11)
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
- System.Memory (>= 4.6.3)
-
.NETStandard 2.0
- Microsoft.Bcl.HashCode (>= 6.0.0)
- Microsoft.Bcl.Memory (>= 10.0.11)
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
- System.Memory (>= 4.6.3)
-
.NETStandard 2.1
- Microsoft.Bcl.Memory (>= 10.0.11)
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
-
net10.0
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
-
net8.0
- Microsoft.Extensions.ObjectPool (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.101 | 196 | 9/1/2026 |
| 0.6.79 | 302 | 8/12/2026 |
| 0.6.51 | 246 | 8/1/2026 |
| 0.6.21 | 273 | 7/4/2026 |
| 0.5.34-preview | 645 | 6/2/2026 |
| 0.5.21-preview | 178 | 5/2/2026 |
| 0.5.13-preview | 134 | 4/2/2026 |
| 0.4.21-preview | 129 | 3/1/2026 |
| 0.4.11-preview | 131 | 2/14/2026 |
| 0.3.19-preview | 133 | 1/26/2026 |