private void CipherDescriptionTest() { CipherDescription cd1 = new CipherDescription( SymmetricEngines.RHX, 192, IVSizes.V128, CipherModes.CTR, PaddingModes.None, BlockSizes.B128, RoundCounts.R22); byte[] bcd = cd1.ToBytes(); CipherDescription cd2 = new CipherDescription(bcd); if (!cd1.Equals(cd2)) { throw new Exception("KeyFactoryTest: CipherDescription serialization has failed!"); } MemoryStream mcd = cd2.ToStream(); CipherDescription cd3 = new CipherDescription(mcd); if (!cd1.Equals(cd3)) { throw new Exception("KeyFactoryTest: CipherDescription serialization has failed!"); } int x = cd1.GetHashCode(); if (x != cd2.GetHashCode() || x != cd3.GetHashCode()) { throw new Exception("KeyFactoryTest: CipherDescription hash code test has failed!"); } }
void SerializeStructTest() { CipherDescription cd = new CipherDescription( SymmetricEngines.RHX, 192, IVSizes.V128, CipherModes.CTR, PaddingModes.PKCS7, BlockSizes.B128, RoundCounts.R22, Digests.Skein512, 64, Digests.SHA512); CipherDescription cy = new CipherDescription(cd.ToStream()); if (!cy.Equals(cd)) { throw new Exception("CipherStreamTest: CipherDescriptions are not equal!"); } cy.KeySize = 0; if (cy.Equals(cd)) { throw new Exception("CipherStreamTest: CipherDescriptionsare not equal!"); } }