| 1 | package xar |
| 2 | |
| 3 | type fileHeader struct { |
| 4 | Magic uint32 |
| 5 | HeaderSize uint16 |
| 6 | Version uint16 |
| 7 | CompressedSize int64 |
| 8 | UncompressedSize int64 |
| 9 | HashType hashType |
| 10 | } |
| 11 | |
| 12 | const xarMagic = 0x78617221 // xar! |
| 13 | |
| 14 | type hashType uint32 |
| 15 | |
| 16 | //nolint:deadcode,varcheck // for doc purposes |
| 17 | const ( |
| 18 | hashNone hashType = iota |
| 19 | hashSHA1 |
| 20 | hashMD5 |
| 21 | hashSHA256 |
| 22 | hashSHA512 |
| 23 | ) |
| 24 | |
| 25 | type tocXar struct { |
| 26 | TOC tocToc `xml:"toc"` |
| 27 | } |
| 28 | |
| 29 | type tocToc struct { |
| 30 | CreationTime string `xml:"creation-time"` |
| 31 | Checksum tocChecksum `xml:"checksum"` |
| 32 | Signature *tocSignature `xml:"signature"` |
| 33 | XSignature *tocSignature `xml:"x-signature"` |
| 34 | |
| 35 | Files []*tocFile `xml:"file"` |
| 36 | } |
| 37 | |
| 38 | type tocChecksum struct { |
| 39 | Style string `xml:"style,attr"` |
| 40 | Offset int64 `xml:"offset"` |
| 41 | Size int64 `xml:"size"` |
| 42 | } |
| 43 | |
| 44 | type tocSignature struct { |
| 45 | Style string `xml:"style,attr"` |
| 46 | Offset int64 `xml:"offset"` |
| 47 | Size int64 `xml:"size"` |
| 48 | Certificates []string `xml:"KeyInfo>X509Data>X509Certificate,omitempty"` |
| 49 | } |
| 50 | |
| 51 | type tocFile struct { |
| 52 | Name string `xml:"name"` |
| 53 | Type string `xml:"type"` |
| 54 | |
| 55 | ArchivedChecksum tocFileSum `xml:"data>archived-checksum"` |
| 56 | ExtractedChecksum tocFileSum `xml:"data>extracted-checksum"` |
| 57 | Encoding tocEncoding `xml:"data>encoding"` |
| 58 | Size int64 `xml:"data>size"` |
| 59 | Offset int64 `xml:"data>offset"` |
| 60 | Length int64 `xml:"data>length"` |
| 61 | |
| 62 | Files []*tocFile `xml:"file"` |
| 63 | } |
| 64 | |
| 65 | type tocEncoding struct { |
| 66 | Style string `xml:"style,attr"` |
| 67 | } |
| 68 | |
| 69 | type tocFileSum struct { |
| 70 | Style string `xml:"style,attr"` |
| 71 | Digest string `xml:",chardata"` |
| 72 | } |