keyderiv

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package keyderiv owns version-separated HKDF-SHA256 derivation.

V1 retains its historical literal info bytes. Suite 0x02 uses ASCII(label)||0x00||context for every branch; keeping the schemes in distinct functions prevents a caller from accidentally applying one version's domain convention to the other.

Index

Constants

View Source
const (
	V2ReadSecretBytes = 16
	V2IdentityBytes   = 16
	V2PKHashBytes     = 16
)
View Source
const (
	V2DescriptorLabel  = "windshare/v2 descriptor"
	V2CatalogLabel     = "windshare/v2 catalog"
	V2FileObjectLabel  = "windshare/v2 file-object"
	V2RevisionLabel    = "windshare/v2 file-revision"
	V2FileSegmentLabel = "windshare/v2 file-segment"
	V2SessionAuthLabel = "windshare/v2 session-auth"
)
View Source
const KeyBytes = 32

KeyBytes 是全部派生密钥的统一长度(AES-256 密钥)。

Variables

View Source
var ErrV2KeyMaterial = errors.New("keyderiv: invalid suite-0x02 key material")

Functions

func ManifestKey

func ManifestKey(readSecret []byte) []byte

ManifestKey 派生清单封装密钥:HKDF(readSecret, "windshare/v1 manifest", 32)。

func SegKey

func SegKey(streamKey []byte, seg uint32) []byte

SegKey 派生第 seg 段(每 SegmentBytes 轮换)的块加密密钥: HKDF(streamKey, "windshare/v1 seg"‖u32_be(seg), 32)。 段号入 info 而非 salt,与另两条派生保持同构(salt 一律为空)。

func StreamKey

func StreamKey(readSecret []byte) []byte

StreamKey 派生打包流根密钥:HKDF(readSecret, "windshare/v1 stream", 32)。 它不直接加密任何块,只作为各段 SegKey 的派生输入。

func V2CatalogKey

func V2CatalogKey(readSecret, shareInstance []byte) ([]byte, error)

V2CatalogKey scopes all catalog generations to one share instance.

func V2DescriptorKey

func V2DescriptorKey(readSecret, pkHash []byte) ([]byte, error)

V2DescriptorKey binds the bootstrap object key to the sender public-key hash.

func V2FileObjectKey

func V2FileObjectKey(readSecret, shareInstance, fileID []byte) ([]byte, error)

V2FileObjectKey isolates revision descriptors by share and file identities.

func V2FileSegmentKey

func V2FileSegmentKey(revisionKey []byte, segment uint64) ([]byte, error)

V2FileSegmentKey rotates block keys every 16 GiB without narrowing the segment index.

func V2RevisionKey

func V2RevisionKey(fileObjectKey, fileRevision []byte) ([]byte, error)

V2RevisionKey ensures a revision change rotates the complete block-key subtree.

func V2SessionAuthKey

func V2SessionAuthKey(readSecret, shareInstance []byte) ([]byte, error)

V2SessionAuthKey authenticates the transcript before sender resource admission.

Types

This section is empty.

Jump to

Keyboard shortcuts

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