A nice outline of the RSA algorithm and implementation can be found at:

Similar documents
LAB: Public-Key Encryption

Public Key Cryptography and the RSA Cryptosystem

Davenport University ITS Lunch and Learn February 2, 2012 Sneden Center Meeting Hall Presented by: Scott Radtke

Cryptography Symmetric Cryptography Asymmetric Cryptography Internet Communication. Telling Secrets. Secret Writing Through the Ages.

Great Theoretical Ideas in Computer Science. Lecture 27: Cryptography

Introduction to Cryptography and Security Mechanisms. Abdul Hameed

Overview. Public Key Algorithms I

Dr. Jinyuan (Stella) Sun Dept. of Electrical Engineering and Computer Science University of Tennessee Fall 2010

Public Key Encryption. Modified by: Dr. Ramzi Saifan

Channel Coding and Cryptography Part II: Introduction to Cryptography

Public Key Cryptography

Public Key Algorithms

Introduction to Cryptography and Security Mechanisms: Unit 5. Public-Key Encryption

Chapter 3 Public Key Cryptography

Cryptography and Network Security. Sixth Edition by William Stallings

Outline. Public Key Cryptography. Applications of Public Key Crypto. Applications (Cont d)

CSCI 454/554 Computer and Network Security. Topic 5.2 Public Key Cryptography

ASYMMETRIC CRYPTOGRAPHY

Applied Cryptography and Computer Security CSE 664 Spring 2018

Outline. CSCI 454/554 Computer and Network Security. Introduction. Topic 5.2 Public Key Cryptography. 1. Introduction 2. RSA

LECTURE 4: Cryptography

NUMB3RS Activity: Creating Codes. Episode: Backscatter

RSA: PUBLIC KEY ALGORITHMS

Public Key Cryptography and RSA

Admin ENCRYPTION. Admin. Encryption 10/29/15. Assignment 6. 4 more assignments: Midterm next Thursday. What is it and why do we need it?

Modern Cryptography Activity 1: Caesar Ciphers

Lecture 6: Overview of Public-Key Cryptography and RSA

Chapter 9. Public Key Cryptography, RSA And Key Management

CSC 474/574 Information Systems Security

Chapter 9 Public Key Cryptography. WANG YANG

Public Key Algorithms

RSA (algorithm) History

