1The following are the known types of zipfile extra fields as of this
2writing.  Extra fields are documented in PKWARE's appnote.txt and are
3intended to allow for backward- and forward-compatible extensions to
4the zipfile format.  Multiple extra-field types may be chained together,
5provided that the total length of all extra-field data is less than 64KB.
6(In fact, PKWARE requires that the total length of the entire file header,
7including timestamp, file attributes, filename, comment, extra field, etc.,
8be no more than 64KB.)
9
10Each extra-field type (or subblock) must contain a four-byte header con-
11sisting of a two-byte header ID and a two-byte length (little-endian) for
12the remaining data in the subblock.  If there are additional subblocks
13within the extra field, the header for each one will appear immediately
14following the data for the previous subblock (i.e., with no padding for
15alignment).
16
17All integer fields in the descriptions below are in little-endian (Intel)
18format unless otherwise specified.  Note that "Short" means two bytes,
19"Long" means four bytes, and "Long-Long" means eight bytes, regardless
20of their native sizes.  Unless specifically noted, all integer fields should
21be interpreted as unsigned (non-negative) numbers.
22
23Christian Spieler, Ed Gordon, 20080717
24
25                        -------------------------
26
27          Header ID's of 0 thru 31 are reserved for use by PKWARE.
28          The remaining ID's can be used by third party vendors for
29          proprietary usage.
30
31          The current Header ID mappings defined by PKWARE are:
32
33          0x0001        Zip64 extended information extra field
34          0x0007        AV Info
35          0x0008        Reserved for extended language encoding data (PFS)
36          0x0009        OS/2 extended attributes      (also Info-ZIP)
37          0x000a        NTFS (Win9x/WinNT FileTimes)
38          0x000c        OpenVMS                       (also Info-ZIP)
39          0x000d        UNIX
40          0x000e        Reserved for file stream and fork descriptors
41          0x000f        Patch Descriptor
42          0x0014        PKCS#7 Store for X.509 Certificates
43          0x0015        X.509 Certificate ID and Signature for
44                        individual file
45          0x0016        X.509 Certificate ID for Central Directory
46          0x0017        Strong Encryption Header
47          0x0018        Record Management Controls
48          0x0019        PKCS#7 Encryption Recipient Certificate List
49          0x0065        IBM S/390 (Z390), AS/400 (I400) attributes
50                        - uncompressed
51          0x0066        Reserved for IBM S/390 (Z390), AS/400 (I400)
52                        attributes - compressed
53          0x4690        POSZIP 4690 (reserved)
54
55          The Header ID mappings defined by Info-ZIP and third parties are:
56
57          0x07c8        Info-ZIP Macintosh (old, J. Lee)
58          0x2605        ZipIt Macintosh (first version)
59          0x2705        ZipIt Macintosh v 1.3.5 and newer (w/o full filename)
60          0x2805        ZipIt Macintosh 1.3.5+
61          0x334d        Info-ZIP Macintosh (new, D. Haase's 'Mac3' field)
62          0x4154        Tandem NSK
63          0x4341        Acorn/SparkFS (David Pilling)
64          0x4453        Windows NT security descriptor (binary ACL)
65          0x4704        VM/CMS
66          0x470f        MVS
67          0x4854        Theos, old inofficial port
68          0x4b46        FWKCS MD5 (see below)
69          0x4c41        OS/2 access control list (text ACL)
70          0x4d49        Info-ZIP OpenVMS (obsolete)
71          0x4d63        Macintosh SmartZIP, by Macro Bambini
72          0x4f4c        Xceed original location extra field
73          0x5356        AOS/VS (binary ACL)
74          0x5455        extended timestamp
75          0x554e        Xceed unicode extra field
76          0x5855        Info-ZIP UNIX (original; also OS/2, NT, etc.)
77          0x6375        Info-ZIP UTF-8 comment field
78          0x6542        BeOS (BeBox, PowerMac, etc.)
79          0x6854        Theos
80          0x7075        Info-ZIP UTF-8 name field
81          0x7441        AtheOS (AtheOS/Syllable attributes)
82          0x756e        ASi UNIX
83          0x7855        Info-ZIP UNIX (16-bit UID/GID info)
84          0x7875        Info-ZIP UNIX 3rd generation (generic UID/GID, ...)
85          0xa220        Microsoft Open Packaging Growth Hint
86          0xfb4a        SMS/QDOS
87
88The following are detailed descriptions of the known extra-field block types:
89
90         -Zip64 Extended Information Extra Field (0x0001):
91          ===============================================
92
93          The following is the layout of the zip64 extended
94          information "extra" block. If one of the size or
95          offset fields in the Local or Central directory
96          record is too small to hold the required data,
97          a zip64 extended information record is created.
98          The order of the fields in the zip64 extended
99          information record is fixed, but the fields will
100          only appear if the corresponding Local or Central
101          directory record field is set to 0xFFFF or 0xFFFFFFFF.
102
103          Note: all fields stored in Intel low-byte/high-byte order.
104
105          Value      Size       Description
106          -----      ----       -----------
107  (ZIP64) 0x0001     2 bytes    Tag for this "extra" block type
108          Size       2 bytes    Size of this "extra" block
109          Original
110          Size       8 bytes    Original uncompressed file size
111          Compressed
112          Size       8 bytes    Size of compressed data
113          Relative Header
114          Offset     8 bytes    Offset of local header record
115          Disk Start
116          Number     4 bytes    Number of the disk on which
117                                this file starts
118
119          This entry in the Local header must include BOTH original
120          and compressed file size fields.  If encrypting the
121          central directory and bit 13 of the general purpose bit
122          flag is set indicating masking, the value stored in the
123          Local Header for the original file size will be zero.
124
125
126         -OS/2 Extended Attributes Extra Field (0x0009):
127          =============================================
128
129          The following is the layout of the OS/2 extended attributes "extra"
130          block.  (Last Revision 19960922)
131
132          Note: all fields stored in Intel low-byte/high-byte order.
133
134          Local-header version:
135
136          Value         Size        Description
137          -----         ----        -----------
138  (OS/2)  0x0009        Short       tag for this extra block type
139          TSize         Short       total data size for this block
140          BSize         Long        uncompressed EA data size
141          CType         Short       compression type
142          EACRC         Long        CRC value for uncompressed EA data
143          (var.)        variable    compressed EA data
144
145          Central-header version:
146
147          Value         Size        Description
148          -----         ----        -----------
149  (OS/2)  0x0009        Short       tag for this extra block type
150          TSize         Short       total data size for this block (4)
151          BSize         Long        size of uncompressed local EA data
152
153          The value of CType is interpreted according to the "compression
154          method" section above; i.e., 0 for stored, 8 for deflated, etc.
155
156          The OS/2 extended attribute structure (FEA2LIST) is
157          compressed and then stored in its entirety within this
158          structure.  There will only ever be one "block" of data in
159          the variable-length field.
160
161
162         -OS/2 Access Control List Extra Field:
163          ====================================
164
165          The following is the layout of the OS/2 ACL extra block.
166          (Last Revision 19960922)
167
168          Local-header version:
169
170          Value         Size        Description
171          -----         ----        -----------
172  (ACL)   0x4c41        Short       tag for this extra block type ("AL")
173          TSize         Short       total data size for this block
174          BSize         Long        uncompressed ACL data size
175          CType         Short       compression type
176          EACRC         Long        CRC value for uncompressed ACL data
177          (var.)        variable    compressed ACL data
178
179          Central-header version:
180
181          Value         Size        Description
182          -----         ----        -----------
183  (ACL)   0x4c41        Short       tag for this extra block type ("AL")
184          TSize         Short       total data size for this block (4)
185          BSize         Long        size of uncompressed local ACL data
186
187          The value of CType is interpreted according to the "compression
188          method" section above; i.e., 0 for stored, 8 for deflated, etc.
189
190          The uncompressed ACL data consist of a text header of the form
191          "ACL1:%hX,%hd\n", where the first field is the OS/2 ACCINFO acc_attr
192          member and the second is acc_count, followed by acc_count strings
193          of the form "%s,%hx\n", where the first field is acl_ugname (user
194          group name) and the second acl_access.  This block type will be
195          extended for other operating systems as needed.
196
197
198         -Windows NT Security Descriptor Extra Field (0x4453):
199          ===================================================
200
201          The following is the layout of the NT Security Descriptor (another
202          type of ACL) extra block.  (Last Revision 19960922)
203
204          Local-header version:
205
206          Value         Size        Description
207          -----         ----        -----------
208  (SD)    0x4453        Short       tag for this extra block type ("SD")
209          TSize         Short       total data size for this block
210          BSize         Long        uncompressed SD data size
211          Version       Byte        version of uncompressed SD data format
212          CType         Short       compression type
213          EACRC         Long        CRC value for uncompressed SD data
214          (var.)        variable    compressed SD data
215
216          Central-header version:
217
218          Value         Size        Description
219          -----         ----        -----------
220  (SD)    0x4453        Short       tag for this extra block type ("SD")
221          TSize         Short       total data size for this block (4)
222          BSize         Long        size of uncompressed local SD data
223
224          The value of CType is interpreted according to the "compression
225          method" section above; i.e., 0 for stored, 8 for deflated, etc.
226          Version specifies how the compressed data are to be interpreted
227          and allows for future expansion of this extra field type.  Currently
228          only version 0 is defined.
229
230          For version 0, the compressed data are to be interpreted as a single
231          valid Windows NT SECURITY_DESCRIPTOR data structure, in self-relative
232          format.
233
234
235         -PKWARE Win95/WinNT Extra Field (0x000a):
236          =======================================
237
238          The following description covers PKWARE's "NTFS" attributes
239          "extra" block, introduced with the release of PKZIP 2.50 for
240          Windows. (Last Revision 20001118)
241
242          (Note: At this time the Mtime, Atime and Ctime values may
243          be used on any WIN32 system.)
244         [Info-ZIP note: In the current implementations, this field has
245          a fixed total data size of 32 bytes and is only stored as local
246          extra field.]
247
248          Value         Size        Description
249          -----         ----        -----------
250  (NTFS)  0x000a        Short       Tag for this "extra" block type
251          TSize         Short       Total Data Size for this block
252          Reserved      Long        for future use
253          Tag1          Short       NTFS attribute tag value #1
254          Size1         Short       Size of attribute #1, in bytes
255          (var.)        SubSize1    Attribute #1 data
256          .
257          .
258          .
259          TagN          Short       NTFS attribute tag value #N
260          SizeN         Short       Size of attribute #N, in bytes
261          (var.)        SubSizeN    Attribute #N data
262
263          For NTFS, values for Tag1 through TagN are as follows:
264          (currently only one set of attributes is defined for NTFS)
265
266          Tag        Size       Description
267          -----      ----       -----------
268          0x0001     2 bytes    Tag for attribute #1
269          Size1      2 bytes    Size of attribute #1, in bytes (24)
270          Mtime      8 bytes    64-bit NTFS file last modification time
271          Atime      8 bytes    64-bit NTFS file last access time
272          Ctime      8 bytes    64-bit NTFS file creation time
273
274          The total length for this block is 28 bytes, resulting in a
275          fixed size value of 32 for the TSize field of the NTFS block.
276
277          The NTFS filetimes are 64-bit unsigned integers, stored in Intel
278          (least significant byte first) byte order. They determine the
279          number of 1.0E-07 seconds (1/10th microseconds!) past WinNT "epoch",
280          which is "01-Jan-1601 00:00:00 UTC".
281
282
283         -PKWARE OpenVMS Extra Field (0x000c):
284          ===================================
285
286          The following is the layout of PKWARE's OpenVMS attributes
287          "extra" block.  (Last Revision 12/17/91)
288
289          Note: all fields stored in Intel low-byte/high-byte order.
290
291          Value         Size        Description
292          -----         ----        -----------
293  (VMS)   0x000c        Short       Tag for this "extra" block type
294          TSize         Short       Total Data Size for this block
295          CRC           Long        32-bit CRC for remainder of the block
296          Tag1          Short       OpenVMS attribute tag value #1
297          Size1         Short       Size of attribute #1, in bytes
298          (var.)        Size1       Attribute #1 data
299          .
300          .
301          .
302          TagN          Short       OpenVMS attribute tag value #N
303          SizeN         Short       Size of attribute #N, in bytes
304          (var.)        SizeN       Attribute #N data
305
306          Rules:
307
308          1. There will be one or more of attributes present, which
309             will each be preceded by the above TagX & SizeX values.
310             These values are identical to the ATR$C_XXXX and
311             ATR$S_XXXX constants which are defined in ATR.H under
312             OpenVMS C.  Neither of these values will ever be zero.
313
314          2. No word alignment or padding is performed.
315
316          3. A well-behaved PKZIP/OpenVMS program should never produce
317             more than one sub-block with the same TagX value.  Also,
318             there will never be more than one "extra" block of type
319             0x000c in a particular directory record.
320
321
322         -Info-ZIP VMS Extra Field:
323          ========================
324
325          The following is the layout of Info-ZIP's VMS attributes extra
326          block for VAX or Alpha AXP.  The local-header and central-header
327          versions are identical.  (Last Revision 19960922)
328
329          Value         Size        Description
330          -----         ----        -----------
331  (VMS2)  0x4d49        Short       tag for this extra block type ("JM")
332          TSize         Short       total data size for this block
333          ID            Long        block ID
334          Flags         Short       info bytes
335          BSize         Short       uncompressed block size
336          Reserved      Long        (reserved)
337          (var.)        variable    compressed VMS file-attributes block
338
339          The block ID is one of the following unterminated strings:
340
341                "VFAB"          struct FAB
342                "VALL"          struct XABALL
343                "VFHC"          struct XABFHC
344                "VDAT"          struct XABDAT
345                "VRDT"          struct XABRDT
346                "VPRO"          struct XABPRO
347                "VKEY"          struct XABKEY
348                "VMSV"          version (e.g., "V6.1"; truncated at hyphen)
349                "VNAM"          reserved
350
351          The lower three bits of Flags indicate the compression method.  The
352          currently defined methods are:
353
354                0       stored (not compressed)
355                1       simple "RLE"
356                2       deflated
357
358          The "RLE" method simply replaces zero-valued bytes with zero-valued
359          bits and non-zero-valued bytes with a "1" bit followed by the byte
360          value.
361
362          The variable-length compressed data contains only the data corre-
363          sponding to the indicated structure or string.  Typically multiple
364          VMS2 extra fields are present (each with a unique block type).
365
366
367         -Info-ZIP Macintosh Extra Field:
368          ==============================
369
370          The following is the layout of the (old) Info-ZIP resource-fork extra
371          block for Macintosh.  The local-header and central-header versions
372          are identical.  (Last Revision 19960922)
373
374          Value         Size        Description
375          -----         ----        -----------
376  (Mac)   0x07c8        Short       tag for this extra block type
377          TSize         Short       total data size for this block
378          "JLEE"        beLong      extra-field signature
379          FInfo         16 bytes    Macintosh FInfo structure
380          CrDat         beLong      HParamBlockRec fileParam.ioFlCrDat
381          MdDat         beLong      HParamBlockRec fileParam.ioFlMdDat
382          Flags         beLong      info bits
383          DirID         beLong      HParamBlockRec fileParam.ioDirID
384          VolName       28 bytes    volume name (optional)
385
386          All fields but the first two are in native Macintosh format
387          (big-endian Motorola order, not little-endian Intel).  The least
388          significant bit of Flags is 1 if the file is a data fork, 0 other-
389          wise.  In addition, if this extra field is present, the filename
390          has an extra 'd' or 'r' appended to indicate data fork or resource
391          fork.  The 28-byte VolName field may be omitted.
392
393
394         -ZipIt Macintosh Extra Field (long):
395          ==================================
396
397          The following is the layout of the ZipIt extra block for Macintosh.
398          The local-header and central-header versions are identical.
399          (Last Revision 19970130)
400
401          Value         Size        Description
402          -----         ----        -----------
403  (Mac2)  0x2605        Short       tag for this extra block type
404          TSize         Short       total data size for this block
405          "ZPIT"        beLong      extra-field signature
406          FnLen         Byte        length of FileName
407          FileName      variable    full Macintosh filename
408          FileType      Byte[4]     four-byte Mac file type string
409          Creator       Byte[4]     four-byte Mac creator string
410
411
412         -ZipIt Macintosh Extra Field (short, for files):
413          ==============================================
414
415          The following is the layout of a shortened variant of the
416          ZipIt extra block for Macintosh (without "full name" entry).
417          This variant is used by ZipIt 1.3.5 and newer for entries of
418          files (not directories) that do not have a MacBinary encoded
419          file.  The local-header and central-header versions are identical.
420          (Last Revision 20030602)
421
422          Value         Size        Description
423          -----         ----        -----------
424  (Mac2b) 0x2705        Short       tag for this extra block type
425          TSize         Short       total data size for this block (min. 12)
426          "ZPIT"        beLong      extra-field signature
427          FileType      Byte[4]     four-byte Mac file type string
428          Creator       Byte[4]     four-byte Mac creator string
429          fdFlags       beShort     attributes from FInfo.frFlags,
430                                    may be omitted
431          0x0000        beShort     reserved, may be omitted
432
433
434         -ZipIt Macintosh Extra Field (short, for directories):
435          ====================================================
436
437          The following is the layout of a shortened variant of the
438          ZipIt extra block for Macintosh used only for directory
439          entries. This variant is used by ZipIt 1.3.5 and newer to
440          save some optional Mac-specific information about directories.
441          The local-header and central-header versions are identical.
442
443          Value         Size        Description
444          -----         ----        -----------
445  (Mac2c) 0x2805        Short       tag for this extra block type
446          TSize         Short       total data size for this block (12)
447          "ZPIT"        beLong      extra-field signature
448          frFlags       beShort     attributes from DInfo.frFlags, may
449                                    be omitted
450          View          beShort     ZipIt view flag, may be omitted
451
452
453          The View field specifies ZipIt-internal settings as follows:
454
455          Bits of the Flags:
456              bit 0           if set, the folder is shown expanded (open)
457                              when the archive contents are viewed in ZipIt.
458              bits 1-15       reserved, zero;
459
460
461         -Info-ZIP Macintosh Extra Field (new):
462          ====================================
463
464          The following is the layout of the (new) Info-ZIP extra
465          block for Macintosh, designed by Dirk Haase.
466          All values are in little-endian.
467          (Last Revision 19981005)
468
469          Local-header version:
470
471          Value         Size        Description
472          -----         ----        -----------
473  (Mac3)  0x334d        Short       tag for this extra block type ("M3")
474          TSize         Short       total data size for this block
475          BSize         Long        uncompressed finder attribute data size
476          Flags         Short       info bits
477          fdType        Byte[4]     Type of the File (4-byte string)
478          fdCreator     Byte[4]     Creator of the File (4-byte string)
479          (CType)       Short       compression type
480          (CRC)         Long        CRC value for uncompressed MacOS data
481          Attribs       variable    finder attribute data (see below)
482
483
484          Central-header version:
485
486          Value         Size        Description
487          -----         ----        -----------
488  (Mac3)  0x334d        Short       tag for this extra block type ("M3")
489          TSize         Short       total data size for this block
490          BSize         Long        uncompressed finder attribute data size
491          Flags         Short       info bits
492          fdType        Byte[4]     Type of the File (4-byte string)
493          fdCreator     Byte[4]     Creator of the File (4-byte string)
494
495          The third bit of Flags in both headers indicates whether
496          the LOCAL extra field is uncompressed (and therefore whether CType
497          and CRC are omitted):
498
499          Bits of the Flags:
500              bit 0           if set, file is a data fork; otherwise unset
501              bit 1           if set, filename will be not changed
502              bit 2           if set, Attribs is uncompressed (no CType, CRC)
503              bit 3           if set, date and times are in 64 bit
504                              if zero date and times are in 32 bit.
505              bit 4           if set, timezone offsets fields for the native
506                              Mac times are omitted (UTC support deactivated)
507              bits 5-15       reserved;
508
509
510          Attributes:
511
512          Attribs is a Mac-specific block of data in little-endian format with
513          the following structure (if compressed, uncompress it first):
514
515          Value         Size        Description
516          -----         ----        -----------
517          fdFlags       Short       Finder Flags
518          fdLocation.v  Short       Finder Icon Location
519          fdLocation.h  Short       Finder Icon Location
520          fdFldr        Short       Folder containing file
521
522          FXInfo        16 bytes    Macintosh FXInfo structure
523            FXInfo-Structure:
524                fdIconID        Short
525                fdUnused[3]     Short       unused but reserved 6 bytes
526                fdScript        Byte        Script flag and number
527                fdXFlags        Byte        More flag bits
528                fdComment       Short       Comment ID
529                fdPutAway       Long        Home Dir ID
530
531          FVersNum      Byte        file version number
532                                    may be not used by MacOS
533          ACUser        Byte        directory access rights
534
535          FlCrDat       ULong       date and time of creation
536          FlMdDat       ULong       date and time of last modification
537          FlBkDat       ULong       date and time of last backup
538            These time numbers are original Mac FileTime values (local time!).
539            Currently, date-time width is 32-bit, but future version may
540            support be 64-bit times (see flags)
541
542          CrGMTOffs     Long(signed!)   difference "local Creat. time - UTC"
543          MdGMTOffs     Long(signed!)   difference "local Modif. time - UTC"
544          BkGMTOffs     Long(signed!)   difference "local Backup time - UTC"
545            These "local time - UTC" differences (stored in seconds) may be
546            used to support timestamp adjustment after inter-timezone transfer.
547            These fields are optional; bit 4 of the flags word controls their
548            presence.
549
550          Charset       Short       TextEncodingBase (Charset)
551                                    valid for the following two fields
552
553          FullPath      variable    Path of the current file.
554                                    Zero terminated string (C-String)
555                                    Currently coded in the native Charset.
556
557          Comment       variable    Finder Comment of the current file.
558                                    Zero terminated string (C-String)
559                                    Currently coded in the native Charset.
560
561
562         -SmartZIP Macintosh Extra Field:
563          ====================================
564
565          The following is the layout of the SmartZIP extra
566          block for Macintosh, designed by Marco Bambini.
567
568          Local-header version:
569
570          Value         Size        Description
571          -----         ----        -----------
572          0x4d63        Short       tag for this extra block type ("cM")
573          TSize         Short       total data size for this block (64)
574          "dZip"        beLong      extra-field signature
575          fdType        Byte[4]     Type of the File (4-byte string)
576          fdCreator     Byte[4]     Creator of the File (4-byte string)
577          fdFlags       beShort     Finder Flags
578          fdLocation.v  beShort     Finder Icon Location
579          fdLocation.h  beShort     Finder Icon Location
580          fdFldr        beShort     Folder containing file
581          CrDat         beLong      HParamBlockRec fileParam.ioFlCrDat
582          MdDat         beLong      HParamBlockRec fileParam.ioFlMdDat
583          frScroll.v    Byte        vertical pos. of folder's scroll bar
584          fdScript      Byte        Script flag and number
585          frScroll.h    Byte        horizontal pos. of folder's scroll bar
586          fdXFlags      Byte        More flag bits
587          FileName      Byte[32]    full Macintosh filename (pascal string)
588
589          All fields but the first two are in native Macintosh format
590          (big-endian Motorola order, not little-endian Intel).
591          The extra field size is fixed to 64 bytes.
592          The local-header and central-header versions are identical.
593
594
595         -Acorn SparkFS Extra Field:
596          =========================
597
598          The following is the layout of David Pilling's SparkFS extra block
599          for Acorn RISC OS.  The local-header and central-header versions are
600          identical.  (Last Revision 19960922)
601
602          Value         Size        Description
603          -----         ----        -----------
604  (Acorn) 0x4341        Short       tag for this extra block type ("AC")
605          TSize         Short       total data size for this block (20)
606          "ARC0"        Long        extra-field signature
607          LoadAddr      Long        load address or file type
608          ExecAddr      Long        exec address
609          Attr          Long        file permissions
610          Zero          Long        reserved; always zero
611
612          The following bits of Attr are associated with the given file
613          permissions:
614
615                bit 0           user-writable ('W')
616                bit 1           user-readable ('R')
617                bit 2           reserved
618                bit 3           locked ('L')
619                bit 4           publicly writable ('w')
620                bit 5           publicly readable ('r')
621                bit 6           reserved
622                bit 7           reserved
623
624
625         -VM/CMS Extra Field:
626          ==================
627
628          The following is the layout of the file-attributes extra block for
629          VM/CMS.  The local-header and central-header versions are
630          identical.  (Last Revision 19960922)
631
632          Value         Size        Description
633          -----         ----        -----------
634 (VM/CMS) 0x4704        Short       tag for this extra block type
635          TSize         Short       total data size for this block
636          flData        variable    file attributes data
637
638          flData is an uncompressed fldata_t struct.
639
640
641         -MVS Extra Field:
642          ===============
643
644          The following is the layout of the file-attributes extra block for
645          MVS.  The local-header and central-header versions are identical.
646          (Last Revision 19960922)
647
648          Value         Size        Description
649          -----         ----        -----------
650  (MVS)   0x470f        Short       tag for this extra block type
651          TSize         Short       total data size for this block
652          flData        variable    file attributes data
653
654          flData is an uncompressed fldata_t struct.
655
656
657         -PKWARE Unix Extra Field (0x000d):
658          ================================
659
660          The following is the layout of PKWARE's Unix "extra" block.
661          It was introduced with the release of PKZIP for Unix 2.50.
662          Note: all fields are stored in Intel low-byte/high-byte order.
663          (Last Revision 19980901)
664
665          This field has a minimum data size of 12 bytes and is only stored
666          as local extra field.
667
668          Value         Size        Description
669          -----         ----        -----------
670 (Unix0)  0x000d        Short       Tag for this "extra" block type
671          TSize         Short       Total Data Size for this block
672          AcTime        Long        time of last access (UTC/GMT)
673          ModTime       Long        time of last modification (UTC/GMT)
674          UID           Short       Unix user ID
675          GID           Short       Unix group ID
676          (var)         variable    Variable length data field
677
678          The variable length data field will contain file type
679          specific data.  Currently the only values allowed are
680          the original "linked to" file names for hard or symbolic
681          links, and the major and minor device node numbers for
682          character and block device nodes.  Since device nodes
683          cannot be either symbolic or hard links, only one set of
684          variable length data is stored.  Link files will have the
685          name of the original file stored.  This name is NOT NULL
686          terminated.  Its size can be determined by checking TSize -
687          12.  Device entries will have eight bytes stored as two 4
688          byte entries (in little-endian format).  The first entry
689          will be the major device number, and the second the minor
690          device number.
691
692         [Info-ZIP note: The fixed part of this field has the same layout as
693          Info-ZIP's abandoned "Unix1 timestamps & owner ID info" extra field;
694          only the two tag bytes are different.]
695
696
697         -PATCH Descriptor Extra Field (0x000f):
698          =====================================
699
700          The following is the layout of the Patch Descriptor "extra"
701          block.
702
703          Note: all fields stored in Intel low-byte/high-byte order.
704
705          Value         Size        Description
706          -----         ----        -----------
707  (Patch) 0x000f        Short       Tag for this "extra" block type
708          TSize         Short       Size of the total "extra" block
709          Version       Short       Version of the descriptor
710          Flags         Long        Actions and reactions (see below)
711          OldSize       Long        Size of the file about to be patched
712          OldCRC        Long        32-bit CRC of the file about to be patched
713          NewSize       Long        Size of the resulting file
714          NewCRC        Long        32-bit CRC of the resulting file
715
716
717          Actions and reactions
718
719          Bits          Description
720          ----          ----------------
721          0             Use for auto detection
722          1             Treat as a self-patch
723          2-3           RESERVED
724          4-5           Action (see below)
725          6-7           RESERVED
726          8-9           Reaction (see below) to absent file
727          10-11         Reaction (see below) to newer file
728          12-13         Reaction (see below) to unknown file
729          14-15         RESERVED
730          16-31         RESERVED
731
732          Actions
733
734          Action       Value
735          ------       -----
736          none         0
737          add          1
738          delete       2
739          patch        3
740
741          Reactions
742
743          Reaction     Value
744          --------     -----
745          ask          0
746          skip         1
747          ignore       2
748          fail         3
749
750          Patch support is provided by PKPatchMaker(tm) technology and is
751          covered under U.S. Patents and Patents Pending. The use or
752          implementation in a product of certain technological aspects set
753          forth in the current APPNOTE, including those with regard to
754          strong encryption, patching, or extended tape operations requires
755          a license from PKWARE.  Please contact PKWARE with regard to
756          acquiring a license.
757
758
759         -PKCS#7 Store for X.509 Certificates (0x0014):
760          ============================================
761
762          This field contains information about each of the certificates
763          files may be signed with.  When the Central Directory Encryption
764          feature is enabled for a ZIP file, this record will appear in
765          the Archive Extra Data Record, otherwise it will appear in the
766          first central directory record and will be ignored in any
767          other record.
768
769          Note: all fields stored in Intel low-byte/high-byte order.
770
771          Value     Size     Description
772          -----     ----     -----------
773  (Store) 0x0014    2 bytes  Tag for this "extra" block type
774          TSize     2 bytes  Size of the store data
775          SData     TSize    Data about the store
776
777          SData
778          Value     Size        Description
779          -----     ----        -----------
780          Version   2 bytes     Version number, 0x0001 for now
781          StoreD    (variable)  Actual store data
782
783          The StoreD member is suitable for passing as the pbData
784          member of a CRYPT_DATA_BLOB to the CertOpenStore() function
785          in Microsoft's CryptoAPI.  The SSize member above will be
786          cbData + 6, where cbData is the cbData member of the same
787          CRYPT_DATA_BLOB.  The encoding type to pass to
788          CertOpenStore() should be
789          PKCS_7_ANS_ENCODING | X509_ASN_ENCODING.
790
791
792         -X.509 Certificate ID and Signature for individual file (0x0015):
793          ===============================================================
794
795          This field contains the information about which certificate in
796          the PKCS#7 store was used to sign a particular file.  It also
797          contains the signature data.  This field can appear multiple
798          times, but can only appear once per certificate.
799
800          Note: all fields stored in Intel low-byte/high-byte order.
801
802          Value         Size        Description
803          -----         ----        -----------
804  (CID)   0x0015        2 bytes     Tag for this "extra" block type
805          CSize         2 bytes     Size of Method
806          Method        (variable)
807
808          Method
809          Value         Size        Description
810          -----         ----        -----------
811          Version       2 bytes     Version number, for now 0x0001
812          AlgID         2 bytes     Algorithm ID used for signing
813          IDSize        2 bytes     Size of Certificate ID data
814          CertID        (variable)  Certificate ID data
815          SigSize       2 bytes     Size of Signature data
816          Sig           (variable)  Signature data
817
818          CertID
819          Value         Size        Description
820          -----         ----        -----------
821          Size1         4 bytes     Size of CertID, should be (IDSize - 4)
822          Size1         4 bytes     A bug in version one causes this value
823                                    to appear twice.
824          IssSize       4 bytes     Issuer data size
825          Issuer        (variable)  Issuer data
826          SerSize       4 bytes     Serial Number size
827          Serial        (variable)  Serial Number data
828
829          The Issuer and IssSize members are suitable for creating a
830          CRYPT_DATA_BLOB to be the Issuer member of a CERT_INFO
831          struct. The Serial and SerSize members would be the
832          SerialNumber member of the same CERT_INFO struct.  This
833          struct would be used to find the certificate in the store
834          the file was signed with.  Those structures are from the MS
835          CryptoAPI.
836
837          Sig and SigSize are the actual signature data and size
838          generated by signing the file with the MS CryptoAPI using a
839          hash created with the given AlgID.
840
841
842         -X.509 Certificate ID and Signature for central directory (0x0016):
843          =================================================================
844
845          This field contains the information about which certificate in
846          the PKCS#7 store was used to sign the central directory structure.
847          When the Central Directory Encryption feature is enabled for a
848          ZIP file, this record will appear in the Archive Extra Data Record,
849          otherwise it will appear in the first central directory record,
850          along with the store.  The data structure is the
851          same as the CID, except that SigSize will be 0, and there
852          will be no Sig member.
853
854          This field is also kept after the last central directory
855          record, as the signature data (ID 0x05054b50, it looks like
856          a central directory record of a different type).  This
857          second copy of the data is the Signature Data member of the
858          record, and will have a SigSize that is non-zero, and will
859          have Sig data.
860
861          Note: all fields stored in Intel low-byte/high-byte order.
862
863          Value     Size     Description
864          -----     ----     -----------
865  (CDID)  0x0016    2 bytes  Tag for this "extra" block type
866          TSize     2 bytes  Size of data that follows
867          TData     TSize    Data
868
869
870         -Strong Encryption Header (0x0017):
871          =================================
872
873          Value     Size     Description
874          -----     ----     -----------
875          0x0017    2 bytes  Tag for this "extra" block type
876          TSize     2 bytes  Size of data that follows
877          Format    2 bytes  Format definition for this record
878          AlgID     2 bytes  Encryption algorithm identifier
879          Bitlen    2 bytes  Bit length of encryption key
880          Flags     2 bytes  Processing flags
881          CertData  TSize-8  Certificate decryption extra field data
882                             (refer to the explanation for CertData
883                              in the section describing the
884                              Certificate Processing Method under
885                              the Strong Encryption Specification)
886
887
888         -Record Management Controls (0x0018):
889          ===================================
890
891          Value     Size     Description
892          -----     ----     -----------
893(Rec-CTL) 0x0018    2 bytes  Tag for this "extra" block type
894          CSize     2 bytes  Size of total extra block data
895          Tag1      2 bytes  Record control attribute 1
896          Size1     2 bytes  Size of attribute 1, in bytes
897          Data1     Size1    Attribute 1 data
898            .
899            .
900            .
901          TagN      2 bytes  Record control attribute N
902          SizeN     2 bytes  Size of attribute N, in bytes
903          DataN     SizeN    Attribute N data
904
905
906         -PKCS#7 Encryption Recipient Certificate List (0x0019):
907          =====================================================
908
909          This field contains information about each of the certificates
910          used in encryption processing and it can be used to identify who is
911          allowed to decrypt encrypted files.  This field should only appear
912          in the archive extra data record. This field is not required and
913          serves only to aide archive modifications by preserving public
914          encryption key data. Individual security requirements may dictate
915          that this data be omitted to deter information exposure.
916
917          Note: all fields stored in Intel low-byte/high-byte order.
918
919          Value     Size     Description
920          -----     ----     -----------
921 (CStore) 0x0019    2 bytes  Tag for this "extra" block type
922          TSize     2 bytes  Size of the store data
923          TData     TSize    Data about the store
924
925          TData:
926
927          Value     Size     Description
928          -----     ----     -----------
929          Version   2 bytes  Format version number - must 0x0001 at this time
930          CStore    (var)    PKCS#7 data blob
931
932
933         -MVS Extra Field (PKWARE, 0x0065):
934          ================================
935
936          The following is the layout of the MVS "extra" block.
937          Note: Some fields are stored in Big Endian format.
938          All text is in EBCDIC format unless otherwise specified.
939
940          Value       Size          Description
941          -----       ----          -----------
942  (MVS)   0x0065      2 bytes       Tag for this "extra" block type
943          TSize       2 bytes       Size for the following data block
944          ID          4 bytes       EBCDIC "Z390" 0xE9F3F9F0 or
945                                    "T4MV" for TargetFour
946          (var)       TSize-4       Attribute data
947
948
949         -OS/400 Extra Field (0x0065):
950          ===========================
951
952          The following is the layout of the OS/400 "extra" block.
953          Note: Some fields are stored in Big Endian format.
954          All text is in EBCDIC format unless otherwise specified.
955
956          Value       Size          Description
957          -----       ----          -----------
958  (OS400) 0x0065      2 bytes       Tag for this "extra" block type
959          TSize       2 bytes       Size for the following data block
960          ID          4 bytes       EBCDIC "I400" 0xC9F4F0F0 or
961                                    "T4MV" for TargetFour
962          (var)       TSize-4       Attribute data
963
964
965         -Info-ZIP Unicode Path Extra Field:
966          =================================
967
968          Stores the UTF-8 version of the entry path as stored in the
969          local header and central directory header.
970          (Last Revision 20070912)
971
972          Value         Size        Description
973          -----         ----        -----------
974  (UPath) 0x7075        Short       tag for this extra block type ("up")
975          TSize         Short       total data size for this block
976          Version       Byte        version of this extra field, currently 1
977          NameCRC32     Long        CRC-32 checksum of standard name field
978          UnicodeName   variable    UTF-8 version of the entry file name
979
980          Currently Version is set to the number 1.  If there is a need
981          to change this field, the version will be incremented.  Changes
982          may not be backward compatible so this extra field should not be
983          used if the version is not recognized.
984
985          The NameCRC32 is the standard zip CRC32 checksum of the File Name
986          field in the header.  This is used to verify that the header
987          File Name field has not changed since the Unicode Path extra field
988          was created.  This can happen if a utility renames the entry but
989          does not update the UTF-8 path extra field.  If the CRC check fails,
990          this UTF-8 Path Extra Field should be ignored and the File Name field
991          in the header should be used instead.
992
993          The UnicodeName is the UTF-8 version of the contents of the File
994          Name field in the header, without any trailing NUL.  The standard
995          name field in the Zip entry header remains filled with the entry
996          name coded in the local machine's extended ASCII system charset.
997          As UnicodeName is defined to be UTF-8, no UTF-8 byte order mark
998          (BOM) is used.  The length of this field is determined by
999          subtracting the size of the previous fields from TSize.
1000          If both the File Name and Comment fields are UTF-8, the new General
1001          Purpose Bit Flag, bit 11 (Language encoding flag (EFS)), should be
1002          used to indicate that both the header File Name and Comment fields
1003          are UTF-8 and, in this case, the Unicode Path and Unicode Comment
1004          extra fields are not needed and should not be created.  Note that,
1005          for backward compatibility, bit 11 should only be used if the native
1006          character set of the paths and comments being zipped up are already
1007          in UTF-8.  The same method, either general purpose bit 11 or extra
1008          fields, should be used in both the Local and Central Directory Header
1009          for a file.
1010
1011          Utilisation rules:
1012          1. This field shall never be created for names consisting solely of
1013             7-bit ASCII characters.
1014          2. On a system that already uses UTF-8 as system charset, this field
1015             shall not repeat the string pattern already stored in the Zip
1016             entry's standard name field. Instead, a field of exactly 9 bytes
1017             (70 75 05 00 01 and 4 bytes CRC) should be created.
1018             In this form with 5 data bytes, the field serves as indicator
1019             for the UTF-8 encoding of the standard Zip header's name field.
1020          3. This field shall not be used whenever the calculated CRC-32 of
1021             the entry's standard name field does not match the provided
1022             CRC checksum value.  A mismatch of the CRC check indicates that
1023             the standard name field was changed by some non-"up"-aware
1024             utility without synchronizing this UTF-8 name e.f. block.
1025
1026
1027         -Info-ZIP Unicode Comment Extra Field:
1028          ====================================
1029
1030          Stores the UTF-8 version of the entry comment as stored in the
1031          central directory header.
1032          (Last Revision 20070912)
1033
1034          Value         Size        Description
1035          -----         ----        -----------
1036   (UCom) 0x6375        Short       tag for this extra block type ("uc")
1037          TSize         Short       total data size for this block
1038          Version       1 byte      version of this extra field, currently 1
1039          ComCRC32      4 bytes     Comment Field CRC32 Checksum
1040          UnicodeCom    Variable    UTF-8 version of the entry comment
1041
1042          Currently Version is set to the number 1.  If there is a need
1043          to change this field, the version will be incremented.  Changes
1044          may not be backward compatible so this extra field should not be
1045          used if the version is not recognized.
1046
1047          The ComCRC32 is the standard zip CRC32 checksum of the Comment
1048          field in the central directory header.  This is used to verify that
1049          the comment field has not changed since the Unicode Comment extra
1050          field was created.  This can happen if a utility changes the Comment
1051          field but does not update the UTF-8 Comment extra field.  If the CRC
1052          check fails, this Unicode Comment extra field should be ignored and
1053          the Comment field in the header used.
1054
1055          The UnicodeCom field is the UTF-8 version of the entry comment field
1056          in the header.  As UnicodeCom is defined to be UTF-8, no UTF-8 byte
1057          order mark (BOM) is used.  The length of this field is determined by
1058          subtracting the size of the previous fields from TSize.  If both the
1059          File Name and Comment fields are UTF-8, the new General Purpose Bit
1060          Flag, bit 11 (Language encoding flag (EFS)), can be used to indicate
1061          both the header File Name and Comment fields are UTF-8 and, in this
1062          case, the Unicode Path and Unicode Comment extra fields are not
1063          needed and should not be created.  Note that, for backward
1064          compatibility, bit 11 should only be used if the native character set
1065          of the paths and comments being zipped up are already in UTF-8.  The
1066          same method, either bit 11 or extra fields, should be used in both
1067          the local and central directory headers.
1068
1069
1070         -Extended Timestamp Extra Field:
1071          ==============================
1072
1073          The following is the layout of the extended-timestamp extra block.
1074          (Last Revision 19970118)
1075
1076          Local-header version:
1077
1078          Value         Size        Description
1079          -----         ----        -----------
1080  (time)  0x5455        Short       tag for this extra block type ("UT")
1081          TSize         Short       total data size for this block
1082          Flags         Byte        info bits
1083          (ModTime)     Long        time of last modification (UTC/GMT)
1084          (AcTime)      Long        time of last access (UTC/GMT)
1085          (CrTime)      Long        time of original creation (UTC/GMT)
1086
1087          Central-header version:
1088
1089          Value         Size        Description
1090          -----         ----        -----------
1091  (time)  0x5455        Short       tag for this extra block type ("UT")
1092          TSize         Short       total data size for this block
1093          Flags         Byte        info bits (refers to local header!)
1094          (ModTime)     Long        time of last modification (UTC/GMT)
1095
1096          The central-header extra field contains the modification time only,
1097          or no timestamp at all.  TSize is used to flag its presence or
1098          absence.  But note:
1099
1100              If "Flags" indicates that Modtime is present in the local header
1101              field, it MUST be present in the central header field, too!
1102              This correspondence is required because the modification time
1103              value may be used to support trans-timezone freshening and
1104              updating operations with zip archives.
1105
1106          The time values are in standard Unix signed-long format, indicating
1107          the number of seconds since 1 January 1970 00:00:00.  The times
1108          are relative to Coordinated Universal Time (UTC), also sometimes
1109          referred to as Greenwich Mean Time (GMT).  To convert to local time,
1110          the software must know the local timezone offset from UTC/GMT.
1111
1112          The lower three bits of Flags in both headers indicate which time-
1113          stamps are present in the LOCAL extra field:
1114
1115                bit 0           if set, modification time is present
1116                bit 1           if set, access time is present
1117                bit 2           if set, creation time is present
1118                bits 3-7        reserved for additional timestamps; not set
1119
1120          Those times that are present will appear in the order indicated, but
1121          any combination of times may be omitted.  (Creation time may be
1122          present without access time, for example.)  TSize should equal
1123          (1 + 4*(number of set bits in Flags)), as the block is currently
1124          defined.  Other timestamps may be added in the future.
1125
1126
1127         -Info-ZIP Unix Extra Field (type 1):
1128          ==================================
1129
1130          The following is the layout of the old Info-ZIP extra block for
1131          Unix.  It has been replaced by the extended-timestamp extra block
1132          (0x5455) and the Unix type 2 extra block (0x7855).
1133          (Last Revision 19970118)
1134
1135          Local-header version:
1136
1137          Value         Size        Description
1138          -----         ----        -----------
1139  (Unix1) 0x5855        Short       tag for this extra block type ("UX")
1140          TSize         Short       total data size for this block
1141          AcTime        Long        time of last access (UTC/GMT)
1142          ModTime       Long        time of last modification (UTC/GMT)
1143          UID           Short       Unix user ID (optional)
1144          GID           Short       Unix group ID (optional)
1145
1146          Central-header version:
1147
1148          Value         Size        Description
1149          -----         ----        -----------
1150  (Unix1) 0x5855        Short       tag for this extra block type ("UX")
1151          TSize         Short       total data size for this block
1152          AcTime        Long        time of last access (GMT/UTC)
1153          ModTime       Long        time of last modification (GMT/UTC)
1154
1155          The file access and modification times are in standard Unix signed-
1156          long format, indicating the number of seconds since 1 January 1970
1157          00:00:00.  The times are relative to Coordinated Universal Time
1158          (UTC), also sometimes referred to as Greenwich Mean Time (GMT).  To
1159          convert to local time, the software must know the local timezone
1160          offset from UTC/GMT.  The modification time may be used by non-Unix
1161          systems to support inter-timezone freshening and updating of zip
1162          archives.
1163
1164          The local-header extra block may optionally contain UID and GID
1165          info for the file.  The local-header TSize value is the only
1166          indication of this.  Note that Unix UIDs and GIDs are usually
1167          specific to a particular machine, and they generally require root
1168          access to restore.
1169
1170          This extra field type is obsolete, but it has been in use since
1171          mid-1994.  Therefore future archiving software should continue to
1172          support it.  Some guidelines:
1173
1174              An archive member should either contain the old "Unix1"
1175              extra field block or the new extra field types "time" and/or
1176              "Unix2".
1177
1178              If both the old "Unix1" block type and one or both of the new
1179              block types "time" and "Unix2" are found, the "Unix1" block
1180              should be considered invalid and ignored.
1181
1182              Unarchiving software should recognize both old and new extra
1183              field block types, but the info from new types overrides the
1184              old "Unix1" field.
1185
1186              Archiving software should recognize "Unix1" extra fields for
1187              timestamp comparison but never create it for updated, freshened
1188              or new archive members.  When copying existing members to a new
1189              archive, any "Unix1" extra field blocks should be converted to
1190              the new "time" and/or "Unix2" types.
1191
1192
1193         -Info-ZIP UNIX Extra Field (type 2):
1194          ==================================
1195
1196          The following is the layout of the new Info-ZIP extra block for
1197          Unix.  (Last Revision 19960922)
1198
1199          Local-header version:
1200
1201          Value         Size        Description
1202          -----         ----        -----------
1203  (Unix2) 0x7855        Short       tag for this extra block type ("Ux")
1204          TSize         Short       total data size for this block (4)
1205          UID           Short       Unix user ID
1206          GID           Short       Unix group ID
1207
1208          Central-header version:
1209
1210          Value         Size        Description
1211          -----         ----        -----------
1212  (Unix2) 0x7855        Short       tag for this extra block type ("Ux")
1213          TSize         Short       total data size for this block (0)
1214
1215          The data size of the central-header version is zero; it is used
1216          solely as a flag that UID/GID info is present in the local-header
1217          extra field.  If additional fields are ever added to the local
1218          version, the central version may be extended to indicate this.
1219
1220          Note that Unix UIDs and GIDs are usually specific to a particular
1221          machine, and they generally require root access to restore.
1222
1223
1224         -Info-ZIP New Unix Extra Field:
1225          ====================================
1226
1227          Currently stores Unix UIDs/GIDs up to 32 bits.
1228          (Last Revision 20080509)
1229
1230          Value         Size        Description
1231          -----         ----        -----------
1232  (UnixN) 0x7875        Short       tag for this extra block type ("ux")
1233          TSize         Short       total data size for this block
1234          Version       1 byte      version of this extra field, currently 1
1235          UIDSize       1 byte      Size of UID field
1236          UID           Variable    UID for this entry
1237          GIDSize       1 byte      Size of GID field
1238          GID           Variable    GID for this entry
1239
1240          Currently Version is set to the number 1.  If there is a need
1241          to change this field, the version will be incremented.  Changes
1242          may not be backward compatible so this extra field should not be
1243          used if the version is not recognized.
1244
1245          UIDSize is the size of the UID field in bytes.  This size should
1246          match the size of the UID field on the target OS.
1247
1248          UID is the UID for this entry in standard little endian format.
1249
1250          GIDSize is the size of the GID field in bytes.  This size should
1251          match the size of the GID field on the target OS.
1252
1253          GID is the GID for this entry in standard little endian format.
1254
1255          If both the old 16-bit Unix extra field (tag 0x7855, Info-ZIP Unix2)
1256          and this extra field are present, the values in this extra field
1257          supercede the values in that extra field.
1258
1259
1260         -ASi UNIX Extra Field:
1261          ====================
1262
1263          The following is the layout of the ASi extra block for Unix.  The
1264          local-header and central-header versions are identical.
1265          (Last Revision 19960916)
1266
1267          Value         Size        Description
1268          -----         ----        -----------
1269  (Unix3) 0x756e        Short       tag for this extra block type ("nu")
1270          TSize         Short       total data size for this block
1271          CRC           Long        CRC-32 of the remaining data
1272          Mode          Short       file permissions
1273          SizDev        Long        symlink'd size OR major/minor dev num
1274          UID           Short       user ID
1275          GID           Short       group ID
1276          (var.)        variable    symbolic link filename
1277
1278          Mode is the standard Unix st_mode field from struct stat, containing
1279          user/group/other permissions, setuid/setgid and symlink info, etc.
1280
1281          If Mode indicates that this file is a symbolic link, SizDev is the
1282          size of the file to which the link points.  Otherwise, if the file
1283          is a device, SizDev contains the standard Unix st_rdev field from
1284          struct stat (includes the major and minor numbers of the device).
1285          SizDev is undefined in other cases.
1286
1287          If Mode indicates that the file is a symbolic link, the final field
1288          will be the name of the file to which the link points.  The file-
1289          name length can be inferred from TSize.
1290
1291          [Note that TSize may incorrectly refer to the data size not counting
1292           the CRC; i.e., it may be four bytes too small.]
1293
1294
1295         -BeOS Extra Field:
1296          ================
1297
1298          The following is the layout of the file-attributes extra block for
1299          BeOS.  (Last Revision 19970531)
1300
1301          Local-header version:
1302
1303          Value         Size        Description
1304          -----         ----        -----------
1305  (BeOS)  0x6542        Short       tag for this extra block type ("Be")
1306          TSize         Short       total data size for this block
1307          BSize         Long        uncompressed file attribute data size
1308          Flags         Byte        info bits
1309          (CType)       Short       compression type
1310          (CRC)         Long        CRC value for uncompressed file attribs
1311          Attribs       variable    file attribute data
1312
1313          Central-header version:
1314
1315          Value         Size        Description
1316          -----         ----        -----------
1317  (BeOS)  0x6542        Short       tag for this extra block type ("Be")
1318          TSize         Short       total data size for this block (5)
1319          BSize         Long        size of uncompr. local EF block data
1320          Flags         Byte        info bits
1321
1322          The least significant bit of Flags in both headers indicates whether
1323          the LOCAL extra field is uncompressed (and therefore whether CType
1324          and CRC are omitted):
1325
1326                bit 0           if set, Attribs is uncompressed (no CType, CRC)
1327                bits 1-7        reserved; if set, assume error or unknown data
1328
1329          Currently the only supported compression types are deflated (type 8)
1330          and stored (type 0); the latter is not used by Info-ZIP's Zip but is
1331          supported by UnZip.
1332
1333          Attribs is a BeOS-specific block of data in big-endian format with
1334          the following structure (if compressed, uncompress it first):
1335
1336              Value     Size        Description
1337              -----     ----        -----------
1338              Name      variable    attribute name (null-terminated string)
1339              Type      Long        attribute type (32-bit unsigned integer)
1340              Size      Long Long   data size for this sub-block (64 bits)
1341              Data      variable    attribute data
1342
1343          The attribute structure is repeated for every attribute.  The Data
1344          field may contain anything--text, flags, bitmaps, etc.
1345
1346
1347         -AtheOS Extra Field:
1348          ==================
1349
1350          The following is the layout of the file-attributes extra block for
1351          AtheOS.  This field is a very close spin-off from the BeOS e.f.
1352          The only differences are:
1353           - a new extra field signature
1354           - numeric field in the attributes data are stored in little-endian
1355             format ("i386" was initial hardware for AtheOS)
1356          (Last Revision 20040908)
1357
1358          Local-header version:
1359
1360          Value         Size        Description
1361          -----         ----        -----------
1362 (AtheOS) 0x7441        Short       tag for this extra block type ("At")
1363          TSize         Short       total data size for this block
1364          BSize         Long        uncompressed file attribute data size
1365          Flags         Byte        info bits
1366          (CType)       Short       compression type
1367          (CRC)         Long        CRC value for uncompressed file attribs
1368          Attribs       variable    file attribute data
1369
1370          Central-header version:
1371
1372          Value         Size        Description
1373          -----         ----        -----------
1374 (AtheOS) 0x7441        Short       tag for this extra block type ("At")
1375          TSize         Short       total data size for this block (5)
1376          BSize         Long        size of uncompr. local EF block data
1377          Flags         Byte        info bits
1378
1379          The least significant bit of Flags in both headers indicates whether
1380          the LOCAL extra field is uncompressed (and therefore whether CType
1381          and CRC are omitted):
1382
1383                bit 0           if set, Attribs is uncompressed (no CType, CRC)
1384                bits 1-7        reserved; if set, assume error or unknown data
1385
1386          Currently the only supported compression types are deflated (type 8)
1387          and stored (type 0); the latter is not used by Info-ZIP's Zip but is
1388          supported by UnZip.
1389
1390          Attribs is a AtheOS-specific block of data in little-endian format
1391          with the following structure (if compressed, uncompress it first):
1392
1393              Value     Size        Description
1394              -----     ----        -----------
1395              Name      variable    attribute name (null-terminated string)
1396              Type      Long        attribute type (32-bit unsigned integer)
1397              Size      Long Long   data size for this sub-block (64 bits)
1398              Data      variable    attribute data
1399
1400          The attribute structure is repeated for every attribute.  The Data
1401          field may contain anything--text, flags, bitmaps, etc.
1402
1403
1404         -SMS/QDOS Extra Field:
1405          ====================
1406
1407          The following is the layout of the file-attributes extra block for
1408          SMS/QDOS.  The local-header and central-header versions are identical.
1409          (Last Revision 19960929)
1410
1411          Value         Size        Description
1412          -----         ----        -----------
1413  (QDOS)  0xfb4a        Short       tag for this extra block type
1414          TSize         Short       total data size for this block
1415          LongID        Long        extra-field signature
1416          (ExtraID)     Long        additional signature/flag bytes
1417          QDirect       64 bytes    qdirect structure
1418
1419          LongID may be "QZHD" or "QDOS".  In the latter case, ExtraID will
1420          be present.  Its first three bytes are "02\0"; the last byte is
1421          currently undefined.
1422
1423          QDirect contains the file's uncompressed directory info (qdirect
1424          struct).  Its elements are in native (big-endian) format:
1425
1426          d_length      beLong          file length
1427          d_access      byte            file access type
1428          d_type        byte            file type
1429          d_datalen     beLong          data length
1430          d_reserved    beLong          unused
1431          d_szname      beShort         size of filename
1432          d_name        36 bytes        filename
1433          d_update      beLong          time of last update
1434          d_refdate     beLong          file version number
1435          d_backup      beLong          time of last backup (archive date)
1436
1437
1438         -AOS/VS Extra Field:
1439          ==================
1440
1441          The following is the layout of the extra block for Data General
1442          AOS/VS.  The local-header and central-header versions are identical.
1443          (Last Revision 19961125)
1444
1445          Value         Size        Description
1446          -----         ----        -----------
1447  (AOSVS) 0x5356        Short       tag for this extra block type ("VS")
1448          TSize         Short       total data size for this block
1449          "FCI\0"       Long        extra-field signature
1450          Version       Byte        version of AOS/VS extra block (10 = 1.0)
1451          Fstat         variable    fstat packet
1452          AclBuf        variable    raw ACL data ($MXACL bytes)
1453
1454          Fstat contains the file's uncompressed fstat packet, which is one of
1455          the following:
1456
1457                normal fstat packet             (P_FSTAT struct)
1458                DIR/CPD fstat packet            (P_FSTAT_DIR struct)
1459                unit (device) fstat packet      (P_FSTAT_UNIT struct)
1460                IPC file fstat packet           (P_FSTAT_IPC struct)
1461
1462          AclBuf contains the raw ACL data; its length is $MXACL.
1463
1464
1465         -Tandem NSK Extra Field:
1466          ======================
1467
1468          The following is the layout of the file-attributes extra block for
1469          Tandem NSK.  The local-header and central-header versions are
1470          identical.  (Last Revision 19981221)
1471
1472          Value         Size        Description
1473          -----         ----        -----------
1474  (TA)    0x4154        Short       tag for this extra block type ("TA")
1475          TSize         Short       total data size for this block (20)
1476          NSKattrs      20 Bytes    NSK attributes
1477
1478
1479         -THEOS Extra Field:
1480          =================
1481
1482          The following is the layout of the file-attributes extra block for
1483          Theos.  The local-header and central-header versions are identical.
1484          (Last Revision 19990206)
1485
1486          Value         Size        Description
1487          -----         ----        -----------
1488  (Theos) 0x6854        Short       'Th' signature
1489          size          Short       size of extra block
1490          flags         Byte        reserved for future use
1491          filesize      Long        file size
1492          fileorg       Byte        type of file (see below)
1493          keylen        Short       key length for indexed and keyed files,
1494                                    data segment size for 16 bits programs
1495          reclen        Short       record length for indexed,keyed and direct,
1496                                    text segment size for 16 bits programs
1497          filegrow      Byte        growing factor for indexed,keyed and direct
1498          protect       Byte        protections (see below)
1499          reserved      Short       reserved for future use
1500
1501            File types
1502            ==========
1503
1504            0x80  library (keyed access list of files)
1505            0x40  directory
1506            0x10  stream file
1507            0x08  direct file
1508            0x04  keyed file
1509            0x02  indexed file
1510            0x0e  reserved
1511            0x01  16 bits real mode program (obsolete)
1512            0x21  16 bits protected mode program
1513            0x41  32 bits protected mode program
1514
1515            Protection codes
1516            ================
1517
1518            User protection
1519            ---------------
1520            0x01  non readable
1521            0x02  non writable
1522            0x04  non executable
1523            0x08  non erasable
1524
1525            Other protection
1526            ----------------
1527            0x10  non readable
1528            0x20  non writable
1529            0x40  non executable Theos before 4.0
1530            0x40  modified Theos 4.x
1531            0x80  not hidden
1532
1533
1534         -THEOS old inofficial Extra Field:
1535          ================================
1536
1537          The following is the layout of an inoffical former version of a
1538          Theos file-attributes extra blocks.  This layout was never published
1539          and is no longer created. However, UnZip can optionally support it
1540          when compiling with the option flag OLD_THEOS_EXTRA defined.
1541          Both the local-header and central-header versions are identical.
1542          (Last Revision 19990206)
1543
1544          Value         Size        Description
1545          -----         ----        -----------
1546  (THS0)  0x4854        Short       'TH' signature
1547          size          Short       size of extra block
1548          flags         Short       reserved for future use
1549          filesize      Long        file size
1550          reclen        Short       record length for indexed,keyed and direct,
1551                                    text segment size for 16 bits programs
1552          keylen        Short       key length for indexed and keyed files,
1553                                    data segment size for 16 bits programs
1554          filegrow      Byte        growing factor for indexed,keyed and direct
1555          reserved      3 Bytes     reserved for future use
1556
1557
1558         -FWKCS MD5 Extra Field (0x4b46):
1559          ==============================
1560
1561          The FWKCS Contents_Signature System, used in automatically
1562          identifying files independent of filename, optionally adds
1563          and uses an extra field to support the rapid creation of
1564          an enhanced contents_signature.
1565          There is no local-header version; the following applies
1566          only to the central header.  (Last Revision 19961207)
1567
1568          Central-header version:
1569
1570          Value         Size        Description
1571          -----         ----        -----------
1572  (MD5)   0x4b46        Short       tag for this extra block type ("FK")
1573          TSize         Short       total data size for this block (19)
1574          "MD5"         3 bytes     extra-field signature
1575          MD5hash       16 bytes    128-bit MD5 hash of uncompressed data
1576                                    (low byte first)
1577
1578          When FWKCS revises a .ZIP file central directory to add
1579          this extra field for a file, it also replaces the
1580          central directory entry for that file's uncompressed
1581          file length with a measured value.
1582
1583          FWKCS provides an option to strip this extra field, if
1584          present, from a .ZIP file central directory. In adding
1585          this extra field, FWKCS preserves .ZIP file Authenticity
1586          Verification; if stripping this extra field, FWKCS
1587          preserves all versions of AV through PKZIP version 2.04g.
1588
1589          FWKCS, and FWKCS Contents_Signature System, are
1590          trademarks of Frederick W. Kantor.
1591
1592          (1) R. Rivest, RFC1321.TXT, MIT Laboratory for Computer
1593              Science and RSA Data Security, Inc., April 1992.
1594              ll.76-77: "The MD5 algorithm is being placed in the
1595              public domain for review and possible adoption as a
1596              standard."
1597
1598
1599         -Microsoft Open Packaging Growth Hint (0xa220):
1600          =============================================
1601
1602          Value         Size        Description
1603          -----         ----        -----------
1604          0xa220        Short       tag for this extra block type
1605          TSize         Short       size of Sig + PadVal + Padding
1606          Sig           Short       verification signature (A028)
1607          PadVal        Short       Initial padding value
1608          Padding       variable    filled with NULL characters
1609