CryptoHives.Foundation.Threading
0.5.13-preview
dotnet add package CryptoHives.Foundation.Threading --version 0.5.13-preview
NuGet\Install-Package CryptoHives.Foundation.Threading -Version 0.5.13-preview
<PackageReference Include="CryptoHives.Foundation.Threading" Version="0.5.13-preview" />
<PackageVersion Include="CryptoHives.Foundation.Threading" Version="0.5.13-preview" />
<PackageReference Include="CryptoHives.Foundation.Threading" />
paket add CryptoHives.Foundation.Threading --version 0.5.13-preview
#r "nuget: CryptoHives.Foundation.Threading, 0.5.13-preview"
#:package CryptoHives.Foundation.Threading@0.5.13-preview
#addin nuget:?package=CryptoHives.Foundation.Threading&version=0.5.13-preview&prerelease
#tool nuget:?package=CryptoHives.Foundation.Threading&version=0.5.13-preview&prerelease
🛡️ CryptoHives Open Source Initiative 🐝
An open, community-driven cryptography and performance library collection for the .NET ecosystem.
🏛️ CryptoHives .NET Foundation Libraries
The CryptoHives Open Source Initiative is a collection of modern, high-assurance libraries for .NET, developed and maintained by The Keepers of the CryptoHives. Each package is designed for security, interoperability, and clarity — making it easy to build secure systems for high performance transformation pipelines and for cryptography workloads without sacrificing developer experience.
📚 Documentation
- 📖 Full Documentation - Comprehensive guides, API reference, and examples
- 🚀 Getting Started Guide
- 📦 Package Documentation
- 📚 API Reference
🧬 Features and Design Principles
🧱 Orthogonal Design
- All development is done on free and open-source tools, e.g. .NET SDK, Visual Studio Community Edition, Visual Studio Code, GitHub, Azure DevOps, etc.
- Each package is designed to be orthogonal and composable with other CryptoHives packages to avoid deep cross dependencies
- Dependencies on other packages are kept to a minimum and shall only include widely adopted, well-maintained libraries, e.g. the Microsoft.Extensions
- OS and hardware dependencies are avoided wherever possible to ensure deterministic behavior across all platforms and runtimes, specifically for security implementations
- There is no intention to replace or shadow existing .NET class libraries; instead, CryptoHives packages are designed to complement and extend existing functionality
⚡ High-Performance Primitives
- All CryptoHives packages are designed for high performance and no operational allocations to optimize high performance transformation pipelines and cryptography workloads
- Algorithms may use managed SIMD intrinsics with scalar fallback.
- Package performance and memory usage are benchmarked against reference implementations
🔐 Secure Development Policy
- Standards-Based Cryptography – Implementations are written from official public specifications and standards (NIST, RFC, ISO)
- All algorithms are verified against official test vectors from specification documents
- Review process includes algorithm validation against reference implementations
- Threat-Modeled by Design – All public APIs and network interfaces assume hostile input
- Secure by Default & Validation – Minimal attack surface, explicit configuration, strict input checks, and resource bounds
- Dependency & Supply-Chain Safety – Minimal, vetted dependencies; reproducible signed (planned) releases.
- Automated Verification – Fuzzing (planned), static analysis, and safe error handling to prevent misuse and information leaks.
- Development may use AI-assisted tooling; no guarantee of clean-room provenance is claimed
🐝 Available CryptoHives
🛠️ Buffer Pools (Memory)
Pooled buffer management for transformation pipelines and high-frequency I/O:
ArrayPoolMemoryStream— drop-inMemoryStreamreplacement backed byArrayPool<byte>withReadOnlySequencehandoff supportReadOnlySequenceMemoryStream— read fromReadOnlySequence<byte>asMemoryStreamwithout copyingArrayPoolBufferWriter<T>—IBufferWriter<T>over pooled arrays for e.g.Utf8JsonWriter- Ownership primitives for zero-copy handoff of pooled buffers
🚀 Concurrency Tools (Threading)
Async-compatible synchronization primitives built on ObjectPool and ValueTask<T>.
Designed to eliminate Task / TaskCompletionSource<T> allocations on the hot path.
AsyncLock— mutual exclusionAsyncSemaphore— counting semaphoreAsyncAutoResetEvent/AsyncManualResetEventAsyncReaderWriterLockAsyncBarrier/AsyncCountdownEvent
All primitives support CancellationToken and ConfigureAwait(false) without the need for extra allocations.
Nuget package contains a C# analyzer to avoid common ValueTask usage mistakes. (Also available as standalone package)
⏱️ Async primitive benchmarks — contested and uncontested scenarios, comparing pooled ValueTask vs. existing Task-based alternatives.
🔐 Managed Code Cryptography (Security.Cryptography)
Fully managed implementations of cryptographic hash algorithms, MACs, and cipher algorithms, written from NIST/RFC/ISO specifications and verified against official test vectors. No OS crypto dependency — deterministic results on every platform. Hardware acceleration via AES-NI, PCLMULQDQ, VPCLMULQDQ, SSE2, SSSE3, and AVX2 intrinsics is automatically enabled on supported hardware, in some cases even outperforming OS implementations.
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 |
| BLAKE | BLAKE2b, BLAKE2s (SIMD-accelerated), BLAKE3 |
| Ascon | Ascon-Hash256, Ascon-XOF128 (NIST lightweight) |
| MAC | KMAC128, KMAC256, BLAKE2 keyed, BLAKE3 keyed |
| Cipher (AEAD) | AES-GCM (128/192/256), AES-CCM (128/256), ChaCha20-Poly1305, XChaCha20-Poly1305 |
| Cipher (Block) | AES-128, AES-192, AES-256 (ECB/CBC/CTR), ChaCha20 |
| Cipher (Regional) | SM4, ARIA (128/192/256), Camellia (128/192/256), Kuznyechik, Kalyna (128/256), SEED |
| Regional | SM3, Streebog, Kupyna, LSH, Whirlpool, RIPEMD-160 |
| Legacy | SHA-1, MD5 (backward compatibility only) |
All XOF algorithms implement IExtendableOutput for streaming variable-length output via Absorb / Squeeze / Reset.
⏱️ Cryptography Benchmarks
Measured with BenchmarkDotNet across various payloads, comparing managed vs. reference vs. OS implementations.
📦 Nuget Packages
| Package | Description | NuGet | Documentation |
|---|---|---|---|
Memory |
Pooled buffers and streams | Docs | |
Threading |
Pooled async synchronization | Docs | |
Security.Cryptography |
Hash, MAC & cipher algorithms | Docs |
All packages are published under the CryptoHives.Foundation prefix and namespace — see the Nuget CryptoHives for details.
🩺 CryptoHives Health
🧩 Installation
Install via NuGet CLI:
dotnet add package CryptoHives.Foundation.Threading
Or using the Visual Studio Package Manager:
Install-Package CryptoHives.Foundation.Threading
🧠 Usage Examples
using CryptoHives.Foundation.Security.Cryptography.Hash;
// Allocation-free hash
using var blake3 = Blake3.Create();
Span<byte> hash = stackalloc byte[32];
blake3.TryComputeHash(data, hash, out _);
// XOF streaming (variable-length output)
using var shake = Shake256.Create(64);
shake.Absorb(data1);
shake.Absorb(data2);
Span<byte> output = stackalloc byte[128];
shake.Squeeze(output);
using CryptoHives.Foundation.Threading.Async.Pooled;
// Allocation-free async lock, even with cancellation token
private readonly AsyncLock _lock = new();
public async Task DoWorkAsync(CancellationToken ct)
{
using await _lock.LockAsync(ct).ConfigureAwait(false);
// critical section
}
🔐 Security Policy
Security is our top priority.
If you discover a vulnerability, please do not open a public issue.
Instead, please follow the guidelines on the CryptoHives Open Source Initiative Security Page.
🔏 Nuget Package Assembly Code Signing
Assemblies in our Nuget packages are currently not code signed. Once there is sufficient demand and funding available, the Keepers plan to implement code signing for all released packages.
📝 No-Nonsense Matters
This project is released under the MIT License because open collaboration matters.
However, the Keepers are well aware that MIT-licensed code often gets copied, repackaged, or commercialized without giving credit.
If you use this code, please do so responsibly:
- Give visible credit to the CryptoHives Open Source Initiative or The Keepers of the CryptoHives and refer to the original source.
- Contribute improvements back and report issues.
Open source thrives on respect, not just permissive licenses.
⚖️ License
Each component of the CryptoHives Open Source Initiative is licensed under a SPDX-compatible MIT license.
By default, packages use the following license tags:
// SPDX-FileCopyrightText: <year> The Keepers of the CryptoHives
// SPDX-License-Identifier: MIT
Some inherited components may use alternative MIT license headers, according to their origin and specific requirements those headers are retained.
🐝 About The Keepers of the CryptoHives
The CryptoHives Open Source Initiative project is maintained by The Keepers of the CryptoHives —
a collective of developers dedicated to advancing open, verifiable, and high-performance cryptography in .NET.
🧩 Contributing
Contributions, issue reports, and pull requests are welcome!
Please see the Contributing Guide before submitting code.
© 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 was computed. 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.AsyncInterfaces (>= 10.0.5)
- Microsoft.Bcl.Hashcode (>= 6.0.0)
- Microsoft.Extensions.ObjectPool (>= 10.0.5)
- System.Memory (>= 4.6.3)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 10.0.5)
- Microsoft.Bcl.Hashcode (>= 6.0.0)
- Microsoft.Extensions.ObjectPool (>= 10.0.5)
- System.Memory (>= 4.6.3)
- System.Threading.Tasks.Extensions (>= 4.6.3)
-
.NETStandard 2.1
- Microsoft.Extensions.ObjectPool (>= 10.0.5)
-
net10.0
- Microsoft.Extensions.ObjectPool (>= 10.0.5)
-
net8.0
- Microsoft.Extensions.ObjectPool (>= 10.0.5)
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.5.13-preview | 43 | 4/2/2026 |
| 0.4.21-preview | 54 | 3/1/2026 |
| 0.4.11-preview | 63 | 2/14/2026 |
| 0.3.19-preview | 61 | 1/26/2026 |
| 0.2.43-preview | 64 | 1/9/2026 |
| 0.2.33-preview | 412 | 12/9/2025 |
| 0.2.30-preview | 327 | 12/8/2025 |
| 0.2.28-preview | 260 | 12/7/2025 |
| 0.2.26-preview | 199 | 12/6/2025 |
| 0.2.22-preview | 549 | 12/1/2025 |
| 0.2.17-preview | 158 | 11/23/2025 |
| 0.2.13-preview | 384 | 11/20/2025 |
| 0.2.11-preview | 974 | 11/19/2025 |