Cryptography
Total Page:16
File Type:pdf, Size:1020Kb
Pattern Recognition and Applications Lab CRYPTOGRAPHY Giorgio Giacinto [email protected] University of Cagliari, Italy Spring Semester 2019-2020 Department of Electrical and Electronic Engineering Cryptography and Security • Used to hide the content of a message • Goals – Confidentiality – Authenticity – Integrity • The text is modified by an encryption function – An interceptor should not be able to understand all or part of the message content http://pralab.diee.unica.it 2 Encryption/Decryption Process Key Key (Optional) (Optional) Original Plaintext Encryption Ciphertext Decryption Plaintext http://pralab.diee.unica.it 3 Keys and Locks http://pralab.diee.unica.it 4 Keys L F A Y B D E T C A R C S E E T Y H G S O U S U D H R D F C E I D B T E M E P Q X N R C I D S F T U A E T C A U R M F N P E C J N A C R D B E M K C I O P F B E W U X I Y M C R E P F N O G I D C N T M http://pralab.diee.unica.it 5 Keys L F A Y B D E T C A R C S E E T Y H G S O U S U D H R D F C E I D B T E M E P Q X N R C I D S F T U A E T C A U R M F N P E C J N A C R D B E M K C I O P F B E W U X I Y M C R E P F N O G I D C N T M http://pralab.diee.unica.it 6 Steganography - = http://pralab.diee.unica.it https://towardsdatascience.com/steganography-hiding-an-image-inside-another-77ca66b2acb1 7 Definitions • Cryptography algorithm C = E(K,M) A function E with two inputs – a message M – a key K that outputs – the encrypted message C The algorithm is based on a shared secret between the sender and the receiver K The Encryption Key http://pralab.diee.unica.it 8 Symmetric and Asymmetric Cryptography • Symmetric cryptography – The algorithm relies on one key the key is the shared secret between the sender and the receiver • Asymmetric cryptography – The algorithm relies on two keys one key is secret, not shared with anyone – the private key the other key is public – anyone can have it http://pralab.diee.unica.it 9 Cryptosystems Key Original Plaintext Encryption Ciphertext Decryption Plaintext (a) Symmetric Cryptosystem Rivest-Shamir-Adelman Encryption Decryption Key Key Original Plaintext Encryption Ciphertext Decryption Plaintext (b) Asymmetric Cryptosystem http://pralab.diee.unica.it 10 Cryptographic primitives • Substitution – Each character of the plain text is substituted by another character according to some rule – This technique aims at the confusion of the message content in the ciphertext • Transposition – The message is subdivided into parts, and their position is modified according to some rule – This technique aims at the diffusion of the message content in the ciphertext http://pralab.diee.unica.it 11 Stream and Block ciphers Key Stream Ciphers (Optional) each byte is encrypted separately …ISSOPMI wdhuw… Plaintext Encryption Ciphertext Key Block Ciphers • Speed of transformation (Optional) .. XN OI TP ES a group of symbols • Low error propagation is encrypted • Low diffusion as a single block • Susceptibility to malicious insertions and modifications Plaintext IH Ciphertext Encryption • Slowness of encryption • Padding • Error propagation po ba • High diffusion qc http://pralab.diee.unica.it • Immunity to insertion of symbols kd 12 em .. Substitution Ciphers http://pralab.diee.unica.it The Imitation Game (2014) http://pralab.diee.unica.it 14 Caesar Cipher • Each character in the plaintext is substituted by the character 3 positions ahead ci = E(pi) = pi + 3 for example computer security becomes frpsxwhu vhfxulwb http://pralab.diee.unica.it 15 Other substitutions • A word is selected as a key to set the substitution of the first letters of the alphabet (e.g., chiefly). ABCDEFGHIJKLMNOPQRSTUVWXYZ CHIEFLYABDGJKLMNOPQRSTUWXZ • Substitution by using as a key a permutation of the alphabet one letter in 3, mod 26 ABCDEFGHIJKLMNOPQRSTUVWXYZ ADGJMPSVYBEHKNQTWZCFILORUX http://pralab.diee.unica.it 16 Other substitutions • OTP (One Time Pad) – a pad of sheets of papers with one-time keys – the encryption of a message of N characters in length will need as many keys as to cover all the N characters – the sender will encrypt the message according to some substitution rule involving each character of the message and the corresponding character of the key • for example, the Vigenère table http://pralab.diee.unica.it 17 Transpositions http://pralab.diee.unica.it Column-based Transpositions • We can convert this text THIS IS A SAMPLE MESSAGE into a five-columns sequence of characters T H I S I S A S A M P L E M E S S A G E The resulting encrypted messages is TSPS HALS ISEA SAMG IMEE http://pralab.diee.unica.it 19 A useful tool for encoding and encryption https://cryptii.com http://pralab.diee.unica.it 20 “Secure” encryption algorithms http://pralab.diee.unica.it Shannon and the definition of “good” ciphers Communication Theory of Secrecy Systems (1949) 1. The amount of secrecy needed should determine the amount of labor appropriate for the encryption and decryption 2. The set of keys and the enciphering algorithm should be free from complexity 3. The implementation of the process should be as simple as possible 4. Errors in ciphering should not propagate and cause corruption of further information in the message 5. The size of the enciphered text should be no larger than the text of the original message http://pralab.diee.unica.it 22 Cryptanalysis • Goal: break an encryption – break (decrypt) a single message – recognize patterns in encrypted messages – infer some meaning without even breaking the encryption, such as from the frequency of messages – easily deduce the key to break one message and perhaps subsequent ones – find weaknesses in the implementation or environment of use of encryption by the sender – find general weaknesses in an encryption algorithm An algorithm is called breakable when given enough time and data an analyst can determine the algorithm http://pralab.diee.unica.it 23 Inputs to cryptanalysis • Ciphertext Only – Look for patterns, similarities, and discontinuities among many messages that are encrypted alike • Plaintext and Ciphertext pair – Full or Partial Plaintext • known-plaintext or probable-plaintext – Ciphertext of Any Plaintext • chosen-plaintext http://pralab.diee.unica.it 24 Breaking Enigma The Imitation Game (2014) http://pralab.diee.unica.it https://www.youtube.com/watch?v=_C25CwNlVjA 25 Trustworthy cryptosystems • Based on sound mathematical foundations • Analyzed by competent experts and found to be sound • Stood the “test of time” http://pralab.diee.unica.it 26 Symmetric Encryption Algorithms http://pralab.diee.unica.it Symmetric Encryption Secret key shared by Secret key shared by sender and recipient sender and recipient K K Transmitted X ciphertext Y = E[K, X] X = D[K, Y] Plaintext Plaintext Encryption algorithm Decryption algorithm input output (e.g., DES) (reverse of encryption algorithm) Figure 2.1 Simplified Model of Symmetric Encryption http://pralab.diee.unica.it 28 Standard and Commercial algorithms • Block ciphers – DES (Data Encryption Standard) – 3DES (Triple DES) – AES (Advanced Encryption Standard) – Blowfish (1993, Bruce Schneier) • Stream ciphers – RC4 (1987, Ron Rivest) http://pralab.diee.unica.it 29 DES • In 1972 the U.S. National Bureau of Standards (NBS, nowadays NIST) called for proposals for producing a public encryption algorithm. • In the second call, in 1974, the most promising proposal was IBM’s Lucifer. IBM developed for NBS the Data Encryption Standard (DES) based on Lucifer. • DES was officially adopted as a U.S. federal standard in November 1977. DES was later accepted as an international standard by ISO. http://pralab.diee.unica.it 30 The complete DES Input Initial Permutation L0 R0 Key Shifted 64-bit blocks Substitution Key Permuted Permutation 64-bit key Cycle 1 L1 = R 0 R1 Key Shifted Substitution Key Permuted Permutation Cycle 2 L2 = R 1 R2 . L15 = R 14 R15 Key Shifted Substitution Key Permuted Permutation Cycle 16 L16 = R 15 R16 Inverse Initial Permutation Output The algorithm at work http://pralab.diee.unica.it http://page.math.tu-berlin.de/~kant/teaching/hess/krypto-ws2006/des.htm 31 A cycle in DES Left Data Half Right Data Half Key Shifted 32 bits 32 bits 56 bits Expansion Permutation 48 bits Key Permuted 48 bits Substitution, Permuted Choice 32 bits Permutation New Left Data Half New Right Data Half (Old Right Half) http://pralab.diee.unica.it 32 DES variants http://pralab.diee.unica.it 33 Security of DES • Diffie and Hellman in 1977 argued that a 56-bit key is too short given the increasing power of computers • In 1998 researchers built a “DES cracker” machine for approximately $200,000 U.S. that could find a DES key in four days (later improved to a few hours) • In 1995 the NIST began the search for a new, strong, and more flexible algorithm The result was the Advanced Encryption Standard - AES http://pralab.diee.unica.it 34 AES • In 1997 NIST called for cryptographers to develop a new encryption system – unclassified – publicly disclosed – royalty free for use worldwide – symmetric block cipher of at least 128 bit – keys 128, 192, and 256 bits long • In Aug 1998, 15 algorithms chosen from the submissions • In Aug 1999, 5 finalists • In 2001 the winning algorithm became the official U.S. standard http://pralab.diee.unica.it 35 AES Name of the algorithm: Rijndael S S S S 1.