Пример #1
0
        private static IList <HeaderBlock> LoadFromReader(AxCryptReaderBase vxReader)
        {
            List <HeaderBlock> headers = new List <HeaderBlock>();

            vxReader.Read();
            if (vxReader.CurrentItemType != AxCryptItemType.MagicGuid)
            {
                throw new FileFormatException("No magic Guid was found.", ErrorStatus.MagicGuidMissing);
            }

            ReadHeadersToLast(headers, vxReader, HeaderBlockType.Data);
            return(headers);
        }
Пример #2
0
        private static void ReadHeadersToLast(IList <HeaderBlock> headerBlocks, AxCryptReaderBase axCryptReader, HeaderBlockType last)
        {
            while (axCryptReader.Read())
            {
                switch (axCryptReader.CurrentItemType)
                {
                case AxCryptItemType.Data:
                case AxCryptItemType.HeaderBlock:
                    break;

                default:
                    throw new InternalErrorException("The reader returned an item type it should not be possible for it to return.");
                }

                headerBlocks.Add(axCryptReader.CurrentHeaderBlock);

                if (axCryptReader.CurrentHeaderBlock.HeaderBlockType == last)
                {
                    return;
                }
            }
            throw new FileFormatException("Premature end of stream.", ErrorStatus.EndOfStream);
        }