Skip to content

Commit

Permalink
Add comment explaining hash unset
Browse files Browse the repository at this point in the history
  • Loading branch information
tobischo committed Jun 13, 2022
1 parent 51ec0eb commit cc03783
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ func (e *Encoder) Encode(db *Database) error {
return err
}

// Comment as taken from the original KDBX source:
// > The header hash is typically only stored in
// > KDBX <= 3.1 files, not in KDBX >= 4 files
// > (here, the header is verified via a HMAC),
// > but we also support it for KDBX >= 4 files
// > (i.e. if it's present, we check it)
// That means that for KDBXv4 files we can unset the hash to make sure that it is blank.
// Additionally it has to happen somewhere before `xml.MarshalIndent` and this is
// the perfect spot just before it specific to KDBXv4 files.
db.Content.Meta.HeaderHash = ""
} else {
db.Content.Meta.HeaderHash = base64.StdEncoding.EncodeToString(hash[:])
Expand Down

0 comments on commit cc03783

Please sign in to comment.