LAB#6 MAC & MASSAGE DIGEST CPIT 425. Message Authentication 2  Message authentication is a mechanism used to verify the integrity of a message.  Message.

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
Network Security: Lab#2 J. H. Wang Apr. 28, 2011.
Internet and Intranet Protocols and Applications Lecture 9a: Secure Sockets Layer (SSL) March, 2004 Arthur Goldberg Computer Science Department New York.
Digital Signatures and Hash Functions. Digital Signatures.
An Introduction to Security Concepts and Public Key Infrastructure (PKI) Mary Thompson.
Session 5 Hash functions and digital signatures. Contents Hash functions – Definition – Requirements – Construction – Security – Applications 2/44.
Lesson Title: Introduction to Cryptography Dale R. Thompson Computer Science and Computer Engineering Dept. University of Arkansas
EEC 693/793 Special Topics in Electrical Engineering Secure and Dependable Computing Lecture 6 Wenbing Zhao Department of Electrical and Computer Engineering.
Dr Alejandra Flores-Mosri Message Authentication Internet Management & Security 06 Learning outcomes At the end of this session, you should be able to:
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.
1 Information System Security AABFS-Jordan Summer 2006 Digital Signature and Hashing Functions Prepared by: Maher Abu Hamdeh & Adel Hamdan Supervised by:
Hash Functions Nathanael Paul Oct. 9, Hash Functions: Introduction Cryptographic hash functions –Input – any length –Output – fixed length –H(x)
CS526Topic 5: Hash Functions and Message Authentication 1 Computer Security CS 526 Topic 5 Cryptography: Cryptographic Hash Functions And Message Authentication.
Cryptography1 CPSC 3730 Cryptography Chapter 11, 12 Message Authentication and Hash Functions.
CRYPTOGRAPHIC DATA INTEGRITY ALGORITHMS
Csci5233 Computer Security1 GS: Chapter 6 Using Java Cryptography for Authentication.
31.1 Chapter 31 Network Security Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Acknowledgements: William Stallings.William Stallings All rights Reserved Session 4 Public Key Cryptography (Part 2) Network Security Essentials Application.
Message Authentication  message authentication is concerned with: protecting the integrity of a message protecting the integrity of a message validating.
Information Security Principles Assistant Professor Dr. Sana’a Wafa Al-Sayegh 1 st Semester ITGD 2202 University of Palestine.
8-1Network Security Chapter 8 roadmap 8.1 What is network security? 8.2 Principles of cryptography 8.3 Message integrity, authentication.
1 Chapter 11: Message Authentication and Hash Functions Fourth Edition by William Stallings Lecture slides by Lawrie Brown (modified by Prof. M. Singhal,
Cryptography, Authentication and Digital Signatures
IS 302: Information Security and Trust Week 5: Integrity 2012.
Message Authentication Code July Message Authentication Problem  Message Authentication is concerned with:  protecting the integrity of a message.
4 th lecture.  Message to be encrypted: HELLO  Key: XMCKL H E L L O message 7 (H) 4 (E) 11 (L) 11 (L) 14 (O) message + 23 (X) 12 (M) 2 (C) 10 (K) 11.
Introduction1-1 Data Communications and Computer Networks Chapter 6 CS 3830 Lecture 31 Omar Meqdadi Department of Computer Science and Software Engineering.
Fall 2002CS 395: Computer Security1 Chapter 11: Message Authentication and Hash Functions.
Network Security7-1 CIS3360: Chapter 8: Cryptography Application of Public Cryptography Cliff Zou Spring 2012 TexPoint fonts used in EMF. Read the TexPoint.
11.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 11 Message Integrity and Message Authentication.
Basic Cryptography Some examples taken from “Coding Theory and Cryptography, the essentials” Second Edition Hankerson, et.al. 2000, Marcel Dekker, Inc.
Advanced Database Course (ESED5204) Eng. Hanan Alyazji University of Palestine Software Engineering Department.
COMPS311F Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
31.1 Chapter 31 Network Security Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Digital Signatures, Message Digest and Authentication Week-9.
Cryptographic Hash Functions and Protocol Analysis
Lecture 2: Introduction to Cryptography
CIT 380: Securing Computer SystemsSlide #1 CIT 380: Securing Computer Systems Modern Cryptography.
Chapter 11 Message Authentication and Hash Functions.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Cryptography and Network Security Chapter 12 Fifth Edition by William Stallings Lecture slides by Lawrie Brown.
Authentication. Goal: Bob wants Alice to “prove” her identity to him Protocol ap1.0: Alice says “I am Alice” Failure scenario?? “I am Alice”
Cryptographic Hash Functions Prepared by Dr. Lamiaa Elshenawy
Cryptography and Network Security (CS435) Part Nine (Message Authentication)
Hash Functions Ramki Thurimella. 2 What is a hash function? Also known as message digest or fingerprint Compression: A function that maps arbitrarily.
1 Session 4 Module 6: Digital signatures. Digital Signatures / Session4 / 2 of 18 Module 4, 5 - Review (1)  Java 2 security model provides a consistent.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
CS426Fall 2010/Lecture 51 Computer Security CS 426 Lecture 5 Cryptography: Cryptographic Hash Function.
IT 221: Introduction to Information Security Principles Lecture 5: Message Authentications, Hash Functions and Hash/Mac Algorithms For Educational Purposes.
Lecture 22 Network Security (cont) CPE 401 / 601 Computer Network Systems slides are modified from Dave Hollinger slides are modified from Jim Kurose,
Cryptography Hyunsung Kim, PhD University of Malawi, Chancellor College Kyungil University February, 2016.
Security. Security Needs Computers and data are used by the authorized persons Computers and their accessories, data, and information are available to.
CRYPTOGRAPHY Cryptography is art or science of transforming intelligible message to unintelligible and again transforming that message back to the original.
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.
LAB#4 PROGRAMMING USING JAVA CRYPTOGRAPHIC LIBRARIES CPIT 425.
Information and Computer Security CPIS 312 Lab 9
Java Assignment Related
Lab#7 Digital signature Cpit 425
Computer Communication & Networks
Cryptographic Hash Function
CSCE 715: Network Systems Security
NET 311 Information Security
Chapter -7 CRYPTOGRAPHIC HASH FUNCTIONS
Hashing Hash are the auxiliary values that are used in cryptography.
One-way Hash Function Network Security.
Secret-Key Encryption
Presentation transcript:

LAB#6 MAC & MASSAGE DIGEST CPIT 425

Message Authentication 2  Message authentication is a mechanism used to verify the integrity of a message.  Message authentication assures that:  The data received are exactly as sent by (contain no modification, insertion …).  The purported identity of the sender is valid.  The two most common cryptographic techniques for message authentication are:  Message Authentication Code (MAC)  Secure hash function

Message Authentication Code MAC 3  MAC is an algorithm that requires the use of a secret key.  MAC takes a variable-length message and a secret key as input and produces an authentication code.  Typically, message authentication codes are used between two parties, say Alice and Bob, that share a secret key K in order to validate information transmitted between these parties.  When Alice has a message to send to Bob, she calculates the MAC as a function of the message and the key:  MAC = C(K, M) where M=input message, C=MAC function, K=shared secret key.

Message Authentication Code MAC 4  Alice sends to Bob a document as well as a MAC. Bob can authenticate who sent the document by performing the same MAC on the document and comparing his MAC to the one that Alice sent. If they match, he knows that Alice sent the document. diamond icon represents a comparison process

Message Authentication Code MAC in Java 5  Java Package: javax.crypto  Java Class : Mac  Methods: getInstance(), init(), update(), doFinal().  Algorithms: HMAC (Hashed MAC) functions supported by JCE:  HmacMD5 and HmacSHA1

Message Digests 6  As with MAC, a hash function accepts a variable- size message M as input and produces a fixed-size output referred to as a hash code(message digest).  Unlike MAC, a hash code does not use a key but is a function only of the input message.  Message digest: Given a message M of arbitrary length, a public function (i.e. hash function) H will produce a fixed-sized output called message digest or hash value h by a function of the form h=H(M).  message (M)  hashing algorithm(H)  digest (h)

Message Digests in Java 7  Java package: java.security  Java class: MessageDigest  Methods: getInstance(), reset(), update(), digest().  Algorithms: MD5, SHA, SHA-1

Message Digests in Java 8  MessageDigest getInstance(String algorithm) Generates a MessageDigest object that implements the specified digest algorithm.  byte[] digest() Completes the hash computation by performing final operations.  byte[] digest(byte[] input) Performs a final update on the digest using the specified array of bytes, then completes the digest computation.  void update(byte[] input) Updates the digest using the specified array of bytes.  void reset() Resets the digest for further use.

Message Digests in Java 9  MessageDigest Class: A MessageDigest object starts out initialized. 1. The data is processed through it using the update methods. 2. Once all the data to be updated has been updated, one of the digest methods should be called once to complete the hash computation. 3. After digest has been called, the MessageDigest object is reset to its initialized state.  Ex: MessageDigest sha = MessageDigest.getInstance("SHA-1"); sha.update(data1); // data1 is a byte array that holds the original massage byte[] msgDigest = sha.digest(); sha.reset(); sha.update(data2);....

Message Digests in Java 10 Alternative classes for computing a message digest on a file: DigestInputStream and DigestOutputStream  Java pakage: java.security  DigestInputStream class:  To complete the message digest computation, call one of read methods. Then call one of the digest methods on the associated message digest.  int read() : Reads a byte, and updates the message digest and then return an integer value of the byte that it read.  Ex: FileInputStream in = new FileInputStream("MD.txt"); MessageDigest md = MessageDigest.getInstance("MD5"); DigestInputStream digestIn = new DigestInputStream(in, md);

Message Digests in Java 11  Java pakage: java.security  DigestOutputStream  To complete the message digest computation, call one of the digest methods on the associated message digest after that call one of the write methods.  void write(byte[] b) : Updates the message digest using the specified array, and in any case writes the array to the output stream.  Ex: MessageDigest md = MessageDigest.getInstance("MD5"); FileOutputStream out = new FileOutputStream("MDout.txt"); DigestOutputStream dout = new DigestOutputStream(out, md);

LAB WORK 12  Write a program that implements Massage Digest using MD5 and SHA-1 algorithms. For each algorithm, digests different string and notice the size of the output. Note: Size of the output digest (SHA-1: 20 bytes MD5: 16 bytes)

HOMEWORK#3 13 write a client/server program that uses the message digest. The Client.java file creates an MD5 message digest, reads a massage from a file (MD.txt) and displays the massage digest in another file (MDout.txt) then displays the contents and the size of the digest array on the standard output. The Server.java file creates an MD5 message digest and reads the massage from a file (MD.txt). Then it reads the message digest that is created by the client side from MDout.txt to compare it with the message digest created by the server side. If they are equal, the server will display “The two message digest are matched ”, else the server will display “The two message digest are not matched”. (NOTE: use DigestInputStream and DigestOutputStream classes to solve the homework)

HOMEWORK#3 14  Submit the following(hard copy + soft copy): 3 programs(MAC, lab work, HW#2)+ output of each one+ txt files (MD.txt + MDout.txt)  Due date: next lab   continue in the next slide

HOMEWORK#3 15  Read this text from the input file (MD.txt): A message digest or hash function is used to turn input of arbitrary length into an output of fixed length, which is called the digest or hash of the input. This output can then be used in place of the original input. This has many advantages. The output always has the same length, so this can be taken into account when processing or storing the message digest. Also, the output is much shorter than the input, so that processing and storing can be done much quicker. The most common cryptographic hash function is MD5. MD5 was designed by well-known cryptographer Ronald Rivest in In 2004, some serious flaws were found in MD5. The complete implications of these flaws has yet to be determined. Another popular hash function is SHA-1.