Cryptography Tuomas Aura CSE-C3400 Information security Aalto University, autumn 2015.

Slides:



Advertisements
Similar presentations
Lecture 5: Cryptographic Hashes
Advertisements

CS 483 – SD SECTION BY DR. DANIYAL ALGHAZZAWI (3) Information Security.
CS 6262 Spring 02 - Lecture #7 (Tuesday, 1/29/2002) Introduction to Cryptography.
Digital Signatures and Hash Functions. Digital Signatures.
1 Introduction CSE 5351: Introduction to cryptography Reading assignment: Chapter 1 of Katz & Lindell.
1 Counter-measures Threat Monitoring Cryptography as a security tool Encryption Digital Signature Key distribution.
Web Security for Network and System Administrators1 Chapter 4 Encryption.
 Stream ciphers o Encrypt chars/bits one at a time o Assume XOR w the key, need long key to be secure  Keystream generators (pseudo-random key) o Synchronous.
Session 5 Hash functions and digital signatures. Contents Hash functions – Definition – Requirements – Construction – Security – Applications 2/44.
Hash functions a hash function produces a fingerprint of some file/message/data h = H(M)  condenses a variable-length message M  to a fixed-sized fingerprint.
ECOMMERCE TECHNOLOGY SUMMER 2002 COPYRIGHT © 2002 MICHAEL I. SHAMOS Cryptographic Security.
Dr Alejandra Flores-Mosri Message Authentication Internet Management & Security 06 Learning outcomes At the end of this session, you should be able to:
Chapter 5 Cryptography Protecting principals communication in systems.
CMSC 414 Computer and Network Security Lecture 5 Jonathan Katz.
Kemal AkkayaWireless & Network Security 1 Department of Computer Science Southern Illinois University Carbondale CS 591 – Wireless & Network Security Lecture.
Secure Hashing and DSS Sultan Almuhammadi ICS 454 Principles of Cryptography.
Cryptography (continued). Enabling Alice and Bob to Communicate Securely m m m Alice Eve Bob m.
McGraw-Hill©The McGraw-Hill Companies, Inc., Security PART VII.
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Hash Functions Nathanael Paul Oct. 9, Hash Functions: Introduction Cryptographic hash functions –Input – any length –Output – fixed length –H(x)
Fall 2010/Lecture 311 CS 426 (Fall 2010) Public Key Encryption and Digital Signatures.
Cryptography and Network Security Chapter 11 Fourth Edition by William Stallings Lecture slides by Lawrie Brown/Mod. & S. Kondakci.
Lecture 23 Symmetric Encryption
Cryptography1 CPSC 3730 Cryptography Chapter 11, 12 Message Authentication and Hash Functions.
Computer Science CSC 774Dr. Peng Ning1 CSC 774 Advanced Network Security Topic 2. Review of Cryptographic Techniques.
Lecture 4 Cryptographic Tools (cont) modified from slides of Lawrie Brown.
Network Security Essentials Fifth Edition by William Stallings Fifth Edition by William Stallings.
Chapter 8.  Cryptography is the science of keeping information secure in terms of confidentiality and integrity.  Cryptography is also referred to as.
CN8816: Network Security1 Confidentiality, Integrity & Authentication Confidentiality - Symmetric Key Encryption Data Integrity – MD-5, SHA and HMAC Public/Private.
1 Chapter 4 Encryption. 2 Objectives In this chapter, you will: Learn the basics of encryption technology Recognize popular symmetric encryption algorithms.
Introduction to Public Key Cryptography
Lecture slides prepared for “Computer Security: Principles and Practice”, 2/e, by William Stallings and Lawrie Brown, Chapter 21 “Public-Key Cryptography.
Acknowledgements: William Stallings.William Stallings All rights Reserved Session 4 Public Key Cryptography (Part 2) Network Security Essentials Application.
Chi-Cheng Lin, Winona State University CS 313 Introduction to Computer Networking & Telecommunication Network Security (A Very Brief Introduction)
Lecture 19 Page 1 CS 111 Online Symmetric Cryptosystems C = E(K,P) P = D(K,C) E() and D() are not necessarily the same operations.
Network Security. Cryptography Cryptography functions Secret key (e.g., DES) Public key (e.g., RSA) Message digest (e.g., MD5) Security services Privacy:
How cryptography is used to secure web services Josh Benaloh Cryptographer Microsoft Research.
Midterm Review Cryptography & Network Security
CS526: Information Security Prof. Sam Wagstaff September 16, 2003 Cryptography Basics.
EE515/IS523 Think Like an Adversary Lecture 4 Crypto in a Nutshell Yongdae Kim.
Message Authentication Code July Message Authentication Problem  Message Authentication is concerned with:  protecting the integrity of a message.
Module 3 – Cryptography Cryptography basics Ciphers Symmetric Key Algorithms Public Key Algorithms Message Digests Digital Signatures.
Basic Cryptography 1. What is cryptography? Cryptography is a mathematical method of protecting information –Cryptography is part of, but not equal to,
Cryptography Wei Wu. Internet Threat Model Client Network Not trusted!!
Chapter 21 Public-Key Cryptography and Message Authentication.
CS555Spring 2012/Topic 111 Cryptography CS 555 Topic 11: Encryption Modes and CCA Security.
Computer Security: Principles and Practice First Edition by William Stallings and Lawrie Brown Lecture slides by Lawrie Brown Chapter 2 – Cryptographic.
Wireless LAN Security. Security Basics Three basic tools – Hash function. SHA-1, SHA-2, MD5… – Block Cipher. AES, RC4,… – Public key / Private key. RSA.
Network Security – Special Topic on Skype Security.
無線網路安全 WEP. Requirements of Network Security Information Security Confidentiality Integrity Availability Non-repudiation Attack defense Passive Attack.
Cryptographic Hash Functions and Protocol Analysis
Lecture 2: Introduction to Cryptography
Cryptography 1 Crypto Cryptography 2 Crypto  Cryptology  The art and science of making and breaking “secret codes”  Cryptography  making “secret.
Lecture 23 Symmetric Encryption
Public Key Algorithms Lesson Introduction ●Modular arithmetic ●RSA ●Diffie-Hellman.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Network Security. Three tools Hash Function Block Cipher Public Key / Private Key.
IT 221: Introduction to Information Security Principles Lecture 5: Message Authentications, Hash Functions and Hash/Mac Algorithms For Educational Purposes.
Prof. Reuven Aviv Tel Hai Academic College Department of Computer Science Public Key Cryptography and Message Authentication (Slides adopted from Stallings,
Cryptography services Lecturer: Dr. Peter Soreanu Students: Raed Awad Ahmad Abdalhalim
1 CPCS425: Information Security (Topic 5) Topic 5  Symmetrical Cryptography  Understand the principles of modern symmetric (conventional) cryptography.
Cryptographic Hash Function. A hash function H accepts a variable-length block of data as input and produces a fixed-size hash value h = H(M). The principal.
@Yuan Xue 285: Network Security CS 285 Network Security Hash Algorithm Yuan Xue Fall 2012.
Cryptography Aalto University, autumn 2013.
Introduction to Symmetric-key and Public-key Cryptography
Review of Cryptography: Symmetric and Asymmetric Crypto Advanced Network Security Peter Reiher August, 2014.
Presentation transcript:

Cryptography Tuomas Aura CSE-C3400 Information security Aalto University, autumn 2015

Outline  Symmetric encryption  Cryptographic hash function  Cryptographic authentication  Public-key encryption  Public-key signature  Notest about cryptogprahy 2 Authentication is always most important! This lecture is intended for those who are not taking a cryptography course yet User’s or engineer’s view of cryptography, and some hints about what is below the bonnet

SYMMETRIC ENCRYPTION 3

Encryption  Message encryption based on symmetric cryptography – Endpoints share a secret key K  Protects secrets, not integrity 4

Ideal encryption: random permutation  Ideal encryption is a random 1-to-1 function i.e. permutation of the set of all strings (up to some maximum length L) to itself  Decryption is the reverse function  Like an old-fashioned military code book, but much larger  In practice, it would be impossible to store and share large random permutations (table with L! rows) 5 Secret random permutation plaintexts ciphertexts

Practical encryption: pseudorandom permutation  Random permutation cannot be implemented. What to do? – Block cipher: string length fixed to bits – Choose the pseudorandom permutation from a family of permutation functions that depends on a secret key  Pseudorandom = indistinguishable from random unless you know the algorithm and key  Kerckhoff’s principle: public algorithm, secret key 6 Pseudorandom permutation plaintexts ciphertexts Secret key K (Block length 128-bits)

Substitution-permutation network  One way to implement a key- dependent pseudorandom permutation  Substitution-permutation network: – S-box = substitution is a small (random) 1-to-1 function for a small block, e.g. 2 4 …2 16 values – P-box = bit-permutation mixes bits between the small blocks – Repeat for many rounds, e.g. 8…100 – Mix key bits with data in each round – Decryption is the reverse  Cryptanalysis tries to detect differences between this and a true random permutation 7 [Wikimedia Commons]

Cipher design  It is not difficult to make strong block cipher: long key, large S-boxes, many many rounds  Good bock ciphers are – fast to compute in software – require little memory – cheap to implement in hardware – optimized for both throughput and latency – use a short (e.g. 128-bit) key, which is expanded to the round keys, but still allow fast key changes – etc.  The difficulty is in finding a balance between performance and security 8

AES  Advance Encryption Standard (AES) – Standardized by NIST in 2001 – 128-bit block cipher – 128, 192 or 256-bit key – 10, 12 or 14 rounds  AES round: – SubBytes: 8-byte S-box, not really random, based on finite-field arithmetic, multiplication in GF(2 8 ) – ShiftRows and MixColumn: reversible linear combination of S-box outputs (mixing effect similar to P-box) – AddRoundKey: XOR bits from expanded key with data  Key schedule: expands key to round keys 9

Cipher modes  Block-cipher mode, e.g. cipher-block chaining (CBC), is used for encrypting longer messages  Random initialization vector (IV) makes ciphertexts different even if the message repeats. IV is sent to the receiver as plaintext; it is not secret  The message is padded to fill full blocks of the block cipher 10 [Wikimedia Commons]

11 Common ciphers and modes  Block ciphers: – DES — old standard, 56-bit keys now too short, 64-bit block – 3DES in EDE mode: DES K3 (DES -1 K2 (DES K1 (M))), 3x56 key bits – AES — at least 128-bit keys, 128-bit block  Block-cipher modes – E.g. electronic code book (ECB), cipher-block chaining (CBC), output feedback (OFB), counter mode (CTR)  Stream ciphers: – XOR plaintext and a keyed pseudorandom bit stream – RC4: simple and fast software implementation  Most encryption modes are malleable: – Attacker can make controlled modifications to the plaintext – E.g. consider public-key encryption or stream cipher  Authenticated encryption modes combine encryption and MAC for lower total cost, e.g. Galois Counter Mode (GCM)

12 Key length  Shared key of 128 bits is strong, <80 bits is weak – Q: How long does a brute-force guessing attack for the key take? – Q: Why is it not necessary to use secret keys of thousands of bits?  Brute-force attacks are easy to parallelize, so cost should never be measured in time but in money – 1 CPU day = $1 on high-end PC, less on cloud infrastructure – Q: If NSA has a billion-dollar computer with which it can break (intentionally weak) encryption keys in 1 second, how much does it cost for you to break them on Amazon EC2?

CRYPTOGRAPHIC HASH FUNCTION 13

Cryptographic hash functions  Hash = message digest = fingerprint  Hash function: functions with arbitrary-length input, fixed-length output e.g. 160 bits  One-way = pre-image resistant: given only output, it is impossible to guess input  Second-pre-image resistant: given one input, impossible to find a second input that produces the same output  Collision-resistant: impossible to find any two inputs that produce the same output  Examples: SHA-256; broken ones MD5, SHA-1,  Notation: h(M), hash(M) 14

Ideal hash function: random function  Ideal hash function is a random function from the set of all strings (of any length L) to bit-strings of fixed-length (e.g. k=256 bits)  Reverse function must be impossible to compute in practice  The function is public, no secrets needed  In practice, it would be impossible to store and share such public and infinite-size functions (table with k L rows) 15 Public random function input: any byte string output: short k-bit string This is called “random oracle”

Hash length  In block ciphers, we typically use 128-bit blocks and 128-bit keys. Q: What is a sufficient length for a hash value? A: About twice as long as the secure key length.  But why? 16

Hash collisions  bit hash values to prevent birthday attack – If an N-bit hash value is safe against brute-force reversal, need 2·N bits to withstand birthday attack  Recent research has found collisions in many standard hash functions (MD5, SHA-1)  Currently, any protocol that depends on a collision-resistant hash functions needs an upgrade plan in case collisions are found  Security proofs for many cryptographic protocols and signature schemes depend on collision resistance because it is part of the standard definition for hash functions  Signed messages, including certificates, tend to become vulnerable if there are hash collisions.  However, most other network-security applications of hash functions do not really need collision resistance, only second-pre-image resistance 17

CRYPTOGRAPHIC AUTHENTICATION 18

Message authentication code (MAC)  Message authentication and integrity protection based on symmetric cryptography – Endpoints share a secret key K – MAC appended to the original message M – Common implementations: HMAC-SHA1, HMAC-SHA256 19

HMAC  HMAC is commonly used in standards: – Way of deriving MAC from a cryptographic hash function h HMAC K (M) = h((K ⊕ opad) | h((K ⊕ ipad) ‖ M)) – Hash function h is instantiated with SHA-1, MD5 etc. to produce HMAC-SHA-1, HMAC-MD5,… – ⊕ is XOR; | is concatenation of byte strings – ipad and opad are bit strings for padding the key to fixed length – Details: [RFC 2104][Bellare, Canetti, Krawczyk Crypto’96] **  HMAC is theoretically stronger than simpler constructions: h(M | K), h(K | M | K)  HMAC is efficient for long messages; optimized for pre- computation  Question: does h need to be collision resistant or just second pre-image resistant? 20

PUBLIC-KEY ENCRYPTION 21

Public-key encryption  Message encryption based on asymmetric cryptography – Key pair: public key and private key  Protects secrets, not integrity 22

RSA encryption  RSA encryption, published 1978 – Based on modulo arithmetic with very large integers  Simplified description of the algorithm: – Public key (e,n) - public exponent and modulus – Private key (d,n)- secret exponent and public modulus – Encryption C = M e mod n – Decryption C d mod n = (M e ) d mod n = M – n is commonly 1024 or 2048 bits long, d will also be long, e can be short (17 or ); M can be at most as long as n  Why does it work? Based on number theory – Euler’s theorem: x ϕ(n) ≡ 1 (mod n), and thus x k ϕ(n)+1 ≡ X (mod n) – We need to have e and d so that ed = kϕ(n)+1 for some k – 1. Choose n as product of two large secret prime numbers n=pq; then, ϕ(n)=(p-1)(q-1) – 2. Then pick a small d, solve for e, and forget p,q,ϕ(n) – RSA security assumption: difficult to solve d when you only know (e,n)  For details and implementation guidelines, see PKCS#1 23 Goal here is to give a feeling of how RSA works, not to understand it all

RSA encryption (again)  Simplified description of the key generation algorithm: – p,q = large secret prime numbers (512…2048 bits long) – Public modulus n = pq – Euler’s totient function ϕ(n) = (p-1)(q-1) (number of integers 1...n that are relatively prime with n) – Public exponent e, typically e=17 or e= – ed ≡ 1 (mod ϕ(n)), use extended Euclidian algorithm to solve the secret exponent d; it is possible because you know ϕ(n) – Public key is (e,n) – Private key is (d,n) – Forget p, q and ϕ(n); these must not be leaked  Simplified encryption and decryption algorithm: – Encryption C = M e mod n – Decryption M = C d mod n  This is not all; for complete details, see PKCS#1 – Never implement RSA without following such a standard! 24

Example: RSA public key  a c7 3a f3 2e a c 6b a e7 e0 ab 47 2e 9f 38 a dc cf 62 bc de 47 a a6 47 9e d d 9f 72 aa c4 4a b7 88 cc 7b c5 a6 18 4f d5 86 a4 9e fb 42 5f e0 ff 10 2e cd ed 4a 4c a8 45 d cd 2f 5f 7d b6 9b f f7 a9 9b 7a 95 d4 a e 3f 0b ff 83 d5 a9 3b d7 8c aa be d0 9d 5d 96 4f fb e7 59 ca ca a bd b1 7c b a 5e e3 29 1a d 5a 47 d4 05 b3 22 3f fd ad 1c 9e 4e ad 39 f4 d1 ae 90 7d f9 e d2 b7 ba cd 68 2e 62 b3 d7 ad 00 4c c 6e bd 9d 3d 1d 4c 4c cc b0 b c c5 7c 1e 2e f6 e3 f d9 fb 23 9d e7 c7 d5 ce d ef ef df 7b 7b 79 2e f a c1 ef a5 c1 2a 01 e a 98 bb d bit modulus public exponent ( ) ASN.1 type tags

26 Key length  In RSA, secure key lengths are >1024 bits  Elliptic-curve cryptography (ECC): public-key crypto with much shorter keys and efficient computation – Used for most new applications and small devices

Key distribution  Main advantage of public-key cryptography is easier key distribution  Shared secret keys, symmetric cryptography: – O(N 2 ) pairwise keys for N participants → does not scale – Keys must be kept secret → hard to distribute safely  Public-key protocols, asymmetric cryptography: – N key pairs needed, one for each participant – Keys are public → can be posted on the Internet  But… both shared and public keys must be authentic – How does Alice know it shares K AB with Bob, not with Trent? – How does Alice know PK B is Bob’s public key, not Trent’s? 27

Hybrid encryption  Symmetric encryption is fast; asymmetric is convenient  Hybrid encryption = symmetric encryption with random session key + asymmetric encryption of the session key 28

Formal security definitions  Cryptographic security definitions for asymmetric encryption  Semantic security (security against passive attackers) – Computational security against a ciphertext-only attack  Ciphertext indistinguishability (active attackers) – IND-CPA — attacker submits two plaintexts, receives one of them encrypted, and is challenged to guess which it is ⇔ semantic security – IND-CCA — indistinguishability under chosen ciphertext attack i.e. attacker has access to a decryption oracle before the challenge – IND-CCA2 — indistinguishability under adaptive chosen ciphertext attack i.e. attacker has access to a decryption oracle before and after the challenge (except to decrypt the challenge)  Non-malleability – Attacker cannot modify ciphertext to produce a related plaintext – NM-CPA ⇒ IND-CPA; NM-CCA2 ⇔ IND-CCA2  It is non-trivial to choose the right kind of encryption for your application; ask a cryptographer! 29

DIGITAL SIGNATURE 30

Digital signature  Message authentication and integrity protection with public-key crypto – Verifier has a public key PK ; signer has the private key PK -1 – Messages are first hashed and then signed – Examples: DSS, RSA + SHA

Digital signature  Digital signature with appendix – Hash the message, sign the hash – The signature is usually appended to the actual message but can also be stored separately  Examples: DSA, RSA [PKCS#1] – Always follow strictly the standard when implementing signatures! There are many subtle points that can go wrong  Signing is not encryption with public key! – Common misconception because in RSA private key can be used both to sign and decrypt  Question: does the hash function h in signatures need to be collision resistant? 32

NOTES ABOUT CRYPTOGRAPHY 33

How strong is cryptography?  Cryptographer: requires continuous analysis and improvement  Engineer: unbreakable if you use strong standard algorithms and 128-bit symmetric keys – May need to upgrade algorithms over decades – Avoid using algorithms in new creative ways, different from their original purpose  Weak crypto is worse than no crypto – Hardly any excuse to use a relatively weak algorithm, even in resource constrained devices  Which algorithms can be trusted? – Block ciphers have withstood time well – Hash functions were considered safe until recently – Quantum computers might break public-key cryptography  Almost no absolute proofs of security exist! – Proving lower bounds on computational complexity is difficult 34

Notations in protocol specifications  Shared key: K = SK = K AB  Symmetric encryption: Enc K (M), E K (M), E(K;M), {M} K, K{M}  Hash function: h(M), H(M), hash(M), SHA-256(M)  Message authentication code: MAC K (M), MAC(K;M), HMAC K (M)  Public/private key: PK = PK A = K A = K + = K + A = e ; SK = PK -1 = PK -1 A = K - = K - A = d  Public-key encryption: Enc B (M), E B (M), PK{M}, {M} PK  Signature notations: S A (M) = Sign A (M) = S(PK -1 ; M) = PK - A (M) = {M} PK -1 35

Message size overhead  Authentication increases the message size: – MAC takes 16–32 bytes – 1024-bit RSA signature is 128 bytes – Appended to the message  Encryption increases the message size: – In block ciphers, messages are padded to nearest full block – IV for block cipher takes 8–16 bytes – 1024-bit RSA encryption of the session key is 128 bytes  Overhead of headers, type tags etc.  Size increase ok for most applications but can cause problems in some: – Signing individual IP packets (1500 byte limit on size) – Authenticating small wireless frames – Encrypting file system sector by sector, but cannot increase sector size by a few bytes to fit in the IV or MAC 36

Security vs. cryptography  Cryptography: mathematical methods for encryption and authentication  In this course, we use cryptography as one building block for security mechanisms  Remember that cryptography alone does not solve all security problems: “Whoever thinks his problem can be solved using cryptography, doesn’t understand the problem and doesn’t understand cryptography.” — attributed to Roger Needham and Butler Lampson 37

Reading material  Stallings and Brown: Computer security, principles and practice, 2008, chapters 2,19,20  Ross Anderson: Security Engineering, 2nd ed., chapter 5  Dieter Gollmann: Computer Security, 2nd ed., chapter 11; 3rd ed. chapter 14  Stallings: Cryptography and Network Security: Principles and Practices, 3rd or 4th edition, Prentice Hall, chapters

Exercises  Confidentiality, integrity, availability – which can be protected with cryptography?  What kind of cryptography would you use to – protect files stored on disk – store client passwords on server disk – implement secure boot – protect in transit – publish an electronic book – implement an electronic bus ticket – identify friendly and enemy aircraft (“friend or foe”) – sign an electronic contract – transmit satellite TV – protect software updates – send pseudonymous letters – timestamp an invention  Which applications require strong collision resistance of hash functions? What attacks have resulted from collisions in MD5?  Find out about DES cracking; why is DES vulnerable and how much security would it give today?  What ethical issues are there related to cryptography? Should commercial products use cryptography that is so strong that even the police cannot break it? 39