Click or drag to resize

RsaSerializer Class

Serializer using RSA.
Inheritance Hierarchy
SystemObject
  Eneter.Messaging.DataProcessing.SerializingRsaSerializer

Namespace:  Eneter.Messaging.DataProcessing.Serializing
Assembly:  Eneter.Messaging.Framework (in Eneter.Messaging.Framework.dll) Version: 8.0.0.0 (8.0.0.0)
Syntax
public class RsaSerializer : ISerializer

The RsaSerializer type exposes the following members.

Constructors
  NameDescription
Public methodRsaSerializer(RSAParameters, RSAParameters)
Constructs the RSA serializer with default paraneters.
Public methodRsaSerializer(RSAParameters, RSAParameters, Int32, ISerializer)
Constructs the RSA serializer with custom parameters.
Top
Methods
  NameDescription
Public methodDeserialize_T
Deserializes data.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSerialize_T
Serializes data.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
The serialization:
  1. Incoming data is serialized by underlying serializer (e.g. XmlStringSerializer)
  2. The random key is generated and used with AES algorythm to encrypt the serialized data.
  3. The random key for AES is encrypted by RSA using the public key.
  4. The serialized data consits of AES encrypted data and RSA encrypted key for AES.
The deserialization:
  1. The receiver decrypts the AES key by RSA using its private key.
  2. Decrypted key is used to decrypt AES encrypted data.
  3. Decrypted data is deserialized by underlying serialized (e.g. XmlStringSerializer)
  4. The deserialization returns deserialized data.

Examples
Example shows how to serialize/deserialize data.
// Generate public and private keys.
RSACryptoServiceProvider aCryptoProvider = new RSACryptoServiceProvider();
RSAParameters aPublicKey = aCryptoProvider.ExportParameters(false);
RSAParameters aPrivateKey = aCryptoProvider.ExportParameters(true);

// Create the serializer.
RsaSerializer aSerializer = new RsaSerializer(aPublicKey, aPrivateKey);

// Serialize data.
object aSerializedData = aSerializer.Serialize<string>("Hello world.");


// Deserialize data.
string aDeserializedData = aSerializer.Deserialize<string>(aSerializedData);
See Also