private void Encode(NTRUParameters param) { NTRUKeyPair kp; using (NTRUKeyGenerator kg = new NTRUKeyGenerator(param)) kp = (NTRUKeyPair)kg.GenerateKeyPair(); // encode to byte[] and reconstruct byte[] enc = kp.ToBytes(); NTRUKeyPair kp2 = new NTRUKeyPair(enc); if (!Evaluate.Equals(kp, kp2)) { throw new Exception("NtruKeyPair encoding test failed!"); } // encode to OutputStream and reconstruct MemoryStream bos = new MemoryStream(); kp.WriteTo(bos); MemoryStream bis = new MemoryStream(bos.ToArray()); NTRUKeyPair kp3 = new NTRUKeyPair(bis); if (!Evaluate.Equals(kp, kp3)) { throw new Exception("NtruKeyPair encoding test failed!"); } }
private void GetOutputLength() { NTRUParameters[] paramSets = new NTRUParameters[] { (NTRUParameters)NTRUParamSets.APR2011439.DeepCopy(), (NTRUParameters)NTRUParamSets.APR2011439FAST.DeepCopy(), (NTRUParameters)NTRUParamSets.APR2011743.DeepCopy(), (NTRUParameters)NTRUParamSets.APR2011743FAST.DeepCopy(), (NTRUParameters)NTRUParamSets.EES1087EP2.DeepCopy(), (NTRUParameters)NTRUParamSets.EES1171EP1.DeepCopy(), (NTRUParameters)NTRUParamSets.EES1499EP1.DeepCopy(), }; byte[] plainText = ByteUtils.GetBytes("secret encrypted text"); foreach (NTRUParameters param in paramSets) { NTRUKeyPair kp; using (NTRUKeyGenerator kg = new NTRUKeyGenerator(param)) kp = (NTRUKeyPair)kg.GenerateKeyPair(); NTRUEncrypt ntru = new NTRUEncrypt(param); ntru.Initialize(kp.PublicKey); byte[] encrypted = ntru.Encrypt(plainText); if (!Evaluate.Equals(param.GetOutputLength(), encrypted.Length)) { throw new Exception("NtruEncryptTest: output length test failed!"); } } }
public void Equals_BothNull_ReturnsTrue() { // ReSharper disable once ConditionIsAlwaysTrueOrFalse // ReSharper disable once EqualExpressionComparison var actual = Evaluate.Equals(null, null); Assert.IsTrue(actual); }
public void Equals_RightNullWithParameters_ReturnsFalse() { var valueA = new FakeTestItem { TestDateTime = DateTime.Now, TestInt = 290, TestString = "blah" }; var actual = Evaluate.Equals(valueA, null, item => item.TestDateTime, item => item.TestInt, item => item.TestString); Assert.IsFalse(actual); }
public void Equals_LeftNull_ReturnsFalse() { var valueB = new FakeTestItem { TestDateTime = DateTime.Now, TestInt = 290, TestString = "blah" }; var actual = Evaluate.Equals(null, valueB); Assert.IsFalse(actual); }
/// <summary> /// Determines whether two <see cref="EntityLocation"/> values represent the same location. /// </summary> /// <returns> /// true if the specified objects are equal; otherwise, false. /// </returns> /// <param name="x"> /// The first object to compare. /// </param> /// <param name="y"> /// The second object to compare. /// </param> public override bool Equals(EntityLocation x, EntityLocation y) { return(Evaluate.Equals( x, y, location => location.EntityType, location => location.Alias, location => location.Name, location => location.Container)); }
public void Equals_TestObjectsWithEqualProperties_ReturnsTrue() { var valueA = new FakeTestItem { TestString = "test", TestInt = 1 }; var valueB = new FakeTestItem { TestString = "test", TestInt = 1 }; var actual = Evaluate.Equals(valueA, valueB); Assert.IsTrue(actual); }
public void Equals_TestObjectsWithSpecificEqualProperties_ReturnsTrue() { var valueA = new FakeTestItem { TestString = "test", TestInt = 1, TestDateTime = DateTime.MinValue }; var valueB = new FakeTestItem { TestString = "test", TestInt = 4, TestDateTime = DateTime.MinValue }; var actual = Evaluate.Equals(valueA, valueB, o => o.TestString, o => o.TestDateTime); Assert.AreEqual(true, actual); }
private void Encode(NTRUParameters param) { NTRUKeyGenerator ntru = new NTRUKeyGenerator(param); NTRUKeyPair kp = (NTRUKeyPair)ntru.GenerateKeyPair(); byte[] priv = ((NTRUPrivateKey)kp.PrivateKey).ToBytes(); byte[] pub = ((NTRUPublicKey)kp.PublicKey).ToBytes(); NTRUKeyPair kp2 = new NTRUKeyPair(new NTRUPublicKey(pub), new NTRUPrivateKey(priv)); if (!Evaluate.Equals(kp.PublicKey, kp2.PublicKey)) { throw new Exception("EncryptionKey: public key comparison test failed!"); } if (kp.PublicKey.GetHashCode() != kp2.PublicKey.GetHashCode()) { throw new Exception("EncryptionKey: public key hash test failed!"); } if (!Evaluate.Equals(kp.PrivateKey, kp2.PrivateKey)) { throw new Exception("EncryptionKey: private key comparison test failed!"); } if (kp.PrivateKey.GetHashCode() != kp2.PrivateKey.GetHashCode()) { throw new Exception("EncryptionKey: private key hash test failed!"); } MemoryStream bos1 = new MemoryStream(); MemoryStream bos2 = new MemoryStream(); ((NTRUPrivateKey)kp.PrivateKey).WriteTo(bos1); ((NTRUPublicKey)kp.PublicKey).WriteTo(bos2); MemoryStream bis1 = new MemoryStream(bos1.ToArray()); MemoryStream bis2 = new MemoryStream(bos2.ToArray()); NTRUKeyPair kp3 = new NTRUKeyPair(new NTRUPublicKey(bis2), new NTRUPrivateKey(bis1)); if (!Evaluate.Equals(kp.PublicKey, kp3.PublicKey)) { throw new Exception("EncryptionKey: public key comparison test failed!"); } if (kp.PublicKey.GetHashCode() != kp3.PublicKey.GetHashCode()) { throw new Exception("EncryptionKey: public key hash test failed!"); } if (!Evaluate.Equals(kp.PrivateKey, kp3.PrivateKey)) { throw new Exception("EncryptionKey: private key comparison test failed!"); } if (kp.PrivateKey.GetHashCode() != kp3.PrivateKey.GetHashCode()) { throw new Exception("EncryptionKey: private key hash test failed!"); } }
public void LoadSave() { NTRUParameters param = (NTRUParameters)NTRUParamSets.EES1499EP1.DeepCopy(); MemoryStream os = new MemoryStream(); param.WriteTo(os); MemoryStream ins = new MemoryStream(os.ToArray()); if (!Evaluate.Equals(param, new NTRUParameters(ins))) { throw new Exception("NtruParameters: load and save test failed!"); } }
public void Clone() { NTRUParameters param = NTRUParamSets.APR2011439; NTRUParameters param2 = (NTRUParameters)param.DeepCopy(); if (!Evaluate.Equals(param, param2)) { throw new Exception("NtruParameters: cloned copy is not equal!"); } if (param.GetHashCode() != param.GetHashCode()) { throw new Exception("Parameters: parameters hash test failed!"); } param = NTRUParamSets.APR2011439FAST; param2 = (NTRUParameters)param.DeepCopy(); if (!Evaluate.Equals(param, param2)) { throw new Exception("NtruParameters: cloned copy is not equal!"); } if (param.GetHashCode() != param.GetHashCode()) { throw new Exception("Parameters: parameters hash test failed!"); } param2.Digest = Digests.Blake2B512; if (Evaluate.Equals(param, param2)) { throw new Exception("NtruParameters: cloned copy is not equal!"); } if (param.GetHashCode() != param.GetHashCode()) { throw new Exception("Parameters: parameters hash test failed!"); } }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(UnifiedField other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(DependentRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(Template other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(ResultPage other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(SignatureOptionRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Compares the equality of two values of the same type. /// </summary> /// <param name="valueA"> /// The first value to compare. /// </param> /// <param name="valueB"> /// The second value to compare. /// </param> /// <returns> /// <c>true</c> if the values are equal; otherwise, <c>false</c>. /// </returns> public static bool operator ==(EntityLocation valueA, EntityLocation valueB) { return(Evaluate.Equals(valueA, valueB)); }
/// <summary> /// Determines whether the specified object is equal to the current object. /// </summary> /// <returns> /// true if the specified object is equal to the current object; otherwise, false. /// </returns> /// <param name="obj"> /// The object to compare with the current object. /// </param> /// <filterpriority>2</filterpriority> public override bool Equals(object obj) { return(Evaluate.Equals(this, obj)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(DocumentVersion other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(FieldValueElement other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(SubEntity other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(InstanceSection other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(OverriddenColumnNameRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(MultiReferenceRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(FakeTestItem other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(RelatedRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(AttributeLocation other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(SubContainerRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(UnifiedFieldValue other) { return(Evaluate.Equals(this, other, ComparisonProperties) && this.FieldValues.SequenceEqual(other?.FieldValues ?? new List <object>())); }
/// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false. /// </returns> /// <param name="other"> /// An object to compare with this object. /// </param> public bool Equals(DomainIdentityRow other) { return(Evaluate.Equals(this, other, ComparisonProperties)); }