4.2 Integration

Plattformspezifische Integrationsanleitungen für WvdS.System.Security.Cryptography.


Plattformen

Plattform Provider Beschreibung
Blazor Server NativeCryptoProvider P/Invoke zu OpenSSL
Blazor WebAssembly WasmCryptoProvider JS Interop zu OpenSSL.wasm
ASP.NET Core NativeCryptoProvider REST-API mit PQ-Zertifikaten
Konsolenanwendung NativeCryptoProvider Batch-Verarbeitung, Tools

Architektur

Die Bibliothek verwendet das Provider-Pattern:

Anwendungscode
    ↓
WvdS.System.Security.Cryptography (Extension Methods)
    ↓
ICryptoProvider (Interface)
    ↓
┌─────────────────────────┬────────────────────────┐
│ NativeCryptoProvider    │ WasmCryptoProvider     │
│ (P/Invoke)              │ (JS Interop)           │
└─────────────────────────┴────────────────────────┘
    ↓                           ↓
OpenSSL 3.6 (Native)      OpenSSL.wasm (Browser)

Der Provider wird automatisch basierend auf der Laufzeitumgebung gewählt.


Service-Registrierung

Für Dependency Injection in ASP.NET Core / Blazor:

// Program.cs
builder.Services.AddSingleton<KeyExchangeService>();
builder.Services.AddScoped<IEphemeralKeyManager, EphemeralKeyManager>();

Blazor Server

// Program.cs
using WvdS.System.Security.Cryptography;
 
var builder = WebApplication.CreateBuilder(args);
 
// PQ-Krypto konfigurieren
CryptoConfig.DefaultMode = CryptoMode.Hybrid;
CryptoConfig.OpenSslPath = builder.Configuration["OpenSslPath"];
 
// Services registrieren
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
builder.Services.AddSingleton<KeyExchangeService>();
 
var app = builder.Build();

Blazor WebAssembly

// Program.cs
using WvdS.System.Security.Cryptography;
 
var builder = WebAssemblyHostBuilder.CreateDefault(args);
 
// WASM-Provider wird automatisch verwendet
CryptoConfig.DefaultMode = CryptoMode.Hybrid;
 
builder.RootComponents.Add<App>("#app");
await builder.Build().RunAsync();

Hinweis: In WASM wird automatisch der WasmCryptoProvider verwendet, der OpenSSL.wasm via JavaScript Interop nutzt.


ASP.NET Core Web API

// Program.cs
using WvdS.System.Security.Cryptography;
 
var builder = WebApplication.CreateBuilder(args);
 
// PQ-Krypto konfigurieren
CryptoConfig.DefaultMode = CryptoMode.Hybrid;
 
// HTTPS mit PQ-Zertifikat (Kestrel)
builder.WebHost.ConfigureKestrel(options =>
{
    options.ConfigureHttpsDefaults(https =>
    {
        https.ServerCertificate = LoadPqCertificate();
    });
});
 
builder.Services.AddControllers();
var app = builder.Build();

Weiterführend


Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional

Zuletzt geändert: den 29.01.2026 um 15:12