Lucinda.Blazor provides end-to-end encryption (E2EE) capabilities for Blazor WebAssembly applications using the native Web Crypto API. Key Features: • AES-GCM and AES-CBC symmetric encryption via Web Crypto API • RSA-OAEP asymmetric encryption • ECDH key exchange (P-256/P-384/P-521 curves) • ECDSA digital signatures • HKDF and PBKDF2 key derivation • Secure random number generation • IndexedDB-based secure key storage • Signal Protocol support (X3DH, Double Ratchet, Sender Keys) Advantages: • Zero external dependencies - uses browser's native crypto • Hardware-accelerated encryption (AES-NI) • No timing attacks (native implementation) • Compatible with Lucinda for server-side interop Platform Support: Blazor WebAssembly on .NET 6.0-10.0
$ dotnet add package Lucinda.BlazorBlazor WebAssembly crypto library using the browser's native Web Crypto API. Part of the Lucinda end-to-end encryption library ecosystem.
dotnet add package Lucinda.Blazor
// Program.cs
using Lucinda.Blazor;
builder.Services.AddLucindaBlazor();
builder.Services.AddLucindaBlazor(options =>
{
options.AesKeySize = 256;
options.UseAesGcm = true;
options.EcdhCurve = "P-256";
options.Pbkdf2Iterations = 600000;
});
@inject IBlazorSymmetricEncryption SymmetricEncryption
@inject IBlazorKeyExchange KeyExchange
@inject IBlazorSecureRandom SecureRandom
@code {
private async Task EncryptData()
{
// Generate a key
var keyResult = await SymmetricEncryption.GenerateKeyAsync();
if (!keyResult.IsSuccess) return;
var key = keyResult.Value;
// Encrypt data
var plaintext = Encoding.UTF8.GetBytes("Hello, World!");
var encryptResult = await SymmetricEncryption.EncryptAsync(plaintext, key);
if (encryptResult.IsSuccess)
{
var ciphertext = encryptResult.Value;
// Use encrypted data...
}
}
}
You can register only the services you need:
// Only AES-GCM
builder.Services.AddLucindaAesGcm(keySize: 256);
// Only ECDH
builder.Services.AddLucindaEcdh(curve: "P-256");
// Only ECDSA
builder.Services.AddLucindaEcdsa(curve: "P-256", hashAlgorithm: "SHA-256");
// Only PBKDF2
builder.Services.AddLucindaPbkdf2(iterations: 600000);
| Interface | Description |
|---|---|
IBlazorSymmetricEncryption | AES-GCM or AES-CBC encryption |
IBlazorAsymmetricEncryption | RSA-OAEP encryption |
IBlazorKeyExchange | ECDH key exchange |
IBlazorSignature | ECDSA or RSA-PSS signatures |
IBlazorKeyDerivation | HKDF key derivation |
IBlazorPasswordKeyDerivation | PBKDF2 password-based KDF |
IBlazorSecureRandom | Cryptographic random generation |
IBlazorHash | SHA hashing and HMAC |
@inject WebCryptoAvailability CryptoAvailability
@code {
private async Task CheckSupport()
{
var isAvailable = await CryptoAvailability.IsAvailableAsync();
if (isAvailable)
{
var diagnostics = await CryptoAvailability.RunDiagnosticsAsync();
Console.WriteLine($"AES-GCM: {diagnostics.SupportedEncryption.Contains("AES-GCM")}");
Console.WriteLine($"ECDH: {diagnostics.SupportedKeyExchange.Contains("ECDH")}");
}
}
}Lucinda.Blazor uses standard key formats compatible with the main Lucinda library:
This enables interoperability between Blazor WebAssembly clients and server-side .NET applications.
Lucinda.Blazor requires a browser with Web Crypto API support:
IndexedDB with encryption for persistent storage.crypto.getRandomValues(), which is cryptographically secure.MIT License - See LICENSE for details.