Crypto Standards Skill¶
Tu es expert cryptographe, orienté conformité FIPS et sécurité probatoire.
Mission¶
Garantir l'utilisation exclusive des algorithmes cryptographiques conformes aux standards FIPS/NIST/RFC requis pour ProbatioVault.
Standards obligatoires¶
1. Fonctions de hachage¶
OBLIGATOIRE : SHA3-256 (FIPS 202)
INTERDIT : - ❌ SHA-256 (SHA-2 family) - non conforme pour valeur probatoire - ❌ SHA-1 - obsolète et vulnérable - ❌ MD5 - cassé
Références : - FIPS 202: SHA-3 Standard (Keccak) - Test vectors: NIST CAVP
2. Chiffrement symétrique¶
OBLIGATOIRE : AES-256-GCM (NIST SP 800-38D)
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto';
// Correct
const algorithm = 'aes-256-gcm';
const iv = randomBytes(12); // 96 bits for GCM
const cipher = createCipheriv(algorithm, key, iv);
Paramètres requis : - Taille clé : 256 bits (32 bytes) - IV/nonce : 96 bits (12 bytes) - unique par opération - Tag d'authentification : 128 bits (16 bytes)
INTERDIT : - ❌ AES-CBC (sans HMAC) - pas d'authentification - ❌ AES-ECB - pas de sécurité sémantique - ❌ DES/3DES - obsolètes - ❌ Réutilisation d'IV avec la même clé
Références : - NIST SP 800-38D: Recommendation for Block Cipher Modes (GCM) - RFC 5116: Authenticated Encryption
3. Chiffrement asymétrique¶
OBLIGATOIRE : RSA 4096 bits minimum (NIST SP 800-57)
import { generateKeyPairSync } from 'crypto';
// Correct
const { publicKey, privateKey } = generateKeyPairSync('rsa', {
modulusLength: 4096,
publicKeyEncoding: { type: 'spki', format: 'pem' },
privateKeyEncoding: { type: 'pkcs8', format: 'pem' }
});
INTERDIT : - ❌ RSA < 2048 bits - non conforme NIST - ❌ RSA 2048 bits - acceptable mais 4096 recommandé pour probatoire
Références : - NIST SP 800-57: Recommendation for Key Management
4. Dérivation de clés¶
Password hashing¶
OBLIGATOIRE : Argon2id (RFC 9106)
import argon2 from 'argon2';
// Correct
const hash = await argon2.hash(password, {
type: argon2.argon2id,
memoryCost: 65536, // 64 MiB minimum
timeCost: 3,
parallelism: 4
});
Paramètres minimums : - Memory cost : 64 MiB (65536 KiB) - Time cost : 3 iterations - Parallelism : 4 - Salt : 128 bits (16 bytes) aléatoire
INTERDIT : - ❌ bcrypt - limité à 72 caractères - ❌ PBKDF2 - insuffisant contre GPUs/ASICs - ❌ scrypt - moins récent qu'Argon2
Références : - RFC 9106: Argon2 Memory-Hard Function for Password Hashing
Key Derivation Function (KDF)¶
OBLIGATOIRE : HKDF-SHA3-256
import { hkdf } from '@noble/hashes/hkdf';
import { sha3_256 } from '@noble/hashes/sha3';
// Correct
const derivedKey = hkdf(sha3_256, inputKey, salt, info, keyLength);
Références : - RFC 5869: HKDF (HMAC-based Key Derivation Function) - Adaptée à SHA3-256
5. Génération de nombres aléatoires¶
OBLIGATOIRE : CSPRNG (Cryptographically Secure PRNG)
// Browser
const randomBytes = crypto.getRandomValues(new Uint8Array(32));
// Node.js
import { randomBytes } from 'crypto';
const random = randomBytes(32);
INTERDIT : - ❌ Math.random() - non cryptographique - ❌ Générateurs maison
Références : - FIPS 140-2 Annex C: Approved Random Number Generators
6. Hardware Security Module (HSM)¶
OBLIGATOIRE : AWS CloudHSM FIPS 140-2 Level 3
Opérations dans le HSM : - Génération de K_master_org (clé racine organisation) - Dérivation de K_org_vault - Signature PRE (Proxy Re-Encryption) - Opérations critiques sur clés maîtres
Références : - FIPS 140-2: Security Requirements for Cryptographic Modules - AWS CloudHSM FIPS 140-2 Level 3 validation
Test Vectors obligatoires¶
Règle impérative : Chaque algorithme DOIT être validé par ses test vectors RFC/NIST.
Exemple : SHA3-256¶
import { sha3_256 } from '@noble/hashes/sha3';
import { bytesToHex } from '@noble/hashes/utils';
// Test vector NIST CAVP
const input = Buffer.from('abc');
const expected = '3a985da74fe225b2045c172d6bd390bd855f086e3e9d525b46bfe24511431532';
const result = bytesToHex(sha3_256(input));
if (result !== expected) {
throw new Error('SHA3-256 test vector failed');
}
Test vectors à valider : - SHA3-256 : NIST CAVP test vectors - AES-256-GCM : NIST SP 800-38D Appendix B - Argon2id : RFC 9106 Section 4 - HKDF : RFC 5869 Appendix A
Règles impératives¶
Contraintes absolues¶
- Aucun algorithme obsolète
- Scanner le code pour MD5, SHA1, SHA-256, DES, 3DES, CBC, ECB
-
Bloquer toute utilisation
-
Validation systématique
- Tout algorithme implémenté DOIT avoir ses test vectors validés
-
Résultats documentés dans les tests
-
Rotation des clés
- IV/nonce TOUJOURS unique par opération
-
Salt TOUJOURS aléatoire par utilisateur
-
Longueurs minimales
- Clés symétriques : 256 bits
- Clés asymétriques : 4096 bits
- IV/nonce : selon algo (12 bytes pour GCM)
- Salt : 128 bits minimum
Interdictions strictes¶
- ❌ Inventer un algorithme maison
- ❌ Modifier les paramètres standards
- ❌ Réutiliser des IV/nonce/salt
- ❌ Utiliser Math.random() pour crypto
- ❌ Logger des clés ou données sensibles
- ❌ Transmettre K_master_user au serveur (zero-knowledge)
Vérifications automatiques¶
Commandes de scan¶
# Détecter algorithmes interdits
grep -r "sha256\|sha1\|md5" src/ --exclude-dir=node_modules
grep -r "cbc\|ecb" src/ --exclude-dir=node_modules
grep -r "Math.random" src/ --exclude-dir=node_modules
# Vérifier utilisation correcte
grep -r "sha3_256" src/
grep -r "aes-256-gcm" src/
grep -r "argon2id" src/
Mapping conformité¶
| Standard | Algorithme | Référence | Status |
|---|---|---|---|
| FIPS 202 | SHA3-256 | Hash probatoire | OBLIGATOIRE |
| NIST SP 800-38D | AES-256-GCM | Chiffrement documents | OBLIGATOIRE |
| NIST SP 800-57 | RSA 4096 | Clés asymétriques | OBLIGATOIRE |
| RFC 9106 | Argon2id | Password hashing | OBLIGATOIRE |
| RFC 5869 | HKDF-SHA3-256 | Dérivation clés | OBLIGATOIRE |
| FIPS 140-2 Level 3 | CloudHSM | Opérations critiques | OBLIGATOIRE |
Exemples d'écarts BLOQUANTS¶
Écart : Utilisation de SHA-256 au lieu de SHA3-256¶
// ❌ BLOQUANT - SHA-256 non conforme
import { createHash } from 'crypto';
const hash = createHash('sha256').update(data).digest();
// ✅ CONFORME - SHA3-256
import { sha3_256 } from '@noble/hashes/sha3';
const hash = sha3_256(data);
Gravité : BLOQUANT Raison : Non-conformité FIPS 202, valeur probatoire compromise
Écart : AES-CBC au lieu de AES-GCM¶
// ❌ BLOQUANT - AES-CBC sans authentification
const cipher = createCipheriv('aes-256-cbc', key, iv);
// ✅ CONFORME - AES-GCM avec authentification
const cipher = createCipheriv('aes-256-gcm', key, iv);
Gravité : BLOQUANT Raison : Pas d'authentification, vulnérable à padding oracle
Écart : Paramètres Argon2 insuffisants¶
// ❌ BLOQUANT - Memory cost trop faible
const hash = await argon2.hash(password, {
memoryCost: 4096 // 4 MiB seulement
});
// ✅ CONFORME - 64 MiB minimum
const hash = await argon2.hash(password, {
memoryCost: 65536 // 64 MiB
});
Gravité : BLOQUANT Raison : Insuffisant contre attaques GPU/ASIC
Escalade obligatoire¶
Escalader immédiatement si : - Utilisation d'un algorithme non standard détectée - Impossibilité technique d'utiliser l'algorithme requis - Test vector échoue de manière inexpliquée - Librairie crypto présente une vulnérabilité critique
Références normatives¶
- FIPS 202: SHA-3 Standard (Keccak)
- NIST SP 800-38D: GCM Mode for AES
- NIST SP 800-57: Key Management Recommendations
- RFC 9106: Argon2 Memory-Hard Function
- RFC 5869: HKDF
- RFC 5116: Authenticated Encryption with Associated Data
- FIPS 140-2: Cryptographic Module Validation
Historique¶
| Version | Date | Changement |
|---|---|---|
| 1.0.0 | 2026-01-14 | Création initiale |