I am learning about block ciphers and while I understand the concept of Electronic Codeblock mode and cipher block chaining, I could not find any relevant practical examples online. Can someone provide a short example of a scenario where we convert plain text into cipher text using ecb and cbc (with initialization vector and keys).
A common scenario is browsing this page e.g. TLS Transport Layer Security uses CBC for example AES among others to encrypt the content between Stack exchange servers and your browser.
CBC Pseudocode for Encryption
cbc key IV plainText nBlocks =
cipher[0] = IV
for i = 0 to nBlocks-1
cipher[i+1] = (encrypt key plainText[i]) XOR cipher[i]
cipher
CBC Pseudocode for Decryption
cbc' key cipher nBlocks =
for i = nBlocks-1 downto 1
plainText[i-1] = (decrypt key cipher[i]) XOR cypher[i-1]
plainText
A naive encrypt function is
encrypt key data = data xor key
decrypt key data = data xor key
you could use this functions in something like this:
let a = [1,2,3]
let iv = 81
let key = 365
let cipher = cbc key iv a 3
and if you do
cbc' cipher key 4
you should get back [1,2,3]
-
$\begingroup$ By example I mean a step by step manual example to show how cbc or ecb is performed. It's a practice question sort of thing for exam $\endgroup$ – x89 May 27 '20 at 23:03
-
-
-
-
$\begingroup$ @x89 encrypt key depends from your cypher. AES for example is very complex to describe. A naive encrypt function is xor : encrypt key data = data xor key and decrypt key cipher = data xor key $\endgroup$ – Koenig Lear May 28 '20 at 10:09