Shift Cipher

미노·2025년 6월 12일

Computer Network

목록 보기
20/23

Crypto-system consists of five tuples

  • (P, C, K, E, D) :
    • P : Plain text
    • C : Cipher text
    • K : Key
    • E : Encryption Algorithm
    • D : Decryption Algorithm

Shift cipher

  • 문자를 K만큼 Shifting
  • 공격자 입장에서 역추적 하기 쉬움
  • P = C = K = Z(26) : Alphabet
for 0 <= k <= 25
y = ek(x) = (x+k) mod 26 ....... modulo
x = dk(y) = (y-k) mod 26 ....... modulo 

Substitution cipher

  • Shifting 하지말고 Shuffle, 임의의 문자로 1:1 mapping
  • P = C = Z(26) : Alphabet
  • K consists of all possible permutation of the 26 symbols (0 ≤ k ≤ 25)4

Affine cipher

  • Alphabet에 mapping 시켜놓은 숫자를 다른 숫자로 수정하여 modular 연산을 진행
P=C=Z26K={(a,b)Z26Z26, gcd(a,26)=1}ek(x)=(ax+b)mod26=ydk(x)=a1mod26=xwhere aa1mod26=1P = C = Z_{26} \\ K = \{(a,b) \in Z_{26} * Z_{26}, \ gcd(a, 26) = 1\} \\e_k(x) = (ax + b) \bmod 26 = y \\d_k(x) = a^{-1}\bmod26 = x \\ where \ a * a^{-1} \bmod 26 = 1
  • 예) K={a,b}={(3,1)}K = \{a, b\} = \{(3, 1)\}일 때,
    • Plain text = SIMPLE → 18 3 12 15 11 4 →
    • Cipher text = DZLUIN → 3 25 11 20 8 13 → 1. +25 → 2. (x 9) → 3. mod 26
    • Plain text = → 28, 50, 36, 45, 33, 38 → 252, 450, 324, 405, 297, 342 → 18, 3, 12, 15, 11, 4 → SIMPLE
  • Decryption 함수 공식화
y3x+1mod26:congruencey+253x+1+25mod263xmod269(y+25)93xmod269(y+25)=x mod26x=9(y+25)mod26x=9y+225mod26x=9y+17mod26Kd=(9,17)y \equiv 3x + 1 \bmod 26 : congruence \\ y + 25 \equiv 3x + 1 + 25 \bmod 26 \\ \equiv 3 x \bmod 26 \\ 9(y+25) \equiv 9\cdot3x\bmod 26 \\ 9(y+25) = x \ \bmod 26 \\ \to x = 9(y+25) \bmod 26 \\ x = 9y + 225 \bmod 26 \\ x = 9y + 17 \bmod 26 \to K_d = (9, 17)
  • 예) (5x+8)mod26(5x + 8) \bmod 26
y5x+8mod26y+185x+8+18mod265xmod2621(y+18)215xmod2621(y+18)xmod26x21(y+18)mod26x21y+14mod26y \equiv 5x + 8 \bmod 26 \\ y + 18 \equiv 5x + 8 + 18 \bmod 26 \\ \equiv 5x mod 26 \\ 21(y+18) \equiv 21 \cdot 5x \bmod 26 \\ 21(y+18) \equiv x \bmod 26 \\ x \equiv 21(y+18) \bmod 26 \\ x \equiv 21y + 14 \bmod 26

0개의 댓글