# ADR-0102: E27 Link and Session Key Lifetimes

Status: Accepted

## Context

E27 employs multiple cryptographic keys with different lifetimes:
long-lived keys establishing trust and short-lived keys protecting sessions.

Confusing these lifetimes results in unnecessary re-linking,
broken reconnect behavior, or invalid authorization escalation.

These lifetimes define the security model of the protocol and
must be explicitly captured architecturally.

## Decision

E27 uses a two-tier key model with distinct lifetimes:

1. Link keys
   - Encryption key and HMAC key
   - Long-lived
   - Persist across:
     - TCP reconnects
     - Session termination
     - Authorization changes
   - Represent the trusted association between client and panel

2. Session keys
   - Session encryption key and session HMAC key
   - Issued during client hello
   - Used for all session-encrypted traffic
   - Persist across session_id changes
   - Re-established on reconnect without re-linking

Session identifiers reflect authorization context only and
do not alter cryptographic keys.

## Rationale

This model:
- mirrors keypad-to-panel behavior
- supports fast reconnects
- allows authorization escalation without renegotiating trust
- aligns with documented and reference behavior

## Consequences

- Link keys must be persisted externally
- Session bootstrap is required on each connection
- Authorization escalation does not renegotiate crypto
- Loss of link keys requires re-linking

## Scope / Non-Goals

- Does not define key storage mechanisms
- Does not define key rotation policy
- Does not define cryptographic primitives

## References

- ADR-0003
- ADR-0004
- E27 API Comms Protocol
