78 lines
1.9 KiB
Markdown
78 lines
1.9 KiB
Markdown
# Block Ciphers
|
|
|
|
The main concept here is twofold:
|
|
|
|
* we take _blocks_ of data and cipher the _blocks_
|
|
* A given key is actually used to generate recursive keys to be further used on the data itself
|
|
|
|
|
|
_bs example ahead_
|
|
|
|
Say we have a key 7 and some data 123456.
|
|
We take the whole data set and chunk it into blocks(for example): 12 34 56.
|
|
|
|
Let's say our function here is to just add 7 to each block so we do the first step:
|
|
|
|
```
|
|
12 + 7 = 19
|
|
Unlike other ciphers we don't reuse 7; instead we use the new thing as both the new key and part of our cipher text
|
|
|
|
19 + 34 = 53
|
|
Cipher: 1953..
|
|
|
|
53 + 56 = 109 <= let's pretend that this rolls over 99 and back to 00
|
|
09 <= like this
|
|
|
|
Final cipher: 195309
|
|
```
|
|
|
|
_It should be noted that in practice these functions usually take in huge keys and blocks_.
|
|
|
|
> Deciphering
|
|
|
|
Start from the back of the cipher not the front; if we used and xor function scheme (which is a symmetrical function) we would simply just xor the last block by itself and thus perform the same encryption scheme but in reverse.
|
|
|
|
Example::Encryption
|
|
|
|
```
|
|
Key: 110
|
|
Function scheme: xor
|
|
Data: 101 001 111
|
|
|
|
101 011 010
|
|
110 001 111
|
|
|
|
011 010 101 <= encrypted
|
|
|
|
```
|
|
|
|
Example::Decryption
|
|
|
|
```
|
|
Ciphered: 011 010 101
|
|
Function scheme: xor
|
|
|
|
...
|
|
```
|
|
|
|
# Feistal Cipher
|
|
|
|
Two main components:
|
|
|
|
1. each _thing_ in the data to cipher is replaced by a _ciphered thing_
|
|
|
|
2. nothing is added or deleted or replaced in sequence, instead the order of _things_ is changed.
|
|
|
|
Basically imagine that every _type of thing_ in our data maps to some other _type of thing/thing_ in the data and thus become swapped/reordered.
|
|
|
|
# DES - Data Encryption Standard
|
|
|
|
Widely used until about 2001 when AES surpassed it as the newer(ish(kinda)) standard.
|
|
|
|
DEA was the actual algorithm tho:
|
|
|
|
* 64 bit blocks
|
|
* 56 bit keys
|
|
* turns a 64-bit input into a 64-bit output (wew)
|
|
* Steps in reverse also reverse the encryption itself
|