“The quick brown fox jumps over the lazy dog”

Slides:



Advertisements
Similar presentations
Hash Functions A hash function takes data of arbitrary size and returns a value in a fixed range. If you compute the hash of the same data at different.
Advertisements

Lecture 5: Cryptographic Hashes
Lecture 7 Overview. Advanced Encryption Standard 10, 12, 14 rounds for 128, 192, 256 bit keys – Regular Rounds (9, 11, 13) – Final Round is different.
ECE454/CS594 Computer and Network Security Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2011.
Digital Signatures and Hash Functions. Digital Signatures.
Outline Project 1 Hash functions and its application on security Modern cryptographic hash functions and message digest –MD5 –SHA.
MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen.
MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen.
MD5 Generation Auto-Generated Slides To Visualize MD5 Hash Generation by Chris Fremgen.
PIITMadhumita Chatterjee Security 1 Hashes and Message Digests.
Announcements: 1. HW7 due next Tuesday. 2. Inauguration today! Questions? This week: Discrete Logs, Diffie-Hellman, ElGamal Discrete Logs, Diffie-Hellman,
Announcements:Questions? This week: Discrete Logs, Diffie-Hellman, ElGamal Discrete Logs, Diffie-Hellman, ElGamal Hash Functions and SHA-1 Hash Functions.
MD5 Message Digest Algorithm CS265 Spring 2003 Jerry Li Computer Science Department San Jose State University.
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.
Slide 1 Vitaly Shmatikov CS 378 Hash Functions. slide 2 We’ve Already Seen Hashes In… Every lecture so far! uIntegrity checking in SSL uAs one of applications.
Company LOGO Midterm Presentation Hash Function using MD5 algorithm Students: Eyal Mendel & Aleks Dyskin Instructor: Evgeny Fiksman High Speed Digital.
Hash Functions Nathanael Paul Oct. 9, Hash Functions: Introduction Cryptographic hash functions –Input – any length –Output – fixed length –H(x)
Lecture 13 Message Signing
Cryptography1 CPSC 3730 Cryptography Chapter 11, 12 Message Authentication and Hash Functions.
Cryptography and Network Security Chapter 11 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Digital signature using MD5 algorithm Hardware Acceleration
Lecture slides prepared for “Computer Security: Principles and Practice”, 2/e, by William Stallings and Lawrie Brown, Chapter 21 “Public-Key Cryptography.
Slide 1 Vitaly Shmatikov CS 378 Cryptographic Hash Functions.
Hash and MAC Algorithms Dr. Monther Aldwairi New York Institute of Technology- Amman Campus 12/3/2009 INCS 741: Cryptography 12/3/20091Dr. Monther Aldwairi.
1 Hashes and Message Digests. 2 Hash Also known as –Message digest –One-way function Function: input message -> output One-way: d=h(m), but not h’(d)
Chapter 21 Public-Key Cryptography and Message Authentication.
ITIS 1210 Introduction to Web-Based Information Systems Chapter 50 Cryptography, Privacy, and Digital Certificates.
Hash and MAC Functions CS427 – Computer Security
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
1 Network Security Lecture 5 Hashes and Message Digests Waleed Ejaz
Hash and Mac Algorithms. Contents Hash Functions Secure Hash Algorithm HMAC.
Cryptographic Hash Functions
6.375 Final Presentation Jeff Simpson, Jingwen Ouyang, Kyle Fritz FPGA Implementation of Whirlpool and FSB Hash Algorithms.
CSCE 815 Network Security Lecture 8 SHA Operation and Kerberos.
Slide 1 EJ Jung Hash Functions. Integrity checks.
Lecture 8 Overview. Secure Hash Algorithm (SHA) SHA SHA SHA – SHA-224, SHA-256, SHA-384, SHA-512 SHA-1 A message composed of b bits.
Chapter 18: One-Way Hash Functions Based on Schneier.
Team TDB Members: Anthony Knopp Zach Langley
Cryptographic Hash Functions and Protocol Analysis
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Modern Cryptography.
Anurag Dwivedi. Basic Block - Gates Gates -> Flip Flops.
Hash Functions Ramki Thurimella. 2 What is a hash function? Also known as message digest or fingerprint Compression: A function that maps arbitrarily.
Lecture 5B Block Diagrams HASH Example.
Computer Science and Engineering Computer System Security CSE 5339/7339 Lecture 11 September 23, 2004.
Computer Science and Engineering Computer System Security CSE 5339/7339 Lecture 10 September 21, 2004.
Information Security and Management 11. Cryptographic Hash Functions Chih-Hung Wang Fall
Lecture 9 Overview. RSA Invented by Cocks (GCHQ), independently, by Rivest, Shamir and Adleman (MIT) Two keys e and d used for Encryption and Decryption.
1 Message Authentication using Message Digests and the MD5 Algorithm Message authentication is important where undetected manipulation of messages can.
CS480 Cryptography and Information Security Huiping Guo Department of Computer Science California State University, Los Angeles 13.Message Authentication.
Chapter 12 – Hash Algorithms
Project 2: Byte Rotation
Information and Computer Security CPIS 312 Lab 9
CHAPTER 4 TJADEN plus Chapters 13 & 14 Crytography Decrypted Hashing Functions, Message Digests, Message Authentication Codes (MACs) Dr. Suzanne Buchele.
Cryptographic Hash Functions & Digital Signatures
Network Security Unit-III
Cryptographic Hash Function
Chapter 5: The Art of Ensuring Integrity
최신정보보호기술 경일대학교 사이버보안학과 김 현성.
These 19 words are given and fixed
Example Best and Median Results
MD5 A Hash Algorithm….
کدهاي احراز تماميت پيام و توابع درهم ساز
MD5 In MD5, St shift constants are defined as:
Faster File matching using GPGPU’s Deephan Mohan Professor: Dr
Lecture 4: Continuation of SystemVerilog
The Secure Hash Function (SHA)
Presentation transcript:

