Inhaltsverzeichnis
4.2 Integration
Platform-specific integration guides for WvdS.System.Security.Cryptography.
Platforms
| Platform | Provider | Description |
|---|---|---|
| Blazor Server | NativeCryptoProvider | P/Invoke to OpenSSL |
| Blazor WebAssembly | WasmCryptoProvider | JS Interop to OpenSSL.wasm |
| ASP.NET Core | NativeCryptoProvider | REST API with PQ certificates |
| Console Application | NativeCryptoProvider | Batch processing, tools |
Architecture
The library uses the provider pattern:
Application Code
|
WvdS.System.Security.Cryptography (Extension Methods)
|
ICryptoProvider (Interface)
|
+-------------------------+------------------------+
| NativeCryptoProvider | WasmCryptoProvider |
| (P/Invoke) | (JS Interop) |
+-------------------------+------------------------+
| |
OpenSSL 3.6 (Native) OpenSSL.wasm (Browser)
The provider is automatically selected based on the runtime environment.
Service Registration
For 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); // Configure PQ crypto CryptoConfig.DefaultMode = CryptoMode.Hybrid; CryptoConfig.OpenSslPath = builder.Configuration["OpenSslPath"]; // Register services 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 is used automatically CryptoConfig.DefaultMode = CryptoMode.Hybrid; builder.RootComponents.Add<App>("#app"); await builder.Build().RunAsync();
Note: In WASM, the WasmCryptoProvider is automatically used, which utilizes OpenSSL.wasm via JavaScript Interop.
ASP.NET Core Web API
// Program.cs using WvdS.System.Security.Cryptography; var builder = WebApplication.CreateBuilder(args); // Configure PQ crypto CryptoConfig.DefaultMode = CryptoMode.Hybrid; // HTTPS with PQ certificate (Kestrel) builder.WebHost.ConfigureKestrel(options => { options.ConfigureHttpsDefaults(https => { https.ServerCertificate = LoadPqCertificate(); }); }); builder.Services.AddControllers(); var app = builder.Build();
Further Reading
- Configuration - OpenSSL paths, environment variables
Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional
Zuletzt geändert: on 2026/01/29 at 11:34 PM