CITS1003 2 Cryptography
CITS1003 2 Cryptography
Cybersecurity
[3] Cryptography
Dr David Glance
A unit about cats
cybersecurity
https://www.cryptokitties.co/
An example of a Non-Fungible
Token
Each digital CryptoKitty is owned
by a user validated on the Ethereum
blockchain
3 things
Understand how cryptography is a
control for confidentiality and integrity
Achieving encryption through
confusion and diffusion
Managing keys for symmetric and
asymmetric cryptography
Some History
Plaintext: THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
Ciphertext: QEB NRFZH YOLTK CLU GRJMP LSBO QEB IXWV ALD
Plaintext H A C K I N G I S F U N
Code 7 0 2 10 8 13 6 8 18 5 20 13
Key C A T S C A T S C A T S
Shift 2 0 19 18 2 0 19 18 2 0 19 18
Ciphertext J A V C K N Z A U F N F
Vigenère Table
Basically a series of Caesar
ciphers
To use, find the letter of the
plaintext along the top row and
the corresponding letter of the
key on the side column and take
the letter that intersects
Breaking Vigenère
Because there are multiple possible ciphertext letters for each plaintext letter, frequency
analysis is not possible
Friedrich Kasiski (1863) developed an attack strategy:
Find repeated use of the same key to estimate the key length
Plaintext: CRYPTOISSHORTFORCRYPTOGRAPHY
Key: ABCDABCDABCDABCDABCDABCDABCD
Ciphertext: CSASTPKVSIQUTGQUCSASTPIUAQJB
The repetitions are 16 characters apart and so the key length is 16,8,4,2 or 1
Once you have the key length, then look at frequency analysis of the individual Caesar ciphers
Other attack strategies: Friedman’s (kappa) test, Kerchoff’s method
One-Time Pads
Longer “shift words” and shorter messages make frequency analysis more difficult and making it
harder it is to crack a message
A one-time pad is a list of random shifts; selected shift sequence must be longer than your message
This is uncrackable , because of 2 important properties
Shifts will never fall into a pattern (because pad is longer than message)
Frequency distribution is uniform (because shifts are random)
One-Time Pads are known as being “Perfectly Secure” as defined by Claude Shannon in 1949
(Shannon, C. (1949) Communication Theory of Secrecy Systems. Bell System Technical Journal 28)
https://netlab.cs.ucla.edu/wiki/files/shannon1949.pdf
Principle is that if the key is perfectly random, the potential number of encrypted messages is the same as
the number of potential keys and the number of messages
However, pseudo-random keys will result in a repeating pattern of keys and so a smaller subset of
encrypted messages
One-Time Pads
Practical limitations
You need to have a large number of random keys
You need to distribute these keys to the senders and receivers
You need to protect them from discovery
Key distribution and protection a general problem even with modern systems
Public Key Infrastructure (PKI) as we will see later
The Enigma Machine
Invented by the German army at the end of WW1 and further developed
during WW2
Consists of a plug board that switches letters AF, GK, LM and a set of
3 (or more) rotors chosen from a larger set) with 26 positions on each rotor.
Start by sharing
Plug board settings
Set of rotors
Ring settings
Initial position
Each time a character is typed, the rotor turns and the characters on each
rotor are added together to form the substitution
Check out emulator https://www.101computing.net/enigma-machine-
emulator/
Transposition
In transposition, we change the order of characters in the ciphertext without making substitution
One method:
Take the message “nowrunalonganddontgetintomischiefimgoingout”
We pad it with 4 xxxx and arrange as a grid:
nowrunalonga
nddontgetint
omischiefiam
goingoutxxxx
p k c p k c p k c
1 1 1 1 1 1 1 1 0
1 0 0 1 0 1 1 0 1
0 1 0 0 1 1 0 1 1
0 0 0 0 0 0 0 0 0
Computers and Ciphers
To encrypt the letter ‘a’ with the letter ‘t’ we could do an ‘AND’, ‘OR’ or ‘XOR’
operation
1100001 AND 1110100 = 1100000 (hex 60 or “`”)
1100001 OR 1110100 = 1110101 (hex 75 or “u”)
1100001 XOR 1110100 = 0010101 (hex 15 or non-printable character)
Why we use XOR
Using a one-time pad to encrypt on a computer is best done using an XOR operation.
To see why: take an image which is represented by bits. Take a string of random bits
and do an AND, OR and XOR
Original AND OR XOR
p k c p k c p k c
1 1 1 1 1 1 1 1 0
1 0 0 1 0 1 1 0 1
0 1 0 0 1 1 0 1 1
0 0 0 0 0 0 0 0 0
Cryptography Today
Two types of encryption used:
Symmetric key cryptography: Both parties share the same single key
Asymmetric key cryptography: Each party has 2 keys: public key and private key
Both types or encryption are used for different purposes and have different benefits
and drawbacks
In addition to the above, there are other cryptographic functions that do not require a
key e.g. Hash functions
Symmetric Key Cryptography
Modern (digital) ciphers arose with the need for encryption in digital systems
Of two types: Block and Stream which differ in how the plaintext is handled
Block ciphers take chunks of the plaintext and manipulates them to encrypt
Stream ciphers encrypts data as a stream of bytes
Data Encryption Standard (DES) becomes first US national standard algorithm in 1976
Invented by IBM and originally called Lucifer which was based on Feistel cipher
Mired in some controversy because of the involvement of the US National Security
Agency (NSA) in the design and decision about the key length
DES
Block length is 64 bits
Key length is 56 bits (64 bits with 8 bits as parity)
The process for encryption involves:
Key schedule
Subkeys are generated from the key for 16 rounds of application to the plaintext
Permutations (diffusion) by initial expansion through duplication and mixing outputs at the end of
each round
Substitutions: using S-boxes which are lookup tables that take 6 input bits and output 4 output
bits
Not overly important to know the details
DES (and other block ciphers) Modes
The previous description details how a single block of plaintext is encrypted but what about a
sequence of blocks?
Some take an Initialisation Vector (IV) which is a
Different modes of encrypting a sequence of blocks:
ECB (Electronic Codebook): Each block is encrypted independently
CBC (Cipher Block Chaining) Each encrypted block is XOR’d with the next block. Start with the IV
CFB (Cipher Feedback) Same mechanism as CBC but operates as a stream of real time data
OFB (Output Feedback) Same as CFB but uses the IV and encrypted versions of the IV as input to
successive blocks
CTR (Counter) Same as OFB but uses a simple counter to alter seed input to each encryption
ECB Mode
ECB (Electronic Codebook):
Each block is encrypted
independently
CBC Mode
CBC (Cipher Block
Chaining) Each encrypted
block is XOR’d with the next
block. Start with the IV
CFB Mode
CFB (Cipher Feedback)
Same mechanism as CBC
but operates as a stream of
real time data
OFB Mode
OFB (Output Feedback)
Same as CFB but uses the IV
and encrypted versions of the
IV as input to successive
blocks
CTR Mode
CTR (Counter) Same as
OFB but uses a simple
counter to alter seed input to
each encryption
Pros and Cons of Modes
ECB leaks information ECB Tux Penguin. This is because the same plaintext block
will generate the same ciphertext
Encryption Decryption
Encryption Decryption