Cryptographic Chaining Mode

来源:互联网 发布:梅林 访客网络设置 编辑:程序博客网 时间:2024/06/08 02:39

Cipher Chaining

ECB(electronic codebook) mode

  • Same plain text produce the same cipher text
  • No error propagation
  • Residue is NO_HANDLE

ecb_plain
ecb_cipher

plain text –CW encrypt–> cipher text
cipher text –CW decrypt–> plain text

ecb_disadvantage

CBC(cipher block chaining) mode

  • Same plain text produce the different cipher text
  • Error propagation to next block
  • Need initialization vector

xor

if A ^ B = Cthen C ^ A = B, C ^ B = A

cbc_plain
cbc_cipher

p(n) xor iv/p(n-1) –CW encrypt–> c(n)
c(n) –CW decrypt–> xor iv/c(n-1) –> p(n)

Residue mode

ANSI(American National Standard Institute) SCTE(Society of Cable Telecommunications Engineers) 52

ansi_scte_52

c(n-1) –>CW encrypt–> c’(n) –> xor short p(n) –> short c(n)
c(n-1) –>CW encrypt–> c’(n) –> xor short c(n) –> short p(n)

CTS(cipher text stealing)

cts_plain
cts_cipher

encrypt:

Remain = sizeof(short p(n))
p’(n) = short p(n) + 0[Remain, Block_Len]
c(n) = c(x)[1, Remain]

p(n-1) xor c(n-2) –CW encrypt–> c(x) –> c(n)
p(n) –> p’(n) –> xor c(x) –> p(x) –CW encrypt–> c(n-1)

decrypt:

c(x) = short c(n) + p(x)[Remain+1, Block_Len]
p(n) = p’(n)[1, Remain]

c(n-1) –CW decrypt–> p(x) –> xor c(x) –> p’(n) –> short p(n)
c(x) –CW decrypt–> xor c(n-2) –> p(n-1)

CFB(cipher feedback) mode

  • Same plain text produce the different cipher text.
  • Need iv.
  • Error propagation to next block.
  • Residue is NO_HANDLE.

cfb

iv/c’(n-1) –CW encrypt–> c’(n) –> xor p(n) –> c(n)
iv/c’(n-1) –CW encrypt–> c’(n) –> xor c(n) –> p(n)

OFB(output feedback) mode

  • Same plain text produce the different cipher text.
  • Need iv.
  • No error propagation.
  • Residue is NO_HANDLE.
  • One error bit of cipher text only cause one error bit of plain text.

ofb

iv/c’(n-1) –CW encrypt–> c’(n) –> xor p(n) –> c(n)
iv/c’(n-1) –CW encrypt–> c’(n) –> xor c(n) –> p(n)

CTR(counter) mode

  • Same plain text produce the different cipher text.
  • Need initialization counter.
  • No error propagation.
  • Residue is NO_HANDLE, but it’s cipher text.
  • One error bit of cipher text only cause one error bit of plain text.

ctr

iv(n-1) – counter –> iv(n)
iv(n) –CW encrypt–> xor p(n) –> c(n)
iv(n) –CW encrypt–> xor c(n) –> p(n)

Reference:
https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation