Documentation
¶
Overview ¶
Package repoconfig encodes and decodes the repository config marker.
An encrypted repository's marker is sealed with the repository encryption key, so its contents can be neither read nor edited by anyone who cannot derive that key. Sealing rather than authenticating is deliberate: AES-GCM covers every byte it seals, so a new field is protected the moment it is added, with no separate list of authenticated fields to keep in sync.
The cost is that the format version moves inside the sealed blob, so it can only be read after the key is resolved. Restic makes the same trade.
An unencrypted repository has no key, so its marker stays plaintext. So does every repository written before sealing existed: backward compatibility is permanent, and a plaintext marker must remain readable forever. The bytes are self-describing, so a reader tells the two apart without being told which to expect.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(raw []byte, encryptionKey []byte) (*core.RepoConfig, error)
Decode decodes raw marker bytes, unsealing them first when they are sealed.
encryptionKey is required for a sealed marker and ignored for a plaintext one. A sealed marker that does not open is reported as tampering rather than as a parse failure: GCM authenticates the whole object, so the only ways to get here are the wrong key or modified bytes.
func Encode ¶
func Encode(cfg core.RepoConfig, encryptionKey []byte) ([]byte, error)
Encode returns the bytes to store for cfg, sealing them when encryptionKey is non-empty. An encrypted repository must always pass its key: writing its marker in plaintext would strip the protection from a repository that had it.
func IsSealed ¶
IsSealed reports whether raw marker bytes are sealed.
This is a length and version-byte check that needs no key, which is what lets a reader decide whether it must unlock before it can decode. A sealed marker also implies an encrypted repository, so callers that only need that much can answer from this alone.
Types ¶
This section is empty.