/// <summary> /// Decides whether the given object <c>other</c> is the same as this field /// </summary> /// /// <param name="Obj">The object for comparison</param> /// /// <returns>Returns <c>(this == other)</c></returns> public override bool Equals(Object Obj) { if (Obj == null || !(Obj is RLWEPublicKey)) { return(false); } RLWEPublicKey key = (RLWEPublicKey)Obj; if (!N.Equals(key.N)) { return(false); } for (int i = 0; i < A.Length; i++) { if (key.A[i] != A[i]) { return(false); } } for (int i = 0; i < P.Length; i++) { if (key.P[i] != P[i]) { return(false); } } return(true); }
/// <summary> /// Get the asymmetric public key from a stream /// </summary> /// /// <param name="KeyStream">The encoded public key</param> /// <param name="Parameters">The cipher parameters</param> /// /// <returns>The public key</returns> private IAsymmetricKey GetAsymmetricPublicKey(Stream KeyStream, IAsymmetricParameters Parameters) { IAsymmetricKey key = null; try { if (Parameters.GetType().Equals(typeof(NTRUParameters))) key = new NTRUPublicKey(KeyStream); else if (Parameters.GetType().Equals(typeof(MPKCParameters))) key = new MPKCPublicKey(KeyStream); else if (Parameters.GetType().Equals(typeof(RLWEParameters))) key = new RLWEPublicKey(KeyStream); return key; } catch (Exception ex) { throw new CryptoProcessingException("DtmKex:GetAsymmetricPublicKey", "The public key could not be loaded!", ex); } }