Files
orca/internal/seal/zero_key_test.go
T
Jon Chery 9e832387c6 feat(P05): seal/audit CLI + chain race fix + key zeroing (REQ-154)
New CLI commands:
- orca cluster seal: OIDC/CA-derived seal + Shamir 3-of-5 shards
- orca cluster unseal: OIDC/CA unseal + --recovery Shamir path
- orca doctor audit: VerifyChain + chain head report
- orca doctor modes: EnforceFileModes across ORCA_HOME

Fixes:
- audit hash-chain race: Append uses BEGIN IMMEDIATE transaction
  (concurrent appends no longer corrupt tamper-evidence)
- secrets rotate-master: re-seals to OIDC on sealed clusters
  (was writing raw key, docstring claimed re-seal)
- key zeroing: ZeroKey helper + defer after master/namespace key use
  (defense-in-depth against pprof heap extraction)
- store.Open: busy_timeout(5000) pragma (concurrent writers wait)

Tests: 18 new test functions (seal round-trip, Shamir recovery, doctor
audit tamper detection, doctor modes 0644 rejection, concurrent append
chain integrity, rotate-master re-seal, key zeroing).

---ci---
project: orca
phase: 5
milestone: v0.13
status: complete
requirements:
  covered: [154]
---/ci---
2026-08-07 21:06:39 +00:00

24 lines
535 B
Go

package seal
import (
"bytes"
"testing"
)
// TestZeroKey verifies that ZeroKey overwrites every byte of the slice
// with zeros (P05 T6, REQ-147).
func TestZeroKey(t *testing.T) {
key := []byte{255, 255, 255, 255, 0, 1, 2, 3, 4, 5}
ZeroKey(key)
want := make([]byte, len(key))
if !bytes.Equal(key, want) {
t.Errorf("ZeroKey did not zero: got %v, want %v", key, want)
}
}
// TestZeroKey_NilAndEmpty verifies ZeroKey is safe on nil/empty slices.
func TestZeroKey_NilAndEmpty(t *testing.T) {
ZeroKey(nil)
ZeroKey([]byte{})
}