OutWit.Database.Core.BouncyCastle 1.0.0

dotnet add package OutWit.Database.Core.BouncyCastle --version 1.0.0
                    
NuGet\Install-Package OutWit.Database.Core.BouncyCastle -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OutWit.Database.Core.BouncyCastle" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OutWit.Database.Core.BouncyCastle" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="OutWit.Database.Core.BouncyCastle" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OutWit.Database.Core.BouncyCastle --version 1.0.0
                    
#r "nuget: OutWit.Database.Core.BouncyCastle, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OutWit.Database.Core.BouncyCastle@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OutWit.Database.Core.BouncyCastle&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=OutWit.Database.Core.BouncyCastle&version=1.0.0
                    
Install as a Cake Tool

OutWit.Database.Core.BouncyCastle

ChaCha20-Poly1305 encryption provider for WitDatabase using BouncyCastle.

This package provides an alternative encryption algorithm when AES-NI hardware acceleration is not available.


Installation

<PackageReference Include="OutWit.Database.Core.BouncyCastle" Version="1.0.0" />

Quick Start

Password-Based Encryption

using OutWit.Database.Core.Builder;
using OutWit.Database.Core.BouncyCastle;

var db = new WitDatabaseBuilder()
    .WithFilePath("encrypted.db")
    .WithBouncyCastleEncryption("my-secure-password")
    .WithBTree()
    .Build();

User + Password Encryption

var db = new WitDatabaseBuilder()
    .WithFilePath("encrypted.db")
    .WithBouncyCastleEncryption("username", "password")
    .WithBTree()
    .Build();

Raw Key Encryption

byte[] key = new byte[32]; // 256-bit key
RandomNumberGenerator.Fill(key);

var db = new WitDatabaseBuilder()
    .WithFilePath("encrypted.db")
    .WithBouncyCastleEncryption(key)
    .WithBTree()
    .Build();

Why ChaCha20-Poly1305?

Feature AES-GCM ChaCha20-Poly1305
Hardware acceleration Requires AES-NI Software-only
Performance (with AES-NI) Faster Slower
Performance (without AES-NI) Slower Faster
Security Excellent Excellent
Key size 128/192/256-bit 256-bit

Use ChaCha20-Poly1305 when:

  • Running on hardware without AES-NI (older CPUs, some ARM devices)
  • Running in Blazor WebAssembly (no hardware acceleration)
  • Consistent performance across all platforms is important

Use AES-GCM (default) when:

  • Running on modern x86/x64 CPUs with AES-NI
  • Maximum performance is required

API Reference

WitDatabaseBuilder Extensions

// Password-based encryption (PBKDF2 key derivation)
builder.WithBouncyCastleEncryption(string password)

// User + password encryption
builder.WithBouncyCastleEncryption(string user, string password)

// Raw 256-bit key
builder.WithBouncyCastleEncryption(byte[] key)

// Raw key with custom salt
builder.WithBouncyCastleEncryption(byte[] key, byte[] salt)

BouncyCastleCryptoProvider

// Create provider with raw key
var provider = new BouncyCastleCryptoProvider(key);

// Create provider from password
var provider = BouncyCastleCryptoProvider.FromPassword(
    password: "secret",
    salt: saltBytes,
    iterations: 100_000
);

// Properties
provider.NonceSize   // 12 bytes
provider.TagSize     // 16 bytes
provider.ProviderKey // "chacha20-poly1305"

Security Details

Key Derivation

  • Algorithm: PBKDF2-SHA256
  • Iterations: 100,000 (default)
  • Key size: 256 bits
  • Salt size: 16 bytes (derived from password or user)

Encryption

  • Algorithm: ChaCha20-Poly1305
  • Key size: 256 bits
  • Nonce size: 96 bits (12 bytes)
  • Authentication tag: 128 bits (16 bytes)

Memory Safety

  • Uses ArrayPool<T> for temporary buffers (reduced GC pressure)
  • Sensitive data is zeroed after use via CryptographicOperations.ZeroMemory
  • Key material is securely cleared on Dispose()

Blazor WebAssembly Support

ChaCha20-Poly1305 works well in Blazor WebAssembly where hardware AES acceleration is not available:

var db = new WitDatabaseBuilder()
    .WithIndexedDbStorage("MyDatabase", JSRuntime)
    .WithBouncyCastleEncryption("password")
    .WithBTree()
    .Build();

Dependencies

Package Version Purpose
BouncyCastle.Cryptography 2.6.2 ChaCha20-Poly1305 implementation
OutWit.Database.Core 1.0.0 Core database library

Project Description
OutWit.Database.Core Core storage engine
OutWit.Database.Core.IndexedDb IndexedDB storage for Blazor WASM
OutWit.Database SQL execution engine

License

Licensed under the Apache License, Version 2.0. See LICENSE.

Attribution (optional)

If you use OutWit.Database.Core.BouncyCastle in a product, a mention is appreciated (but not required), for example: "Powered by WitDatabase https://witdatabase.io/".

Trademark / Project name

"WitDatabase" and the WitDatabase logo are used to identify the official project by Dmitry Ratner.

You may:

  • refer to the project name in a factual way (e.g., "built with WitDatabase");
  • use the name to indicate compatibility (e.g., "WitDatabase-compatible").

You may not:

  • use "WitDatabase" as the name of a fork or a derived product in a way that implies it is the official project;
  • use the WitDatabase logo to promote forks or derived products without permission.

See Also

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 40 1/25/2026