PD-33 — Plan d'implémentation¶
📚 Navigation User Story
| Document | | | ---------- | -- | | 📋 [Spécification](PD-33-specification.md) | | | 🛠️ **Plan d'implémentation** | *(ce document)* | | ✅ [Critères d'acceptation](PD-33-acceptability.md) | | | 📝 [Retour d'expérience](PD-33-rex.md) | | [← Retour à crypto](../PD-189-epic.md) · [↑ Index User Story](index.md)Objectif¶
Implémenter la dérivation Argon2id conforme RFC 9106 pour transformer le mot de passe utilisateur en clés cryptographiques K_encryption et K_auth.
Choix techniques retenus¶
- Bibliothèque :
argon2-browser(bundle WASM) - Fallback Expo Go : PBKDF2 via
crypto-js(DEV-ONLY) - Paramètres OWASP 2024 : t=3, m=64 MiB, p=4
- Domain separation : Contextes distincts pour K_encryption et K_auth
Architecture ciblée¶
src/services/keyDerivation.ts
├── deriveEncryptionKey() → K_encryption (chiffre K_master)
├── deriveSRPAuthKey() → K_auth (authentification SRP)
├── generateSalt() → Salt CSPRNG 16 bytes
└── Helpers (wipeKey, bytesToHex, hexToBytes)
Découpage technique¶
Phase 1 : Configuration Argon2id¶
- Définir interface
Argon2Paramsavec paramètres OWASP - Créer constantes
DEFAULT_ARGON2_PARAMSetDEVICE_PARAMS - Implémenter détection WebAssembly (
isWebAssemblyAvailable()) - Implémenter détection Expo Go (
isExpoGo())
Phase 2 : Fallback PBKDF2 (DEV-ONLY)¶
- Implémenter
deriveKeyPBKDF2Fallback()via crypto-js - Itérations adaptées : 10k (Expo Go) / 600k (prod impossible)
- Logs d'avertissement explicites (non-conformité PD-97)
- Bloquer en production si Argon2id indisponible
Phase 3 : Dérivation principale¶
- Implémenter
deriveKeyInternal()avec validation input - Import dynamique
argon2-browser/dist/argon2-bundled.min.js - Domain separation via
secret(associated data) - Wrapper
deriveEncryptionKey()avec contexteProbatioVault::Encryption::v1 - Wrapper
deriveSRPAuthKey()avec contexteProbatioVault::SRP_Auth::v1
Phase 4 : Utilitaires¶
generateSalt()viaexpo-crypto(16 bytes CSPRNG)wipeKey()pour effacement mémoire (best effort)detectDeviceCapability()pour ajustement params (TODO)- Conversions
bytesToHex()/hexToBytes()
Phase 5 : Tests¶
- Tests unitaires conformité RFC 9106
- Tests vecteurs IETF officiels
- Tests performance (~500ms sur iPhone 12+)
- Tests rejet paramètres invalides
Points de vigilance¶
- Expo Go : Pas de WebAssembly → fallback PBKDF2 en DEV uniquement
- Production : Argon2id OBLIGATOIRE, erreur si indisponible
- Password minimum : 12 caractères (prod), 4 (dev)
- Memory leak : Appeler
wipeKey()après usage - Strings immutables : Effacement password best-effort en JS
Hors périmètre¶
- Stockage des clés dérivées (→ PD-98)
- Intégration SRP complète (→ PD-24)
- Dérivation K_doc (→ PD-34)