“The quick brown fox jumps over the lazy dog” Secure Hash Algorithm Goal is to compute a unique hash value for any input “message”, where a “message” can be anything. SHA-1 (widely used) returns a 160-bit hash value (a.k.a. message digest or strong checksum) “The quick brown fox jumps over the lazy dog” SHA-1 2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12 160-bits = five 32-bit words SHA-1 some 160-bit value SHA-1 some 160-bit value file: avatar.avi file: chopin.mp3

SHA-1 Just a small change, e.g. from “dog” to “cog”, will completely change the hash value “The quick brown fox jumps over the lazy dog” SHA-1 2fd4e1c6 7a2d28fc ed849ee1 bb76e739 1b93eb12 “The quick brown fox jumps over the lazy cog” SHA-1 de9f2c7f d25e1b3a fad3e85a 0bd17d9b 100db4b3

Verifying File Integrity VIRUS badFile goodFile NY Times hash(goodFile) BigFirm™ User Software manufacturer wants to ensure that the executable file is received by users without modification … Sends out the file to users and publishes its hash in NY Times The goal is integrity, not secrecy Idea: given goodFile and hash(goodFile), very hard to find badFile such that hash(goodFile)=hash(badFile)

Authentication Bob Alice SECRET SECRET msg, H(SECRET,msg) Alice Bob Alice wants to ensure that nobody modifies message in transit (both integrity and authentication) Idea: given msg, very hard to compute H(SECRET, msg) without SECRET; easy with SECRET

SHA-1 Developed by NIST, specified in the Secure Hash Standard (SHS, FIPS Pub 180), 1993 SHA-1 is specified as the hash algorithm in the Digital Signature Standard (DSS), NIST

General Logic Input message must be < 264 bits not really a problem Message is processed in 512-bit blocks sequentially Message digest is 160 bits

SHA-1 Algorithm Step 1: Padding bits A b-bit message M is padded in the following manner: Add a single “1” to the end of M Then pad message with “0’s” until the length of message is congruent to 448, modulo 512 (which means pad with 0’s until message is 64-bits less than some multiple of 512). Step 2: Appending length as 64 bit unsigned A 64-bit representation of b is appended to the result of Step 1. The resulting message is a multiple of 512 bits e.g. suppose b = 900 2 x 512 = 1024 bits M 1 … 900 900 bits 59 0’s 64 bits

SHA-1 Algorithm Step 3: Buffer initiation – initialize message digest (MD) to these five 32-bit words H0 = 67452301 H1 = efcdab89 H2 = 98badcfe H3 = 10325476 H4 = c3d2e1f0

SHA-1 Algorithm Step 4: Processing of the message (the algorithm) Divide message M into 512-bit blocks, M0, M1, … Mj, … Process each Mj sequentially, one after the other Input: Wt : a 32-bit word from the message Kt : a constant H0, H1, H2, H3, H4 : current MD Output: H0, H1, H2, H3, H4 : new MD

SHA-1 Algorithm Step 4: Cont’d At the beginning of processing each Mj, initialize (A, B, C, D, E) = (H0, H1, H2, H3, H4) Then 80-step processing of 512-bit blocks – 4 rounds, 20 steps each Each step t (0 ≤ t ≤ 79): Wt If t < 16, Wt = tth 32-bit word of Mj If t ≥ 16, Wt = (Wt-3 xor Wt-8 xor Wt-14 xor Wt-16) leftrotate 1

SHA-1 Algorithm Step 4: Cont’d Each step t (0 ≤ t ≤ 79): Kt 0 ≤ t ≤ 19, Kt = 5a827999 20 ≤ t ≤ 39, Kt = 6ed9eba1 40 ≤ t ≤ 59, Kt = 8f1bbcdc 60 ≤ t ≤ 79, Kt = ca62c1d6

SHA-1 Algorithm Step 4: Cont’d Each step t (0 ≤ t ≤ 79): Define F(X, Y, Z) as follows: 0 ≤ t ≤ 19, F(X, Y, Z) = (X and Y) xor ((not X) and Z) 20 ≤ t ≤ 39, F(X, Y, Z) = X xor Y xor Z 40 ≤ t ≤ 59, F(X, Y, Z) = (X and Y) xor (X and Z) xor (Y and Z) 60 ≤ t ≤ 79, F(X, Y, Z) = X xor Y xor Z Then compute (called the SHA-1 step function) T = (A leftrotate 5) + F(B, C, D) + Wt + Kt + E

