Cryptographic Hashing

Slides:



Advertisements
Similar presentations
ECE454/CS594 Computer and Network Security Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2011.
Advertisements

Digital Signatures and Hash Functions. Digital Signatures.
PIITMadhumita Chatterjee Security 1 Hashes and Message Digests.
1 Chapter 5 Hashes and Message Digests Instructor: 孫宏民 Room: EECS 6402, Tel: , Fax :
Introduction to Cryptography and Security Mechanisms: Unit 5 Theoretical v Practical Security Dr Keith Martin McCrea
Announcements: 1. HW7 due next Tuesday. 2. Inauguration today! Questions? This week: Discrete Logs, Diffie-Hellman, ElGamal Discrete Logs, Diffie-Hellman,
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.
Hashes and Message Digest Hash is also called message digest One-way function: d=h(m) but no h’(d)=m –Cannot find the message given a digest Cannot find.
Chapter 4  Hash Functions 1 Overview  Cryptographic hash functions are functions that: o Map an arbitrary-length (but finite) input to a fixed-size output.
Apr 4, 2003Mårten Trolin1 Previous lecture TLS details –Phases Handshake Securing messages –What the messages contain –Authentication.
1 Pertemuan 09 Hash and Message Digest Matakuliah: H0242 / Keamanan Jaringan Tahun: 2006 Versi: 1.
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
Cryptography1 CPSC 3730 Cryptography Chapter 11, 12 Message Authentication and Hash Functions.
1 Cryptography and Network Security (Various Hash Algorithms) Fourth Edition by William Stallings Lecture slides by Lawrie Brown (Changed by Somesh Jha)
Chapter 8.  Cryptography is the science of keeping information secure in terms of confidentiality and integrity.  Cryptography is also referred to as.
Cryptography and Network Security Chapter 11 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Lecture 15 Lecture’s outline Public algorithms (usually) that are each other’s inverse.
Dan Johnson. What is a hashing function? Fingerprint for a given piece of data Typically generated by a mathematical algorithm Produces a fixed length.
IT253: Computer Organization
Based on Bruce Schneier Chapter 7: Key Length Dulal C. Kar.
Hashing Algorithms: Basic Concepts and SHA-2 CSCI 5857: Encoding and Encryption.
1 Hash Functions. 2 A hash function h takes as input a message of arbitrary length and produces as output a message digest of fixed length
H ASHING : SHA256 T AYLER A NGEVINE B ACHELOR OF A RTS D R. K EN B LAHA 3/13/2014.
6fb52297e004844aa81be d50cc3545bc Hashing!. Hashing  Group Activity 1:  Take the message you were given, and create your own version of hashing.  You.
Hash Algorithms see similarities in the evolution of hash functions & block ciphers –increasing power of brute-force attacks –leading to evolution in algorithms.
Lecture 2: Introduction to Cryptography
Understanding Cryptography – A Textbook for Students and Practitioners by Christof Paar and Jan Pelzl Chapter 11 – Hash Functions.
Week 4 - Friday.  What did we talk about last time?  Snow day  But you should have read about  Key management.
CRYPTOGRAPHY. WHAT IS PUBLIC-KEY ENCRYPTION? Encryption is the key to information security The main idea- by using only public information, a sender can.
Hash Functions Ramki Thurimella. 2 What is a hash function? Also known as message digest or fingerprint Compression: A function that maps arbitrarily.
CSCE 715: Network Systems Security Chin-Tser Huang University of South Carolina.
Information Security and Management 11. Cryptographic Hash Functions Chih-Hung Wang Fall
Cryptography and Network Security Third Edition by William Stallings Lecture slides by Lawrie Brown.
 Encryption provides confidentiality  Information is unreadable to anyone without knowledge of the key  Hashing provides integrity  Verify the integrity.
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.
Chapter 12 – Hash Algorithms
Secure Hash Algorithm A SEARIES OF SHA….
Public Key Cryptography
CHAPTER 4 TJADEN plus Chapters 13 & 14 Crytography Decrypted Hashing Functions, Message Digests, Message Authentication Codes (MACs) Dr. Suzanne Buchele.
NUMBER SYSTEMS.
Attacks on Public Key Encryption Algorithms
CSCE 715: Network Systems Security
MD5 A Hash Algorithm….
Cryptographic Hash Function
Network Security.
A Level Computing Component 2
Topic 14: Random Oracle Model, Hashing Applications
Cryptographic Hash Functions Part I
Cryptography Lecture 13.
ICS 454 Principles of Cryptography
Cryptographic Hashing
PHP: Security issues FdSc Module 109 Server side scripting and
Kiran Subramanyam Password Cracking 1.
ICS 454 Principles of Cryptography
Network Security.
Cryptographic Hash Functions Part I
Lecture 4.1: Hash Functions, and Message Authentication Codes
Practical Aspects of Modern Cryptography
Cryptography Lecture 14.
Cryptography Lecture 13.
Cryptographic Hash Functions
Cryptography Lecture 13.
Cryptography Lecture 18.
The RSA Public-Key Encryption Algorithm
Cryptographic Hashing Special Session
One-Way Hash Functions
Blockchains Lecture 4.
Presentation transcript:

