DDR-0030: E27 Key Material Scope and Lifetime Separation

Status: Accepted
Date: 2025-01-xx

Context
-------
The E27 protocol uses multiple cryptographic keys with distinct purposes and lifetimes:

- Provisioning credentials (access code, pass phrase)
- Persistent link credentials
- Per-session encryption keys

Early implementations risked conflating these roles, especially across api_link, hello, and authenticate.

Decision
--------
The implementation SHALL enforce strict separation of key material:

- Access Code and Pass Phrase:
  - Used only for api_link
  - Never persisted
  - Never reused after linking

- Link Key and Link HMAC:
  - Returned by api_link
  - Persisted across TCP sessions
  - Used to decrypt the hello response

- Session Key and Session HMAC:
  - Returned by hello
  - Valid only for the lifetime of a single TCP connection
  - Used for all schema-0 encrypted traffic after authentication

Keys MUST NOT be reused outside their defined scope.

Consequences
------------
- session.py MUST fail early if link credentials are missing
- provisioning.py handles credential acquisition but not storage
- Reconnecting without stored link credentials MUST trigger provisioning
- Silent panel timeouts caused by incorrect credentials are treated as provisioning failure

Related
-------
- ADR-010x (E27 key lifetimes)
- DDR-0029 (api_link transport asymmetry)
- DDR-0024 (Session lifecycle states)
