Class RSACryptoTransform
Implements a cryptographic transformation that encrypts data using the RSA algorithm.
Inherited Members
Namespace: TheXDS.MCART.Security.Cryptography
Assembly: MCART.Windows.dll
Syntax
public class RSACryptoTransform : Disposable, IDisposableEx, ICryptoTransform, IDisposable
Constructors
| Edit this page View SourceRSACryptoTransform()
Initializes a new instance of the RSACryptoTransform class, generating a 4096‑bit RSA key.
Declaration
public RSACryptoTransform()
RSACryptoTransform(byte[])
Initializes a new instance of the RSACryptoTransform class using the specified byte blob containing RSA configuration information.
Declaration
public RSACryptoTransform(byte[] keyBlob)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | keyBlob | Binary CSP blob that contains the RSA key configuration. |
RSACryptoTransform(int)
Initializes a new instance of the RSACryptoTransform class with the specified RSA key size.
Declaration
public RSACryptoTransform(int keySize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | keySize | Size of the RSA key to generate. |
RSACryptoTransform(int, CspParameters)
Initializes a new instance of the RSACryptoTransform class, specifying the key size and CspParameters for initialization.
Declaration
public RSACryptoTransform(int dwKeySize, CspParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| int | dwKeySize | RSA key size to use. |
| CspParameters | parameters | CspParameters for the RSA provider. |
RSACryptoTransform(CspParameters)
Initializes a new instance of the RSACryptoTransform class, specifying the CspParameters to use for initialization.
Declaration
public RSACryptoTransform(CspParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| CspParameters | parameters | CspParameters for the RSA provider. |
RSACryptoTransform(RSACryptoServiceProvider)
Initializes a new instance of the RSACryptoTransform class with the supplied RSACryptoServiceProvider.
Declaration
public RSACryptoTransform(RSACryptoServiceProvider rsa)
Parameters
| Type | Name | Description |
|---|---|---|
| RSACryptoServiceProvider | rsa |
RSACryptoTransform(RSAParameters)
Initializes a new instance of the RSACryptoTransform class, specifying the RSA parameters to use for initialization.
Declaration
public RSACryptoTransform(RSAParameters parameters)
Parameters
| Type | Name | Description |
|---|---|---|
| RSAParameters | parameters | RSA initialization parameters. |
Properties
| Edit this page View SourceCanReuseTransform
Indicates whether this ICryptoTransform can be reused to transform more than one block.
Declaration
public bool CanReuseTransform { get; }
Property Value
| Type | Description |
|---|---|
| bool |
CanTransformMultipleBlocks
Indicates whether this ICryptoTransform can transform multiple blocks.
Declaration
public bool CanTransformMultipleBlocks { get; }
Property Value
| Type | Description |
|---|---|
| bool |
InputBlockSize
Gets the input block size for the transformation.
Declaration
public int InputBlockSize { get; }
Property Value
| Type | Description |
|---|---|
| int |
OutputBlockSize
Gets the output block size for the transformation.
Declaration
public int OutputBlockSize { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
| Edit this page View SourceGetRSACspBlob(bool)
Exports the RSA CSP blob for this RSACryptoTransform.
Declaration
public byte[] GetRSACspBlob(bool includePrivateParameters)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includePrivateParameters | Indicates whether to include private key parameters in the exported value. |
Returns
| Type | Description |
|---|---|
| byte[] | The RSA CSP blob for this RSACryptoTransform. |
GetRSAParameters(bool)
Gets the RSA parameters for this RSACryptoTransform.
Declaration
public RSAParameters GetRSAParameters(bool includePrivateParameters)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | includePrivateParameters | Indicates whether to include private key parameters in the exported value. |
Returns
| Type | Description |
|---|---|
| RSAParameters | The RSA parameters for this RSACryptoTransform. |
OnDispose()
Releases all resources used by this object.
Declaration
protected override void OnDispose()
Overrides
| Edit this page View SourceToStream(Stream, RSACryptoServiceProvider)
Instantiates a new CryptoStream using the RSACryptoServiceProvider instance to create a new RSACryptoTransform.
Declaration
public static CryptoStream ToStream(Stream stream, RSACryptoServiceProvider rsa)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | Stream on which to write the encrypted data. |
| RSACryptoServiceProvider | rsa | RSACryptoServiceProvider instance to use for constructing the new RSACryptoTransform. |
Returns
| Type | Description |
|---|---|
| CryptoStream | A new CryptoStream with the specified destination and transformation object. |
TransformBlock(byte[], int, int, byte[], int)
Performs the transformation of a block of data.
Declaration
public int TransformBlock(byte[] inputBuffer, int inputOffset, int inputCount, byte[] outputBuffer, int outputOffset)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | inputBuffer | Input data buffer. |
| int | inputOffset | Offset within the input buffer from which to begin reading data. |
| int | inputCount | Number of bytes from the input buffer to transform. |
| byte[] | outputBuffer | Output buffer for the transformed data. |
| int | outputOffset | Offset within the output buffer at which to start writing. |
Returns
| Type | Description |
|---|---|
| int | The number of bytes written to the output buffer. |
TransformFinalBlock(byte[], int, int)
Performs the transformation of the final block of data.
Declaration
public byte[] TransformFinalBlock(byte[] inputBuffer, int inputOffset, int inputCount)
Parameters
| Type | Name | Description |
|---|---|---|
| byte[] | inputBuffer | Input data buffer. |
| int | inputOffset | Offset within the input buffer from which to begin reading. |
| int | inputCount | Number of bytes from the input buffer to transform. |
Returns
| Type | Description |
|---|---|
| byte[] | The transformed data block. |