![]() |
BogaNet 1.4.0
|
Helper for RSA cryptography and X509 certificates. More...
Static Public Member Functions | |
static X509Certificate2 | GenerateSelfSignedCertificate (string certName, RSAKeyLength keyLength=RSAKeyLength._2048, string oid="1.2.840.10045.3.1.7") |
Generates a self-signed X509-certificate. | |
static X509Certificate2 | GetCertificateFromStore (string certName, StoreLocation storeLocation=StoreLocation.LocalMachine) |
Gets a X509-certificate from the key store. | |
static void | AddCertificateToStore (X509Certificate2 cert, StoreName storeName=StoreName.TrustedPublisher, StoreLocation storeLocation=StoreLocation.LocalMachine) |
Adds a X509-certificate to the key store. | |
static X509Certificate2 | GetPublicCertificate (X509Certificate2 cert, string? password=null) |
Gets the public key from a X509-certificate. | |
static X509Certificate2 | GetPrivateCertificate (X509Certificate2 cert, string? password=null) |
Gets the private and public key from a X509-certificate. NOTE: never share this data with people outside of your organisation! | |
static X509Certificate2 | GetCertificate (byte[] data, string? password=null) |
Gets a X509-certificate from a byte-array. | |
static bool | WritePublicCertificateToFile (string filename, X509Certificate2 cert, string? password=null) |
Writes the public key as X509-certificate to a file. | |
static async Task< bool > | WritePublicCertificateToFileAsync (string filename, X509Certificate2 cert, string? password=null) |
Writes the public key as X509-certificate to a file asynchronously. | |
static bool | WritePrivateCertificateToFile (string filename, X509Certificate2 cert, string password) |
Writes the private and public key as X509-certificate to a file. NOTE: never share this file with people outside of your organisation! | |
static async Task< bool > | WritePrivateCertificateToFileAsync (string filename, X509Certificate2 cert, string password) |
Writes the private and public key as X509-certificate to a file asynchronously. NOTE: never share this file with people outside of your organisation! | |
static X509Certificate2 | ReadCertificateFromFile (string filename, string? password=null) |
Reads a X509-certificate from a file. | |
static async Task< X509Certificate2 > | ReadCertificateFromFileAsync (string filename, string? password=null) |
Reads a X509-certificate from a file asynchronously. | |
static byte[] | Encrypt (byte[] dataToEncrypt, X509Certificate2 cert, RSAEncryptionPadding? padding=null) |
Encrypts a byte-array with a X509-certificate. | |
static byte[] | Encrypt (string? textToEncrypt, X509Certificate2 cert, RSAEncryptionPadding? padding=null, Encoding? encoding=null) |
Encrypts a string with a X509-certificate. | |
static byte[] | Decrypt (byte[] dataToDecrypt, X509Certificate2 cert, RSAEncryptionPadding? padding=null) |
Decrypts a byte-array with a X509-certificate. | |
Helper for RSA cryptography and X509 certificates.
|
static |
Adds a X509-certificate to the key store.
cert | X509-certificate |
storeName | Name of the key store (optional, default: TrustedPublisher) |
storeLocation | Location in the key store (optional, default: LocalMachine) |
|
static |
Decrypts a byte-array with a X509-certificate.
dataToDecrypt | byte-array to decrypt |
cert | X509-certificate |
padding | Padding for the asymmetric encryption (optional, default: OaepSHA256) |
ArgumentNullException |
|
static |
Encrypts a byte-array with a X509-certificate.
dataToEncrypt | byte-array to encrypt |
cert | X509-certificate |
padding | Padding for the asymmetric encryption (optional, default: OaepSHA256) |
ArgumentNullException |
|
static |
Encrypts a string with a X509-certificate.
textToEncrypt | string to encrypt |
cert | X509-certificate |
padding | Padding for the asymmetric encryption (optional, default: OaepSHA256) |
encoding | Encoding of the string (optional, default: UTF8) |
ArgumentNullException |
|
static |
Generates a self-signed X509-certificate.
certName | Name of the certificate |
keyLength | Key length of the certificate (optional, default: 2048) |
oid | OID for the certificate (optional, default: "1.2.840.10045.3.1.7" |
|
static |
Gets a X509-certificate from a byte-array.
data | X509-certificate as byte-array |
password | Password for the certificate |
ArgumentNullException |
|
static |
Gets a X509-certificate from the key store.
certName | Name of the certificate |
storeLocation | Location in the key store (optional, default: LocalMachine) |
|
static |
Gets the private and public key from a X509-certificate. NOTE: never share this data with people outside of your organisation!
cert | X509-certificate |
password | Password for the file (optional, default: none) |
|
static |
Gets the public key from a X509-certificate.
cert | X509-certificate |
password | Password for the file (optional, default: none) |
|
static |
Reads a X509-certificate from a file.
filename | Name of the file with the certificate |
password | Password for the file |
Exception |
|
static |
Reads a X509-certificate from a file asynchronously.
filename | Name of the file with the certificate |
password | Password for the file |
Exception |
|
static |
Writes the private and public key as X509-certificate to a file. NOTE: never share this file with people outside of your organisation!
filename | Name of the file for the certificate |
cert | X509-certificate |
password | Password for the file |
Exception |
|
static |
Writes the private and public key as X509-certificate to a file asynchronously. NOTE: never share this file with people outside of your organisation!
filename | Name of the file for the certificate |
cert | X509-certificate |
password | Password for the file |
Exception |
|
static |
Writes the public key as X509-certificate to a file.
filename | Name of the file |
cert | X509-certificate |
password | Password for the file (optional, default: none) |
Exception |
|
static |
Writes the public key as X509-certificate to a file asynchronously.
filename | Name of the file |
cert | X509-certificate |
password | Password for the file (optional, default: none) |
Exception |