Debian Codegraph @

lib/cabfile/structs.go

raw symbols SCIP
1 //
2 // Copyright (c) SAS Institute Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16
17 package cabfile
18
19 import "crypto"
20
21 const Magic = 0x4643534d // MSCF
22
23 type CabinetFlag uint16
24
25 const (
26 FlagPrevCabinet CabinetFlag = 1 << iota
27 FlagNextCabinet
28 FlagReservePresent
29 )
30
31 type Header struct {
32 Magic uint32
33 Reserved1 uint32
34 TotalSize uint32
35 Reserved2 uint32
36 OffsetFiles uint32
37 Reserved3 uint32
38 Version uint16
39 NumFolders uint16
40 NumFiles uint16
41 Flags CabinetFlag
42 SetID uint16
43 CabNumber uint16
44 }
45
46 const reserveHeaderSize = 4
47
48 type ReserveHeader struct {
49 HeaderSize uint16
50 FolderSize uint8
51 DataSize uint8
52 }
53
54 const signatureHeaderSize = 20
55
56 type SignatureHeader struct {
57 Unknown1 uint32
58 CabinetSize uint32
59 SignatureSize uint32
60 Unknown2, Unknown3 uint32
61 }
62
63 func (sh *SignatureHeader) Size() uint32 {
64 if sh == nil {
65 return 0
66 }
67 return sh.SignatureSize
68 }
69
70 type FolderHeader struct {
71 Offset uint32
72 NumData uint16
73 Compression uint16
74 }
75
76 // the pieces of Header that are part of the signature
77 type sigBlob struct {
78 // skipped fields: Reserved1, CabNumber
79 Magic uint32
80 TotalSize uint32
81 Reserved2 uint32
82 OffsetFiles uint32
83 Reserved3 uint32
84 Version uint16
85 NumFolders uint16
86 NumFiles uint16
87 Flags CabinetFlag
88 SetID uint16
89 SigUnknown3 uint32
90 }
91
92 type Cabinet struct {
93 Header Header
94 ReserveHeader ReserveHeader
95 ReserveData []byte
96 SignatureHeader *SignatureHeader
97 Signature []byte
98 }
99
100 type CabinetDigest struct {
101 Cabinet *Cabinet
102 Imprint []byte
103 HashFunc crypto.Hash
104 Patched []byte
105 }