forked from security/hakurei
internal/pkg: encode checksum in ident
This also rearranges the ident ir to be more predictable, and avoids an obvious and somewhat easy to get into inconsistent state. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -589,12 +589,21 @@ func (c *Cache) unsafeIdent(a Artifact, encodeKind bool) (
|
||||
h := sha512.New384()
|
||||
binary.LittleEndian.PutUint64(buf[:], uint64(a.Kind()))
|
||||
h.Write(buf[:wordSize])
|
||||
i := IContext{c, h}
|
||||
a.Params(&i)
|
||||
i.cache, i.h = nil, nil
|
||||
for _, dn := range idents {
|
||||
h.Write(dn[:])
|
||||
}
|
||||
kcBuf := c.getIdentBuf()
|
||||
if kc, ok := a.(KnownChecksum); ok {
|
||||
*(*Checksum)(kcBuf[:]) = kc.Checksum()
|
||||
} else {
|
||||
*(*Checksum)(kcBuf[:]) = Checksum{}
|
||||
}
|
||||
h.Write((*Checksum)(kcBuf[:])[:])
|
||||
c.putIdentBuf(kcBuf)
|
||||
|
||||
i := IContext{c, h}
|
||||
a.Params(&i)
|
||||
i.cache, i.h = nil, nil
|
||||
|
||||
h.Sum(buf[wordSize:wordSize])
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user