RSA (material drawn from Avi Kak Lecture 12, Lecture Notes on "Computer and Network Security" Used in asymmetric crypto.

Project Report. Title: Finding and Implementing Auto Parallelization in RSA Encryption and Decryption Algorithm

Assignment 9 / Cryptography

Cryptographic Techniques. Information Technologies for IPR Protections 2003/11/12 R107, CSIE Building

Key Exchange. Secure Software Systems

Math From Scratch Lesson 22: The RSA Encryption Algorithm

RSA. Public Key CryptoSystem

Computer Security. 08. Cryptography Part II. Paul Krzyzanowski. Rutgers University. Spring 2018

What did we talk about last time? Public key cryptography A little number theory

CS669 Network Security

Encryption à la Mod Name

CS Lab 11. Today's Objectives. Prime Number Generation Implement Diffie-Hellman Key Exchange Implement RSA Encryption

Distributed Systems. 26. Cryptographic Systems: An Introduction. Paul Krzyzanowski. Rutgers University. Fall 2015

Cryptography (DES+RSA) by Amit Konar Dept. of Math and CS, UMSL

Cryptography. How to Protect Your Data

Security in Distributed Systems. Network Security

Computer Security 3/23/18

Cryptography Worksheet

3/22/17. Admin. Assignment 6 ENCRYPTION. David Kauchak CS52 Spring Survey: How is the class going? Survey: respondents. 24 total respondents

Lecture IV : Cryptography, Fundamentals

An overview and Cryptographic Challenges of RSA Bhawana

Understanding Cryptography A Textbook for Students and Practitioners by Christof Paar and Jan Pelzl. Chapter 6 Introduction to Public-Key Cryptography

The Application of Elliptic Curves Cryptography in Embedded Systems

Issues in Information Systems Volume 18, Issue 2, pp , 2017

CS Network Security. Nasir Memon Polytechnic University Module 7 Public Key Cryptography. RSA.

Secrets & Lies, Knowledge & Trust. (Modern Cryptography) COS 116 4/20/2006 Instructor: Sanjeev Arora

RSA Public Key Encryption 1. Ivor Page 2

Cryptographic Concepts

Senior Math Circles Cryptography and Number Theory Week 1

Lecture 2 Applied Cryptography (Part 2)

Algorithms (III) Yijia Chen Shanghai Jiaotong University

Hardware Design and Software Simulation for Four Classical Cryptosystems

Enhanced Asymmetric Public Key Cryptography based on Diffie-Hellman and RSA Algorithm

CS 332 Computer Networks Security

Algorithms (III) Yijia Chen Shanghai Jiaotong University

Introduction to Cryptography Lecture 7

Algorithms (III) Yu Yu. Shanghai Jiaotong University

LECTURE NOTES ON PUBLIC- KEY CRYPTOGRAPHY. (One-Way Functions and ElGamal System)

Cryptography. What is Cryptography?

Recovery. Independent Checkpointing

CPSC 467b: Cryptography and Computer Security

CS 6324: Information Security More Info on Key Establishment: RSA, DH & QKD

CRYPTOGRAPHY & DIGITAL SIGNATURE

Hybrid Public Key Cryptosystem Combining RSA & DES Algorithms

Number Theory and RSA Public-Key Encryption

Spring 2008, CSC395 Special Topics: Information Security Project 3

Some Stuff About Crypto

Cryptography: Matrices and Encryption

Public Key Algorithms

Cryptography. Cryptography is much more than. What is Cryptography, exactly? Why Cryptography? (cont d) Straight encoding and decoding

Math236 Discrete Maths with Applications

VHDL for RSA Public Key System

Public-key encipherment concept

The Hill Cipher. In 1929 Lester Hill, a professor at Hunter College, published an article in the American

Chapter 8 Security. Computer Networking: A Top Down Approach. 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012

Introduction. CSE 5351: Introduction to cryptography Reading assignment: Chapter 1 of Katz & Lindell

Public-Key Cryptography. Professor Yanmin Gong Week 3: Sep. 7

Cryptography on MSX Fubswrjudskb rq PVZ

CS1800 Discrete Structures Summer 2017 Prof. Schnyder May 26, CS1800 Discrete Structures Midterm Practice Exam

ECE 646 Fall 2009 Final Exam December 15, Multiple-choice test

Introduction to Cryptography Lecture 7

IMPORTANCE OF NUMBER THEORY IN CRYPTOGRAPHY

Provable Partial Key Escrow

A Tour of Classical and Modern Cryptography

Topics. Number Theory Review. Public Key Cryptography

CS 161 Computer Security

Introduction to cryptography

Keywords Security, Cryptanalysis, RSA algorithm, Timing Attack

Transcription:

Cryptography Lab: RSA Encryption and Decryption Lab Objectives: After this lab, the students should be able to Explain the simple concepts of encryption and decryption to protect information in transmission. Explain the concepts of cryptography, symmetric key, public keys and private keys used in practice. Write programs that encrypt and decrypt data files using RSA cryptography algorithm. Definitions: Public key encryption is a method where two keys are generated, one to encrypt the message and another to decrypt the message. The encryption key is available to everyone. That is anyone can generate an encrypted message for a specific receiver. However, the decrypt key is kept secret. Only the holders of the decryption key can un-encrypt the cipher text. The RSA encryption algorithm was first publicly described by Ron Rivest, Adi Shamir and Leonard Aldeman in 1978. RSA is a popular public key encryption algorithm. It uses two secret prime numbers and properties of modulus arithmetic to generate both the public and private keys. A nice outline of the RSA algorithm and implementation can be found at: http://www.dimgt.com.au/rsa_alg.html More generally, the public key consists of two values: (e, n) where the plain text message, m, is encrypted (cipher text c) via the following formula: The private key consists of two values (d,n), where the encrypted text c is decrypted by the following formula m= c d mod n These algorithms is based on the theorems of modulus arithmetic.

Outline of work: You are to create 3 programs: 1. Key generation program Input:?? Output: integers : public key, integers : private key 2. Encryption program Input: integers : public key string : plain text message Output string: encrypted message 3. Decryption program Input: integers : private key string : encrypted message Output: string: plain text message In your write-up, just be clear on what I need to do to compile and run these. Key generation program Generation of the keys is imitated with the selection of two large prime numbers, p and q. A requirement can sometimes be that the product of these numbers is 1024 bits long. Obviously, the longer the numbers the more difficult it will be to break this encryption. A suggestion is to pick two different primes between small ranges, like 137 311. Randomly pick a number, test for prime, increase the number if it is not prime. The values of the algorithm are built from these two prime numbers. n is the product of these two numbers. n = pq e is built as follows: o z is the product of one less than each of these two numbers. z = (p-1)(q-1) o Choose e such that 1 < e < z And gcd(e,z) = 1 Note from David Ireland (above link):

In practice, common choices for e are 3, 17 and 65537 (216+1). The2 x se are Fermat primes, sometimes referred to as F0, F2 and F4 respectively (Fx=2 2x +1). They are chosen because they make the modular exponentiation operation faster. Also, having chosen e, it is simpler to test whether gcd(e, p-1)=1 and gcd(e, q-1)=1 while generating and testing the primes in step 1. Values of p or q that fail this test can be rejected there and then. (Even better: if e is prime and greater than 2 then you can do the less-expensive test (p mod e)!=1 instead of gcd(p-1,e)==1.) Choose d such that 1 < d < z And ed mod z = 1 Note from David Ireland (above link): To compute the value for d, use the Extended Euclidean Algorithm to calculate d = e -1 mod phi, also written d = (1/e) mod phi. This is known as modular inversion. Note that this is not integer division. The modular inverse d is defined as the integer value such that ed = 1 mod phi. It only exists if e and phi have no common factors. PUBLIC KEY : (e, n) PRIVATE KEY : (d, n) Encryption program Procedure to encrypt and decipher: To encrypt a string message M, it is first converted into message blocks M1, M2,, Mn (each block can consist of 1 to some number k of characters). Then each message block Mi is mapped to an integer mi (by an array for example). From mi we calculate the cipher text, ci, as described in Definitions section. The public key consists of two values: (e, n) where the plain text message, m, is encrypted (cipher text c) via the following formula: Decryption program Procedure to encrypt and decipher: To encrypt a string message M, it is first converted into message blocks M1, M2,, Mn (each block can consist of 1 to some number k of characters). Then each message block Mi is mapped to an integer Pi (by an array for example). From Pi we calculate Cipheri as described in Definitions section: The public key consists of two values: (e, n) where the plain text message, m, is encrypted (cipher text c) via the following formula: NOTES:

I have read where a block of two characters was used. Each character is assigned to a numerical value in an array : A 0; B 1, Z 25, a 26, z 51, 52,. 53 Each two character block now is represented by two integers x1 and x2. These two characters are then mapped to a intermediary value P where P = x1*100 + x2 The cipher text is calculated over P. Ex : ID is mapped I8, D3. P is now 803 Cipher text = 803 e mod n I have also read where a block of three characters was used. The following is copied from Dr. Arjan Durresi, Louisiana State University ENCODING: Split the plaintext up into blocks of three letters (called trigraphs). Obtain a numeric representation for each letter based on its position in the alphabet (A 0, B 1, etc.). Compute a numeric code for each trigraph using the formula (First Letter Code) * 26 2 + (Second Letter Code) * 26 + (Third Letter code). For the mathematically inclined, this is interpreting each trigraph as a number in base twenty-six. Encipher each plaintext trigraph code by computing (Plaintext trigraph code)public Key, dividing the result by the Modulus and taking the remainder. Convert each enciphered trigraph code into a quadragraph a block of four letters as follows: o Divide the code by 26 3. The quotient is the code for the first letter of the quadragraph. The spreadsheet uses the remainder to get codes for the other three letters. o Divide the remainder from the first step by 26 2. The quotient is the code for the second letter. The spreadsheet uses the remainder to get the codes for the other two letters. o Divide the remainder from the second step by 26. The quotient is the code for the third letter and the remainder is the code for the fourth letter. For the mathematically inclined, this quadragraph calculation determines the representation of the enciphered message as a four-digit number in base twenty-six (using the letters of the alphabet as our digits).

DECODING Split the ciphertext up into quadragraphs (instead of trigraphs). Obtain the numeric representation for each letter and compute a numeric code for each trigraph using the formula (First Letter Code) * 26 3 + (Second Letter Code) * 26 2 + (Third Letter Code) * 26 + (Fourth Letter Code). Encipher each ciphertext quadragraph code by computing (Ciphertext quadragraph code) Private Key, dividing the result by the Modulus and taking the remainder Convert each deciphered quadragraph code into a trigraph. o Divide the code by 26 2. The quotient is the code for the first letter. o Divide the remainder from the first step by 26. The quotient will be the code for the second letter and the remainder the code for the third. HINT: It s easiest to do this in Java. Use the class BigInteger() to handle the math. I don t know the equivalent in C++ or C. There are some equivalent algorithms out there though.