internal static ZipIOCentralDirectoryDigitalSignature ParseRecord(BinaryReader reader) { // this record is optional, so let's check for presence of signature rightaway //let's ensure we have at least enough data to cover _fixedMinimalRecordSize bytes of signature if ((reader.BaseStream.Length - reader.BaseStream.Position) < _fixedMinimalRecordSize) { return(null); } UInt32 signatureValue = reader.ReadUInt32(); if (signatureValue != _signatureConstant) { return(null); } //at this point we can assume that Digital Signature Record is there // Convention is to throw throw new NotSupportedException(SR.Get(SRID.ZipNotSupportedSignedArchive)); // disable creation/parsing of zip archive digital signatures #if ArchiveSignaturesEnabled ZipIOCentralDirectoryDigitalSignature record = new ZipIOCentralDirectoryDigitalSignature(); record._signature = signatureValue; record._sizeOfData = reader.ReadUInt16(); record._signatureData = reader.ReadBytes(record._sizeOfData); record.Validate(); return(record); #endif }
internal static ZipIOCentralDirectoryDigitalSignature ParseRecord(BinaryReader reader) { // this record is optional, so let's check for presence of signature rightaway //let's ensure we have at least enough data to cover _fixedMinimalRecordSize bytes of signature if ((reader.BaseStream.Length - reader.BaseStream.Position) < _fixedMinimalRecordSize) { return null; } UInt32 signatureValue = reader.ReadUInt32(); if (signatureValue != _signatureConstant) { return null; } //at this point we can assume that Digital Signature Record is there // Convention is to throw throw new NotSupportedException(SR.Get(SRID.ZipNotSupportedSignedArchive)); // Zeus PS 3: disable creation/parsing of zip archive digital signatures #if ArchiveSignaturesEnabled ZipIOCentralDirectoryDigitalSignature record = new ZipIOCentralDirectoryDigitalSignature (); record._signature = signatureValue; record._sizeOfData = reader.ReadUInt16(); record._signatureData = reader.ReadBytes(record._sizeOfData ); record.Validate(); return record; #endif }
private void ParseRecord(BinaryReader reader, long centralDirectoryOffset, int centralDirectoryCount, long expectedCentralDirectorySize) { if (centralDirectoryCount > 0) { // collect all headers into a local array list for sorting SortedList headerList = new SortedList(centralDirectoryCount); ZipIOCentralDirectoryFileHeader header; for (int i = 0; i < centralDirectoryCount; i++) { header = ZipIOCentralDirectoryFileHeader.ParseRecord(reader, _blockManager.Encoding); headerList.Add(header.OffsetOfLocalHeader, header); } if (reader.BaseStream.Position - centralDirectoryOffset > expectedCentralDirectorySize) { // it looks like a corrupted file, as we have parsed more than central directory supposed to contain throw new FileFormatException(SR.Get(SRID.CorruptedData)); } // then add to the ordered dictionary in sorted order foreach (ZipIOCentralDirectoryFileHeader fileHeader in headerList.Values) { // at this point fileHeader.FileName is normalized using // the ZipIOBlockManager.ValidateNormalizeFileName CentralDirectoryDictionary.Add(fileHeader.FileName, fileHeader); } //load central directory [digital signature] - this has nothing to // do with OPC digital signing // this record is optional, and the function might return null _centralDirectoryDigitalSignature = ZipIOCentralDirectoryDigitalSignature.ParseRecord(reader); } _offset = centralDirectoryOffset; _dirtyFlag = false; Validate(expectedCentralDirectorySize); }
internal static ZipIOCentralDirectoryDigitalSignature CreateNew() { ZipIOCentralDirectoryDigitalSignature record = new ZipIOCentralDirectoryDigitalSignature(); return(record); }
internal static ZipIOCentralDirectoryDigitalSignature CreateNew() { ZipIOCentralDirectoryDigitalSignature record = new ZipIOCentralDirectoryDigitalSignature (); return record; }