Lec 5.pdf
Document Details
Uploaded by BlissfulPluto
Tags
Full Transcript
Cybersecurity Essentials Course Lec. 5 Cryptography Dr. Eman Zahran Cryptography Cryptography is the science of keeping messages secret, or hidden writing Is the study of secret (crypto-) writing (-graphy) people who do cryptograph...
Cybersecurity Essentials Course Lec. 5 Cryptography Dr. Eman Zahran Cryptography Cryptography is the science of keeping messages secret, or hidden writing Is the study of secret (crypto-) writing (-graphy) people who do cryptography are cryptographers Cryptanalysis is the art of breaking ciphers, i.e. retrieving the plaintext without knowing the secret key, and practitioners of cryptanalysis are cryptanalysts Used in secure messaging, authentication, digital signatures, Banking, and other applications Basic terminology Plaintext: original message to be encrypted Ciphertext: the encrypted message Enciphering or encryption: the process of converting plaintext into ciphertext Encryption algorithm: performs encryption – Two inputs: a plaintext and a secret key 3 Basic terminology Cont. Deciphering or decryption: recovering plaintext from ciphertext Decryption algorithm: performs decryption – Two inputs: ciphertext and secret key Secret key: The key is data string independent of the plaintext and of the algorithm used in the encryption and decryption processes. 4 Cryptography Cryptography Cryptographic systems are generically classified along three independent dimensions: 1. The type of operations used for transforming plaintext to ciphertext 2. The way in which the plaintext is processed 3. The number of keys used Cryptography (cont.) 1. The type of operations used for transforming plaintext to ciphertext All encryption algorithms are based on two basic operations: – Substitution: each element in the plaintext (bit, letter, group of bits or letters) is mapped into another element in the ciphertext – Transposition: elements in the plaintext are rearranged here, all operations must be reversible and no information is lost Cryptography (cont.) 2. The way in which the plaintext is processed A block cipher processes the input one block of elements at a time, producing an output block for each input block A stream cipher processes the input elements continuously, producing output one element at a time, like a stream Cryptography (cont.) 3. The number of keys used If both sender and receiver use the same key, the system is referred to as symmetric, single-key, secret-key, or conventional encryption If sender and receiver each uses a different key, the system is referred to as asymmetric, two-key, or public- key encryption Basic Cryptographic Algorithms All modern algorithms use a key to control encryption and decryption; a message can be decrypted only if the key matches the encryption key There are two classes of key-based encryption algorithms, 1- symmetric (or secret-key) algorithms 2- asymmetric (or public-key) algorithms Symmetric key Algorithms Symmetric algorithms use the same key for encryption and decryption Symmetric algorithms can be divided into stream ciphers and block ciphers Stream ciphers encrypt a single bit of plaintext at a time Block ciphers take a number of bits and encrypt them as a single unit Encrypt data one block at a time (typically 64 bits, or 128 bits) Asymmetric Algorithms Asymmetric algorithms use different keys for encryption and decryption (also called public-key algorithms) permit the encryption key to be public allowing anyone to encrypt with the key, whereas only the proper recipient (who knows the decryption key) can decrypt the message – The encryption key is also called the public key and the decryption key the private key or secret key Classical Encryption Techniques The two basic building blocks of all encryption techniques: Substitution Each element in the plaintext (bit, letter, group of bits or letters) is mapped into another element in the ciphertext The earliest known use of a Caesar cipher, and the simplest, was by Julius Caesar Transposition Elements in the plaintext are rearranged by performing some sort of permutation on the plaintext letters The simplest such cipher is the rail fence technique Classic Techniques (cont.) Systems, referred to as product systems, involve multiple stages of substitutions and transpositions These techniques may be: – Monoalphabetic - only one substitution / transposition is used, or – Polyalphabetic - where several substitutions / transpositions are used Substitution Ciphers Simple substitution cipher: a = p, b = m, c = f,... Polyalphabetic substitution cipher a = p, b = m, c = f,... a = l, b = t, c = a,... a = f, b = x, c = p,... Caesar Cipher Each letter of the alphabet is replaced with the letter standing three places further down the alphabet (letter = letter + 3) and the alphabet is wrapped around, so that the letter following Z is A – Plain alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ – Cipher alphabet: DEFGHIJKLMNOPQRSTUVWXYZABC Example: – plaintext: I CAME I SAW I CONQUERED – Ciphertext: L FDPH L VDZ L FRQTXHUHG Caesar cipher Encrypt the following message using Caeser Cipher then decrypt it Attack at Dawn meet me after the party Caesar cipher Encryption Plain Text Cipher Text Cipher: Message: Caesar Cipher Message: Attack at Dawn Algorithm Dwwdfn Dw GdZq Key (3) Decryption Cipher Text Plain Text Cipher: Message: Caesar Cipher Message: Dwwdfn Dw GdZq Algorithm Attack at Dawn Key (3) Caesar cipher Plaintext: meet me after the party Ciphertext: PHHW PH DIWHU WKH SDUWB Mixed Monoalphabetic Substitution Cipher Any letter can be substituted for any other letter Shuffle the letters arbitrarily each plaintext letter maps to a different random ciphertext letter or even to 26 arbitrary symbols. Hence, key is 26 letters long This is known as a Mixed Monoalphabetic substitution e.g., – Plain: ABCDEFGHIJKLMNOPQRSTUVWXYZ – Cipher: DKVQFIBJWPESCXHTMYAUOLRGZN – For example: Plaintext: IFWEWISHTOREPLACELETTERS Ciphertext: WIRFRWAJUHYFTSDVFSFUUFYA General Monoalphabetic Cipher e.g., given the keyword “STARWARS” Remove repeated letters to get “STARW” S T A R W Write out and fill in remaining letters as follows: B C D E F STARW BCDEF GHIJK LMNOP QUVXY Z G H I J K Then read off by columns to get the translation alphabet L M N O P Plaintext: ABCDEFGHIJKLMNOPQRSTUVWXYZ Q U V X Y Ciphertext: SBGLQZTCHMUADINVREJOXWFKPY Z Can then use this to encrypt/decrypt, e.g. Plaintext: I KNOW ONLY THAT I KNOW NOTHING Ciphertext: H UINF NIAP OCSO H UINF INOCHIT Polyalphabetic Substitution Ciphers To improve security of the simple monoalphabetic technique use many monoalphabetic substitution alphabets where each letter can be replaced by many others (this is called polyalphabetic) Use a key to select which alphabet is used for each letter of the message (ith letter of key specifies ith alphabet to use) Use each alphabet in turn and repeat from start after end of key is reached Blaise de Vigenère is generally credited as the inventor of the “polyalphabetic substitution cipher” Vigenère Cipher To use Vigenère scheme, first write the plaintext and under it write the keyword repeated Using each key letter in turn as a Caesar Cipher key, encrypt the corresponding plaintext letter (encryption and decryption follow the same process) e.g., using the keyword ‘CIPHER’ as a key: – Plaintext: THISPROCESSCANALSOBEEXPRESSED – Keyword: CIPHERCIPHERCIPHERCIPHERCIPHE – Ciphertext: VPXZTIQKTZWTCVPSWFDMTETIGAHLH Vigenère: Example Plaintext: THISPROCESSCANALSOBEEXPRESSED Using the keyword “CIPHER”, we have the following translation alphabets: ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ – C CDEFGHIJKLMNOPQRSTUVWXYZAB – I IJKLMNOPQRSTUVWXYZABCDEFGH – P PQRSTUVWXYZABCDEFGHIJKLMNO – H HIJKLMNOPQRSTUVWXYZABCDEFG – E EFGHIJKLMNOPQRSTUVWXYZABCD – R RSTUVWXYZABCDEFGHIJKLMNOPQ Vigenère: Example (cont.) Hence, map the plaintext message as follows: – ‘T’ uses key ‘C’ maps to ‘V’ – ‘H’ uses key ‘I’ maps to ‘P’ – ‘I’ uses key ‘P’ maps to ‘X’ etc. – Ciphertext: VPXZTIQKTZWTCVPSWFDMTETIGAHLH Transposition Ciphers The plaintext remains the same, but the order of characters is shuffled around (e.g., shuffle secret to etcrse) Transposition is not a permutation of alphabet characters but a permutation of places – Letters remain their identity but lose their position – There is a permutation of the plaintext letters Rail Fence Simplest form of the transposition techniques Plaintext is written down as a sequence of diagonals and then read off as a sequence of rows to give the ciphertext e.g., Plaintext: MERCHANT TAYLORS’ SCHOOLANT TAYLORS’ SCHOOL Ciphertext: MRHNTYOSCOLECATALRSHO Complexity of Transposition Cipher Involves no additional work beyond arranging the letters and reading off again The time for the algorithm is proportional to the length of the message The algorithm requires space for all characters of the message and therefore it depends directly on the length of the message Due to storage and delay, this algorithm is not appropriate for long messages Thank You