Documentation
¶
Overview ¶
Package crypt implements the files byte-layer cipher: whole-file AES-256-CFB with a zero IV and a random per-file key — the exact format anytype-heart writes (cfb.New(key, [aes.BlockSize]byte{})), so ciphertext and the derived UnixFS cids stay byte-compatible.
A zero IV is safe here because a file key is generated fresh per file and never reused; integrity comes from the merkle cids over the ciphertext, not from the cipher (CFB carries no tags). Readers must therefore only feed cid-verified bytes into a decryptor.
Index ¶
Constants ¶
const KeySize = 32
KeySize is the AES-256 key length in bytes.
Variables ¶
var ErrBadKey = errors.New("crypt: key must be 32 bytes")
ErrBadKey is returned for a key of the wrong length.
Functions ¶
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader decrypts an AES-256-CFB ciphertext stream with random access. Seek re-keys the stream from the ciphertext block boundary before the target offset: the 16 ciphertext bytes preceding the aligned position are the IV, so decryption never restarts from zero (ports anytype-heart's cfb.CFBDecryptor).
The underlying ciphertext reader must serve only cid-verified bytes; Reader adds no integrity of its own.