Skip to content

[encstore] Shared PIN-gated encrypted storage module + keyring app - #4428

Open
GlassOnTin wants to merge 1 commit into
espruino:masterfrom
GlassOnTin:encstore-keystore
Open

GlassOnTin wants to merge 1 commit into
espruino:masterfrom
GlassOnTin:encstore-keystore

Conversation

@GlassOnTin

Copy link
Copy Markdown
Contributor

Adds modules/encstore.js and modules/EncStore.md: a shared, app-agnostic encrypted Storage module, plus apps/keyring as its first consumer.

Design (uses only the hash primitives the firmware exposes; no block cipher):

  • Key material: PBKDF1-style SHA256 chain over pin || salt, default 400 rounds (~2-4 s per unlock on a Bangle.js 2), split into separate encryption and MAC keys via domain separation.
  • Cipher: SHA-256 keystream, ct = pt XOR SHA256(encKey || iv || be32(i)) over 32-byte blocks.
  • Integrity: encrypt-then-MAC, HMAC-SHA256 over iv || ct with the separately derived MAC key. Wrong PIN or tampering yields no data.
  • IV/salt: no hardware RNG is exposed to JS, so they mix a monotonic boot counter (reuse impossible across reboots) with time, temperature and Math.random, hashed through SHA256.
  • The store is app-agnostic: each app seals under its own Storage file name.

apps/keyring consumes the module: a PIN gate over a list of label/secret/comment entries, view on tap, relock on BTN1. Entries are provisioned off-watch so secrets never get typed on a 176 px screen.

Off-watch reference and tool: apps/authentiwatch/tools/seal_lock.py (from the authentiwatch PR) reads, verifies and seals the same format with stdlib only. The keyring lock shipped in testing was cross-verified against it byte-for-byte, both directions (correct PIN decodes; wrong PIN rejected with no content revealed).

Code written with AI assistance, reviewed and tested on a Bangle.js 2 (firmware 2v29): PIN setup, unlock, wrong-PIN path, viewer, and cross-implementation checks.

This branch has not been deployed

No deployments
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.

1 participant