Skip to content

Commit bdff266

Browse files
committed
intelmeta: special handling for TXT entry
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent b6a7c36 commit bdff266

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

cmds/intelmeta/main.go

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,23 @@ func getLeakedKeys() ([10][]byte, error) {
5454

5555
type Manifest interface{}
5656

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+
5771
type FEntry struct {
5872
Type string
59-
Address fit.Address64
73+
Address uint64
6074
Offset uint64
6175
Size uint32
6276
Version fit.EntryVersion
@@ -65,8 +79,7 @@ type FEntry struct {
6579
type Meta struct {
6680
Keym Manifest
6781
Polm Manifest
68-
Fit []fit.Entry
69-
Entries []FEntry
82+
Fit []FEntry
7083
LeakedKey string
7184
}
7285

@@ -87,30 +100,35 @@ func main() {
87100
}
88101

89102
var meta Meta
90-
// TODO: the whole FIT is too verbose
91-
// meta.Fit = entries
92-
93103
var bme fit.Entry
94104
var kme fit.Entry
95105
var txte fit.Entry
96106
for idx, entry := range entries {
107+
t := entry.GetEntryBase().Headers.Type()
97108
// if entry.GetEntryBase().Headers.Type() == fit.EntryTypeStartupACModuleEntry {
98-
if entry.GetEntryBase().Headers.Type() == fit.EntryTypeKeyManifestRecord {
109+
if t == fit.EntryTypeKeyManifestRecord {
99110
kme = entry
100111
fmt.Fprintf(os.Stderr, "key manifest @ %v\n", idx)
101112
}
102-
if entry.GetEntryBase().Headers.Type() == fit.EntryTypeBootPolicyManifest {
113+
if t == fit.EntryTypeBootPolicyManifest {
103114
bme = entry
104115
fmt.Fprintf(os.Stderr, "boot policy manifest @ %v\n", idx)
105116
}
106-
if entry.GetEntryBase().Headers.Type() == fit.EntryTypeTXTPolicyRecord {
117+
if t == fit.EntryTypeTXTPolicyRecord {
107118
txte = entry
108119
fmt.Fprintf(os.Stderr, "TXT policy manifest @ %v\n", idx)
109120
}
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,
114132
Size: entry.GetEntryBase().Headers.Size.Uint32(),
115133
Version: entry.GetEntryBase().Headers.Version,
116134
})

0 commit comments

Comments
 (0)