Table of Contents

Class Asymmetric

Namespace
SunamoShared.Crypting
Assembly
SunamoShared.dll

Asymmetric encryption uses a pair of keys to encrypt and decrypt. There is a "public" key which is used to encrypt. Decrypting, on the other hand, requires both the "public" key and an additional "private" key. The advantage is that people can send you encrypted messages without being able to decrypt them.

public class Asymmetric
Inheritance
Asymmetric
Inherited Members
Extension Methods

Remarks

The only provider supported is the RSACryptoServiceProvider

Constructors

Asymmetric()

Instantiates a new asymmetric encryption session using the default key size (usually 1024 bits).

public Asymmetric()

Asymmetric(int)

Instantiates a new asymmetric encryption session using a specific key size.

public Asymmetric(int keySize)

Parameters

keySize int

The key size in bits.

Properties

DefaultPrivateKey

Returns the default private key as stored in the *.config file.

public Asymmetric.PrivateKey DefaultPrivateKey { get; }

Property Value

Asymmetric.PrivateKey

DefaultPublicKey

Returns the default public key as stored in the *.config file.

public Asymmetric.PublicKey DefaultPublicKey { get; }

Property Value

Asymmetric.PublicKey

KeyContainerName

Sets the name of the key container used to store this key on disk; this is an unavoidable side effect of the underlying Microsoft CryptoAPI.

public string KeyContainerName { get; set; }

Property Value

string

Remarks

KeySizeBits

Returns the current key size, in bits.

public int KeySizeBits { get; }

Property Value

int

KeySizeMaxBits

Returns the maximum supported key size, in bits.

public int KeySizeMaxBits { get; }

Property Value

int

KeySizeMinBits

Returns the minimum supported key size, in bits.

public int KeySizeMinBits { get; }

Property Value

int

KeySizeStepBits

Returns valid key step sizes, in bits.

public int KeySizeStepBits { get; }

Property Value

int

Methods

Decrypt(DataCrypt)

Decrypts data using the default private key from the config file.

public DataCrypt Decrypt(DataCrypt encryptedDataCrypt)

Parameters

encryptedDataCrypt DataCrypt

The encrypted data to decrypt.

Returns

DataCrypt

Decrypt(DataCrypt, PrivateKey)

Decrypts data using the provided private key.

public DataCrypt Decrypt(DataCrypt encryptedDataCrypt, Asymmetric.PrivateKey privateKey)

Parameters

encryptedDataCrypt DataCrypt

The encrypted data to decrypt.

privateKey Asymmetric.PrivateKey

The private key to use for decryption.

Returns

DataCrypt

Decrypt(DataCrypt, string)

Decrypts data using the provided private key as XML.

public DataCrypt Decrypt(DataCrypt encryptedDataCrypt, string privateKeyXml)

Parameters

encryptedDataCrypt DataCrypt

The encrypted data to decrypt.

privateKeyXml string

The private key XML string.

Returns

DataCrypt

Encrypt(DataCrypt)

Encrypts data using the default public key.

public DataCrypt Encrypt(DataCrypt dataCrypt)

Parameters

dataCrypt DataCrypt

The data to encrypt.

Returns

DataCrypt

Encrypt(DataCrypt, PublicKey)

Encrypts data using the provided public key.

public DataCrypt Encrypt(DataCrypt dataCrypt, Asymmetric.PublicKey publicKey)

Parameters

dataCrypt DataCrypt

The data to encrypt.

publicKey Asymmetric.PublicKey

The public key to use for encryption.

Returns

DataCrypt

Encrypt(DataCrypt, string)

Encrypts data using the provided public key as XML.

public DataCrypt Encrypt(DataCrypt dataCrypt, string publicKeyXml)

Parameters

dataCrypt DataCrypt

The data to encrypt.

publicKeyXml string

The public key XML string.

Returns

DataCrypt

GenerateNewKeyset(ref PublicKey, ref PrivateKey)

Generates a new public/private key pair as objects.

public void GenerateNewKeyset(ref Asymmetric.PublicKey publicKey, ref Asymmetric.PrivateKey privateKey)

Parameters

publicKey Asymmetric.PublicKey

The generated public key object.

privateKey Asymmetric.PrivateKey

The generated private key object.

GenerateNewKeyset(ref string, ref string)

Generates a new public/private key pair as XML strings.

public void GenerateNewKeyset(ref string publicKeyXml, ref string privateKeyXml)

Parameters

publicKeyXml string

The generated public key XML string.

privateKeyXml string

The generated private key XML string.