public static void TestHeaderBlockFactory(CryptoImplementation cryptoImplementation)
        {
            SetupAssembly.AssemblySetupCrypto(cryptoImplementation);

            V1DocumentHeaders headers = new V1DocumentHeaders(new Passphrase("passphrase"), 10);

            using (MemoryStream stream = new MemoryStream())
            {
                headers.WriteWithoutHmac(stream);
                stream.Position = 0;

                UnversionedAxCryptReader reader = new UnversionedAxCryptReader(new LookAheadStream(stream));
                bool unexpectedHeaderTypeFound  = false;
                while (reader.Read())
                {
                    if (reader.CurrentItemType != AxCryptItemType.HeaderBlock)
                    {
                        continue;
                    }
                    switch (reader.CurrentHeaderBlock.HeaderBlockType)
                    {
                    case HeaderBlockType.Preamble:
                    case HeaderBlockType.Version:
                    case HeaderBlockType.Data:
                    case HeaderBlockType.Unrecognized:
                        break;

                    default:
                        unexpectedHeaderTypeFound = !(reader.CurrentHeaderBlock is UnrecognizedHeaderBlock);
                        break;
                    }
                }
                Assert.That(unexpectedHeaderTypeFound, Is.False);
            }
        }
示例#2
0
        private static IList <HeaderBlock> LoadUnversionedHeaders(LookAheadStream inputStream)
        {
            UnversionedAxCryptReader vxReader = new UnversionedAxCryptReader(inputStream);

            return(LoadFromReader(vxReader));
        }
        public static void TestNotImplemented()
        {
            UnversionedAxCryptReader reader = new UnversionedAxCryptReader(new LookAheadStream(Stream.Null));

            Assert.Throws <NotImplementedException>(() => reader.Document(new Passphrase("test"), new V1Aes128CryptoFactory().CryptoId, new Headers()));
        }