nativeformat

package
v1.0.0-beta1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuditMagic     = "\x89BAUDIT\n"
	RecordingMagic = "\x89BCAST\n"
	CommitMarker   = "BFCOMMIT"

	MaxMetadataPayload       = 4 << 10
	MaxAuditEventPayload     = 64 << 10
	MaxAuditRecordPayload    = 128 << 10
	MaxRecordingDecodedChunk = 2 << 20
	MaxRecordingChunkPayload = 4 << 20
)

Variables

This section is empty.

Functions

func DecodeStoredPayload

func DecodeStoredPayload(stored []byte, identities *crypto.AgeSshIdentities, recipientFingerprint string, limits PayloadLimits) ([]byte, error)

DecodeStoredPayload never returns partial plaintext: age must authenticate through EOF before the single Zstd frame can be accepted.

func DecodeZstdFrame

func DecodeZstdFrame(frame []byte, limits PayloadLimits) ([]byte, error)

func EncodeStoredPayload

func EncodeStoredPayload(plaintext []byte, recipient *crypto.AgeSshRecipient, limits PayloadLimits) ([]byte, error)

EncodeStoredPayload produces a separate Zstd frame and optional age message for one audit record or recording chunk. The signed container supplies the recipient fingerprint and binds the resulting stored bytes.

func EncodeUnit

func EncodeUnit(kind UnitType, payload []byte, maximum int) ([]byte, error)

func EncodeZstdFrame

func EncodeZstdFrame(plaintext []byte, limits PayloadLimits) ([]byte, error)

EncodeZstdFrame encodes one independently decodable, checksum-protected frame. Incompressible input may use Zstd raw blocks, not a second wire codec.

func HasCommittedUnitWithin

func HasCommittedUnitWithin(source io.ReaderAt, start, end, size int64, maximum int) (bool, error)

HasCommittedUnitWithin searches only [start,end) for a candidate prefix. A state-1 prefix with a valid kind/length and a marker at its computed trailer is evidence even when its CRC is damaged. Payload bytes (including encrypted bytes) can mimic a frame, so a match is ambiguous and must fail closed.

func Marshal

func Marshal(value any, maximum int) ([]byte, error)

Marshal encodes a typed wire map and checks that its bytes are acceptable to the same strict decoder used for untrusted containers.

func Unmarshal

func Unmarshal[T any](encoded []byte, maximum int) (T, error)

Unmarshal requires a fresh, typed wire schema; re-encoding rejects alternate but semantically equivalent encodings before they can enter a signed chain.

Types

type Family

type Family uint8
const (
	AuditFamily Family = iota + 1
	RecordingFamily
)

func DetectFamily

func DetectFamily(source io.ReaderAt) (Family, int64, error)

type PayloadLimits

type PayloadLimits struct {
	MaxDecoded int
	MaxStored  int
}

type Timestamp

type Timestamp struct {
	Seconds     int64
	Nanoseconds uint32
}

Timestamp uses the same two-element CBOR array in every native wire schema. Encoding time.Time directly would otherwise depend on library time options.

func TimestampOf

func TimestampOf(value time.Time) Timestamp

func (Timestamp) MarshalCBOR

func (this Timestamp) MarshalCBOR() ([]byte, error)

func (Timestamp) Time

func (this Timestamp) Time() (time.Time, error)

func (*Timestamp) UnmarshalCBOR

func (this *Timestamp) UnmarshalCBOR(encoded []byte) error

type Unit

type Unit struct {
	Type    UnitType
	Payload []byte
}

func ReadUnitAt

func ReadUnitAt(source io.ReaderAt, offset, size int64, maximum int) (Unit, int64, bool, error)

ReadUnitAt distinguishes an uncommitted tail from an invalid committed unit. Callers must compare the tail against their signed recovery checkpoint.

type UnitType

type UnitType uint8
const (
	HeaderUnit UnitType = iota + 1
	ContentUnit
	SealUnit
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL