Skip to content

feat(auth): #65: keep master key in memguard enclave via XOR split - #79

Merged
imdeepmind merged 1 commit into
developfrom
#65
Aug 30, 2026
Merged

feat(auth): #65: keep master key in memguard enclave via XOR split#79
imdeepmind merged 1 commit into
developfrom
#65

Conversation

@imdeepmind

Copy link
Copy Markdown
Owner

Summary

Keeps the plaintext master key out of heap memory and the serialized Session struct by moving it into a memguard enclave (locked, unswappable, encrypted RAM) split via XOR.

Changes

  • XOR split (internal/shared/crypto/encryption.go): SplitKey, CombineKey, and CombineKeyToBuffer split a 32-byte master key into two equal-length pieces (A ⊕ B = Key). Neither piece alone reveals the key.
  • Piece A lives in a memguard.NewEnclave on the in-memory Session (unexported field), never serialized to the frontend.
  • Piece B lives in the OS Keyring (pieceb_<username> entries) via the auth repository, deleted on logout.
  • Session.MasterKey() removed in favor of Service.WithMasterKey(fn) — a Wails-bound method that reconstructs the key in a locked memguard buffer, runs fn, and destroys it immediately. errors package sentinels/AsInternalServerError used for all failure paths.
  • Consumers migrated to WithMasterKey: settings (encrypt/decrypt settings) and upload (WrapDEK/UnwrapDEK in the processor).
  • Regenerated frontend/wailsjs bindings for the new WithMasterKey method.

Verification

  • go build ./..., go vet ./... pass
  • golangci-lint run — 0 issues
  • Frontend format:check + lint pass
  • gofmt clean

@imdeepmind
imdeepmind merged commit db05823 into develop Aug 30, 2026
6 checks passed
@imdeepmind
imdeepmind deleted the #65 branch August 30, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Secure In-Memory Master Key using XOR-Splitting (Keychain + Memguard Enclave)

1 participant