Class RsaKeyReader
Reads RSA keys from PEM or DER and creates BCL RSA instances. Supports PKCS#1 (RSAPrivateKey, RSAPublicKey), PKCS#8 PrivateKeyInfo, and SubjectPublicKeyInfo.
Inherited Members
Namespace: DRIT.Mail.Rfc.Crypto
Assembly: DRIT.Mail.dll
Syntax
public static class RsaKeyReader
Methods
View SourceCreateFromPrivateKeyPem(string)
Creates an RSA instance from a PEM-encoded RSA private key.
Declaration
public static RSA CreateFromPrivateKeyPem(string pemText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pemText | The pem text used by the operation. |
Returns
| Type | Description |
|---|---|
| RSA |
CreateFromPublicKeyPem(string)
Creates an RSA instance from a PEM-encoded RSA public key.
Declaration
public static RSA CreateFromPublicKeyPem(string pemText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pemText | The pem text used by the operation. |
Returns
| Type | Description |
|---|---|
| RSA |
ReadPkcs1PrivateKey(byte[])
Reads a PKCS#1 RSAPrivateKey from DER bytes.
Declaration
public static RSAParameters ReadPkcs1PrivateKey(byte[] der)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | der | Specifies the der value. |
Returns
| Type | Description |
|---|---|
| RSAParameters |
ReadPkcs1PublicKey(byte[])
Reads a PKCS#1 RSAPublicKey from DER bytes.
Declaration
public static RSAParameters ReadPkcs1PublicKey(byte[] der)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | der | Specifies the der value. |
Returns
| Type | Description |
|---|---|
| RSAParameters |
ReadPkcs8PrivateKey(byte[])
Reads a PKCS#8 PrivateKeyInfo containing an RSA private key.
Declaration
public static RSAParameters ReadPkcs8PrivateKey(byte[] der)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | der | Specifies the der value. |
Returns
| Type | Description |
|---|---|
| RSAParameters |
ReadPrivateKeyFromPem(string)
Reads an RSA private key from PEM text. Supports both RSA PRIVATE KEY
(PKCS#1) and PRIVATE KEY (PKCS#8) labels.
Declaration
public static RSAParameters ReadPrivateKeyFromPem(string pemText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pemText | The pem text used by the operation. |
Returns
| Type | Description |
|---|---|
| RSAParameters |
ReadPublicKeyFromPem(string)
Reads an RSA public key from PEM text. Supports both RSA PUBLIC KEY
(PKCS#1) and PUBLIC KEY (SubjectPublicKeyInfo) labels.
Declaration
public static RSAParameters ReadPublicKeyFromPem(string pemText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | pemText | The pem text used by the operation. |
Returns
| Type | Description |
|---|---|
| RSAParameters |
ReadSubjectPublicKeyInfo(byte[])
Reads a SubjectPublicKeyInfo containing an RSA public key.
Declaration
public static RSAParameters ReadSubjectPublicKeyInfo(byte[] der)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | der | Specifies the der value. |
Returns
| Type | Description |
|---|---|
| RSAParameters |