OpenSLLWrapper is a lightweight .NET Framework library that provides helpers for RSA key generation, PEM conversions, signing and verification. It uses BouncyCastle under the hood and exposes convenient stream and byte[] overloads for interoperable cryptographic operations.
$ dotnet add package OpenSLLWrapperVersion: 1.0.2
Release: v1.0.2
This release includes a small version bump and packaging metadata updates (nuspec, README and icon included in package).
Managed .NET wrapper for RSA key operations, PEM conversions and signing/verification using BouncyCastle.
Features
Requirements
Projects
OpenSLLWrapper - library with all helpers (uses BouncyCastle)OpenSLLWrapper.Tests - console test runner that exercises generation, CSR, signing, conversion and OpenSSL interoperability checks (if OpenSSL is available)Quick start
packages.config in OpenSLLWrapper).OpenSslFacade class as the public API entry point, for example:// generate key
OpenSslFacade.GenerateRsaPrivateKey("private_key.pem", 2048);
// export public key
OpenSslFacade.ExportPublicKeyPemFromPrivateKey("private_key.pem", "public_key.pem");
// sign challenge (base64->signature-base64)
string challengeB64 = Convert.ToBase64String(Encoding.UTF8.GetBytes("hello"));
string sigB64 = OpenSslFacade.SignBase64Challenge(challengeB64, "private_key.pem");
// verify signature
bool ok = OpenSLLWrapper.VerifyBase64Signature(challengeB64, sigB64, "public_key.pem");
Running tests / examples
OpenSLLWrapper.Tests � build and run the executable. It will generate temporary files and run interoperability checks with OpenSSL if available.OpenSSL interoperability
SHA256withRSA) to match OpenSSL dgst -sha256 -sign and dgst -sha256 -verify behavior.usePss=true on signing/verification methods to enable RSASSA-PSS (both sides must agree on PSS params).Security notes
Contributing
License
Secure PEM storage examples
// Generate private key bytes
var pkPem = OpenSLLWrapper.GenerateRsaPrivateKeyBytes(2048);
// Save to file and restrict ACLs so only current user can access
OpenSLLWrapper.SavePemFileSecure("C:\\keys\\private_key.pem", pkPem);
var pkPem = OpenSLLWrapper.GenerateRsaPrivateKeyBytes(2048);
string password = "s3cureP@ssw0rd";
OpenSLLWrapper.SavePemFileEncrypted("C:\\keys\\private_key.enc", pkPem, password);
// Later: read and decrypt
byte[] decrypted = OpenSLLWrapper.LoadPemFileEncrypted("C:\\keys\\private_key.enc", password);
// Use the decrypted bytes (PEM) with existing helpers
var pubPem = OpenSLLWrapper.ExportPublicKeyPemFromPrivateKeyBytes(decrypted);
Notes
SavePemFileSecure attempts to restrict filesystem ACLs on Windows only; on non-Windows platforms it will write the file without ACL modifications.SavePemFileEncrypted uses a password-based scheme (PBKDF2 with HMAC-SHA256, AES-256-CBC and HMAC-SHA256 for integrity). Keep your password secure and consider using a stronger iteration count for high-security scenarios.