public static void TestClone() { V1KeyWrap2HeaderBlock keyWrap2HeaderBlock = new V1KeyWrap2HeaderBlock(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }); V1KeyWrap2HeaderBlock cloned = (V1KeyWrap2HeaderBlock)keyWrap2HeaderBlock.Clone(); Assert.That(keyWrap2HeaderBlock, Is.Not.SameAs(cloned), "The clone should not be the same reference."); Assert.That(cloned.GetDataBlockBytes(), Is.EquivalentTo(keyWrap2HeaderBlock.GetDataBlockBytes()), "The clone should have equivalent data block bytes as the original."); }
public static void TestKeyWrap2HeaderBlock() { using (MemoryStream inputStream = new MemoryStream()) { AxCrypt1Guid.Write(inputStream); PreambleHeaderBlock preambleHeaderBlock = new PreambleHeaderBlock(); preambleHeaderBlock.Write(inputStream); V1KeyWrap2HeaderBlock keyWrap2HeaderBlock = new V1KeyWrap2HeaderBlock(new byte[0]); keyWrap2HeaderBlock.Write(inputStream); inputStream.Position = 0; using (V1AxCryptReader axCryptReader = new V1AxCryptReader(new LookAheadStream(inputStream))) { Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the Guid"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.MagicGuid), "We're expecting to have found a MagicGuid"); Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the next HeaderBlock"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.HeaderBlock), "We're expecting to have found a HeaderBlock"); Assert.That(axCryptReader.CurrentHeaderBlock.HeaderBlockType, Is.EqualTo(HeaderBlockType.Preamble), "We're expecting to have found a Preamble specifically"); Assert.That(axCryptReader.Read(), Is.True, "We should be able to read the next HeaderBlock"); Assert.That(axCryptReader.CurrentItemType, Is.EqualTo(AxCryptItemType.HeaderBlock), "We're expecting to have found a HeaderBlock"); Assert.That(axCryptReader.CurrentHeaderBlock.HeaderBlockType, Is.EqualTo(HeaderBlockType.KeyWrap2), "We're expecting to have found a KeyWrap2 specifically"); } } }
public override object Clone() { V1KeyWrap2HeaderBlock block = new V1KeyWrap2HeaderBlock((byte[])GetDataBlockBytesReference().Clone()); return(block); }