Asymmetric encryption (3). NET Asymmetric Encryption system

Source: Internet
Author: User
Tags abstract constructor asymmetric encryption

As with symmetric encryption algorithms, the related classes of all asymmetric algorithms also exist in the System.Security.Cryptography namespace. In this namespace,. NET Framework provides four kinds of asymmetric encryption algorithms, such as RSA, DSA, ECC and Differ-hellman. This section describes several of the major related classes and interfaces. The relevant content of the application will be described in the next section.

AsymmetricAlgorithm class

The AsymmetricAlgorithm abstract class is the base class for all asymmetric cryptographic algorithm-related classes. The main members of the class are as follows:

1) AsymmetricAlgorithm () function. The function is the constructor of the AsymmetricAlgorithm class.

2) static Create () function. Creates an execution object for an asymmetric cryptographic algorithm.

3) Static AsymmetricAlgorithm Create (string algname) function. Creates an image of the execution of an asymmetric cryptographic algorithm that specifies the name.

4) abstract void fromxmlstring (String xmlstring) function. When overridden in a derived class, reconstructs the AsymmetricAlgorithm object from an XML string.

5 int keysizevalue field. Represents the size, in bits, of the key module used by the asymmetric algorithm.

6) keysizes[] legalkeysizesvalue field. Specifies the key size that is supported by the asymmetric algorithm. The asymmetric algorithm only supports key sizes that match entries in the array.

7 Abstract string Keyexchangealgorithm {get;} Property. When overridden in a derived class, gets the name of the key exchange algorithm.

8 virtual int KeySize {get; set;} Property. Gets or sets the size, in bits, of the key module used by the asymmetric algorithm.

9) Virtual keysizes[] legalkeysizes {get;} Property. Gets the key size that is supported by the asymmetric algorithm. The asymmetric algorithm only supports key sizes that match entries in the array.

Abstract string Signaturealgorithm {get;} Property. Gets the name of the signature algorithm.

RSA class

The RSA class is the base class for all RSA algorithm implementation classes and inherits from the AsymmetricAlgorithm class. The main members of the RSA class are as follows (the members inherited from the AsymmetricAlgorithm class are no longer repeated):

1) Abstract byte[] Decryptvalue (byte[] RGB) method. When overridden in a derived class, decrypts the input data using the private key. Parameter RGB is the cipher text to decrypt.

2 abstract RSAParameters exportparameters (bool includeprivateparameters) method. When overridden in a derived class, exports the RSAParameters instance. False if the parameter includeprivateparameters is true to include a private parameter.

3 abstract void ImportParameters (RSAParameters parameters) method. When overridden in a derived class, imports the specified RSAParameters instance.

RSACryptoServiceProvider class

The RSACryptoServiceProvider class is the default implementation of the RSA class and inherits the Icspasymmetricalgorithm interface. The following are the non-State successor members of the class:

1) RSACryptoServiceProvider () constructor. Initializes a new instance of the RSACryptoServiceProvider class with the default key. If no default key is found, a new key is created. This constructor creates an exchange key pair that encrypts session keys so that they can be securely stored and exchanged with other users. The generated key corresponds to the key that is generated with the At_keyexchange value used in the unmanaged Microsoft cryptographic API (CAPI).

2) RSACryptoServiceProvider (int dwkeysize) constructor. Initializes a new instance of the RSACryptoServiceProvider class with the specified key size.

3) RSACryptoServiceProvider (cspparameters parameters) constructor. Initializes a new instance of the RSACryptoServiceProvider class with the specified parameters. This constructor creates or reuses the key container specified by the KeyContainerName field using the parameters parameter. By default, this constructor creates an exchange key pair that encrypts session keys so that they can be securely stored and exchanged with other users.   The generated key corresponds to the key that is generated with the At_keyexchange value used in the unmanaged Microsoft Cryptographic API (CAPI). You can create a signature key pair to authenticate a message or file (digitally signed) by setting the Keynumber field of the parameters parameter to the signature value. This type of key corresponds to the at_signature value used in CAPI. If you create a RSACryptoServiceProvider object with the specified exchange value, and then create another RSACryptoServiceProvider object with the specified signature value, If all two objects specify the same key container name, two keys are placed in a container. To create a key that is compatible with a strong name signature that uses the RSACryptoServiceProvider class, you must create a signature key pair.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.