Cryptographic Hashing Campbell R. Harvey Duke University and NBER

Overview Cryptographic hashing is not “encryption” We encrypt something with the purpose of decrypting A hash is a one-way function The only way to recover the original message is by brute force or a dictionary attack Hashes are also known as “Message Digests” or “Fingerprints” (with a fingerprint you can identify the person but you cannot use the print to recreate the person)

Overview Property of good cryptographic hashes Easy to compute – but not too easy (fast) Same input generates the same output (deterministic) Infeasible to recreate original message from the hash (one-way) Improbable to alter message without changing hash (secure) Improbable for two messages to create the same hash (collision resistant)

SHA Secure Hash Algorithm SHA-256 is standard and its output is 256 bits SHA-1 has been replaced by SHA-2 (because of insecurity) SHA-1 output is 160 bits We will focus on SHA-1 because it is very similar to SHA-256 SHA-256 is strongly recommended because it is harder to find collisions SHA-3 (used by Ethereum) even stronger

SHA Collisions To undo a SHA-1, you need to brute force 2160 combinations of bits (0s and 1s). One of these combinations will be the original message. However, to find a collision is a lot easier because of the birthday paradox How many people do you need in a classroom to have a 50% probability that two people have the same birthday?

SHA

SHA Collisions To undo a SHA-1, you need to brute force 2160 However, to find a collision is a lot easier because of the birthday paradox Need approximately 280 tries

SHA-256 Maximum input size is 264-1. Consider the following visualization: Assume that 1 bit equals to 1 mm2. A soccer field has dimensions of 7,140 m2, therefore 264-1 bits could theoretically fit in 2,583,577,601 soccer fields. As the whole surface of the earth equals to 510,000,000,000,000 m2, we could also cover around 36,170 times the earth with the theoretical input size. This input information will be represented by very short output, the 256 bit hash.

SHA-256 Basic idea: Supplementary section goes through the details of a SHA-1 (160 bit output) and also explains the relation between SHA-1 and SHA-2. Input (what you want to hash) is broken up into 512 bit chunks. Each chunk is broken up into 16 32 bit “words” (16x32=512). These are fed into a series of functions – some of which are irreversible. Modular arithmetic is used in one of these functions.

SHA-256 Basic idea: Suppose your input is the number of hours since January 1, 2010. Suppose that number is 24,002. Now we apply the mod operator with base 24. This gives us the remainder of 24,002/24 = 2. Suppose you see “2” which represents 2am. You have no way of reversing the 2. It could be 2am on any day. The only way to “reverse” is by brute force.

SHA-256 Basic idea: There are other operators used such as the XOR function (when adding two binary numbers this will take the value of 1 if either the first number or the second number is a 1). There is no way to reverse this other than brute force. 0101 (decimal 5) XOR 0011 (decimal 3) = (1 if either first or second bit 1) = 0110 (decimal 6) No idea if two 0s or two 1s No idea if the first number is 1 or the second number of 1

SHA-256 Basic idea: After doing all these adding operations, we get 160 bits. We use this as the starting point and grab the next 512 bits of the input and start again I have not described all the details which include jumbling functions and other fun!

SHA-256 Basic idea: The essential intuition is that there is information lost. This is not like a scrambled Rubik’s cube. The SHA code is open access. You can see every step – but you cannot reverse it due to the information loss. If every step of a Rubik’s cube’s permutation was published, it would be trivial to reverse. Also, note the number of squares in the cube is 54 (input) and the output is also 54. This is way different than 264 -1 maximum input and the output of only 256 bits!

SHA Online calculators https://emn178.github.io/online-tools/sha256.html https://anders.com/blockchain/hash.html

SHA-1 [Supplementary] Original message can be long. It is processed in 512 bit chunks. Let’s call the first message “x” and it is 512 bits Message is padded if original is less than 512 bits

