Caesar Cipher

Simple algorithm which could easily be decrypted if you know the key Its done by shifting each letter by key amount of letters

Modulo could be used to avoid making a table. So 8 mod 5 = 3

Generalized Formula encoding: (plain letter index + key) mod (total number of letters)

for English TNOL is 26

Generalized Formula decoding: (cipher letter idnex - key) mod (total number of letters)

Problem with Caesar Cipher

  • Too easy to break
  • could be easily decoded if you used a table and make a list of all possible keys

Photo Encryption - Colors

because colors are represented by a vector3(RGB) we can easily shift our colors

Color adding isn’t the same as real life so a mix of yellow and blue does not give out green but another shade

we would only just need to shift them if we go past the 255 mark(just like [Carsar Cipher](#Carsar Cipher))

Decoding

we’d just subtract the color we added.

Cryptography

Study & practice of hiding information

Both encryption methods we talked about have 1 flaw, they are too weak for the real-world

There are many more methods of cryptography that are much more foolproof

Usually the way Cryptography works is by a shared Secret key between both sender and recipient.

Where Y = E[K,X] Y is ciphertext E is the Encryption function K is the key X is the Text

and for Decryption Where X = D[K,Y] X is the text D is the Decryption K is the key Y is the CipherText


Attacking Symmetric Encryption

  • Cryptanalysis
    • Rely on nature of algo
    • some knowledge of plaintext characteristics
    • sample plaintext-ciphertext pairs
    • Exploits characteristics of algorithm to deduce specific plaintext or key
  • Brute-force attack
    • Try all possible keys

Diff of each attack

  • Ciphertext only - Least info, hardest
  • known plaintext - some plain/cipher pairs
  • chosen plaintext - get own plain/cipher pairs

DES data encryption standard and its feistel cipher

How is the Block Cipher Structure

  • Have general iterative block cipher structure
    • sequence of rounds
    • substitutions / permutations controlled by key
  • Parameters
    • block size
    • key size
    • number of rounds
    • subkey generation algo
    • round function
    • fast software en/decrypt

Ciphers has two sides

  • block ciphers
    • DES
    • 3DES
    • AES(best)
  • Stream Cipher
    • mobile communication
    • GSM
    • RC4

Triple DES(3DES) No longer used as computers have gotten strong

Advanced Encryption Standard(AES)

  • Came in 1997
  • size of the key is what made it strong
  • bit shifting

Modes of Operation

Block ciphers process data in blocks

Longer messages must break up

5 Modes but we focus on 2

  • [Electronic Code Book(ECB) mode](#Electronic Codebook)
  • Cipher Block chaining (CBC) mode

Electronic Codebook

  • Simplest
  • split plaintext into blocks
  • encrypt each block using the same key

Block ciphers are divided into to two things

  • Symmetric
    • DES
    • 3DES
    • AES
  • Asymmetric
    • RSA + Defihelman

Hash functions

Requirements
  • Applied to any size data
  • H produces a fixed-length output
  • H(x) is relatively easy to compute for any given x
  • one-way property
  • weak collision resistance
  • strong collision resistance

Hash functions have 2 ways of getting attacked

  • Cryptoanalysis
  • Brute-force attack

SHA most widely used hash algorithm

  • SHA-1 gives 160 bit hash
  • more recent SHA-256, SHA-384, SHA-512

Public key encryption

When it comes to this its nearly the same as Cryptography but rather than having both private key, a public key is shared. From the sender to receiver

So if the sender sent a msg the public key will encrypt it, and when it reaches the receiver their private key will decrypt it. This falls under the Confidentiality triad

Same concept but in reverse and it would fall under the Authentication triad

What are Public Key Requirements

  • Easy to create
  • easy for sender knowing public key to encrypt messages
  • easy for receiver knowing private key to decrypt ciphertext
  • infeasible for opponent to determine private key from public key
  • infeasible for opponent to otherwise recover original message
  • useful if either key can be used for each role

Common Public Key Algorithms

  • RSA
  • Diffie-hellman
  • Digital Signature Standard (DSS)
  • Elliptic curve cryptography (ECC)