SHA-1 Algorithm Step 4: Cont’d Each step t (0 ≤ t ≤ 79): The values of (A, B, C, D, E) are updated as follows: (A, B, C, D, E) = (T, A, B leftrotate 30, C, D)

SHA-1 Algorithm Step 4: Cont’d Finally, when all 80 steps have been processed, set H0 = H0 + A H1 = H1 + B H2 = H2 + C H3 = H3 + D H4 = H4 + E

SHA-1 Algorithm Step 5: Output When all Mj have been processed, the 160-bit hash of M is available in H0, H1, H2, H3, and H4

SHA-1 Algorithm More information can be found in the Wikipedia page https://en.wikipedia.org/wiki/SHA-1 where several alternative implementations of the F(X, Y, Z) function are shown.

SHA-1 Algorithm As shown the Wikipedia page.

SHA-1 Algorithm As shown the Wikipedia page.

(provided by testbench) Module Interface Wait in idle state for start, read message starting at message_addr and write final hash {H0, H1, H2, H3, H4} in 5 words to memory starting at output_addr. message_addr and output_addr are word addresses. size is given in number of bytes (not necessarily multiples of 4). Set done to 1 when finished. Memory (provided by testbench) sha1 mem_clk mem_addr[15:0] mem_we mem_write_data [31:0] mem_read_data[31:0] memory interface clk reset_n message_addr[31:0] size[31:0] start done output_addr[31:0]

Module Interface Write the final hash {H0, H1, H2, H3, H4} in 5 words to memory starting at output_addr as follows: mem_addr <= output_addr; mem_write_data <= H0; mem_addr <= output_addr + 1; mem_write_data <= H1; ... mem_addr <= output_addr + 4; mem_write_data <= H4; Just write out H0, H1, etc, without any further byte swapping. output_addr H0 output_addr + 1 H1 output_addr + 2 H2 output_addr + 3 H3 output_addr + 4 H4

(provided by testbench) Module Interface Your assignment is to design the yellow box: module sha1(input logic clk, reset_n, start, input logic [31:0] message_addr, size, output_addr, output logic done, mem_clk, mem_we, output logic [15:0] mem_addr, output logic [31:0] mem_write_data, input logic [31:0] mem_read_data); ... endmodule Memory (provided by testbench) sha1 mem_clk mem_addr[15:0] mem_we mem_write_data [31:0] mem_read_data[31:0] memory interface clk reset_n message_addr[31:0] size[31:0] start done output_addr[31:0]

Disable Block Memories Altera Quartus will automatically replace some registers with block memories, which are not counted in the total number of registers. If you look at the Analysis & Synthesis Summary, you will see a Total block memory bits entry. If it is non-zero, it means block memories were allocated. To provide a common basis for comparison, you should disable the use of block memories. This can be done as follows: In the analysis and synthesis settings, there is an option for auto shift register replacement. Turning that off will disable the use of block memories.

Projects 3 and 4 Project 3: Two parts Determine the number of blocks Design a hash operation block Project 4: Design the entire sha1 module

Project 3: Part 1 Calculate the number of blocks (e.g., if size = 100 bytes, then we have 2 x 512-bit blocks) module calc_num_blocks(input logic [31:0] size, output logic [15:0] num_blocks); function logic [15:0] determine_num_blocks(input logic [31:0] size); ... determine_num_blocks = ...; endfunction assign num_blocks = determine_num_blocks(size); endmodule

Project 3: Part 2 Design a hash operation block module hash_block(input logic [31:0] a, b, c, d, e, w, input logic [7:0] t, output logic [159:0] hash); function logic [159:0] hash_op(input logic [31:0] a, b, c, d, e, w, input logic [7:0] t); ... hash_op = {a1, b1, c1, d1, e1}; endfunction assign hash = hash_op(a, b, c, d, e, w, t); endmodule

Project 3: Both Parts Both calc_num_blocks and hash_block are pure combinational logic modules. Therefore, no Fmax (clock period) will be computed because there will be no clocked flip-flops. Also, the hash_block module has many inputs and outputs, almost 350 “pins”. Therefore, the Fitter (Place & Route) will not work in Quartus since the FPGA device does not have that many pins, so you cannot it run the Fitter part of the compilation process, which is performed by default if you run “Start Compilation”. Instead, you should just run “Start -> Start Analysis & Synthesis” from the “Processing” menu for both parts in Project 3.

Project 4 Design the complete sha1 module module sha1(input logic clk, reset_n, start, input logic [31:0] message_addr, size, output_addr, output logic done, mem_clk, mem_we, output logic [15:0] mem_addr, output logic [31:0] mem_write_data, input logic [31:0] mem_read_data); ... endmodule

Testbenches Testbenches are provided for Projects 3 and 4