Up to 3.1.1, the Jackson KDBX implementation holds attachment (binary property) content as the
Base64 text of the gzipped bytes, in KeePassFile.Binary, and decodes it on every
getBinaryProperty. This is the same whether or not the attachment is protected, and attachments
read from the KDBX 4 inner header are re-encoded that way. The protected flag itself was lost:
KDBX 4 attachments were always written as not protected, and KDBX 3.1 files with protected
attachments (Protected="True" in Meta/Binaries) could not be read.
From 3.1.2, attachment content is held as a PropertyValue: protected attachments use the
strategy's newProtected() factory (SealedStore by default), and unprotected attachments always
use BytesStore.
The strategy isn't used for unprotected attachments because newUnprotected() may return a
factory that holds strings (StringStore), whose of(byte[]) decodes the bytes as UTF-8 and so
can't hold arbitrary binary content. For the same reason, a custom newProtected() that holds
strings would corrupt protected attachments.
For 3.2.0, PropertyValue.Strategy should name the factories for binary properties explicitly,
e.g. default methods newProtectedBinary() and newUnprotectedBinary() (defaults SealedStore
and BytesStore), so that a strategy can choose how attachments are held in memory, and the
contract says these factories must hold arbitrary bytes unchanged. Update
PropertyValueProtection.md and BinaryProperties.md to match.
Up to 3.1.1, the Jackson KDBX implementation holds attachment (binary property) content as the
Base64 text of the gzipped bytes, in
KeePassFile.Binary, and decodes it on everygetBinaryProperty. This is the same whether or not the attachment is protected, and attachmentsread from the KDBX 4 inner header are re-encoded that way. The protected flag itself was lost:
KDBX 4 attachments were always written as not protected, and KDBX 3.1 files with protected
attachments (
Protected="True"inMeta/Binaries) could not be read.From 3.1.2, attachment content is held as a
PropertyValue: protected attachments use thestrategy's
newProtected()factory (SealedStoreby default), and unprotected attachments alwaysuse
BytesStore.The strategy isn't used for unprotected attachments because
newUnprotected()may return afactory that holds strings (
StringStore), whoseof(byte[])decodes the bytes as UTF-8 and socan't hold arbitrary binary content. For the same reason, a custom
newProtected()that holdsstrings would corrupt protected attachments.
For 3.2.0,
PropertyValue.Strategyshould name the factories for binary properties explicitly,e.g. default methods
newProtectedBinary()andnewUnprotectedBinary()(defaultsSealedStoreand
BytesStore), so that a strategy can choose how attachments are held in memory, and thecontract says these factories must hold arbitrary bytes unchanged. Update
PropertyValueProtection.mdandBinaryProperties.mdto match.