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
keySizeintThe key size in bits.
Properties
DefaultPrivateKey
Returns the default private key as stored in the *.config file.
public Asymmetric.PrivateKey DefaultPrivateKey { get; }
Property Value
DefaultPublicKey
Returns the default public key as stored in the *.config file.
public Asymmetric.PublicKey DefaultPublicKey { get; }
Property Value
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
Remarks
http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/q322/3/71.asp&NoWebContent=1
KeySizeBits
Returns the current key size, in bits.
public int KeySizeBits { get; }
Property Value
KeySizeMaxBits
Returns the maximum supported key size, in bits.
public int KeySizeMaxBits { get; }
Property Value
KeySizeMinBits
Returns the minimum supported key size, in bits.
public int KeySizeMinBits { get; }
Property Value
KeySizeStepBits
Returns valid key step sizes, in bits.
public int KeySizeStepBits { get; }
Property Value
Methods
Decrypt(DataCrypt)
Decrypts data using the default private key from the config file.
public DataCrypt Decrypt(DataCrypt encryptedDataCrypt)
Parameters
encryptedDataCryptDataCryptThe encrypted data to decrypt.
Returns
Decrypt(DataCrypt, PrivateKey)
Decrypts data using the provided private key.
public DataCrypt Decrypt(DataCrypt encryptedDataCrypt, Asymmetric.PrivateKey privateKey)
Parameters
encryptedDataCryptDataCryptThe encrypted data to decrypt.
privateKeyAsymmetric.PrivateKeyThe private key to use for decryption.
Returns
Decrypt(DataCrypt, string)
Decrypts data using the provided private key as XML.
public DataCrypt Decrypt(DataCrypt encryptedDataCrypt, string privateKeyXml)
Parameters
encryptedDataCryptDataCryptThe encrypted data to decrypt.
privateKeyXmlstringThe private key XML string.
Returns
Encrypt(DataCrypt)
Encrypts data using the default public key.
public DataCrypt Encrypt(DataCrypt dataCrypt)
Parameters
dataCryptDataCryptThe data to encrypt.
Returns
Encrypt(DataCrypt, PublicKey)
Encrypts data using the provided public key.
public DataCrypt Encrypt(DataCrypt dataCrypt, Asymmetric.PublicKey publicKey)
Parameters
dataCryptDataCryptThe data to encrypt.
publicKeyAsymmetric.PublicKeyThe public key to use for encryption.
Returns
Encrypt(DataCrypt, string)
Encrypts data using the provided public key as XML.
public DataCrypt Encrypt(DataCrypt dataCrypt, string publicKeyXml)
Parameters
Returns
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
publicKeyAsymmetric.PublicKeyThe generated public key object.
privateKeyAsymmetric.PrivateKeyThe 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)