SHA-1 [Supplementary] Inputs: one piece at a time 512 bits are divided up into 16 32-bits pieces, xj j=0,…15 “Words” Wj are then formed There are 80 of these words because there are 80 “steps” of activity

SHA-1 [Supplementary] Inputs: 80 “words” formed The first 16 are exactly the original message divided into 32 bit pieces: Wj = xj for j=0 to 15 The next 64 words are a mash using the following: Wj = (Wj-16 Wj-14 Wj-8 Wj-3)<<1 for j=16 to 79 Where, is “XOR”; and << shifts left one bit

SHA-1 [Supplementary] Digression: bitwise Boolean operations NOT 0111 (decimal 7) = (opposite) 1000 (decimal 8) 0101 (decimal 5) AND (intersection of 1s, ‘multiply’) 0011 (decimal 3) = 0001 (decimal 1)

SHA-1 [Supplementary] 0101 (decimal 5) Digression: bitwise boolean operations 0101 (decimal 5) OR 0011 (decimal 3) = (if both 0, then 0, otherwise 1 0111 (decimal 7) 0101 (decimal 5) XOR 0011 (decimal 3) = (1 if either first or second bit 1) 0110 (decimal 6)

SHA-1 [Supplementary] The math is not hard – it is mechanical. This is hard:

SHA-1 [Supplementary] If message longer than 512 bits… Initial 512 bit message is hashed to 160 bits This 160 bit hash forms the “initial values” for the hash that will result from the next 512 bits

SHA-1 [Supplementary] There are 4 rounds each with 20 steps Initial 160 bit hash is split into 5 pieces (each 32 bits): A,B,C,D,E Notice the modular addition of the original A-E with results of 80 steps Diagrams from Paar and Pelzl, Understanding Cryptography

SHA-1 [Supplementary] Initial values of A,B,C,D,E, i.e. the starting hash, H0 A=H0(0) = 67452301 B=H0(1) = EFCDAB89 C=H0(2) = 98BADCFE D=H0(3) = 10325476 E=H0(4) = C3D2E1F0 Each is 32 bits long and the above in hexadecimal form (0-9,a,b,c,d,e,f); values the same for every hash

SHA-1 We now need to figure out what is happening in each of the 4 rounds. This is very convoluted as you will see. Note rectangle symbol with cross is addition mod 232 *Think of a clock which is mod 12. If we add 3 hours past 12 noon, that is 15 – but in mod 12 we call it 3.

SHA-1 [Supplementary] This is what happens in round t for each Wj New A=(E + ft(B,C,D) + (A)<<5 + Wj + Kt) New B=A New C=(B)<<30 New D=C New E=D The function ft changes each round as does Kt There are a total of 80 steps (4x20)

SHA-1 [Supplementary] The jumbling functions and the constants: Note ^ = AND; v = OR; - = NOT; = XOR

SHA-1 [Supplementary] The initial hash values and the constants are arbitrary but are not NSA backdoor codes: H0 is a simple four bit counter (in reverse)* Round constants, Kt, are just square roots of 2,3,5,10 The slang for this is “nothing up my sleeve” – important because proposed by NSA! *e.g. 0111 0110 0101 0100 0011 0010 0001 0000 = LE (little endian) 76543210 = BE (big endian) 67452301

SHA-1 [Supplementary] The result of the 80 steps is H1. The 160 bit hash is now the starting point (the new initial A,B,C,D,E) to process the second 512 bit part of the message (assuming the message is longer than 512 bits). Again, SHA-256 very similar but the output is 256 bits not 160 bits.

SHA-1 vs. SHA-256 [Supplementary] Produces 256 bits not 160 bits Values A-E (SHA-1, i.e. 5x32) are A-H (SHA-256, i.e. 8x32) Starting A-H determined by the fractional part of the square roots of the first 8 primes 64 rounds – not 80 steps (4 rounds each with 20 steps) Constants for every step in SHA-256, fractional part of cube root of first 64 primes

Mining in Excel [Supplementary] It is a bad idea Notice there is no need for floating point operations Hence, we do not need CPUs to do this. Miners use a specialized ASIC technology However, if you wanted to mine in Excel… https://www.youtube.com/watch?v=UZBZPOEVyJA

References [Supplementary] Here are some walk throughs https://www.cryptocompare.com/coins/guides/how-does-a-hashing- algorithm-work/ https://blog.goodaudience.com/very-basic-intro-to-hash-functions- sha-256-md-5-etc-ed721622ff8

Application: Passwords Bad ideas Website stores your password on their site. You can tell if they do this if you can request that your password be sent back to you if you forget it. Website encrypts your password on their site. However, two problems. First, if the hacker gets the encryption key, all passwords are at risk. Second, many people have the same password. (Also, bad idea to store hints.) Website stores hash of your password. This is the industry standard but still a bad idea. Again, there are many common passwords and Google has a database of hashes associated with common passwords. Try Googling 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8

Application: Passwords Good idea Salted hashes. Some random data is added to your password so that the hash is unique. Even though many people have the same password, they all appear different to the attacker. Company keeps your username and salt. When you enter the password, the company appends the salt and then hashes. This makes an attack much more difficult even if the attacker steals the usernames and salts.

Application: File Transfer Download a file from a website On the original website, there is often a “checksum” which is a hash of the file and details of the type of hashing algorithm. Once you download the file, you can hash it and verify that the downloaded file is exactly the same has the file on website (it has not been corrupted).

Application: File Transfer Download a file from a website

Efficiency Antminer S9 does 14 trillion hashes per second for SHA-256

Efficiency S9 introduced in November 2017, it is not profitable any more. https://www.asicminervalue.com/ Power cost assumption $0.13/kwh

Efficiency S9 marginally profitable at commercial rates. https://www.asicminervalue.com/ Power cost assumption $0.06/kwh

Efficiency ASICminer 8 Nano does 44 trillion hashes per second for SHA-256

Efficiency ASICminer 8 Nano does 44 trillion hashes per second for SHA-256 https://www.asicminervalue.com/ Power cost assumption $0.13/kwh

Efficiency ASICminer 8 Nano does 44 trillion hashes per second for SHA-256 https://www.asicminervalue.com/ Power cost assumption $0.06/kwh

Efficiency E3 does 190 million hashes per second for Keccak-256 (SHA-3)

Efficiency E3 does 190 million hashes per second for Keccak-256 (SHA-3) Power cost assumption $0.13/kwh

Efficiency E3 does 190 million hashes per second for Keccak-256 (SHA-3) Power cost assumption $0.06/kwh

Application: Brute forcing SHA-256 The SHA-256 hash has 2256-1 different outputs. However, you should be able to get a collision with just one more possible input, i.e. the 2256th must cause a collision.

Application: Brute forcing SHA-256 “One of the consequences of the second law of thermodynamics is that a certain amount of energy is necessary to represent information. To record a single bit by changing the state of a system requires an amount of energy no less than kT, where T is the absolute temperature of the system and k is the Boltzman constant. (Stick with me; the physics lesson is almost over.)

Application: Brute forcing SHA-256 “Given that k = 1.38×10-16 erg/°Kelvin, and that the ambient temperature of the universe is 3.2°Kelvin, an ideal computer running at 3.2°K would consume 4.4×10-16ergs every time it set or cleared a bit. To run a computer any colder than the cosmic background radiation would require extra energy to run a heat pump.

Application: Brute forcing SHA-256 “Now, the annual energy output of our sun is about 1.21×1041 ergs. This is enough to power about 2.7×1056 single bit changes on our ideal computer; enough state changes to put a 187-bit counter through all its values [i.e. 2.7×1056 =2187]. If we built a Dyson sphere* around the sun and captured all its energy for 32 years, without any loss, we could power a computer to count up to 2192 [i.e. 32×2.7×1056 =2192]. Of course, it wouldn't have the energy left over to perform any useful calculations with this counter. *Freeman Dyson, 1960. The search for artificial stellar sources of infrared radiation.

Application: Brute forcing SHA-256 “But that's just one star, and a measly one at that. A typical supernova releases something like 1051 ergs. (About a hundred times as much energy would be released in the form of neutrinos, but let them go for now.) If all of this energy could be channeled into a single orgy of computation, a 219-bit counter could be cycled through all of its states [i.e. 2219].

Application: Brute forcing SHA-256 “These numbers have nothing to do with the technology of the devices; they are the maximums that thermodynamics will allow. And they strongly imply that brute-force attacks against 256-bit keys will be infeasible until computers are built from something other than matter and occupy something other than space.

Application: Brute forcing SHA-256 “…Even a mythical quantum computer won't be able to brute-force that large a keyspace.”  From Bruce Schneiner https://www.schneier.com/blog/archives/2009/09/the_doghouse_cr.html See also https://medium.com/tokyo-fintech/the-quantum-computing-threat-that-isnt- a005f3417841

Application: Brute forcing SHA-256 The “mythical” quantum computer in 2009 is no longer a myth. However, it is not useful for finding collisions

Application: Brute forcing SHA-256 http://www.qxbranch.com