/// <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(); } }
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))); }
/// <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(); }
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))); }