====== 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();
builder.Services.AddScoped();
----
===== 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();
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");
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 =====
* [[de:int:pqcrypt:api:providers:start|Provider API-Referenz]]
* [[de:int:pqcrypt:administrator:konfiguration|Konfiguration]] – OpenSSL-Pfade, Umgebungsvariablen
----
//Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//
{{tag>integration blazor aspnet provider}}