Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> Lập Trình

Khác biệt giữa Confusion (Gây nhiễu loạn) và Diffusion (Khuếc tán)

Hai nguyên tắc cốt lõi của thiết kế mật mã theo Claude Shannon (1949): Confusion và Diffusion. Cần cả hai mới đạt an toàn.

Confusion (Gây nhiễu loạn)

Mục tiêu: Làm cho mối quan hệ giữa Khóa (Key) và Ciphertext phức tạp, không thể suy diễn.

  • Mỗi bit ciphertext phụ thuộc phức tạp vào nhiều bit khóa.
  • Thay đổi 1 bit khóa → nhiều bit ciphertext thay đổi (avalanche wrt key).
  • Đạt được bằng: Substitution phi tuyến (S-box), modular addition, ARX operations.
  • Che giấu: Key pattern, key schedule structure.

Diffusion (Khuếc tán)

Mục tiêu: Lan tỏa thông tin thống kê của Plaintext ra Ciphertext.

  • Mỗi bit ciphertext phụ thuộc vào nhiều bit plaintext.
  • Thay đổi 1 bit plaintext → ~nửa bit ciphertext thay đổi (avalanche effect).
  • Đạt được bằng: Permutation (P-box), Linear mixing (MDS matrix), Feistel swap, ARX rotation.
  • Che giấu: Plaintext pattern, redundancy, statistical structure.

Bảng so sánh chi tiết

Tiêu chíConfusion (Gây nhiễu loạn)Diffusion (Khuếc tán)
Mối quan hệ che giấu
Key ↔ CiphertextPlaintext ↔ Ciphertext
Thay đổi 1 bit1 bit Key → nhiều bit Ciphertext thay đổi1 bit Plaintext → nhiều bit Ciphertext thay đổi
Kỹ thuật chínhSubstitution (S-box), Non-linear transformPermutation (P-box), Linear mixing (MDS), Rotation
Kết quả thống kêTăng vagueness (sự mơ hồ) của ciphertext về keyTăng redundancy dissipation (sự tan rã thừa) của plaintext
Ví dụ AESSubBytes (S-box x⁻¹+affine)ShiftRows + MixColumns (MDS branch=5)
Ví dụ DES8 S-boxes (6→4 bit)Expansion E, Permutation P, Feistel swap
Ví dụ ChaCha20ARX: Add (mod 2³²) — non-linear wrt XORARX: Rotate + XOR — lan tỏa bit giữa word

Mối quan hệ: Substitution-Permutation Network (SPN)

Kiến trúc SPN (AES, PRESENT, SKINNY) kết hợp tự nhiên:

Round:
  SubBytes (S-box)     → CONFUSION
  ShiftRows (perm)     → DIFFUSION (byte level)
  MixColumns (MDS)     → DIFFUSION (column level, full diffusion sau 2 vòng)
  AddRoundKey          → KEY MIXING (cũng góp phần confusion)

Feistel Network (DES, Camellia, SM4)

  • F-function cung cấp Confusion (S-box + key mixing).
  • Swap nửa khối cung cấp Diffusion (lan tỏa giữa 2 nửa).
  • Cần nhiều vòng hơn SPN để đạt full diffusion (DES 16 vòng vs AES 10 vòng).

ARX Ciphers (ChaCha20, BLAKE2, Speck)

Không tách biệt S-box/P-box. Cả confusion và diffusion đạt bằng:

  • Addition mod 2ⁿ: Non-linear wrt XOR (carry propagation) → Confusion.
  • Rotation: Di chuyển bit vị trí → Diffusion.
  • XOR: Linear mixing.
  • Quarter round (ChaCha20): a+=b; d^=a; d≫16; c+=d; b^=c; b≫12; a+=b; d^=a; d≫8; c+=d; b^=c; b≫7 — lặp 20 lần.

Kiểm tra Diffusion/Confusion (Testing)

  • Avalanche Test: Flip 1 bit input/key → measure % output bit flip (target ~50%).
  • SAC (Strict Avalanche Criterion): Mỗi bit output flip prob = ½ khi flip 1 bit input.
  • BIC (Bit Independence Criterion): Output bit changes independent.
  • Linear Approximation Table (LAT) / Differential Distribution Table (DDT): Đánh giá S-box/ARX component.

Kết luận: Confusion che giấu Key, Diffusion che giấu Plaintext. Cipher an toàn = Confusion mạnh + Diffusion mạnh + Key Schedule tốt + Số vòng đủ margin. AES = SPN gold standard; ChaCha20 = ARX gold standard.