/// <summary>
 /// Injectable constructor that can use your own IAsymmetricCryptography implementation.
 /// </summary>
 /// <param name="asymmetricCryptography">Class that implements IAsymmetricCryptography.</param>
 public AsymmetricCrypto(IAsymmetricCrypto asymmetricCryptography)
 {
     _asymmetricCryptography = asymmetricCryptography;
     if (_asymmetricCryptography == null)
     {
         _asymmetricCryptography = new RSACrypto();
     }
 }
예제 #2
0
        public void Serialize(ISerializationContext context, IValueWriter writer, IAsymmetricCrypto crypto)
        {
            if (!writer.WriteBool(this.publicKey != null))
            {
                return;
            }

            writer.WriteBytes(crypto.Encrypt(Exponent));

            int first = this.Modulus.Length / 2;

            writer.WriteBytes(crypto.Encrypt(Modulus.Copy(0, first)));
            writer.WriteBytes(crypto.Encrypt(Modulus.Copy(first, Modulus.Length - first)));
        }
예제 #3
0
 /// <summary>Constructor taking a reference to an implementation of the <c>IAsymmetricCrypto</c> service interface.</summary>
 public AsymmetricController(IAsymmetricCrypto crypto)
 {
     this.crypto = crypto;
 }
 /// <summary>
 /// Default constructor assigns RsaCrypto class to perform Asymmetric Cryptography operations.
 /// </summary>
 public AsymmetricCrypto()
 {
     _asymmetricCryptography = new RSACrypto();
 }
예제 #5
0
        public void Serialize(ISerializationContext context, IValueWriter writer, IAsymmetricCrypto crypto)
        {
            if (!writer.WriteBool (this.publicKey != null))
                return;

            writer.WriteBytes (crypto.Encrypt (Exponent));

            int first = this.Modulus.Length / 2;
            writer.WriteBytes (crypto.Encrypt (Modulus.Copy (0, first)));
            writer.WriteBytes (crypto.Encrypt (Modulus.Copy (first, Modulus.Length - first)));
        }