@@ -54,9 +54,23 @@ func getLeakedKeys() ([10][]byte, error) {
54
54
55
55
type Manifest interface {}
56
56
57
+ /*
58
+ FIXME: Do address and offset really always exist? I don't think so...
59
+ Example FIT:
60
+
61
+ 01c39980: 5f46 4954 5f20 2020 0700 0000 0001 0000 _FIT_ ........
62
+ 01c39990: 0004 bdff 0000 0000 0000 0000 0001 0100 ................
63
+ 01c399a0: 0028 c0ff 0000 0000 0000 0000 0001 0100 .(..............
64
+ 01c399b0: 0000 f8ff 0000 0000 0000 0000 0001 0200 ................
65
+ 01c399c0: 7000 7100 0104 7d00 0000 0000 0000 0a00 p.q...}.........
66
+ 01c399d0: 0046 feff 0000 0000 5503 0000 0001 0b00 .F......U.......
67
+ 01c399e0: 0041 feff 0000 0000 9504 0000 0001 0c00 .A..............
68
+
69
+ */
70
+
57
71
type FEntry struct {
58
72
Type string
59
- Address fit. Address64
73
+ Address uint64
60
74
Offset uint64
61
75
Size uint32
62
76
Version fit.EntryVersion
@@ -65,8 +79,7 @@ type FEntry struct {
65
79
type Meta struct {
66
80
Keym Manifest
67
81
Polm Manifest
68
- Fit []fit.Entry
69
- Entries []FEntry
82
+ Fit []FEntry
70
83
LeakedKey string
71
84
}
72
85
@@ -87,30 +100,35 @@ func main() {
87
100
}
88
101
89
102
var meta Meta
90
- // TODO: the whole FIT is too verbose
91
- // meta.Fit = entries
92
-
93
103
var bme fit.Entry
94
104
var kme fit.Entry
95
105
var txte fit.Entry
96
106
for idx , entry := range entries {
107
+ t := entry .GetEntryBase ().Headers .Type ()
97
108
// if entry.GetEntryBase().Headers.Type() == fit.EntryTypeStartupACModuleEntry {
98
- if entry . GetEntryBase (). Headers . Type () == fit .EntryTypeKeyManifestRecord {
109
+ if t == fit .EntryTypeKeyManifestRecord {
99
110
kme = entry
100
111
fmt .Fprintf (os .Stderr , "key manifest @ %v\n " , idx )
101
112
}
102
- if entry . GetEntryBase (). Headers . Type () == fit .EntryTypeBootPolicyManifest {
113
+ if t == fit .EntryTypeBootPolicyManifest {
103
114
bme = entry
104
115
fmt .Fprintf (os .Stderr , "boot policy manifest @ %v\n " , idx )
105
116
}
106
- if entry . GetEntryBase (). Headers . Type () == fit .EntryTypeTXTPolicyRecord {
117
+ if t == fit .EntryTypeTXTPolicyRecord {
107
118
txte = entry
108
119
fmt .Fprintf (os .Stderr , "TXT policy manifest @ %v\n " , idx )
109
120
}
110
- meta .Entries = append (meta .Entries , FEntry {
111
- Type : entry .GetEntryBase ().Headers .Type ().String (),
112
- Address : entry .GetEntryBase ().Headers .Address ,
113
- Offset : entry .GetEntryBase ().Headers .Address .Offset (uint64 (len (data ))),
121
+ var a uint64
122
+ var o uint64
123
+ if t != fit .EntryTypeFITHeaderEntry && t != fit .EntryTypeTXTPolicyRecord {
124
+ addr := entry .GetEntryBase ().Headers .Address
125
+ a = addr .Pointer ()
126
+ o = addr .Offset (uint64 (len (data )))
127
+ }
128
+ meta .Fit = append (meta .Fit , FEntry {
129
+ Type : t .String (),
130
+ Address : a ,
131
+ Offset : o ,
114
132
Size : entry .GetEntryBase ().Headers .Size .Uint32 (),
115
133
Version : entry .GetEntryBase ().Headers .Version ,
116
134
})
0 commit comments