Computer Science 320 Massive Parallelism. Example Problem: Breaking a Cipher Somehow obtain a sample plaintext and its ciphertext Then search for the.

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Formal Language, chapter 4, slide 1Copyright © 2007 by Adam Webber Chapter Four: DFA Applications.
Q1 Review. Other News US News top CS Universities global-universities/computer- science?int=994b08.
Graohics CSC 171 FALL 2001 LECTURE 16. History: COBOL Conference on Data System Languages (CODASYL) - led by Joe Wegstein of NBS developed the.
Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
A Java API Package java.security  The Java Security Package contains classes and interfaces that are required by many Java programs.  This package is.
Lecture 27 Exceptions COMP1681 / SE15 Introduction to Programming.
Arrays Horstmann, Chapter 8. arrays Fintan Array of chars For example, a String variable contains an array of characters: An array is a data structure.
1 TP #4 n Last TP exercises solved; n Parsing command line arguments; n Static; n Wrapper classes for primitive types; n Package visibility.
Jan Art of Programming Yangjun Chen Dept. Business Computing University of Winnipeg.
Csci5233 Computer Security1 GS: Chapter 5 Asymmetric Encryption in Java.
Hybrid Cipher encryption Plain Text Key Cipher Text Key Plain Text IV Hybrid Cipher decryption Hybrid Cipher Note: IV used in encryption is not used in.
Options for User Input Options for getting information from the user –Write event-driven code Con: requires a significant amount of new code to set-up.
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Lecture 3: Cryptographic Tools modified from slides of Lawrie Brown.
Java supports encryption by a wide variety of packages: The standard java.security package The standard javax.crypto package Packages supplied by third.
Block Cipher Transmission Modes CSCI 5857: Encoding and Encryption.
Example 1 :- Handling integer values public class Program1 { public static void main(String [] args) { int value1, value2, sum; value1 = Integer.parseInt(args[0]);
A Bridge to Your First Computer Science Course Prof. H.E. Dunsmore Concurrent Programming Threads Synchronization.
General Features of Java Programming Language Variables and Data Types Operators Expressions Control Flow Statements.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Monitor's Secret Key Crypto - KARN, encrypt 512 bit Secret.
CSE 131 Computer Science 1 Module 1: (basics of Java)
Chapter 9 1 Chapter 9 – Part 1 l Overview of Streams and File I/O l Text File I/O l Binary File I/O l File Objects and File Names Streams and File I/O.
Exceptions. Exception Abnormal event occurring during program execution Examples –Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Password authentication Basic idea –User has a secret password –System checks password to authenticate user Issues –How is password stored? –How does system.
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington 2D arrays COMP 102 # T1.
1 Week 12 l Overview of Streams and File I/O l Text File I/O Streams and File I/O.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
2.1 Functions Introduction to Programming in Java: An Interdisciplinary Approach · Robert Sedgewick and Kevin Wayne · Copyright © 2008 · 9/10/08 9/10/08.
Introduction to Java Lecture Notes 3. Variables l A variable is a name for a location in memory used to hold a value. In Java data declaration is identical.
Recap of Functions. Functions in Java f x y z f (x, y, z) Input Output Algorithm Allows you to clearly separate the tasks in a program. Enables reuse.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Computer Science 320 Introduction to Hybrid SMP/Clusters.
Computer Science 320 Reduction. Estimating π Throw N darts, and let C be the number of darts that land within the circle quadrant of a unit circle Then,
More loops while and do-while. Recall the for loop in general for (initialization; boolean_expression; update) { }
1 Homework –Continue Reading K&R Chapter 2 –We’ll go over HW2 at end of class today –Continue working on HW3 Questions?
Review TEST 2 Chapters 4,5,7. QUESTION For which type of operands does the == operator always work correctly: (a) int, (b) double, or (c) String?
DES Analysis and Attacks CSCI 5857: Encoding and Encryption.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
Peter Andreae Computer Science Victoria University of Wellington Copyright: Peter Andreae, Victoria University of Wellington 2D arrays COMP 102 # T1.
Exceptions. Exception  Abnormal event occurring during program execution  Examples Manipulate nonexistent files FileReader in = new FileReader("mumbers.txt“);
CSC 298 Streams and files.
Computer Science 320 A First Program in Parallel Java.
Chapter 5 : Methods Part 2. Returning a Value from a Method  Data can be passed into a method by way of the parameter variables. Data may also be returned.
int [] scores = new int [10];
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
Cipher Transmission and Storage Modes Part 2: Stream Cipher Modes CSCI 5857: Encoding and Encryption.
A Introduction to Computing II Lecture 1: Java Review Fall Session 2000.
Midterm Review Tami Meredith. Primitive Data Types byte, short, int, long Values without a decimal point,..., -1, 0, 1, 2,... float, double Values with.
Computer Science 320 Barrier Actions. 1-D Continuous Cellular Automata 1-D array of cells, each having a value between 0.0 and 1.0 Each cell has a neighborhood.
Computer Science 320 Cache Interference. Unexpected Performance The testing of the partial key search SMP program produced anomalous results In particular,
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
Exception and Exception Handling. Exception An abnormal event that is likely to happen during program is execution Computer could run out of memory Calling.
Object Oriented Programming Lecture 2: BallWorld.
Command Line Arguments
An Introduction to Java – Part I
Operators Laboratory /11/16.
An Introduction to Java – Part I, language basics
Rivest, Shamir and Adleman
Java so far Week 7.
CSE 214 – Computer Science II Stack Applications
class PrintOnetoTen { public static void main(String args[]) {
Scope of variables class scopeofvars {
Presentation transcript:

Computer Science 320 Massive Parallelism

Example Problem: Breaking a Cipher Somehow obtain a sample plaintext and its ciphertext Then search for the AES key, using encrypt(pt, k) Exhaustive search might examine potentially or possible values, requiring more time than the lifetime of the universe

Partial Key Search Work with a partial key having, say, all but at most the least significant 30 bits known Solve for just these bits by an exhaustive search Inputs: plaintext, ciphertext (128 bits each), key (256 bits), and the number of bits for which to solve

Generate a Random, 256-Bit Key import edu.rit.util.Hex; import java.security.SecureRandom; public class MakeKey{ public static void main(String[] args) throws Exception{ System.out.println(Hex.toString(SecureRandom.getSeed(32))); } Use SecureRandom to get a 256-bit number from the system’s entropy source file java.util.Random uses only 48 bits

Generate a Plaintext and Ciphertext import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class Encrypt{ public static void main(String[] args) throws Exception{ // Parse command line arguments. if (args.length != 3) usage(); String message = args[0]; byte[] key = Hex.toByteArray(args[1]); int n = Integer.parseInt(args[2]); Inputs: a plaintext (string), a key (hex string), and the number of bits to zero out (digit string)

Generate a Plaintext and Ciphertext import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class Encrypt{ public static void main(String[] args) throws Exception{ // Set up plaintext block. byte[] msg = message.getBytes(); byte[] block = new byte [16]; System.arraycopy(msg, 0, block, 0, Math.min(msg.length, 16)); System.out.println(Hex.toString(block));

Generate a Plaintext and Ciphertext import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class Encrypt{ public static void main(String[] args) throws Exception{ // Set up plaintext block. byte[] msg = message.getBytes(); byte[] block = new byte [16]; System.arraycopy(msg, 0, block, 0, Math.min(msg.length, 16)); System.out.println(Hex.toString(block)); // Encrypt plaintext. AES256Cipher cipher = new AES256Cipher(key); cipher.encrypt(block); System.out.println(Hex.toString(block));

Generate a Plaintext and Ciphertext import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class Encrypt{ public static void main(String[] args) throws Exception{ // Wipe out n least significant bits of the key. int off = 31; int len = n; while (len >= 8){ key[off] = (byte) 0; -- off; len -= 8; } key[off] &= mask[len]; System.out.println(Hex.toString(key)); System.out.println(n); }

Sequential Key Search Program import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class FindKeySeq{ // Command line arguments. static byte[] plaintext; static byte[] ciphertext; static byte[] partialkey; static int n; // Variables for doing trial encryptions. static int keylsbs; static int maxcounter; static byte[] foundkey; static byte[] trialkey; static byte[] trialciphertext; static AES256Cipher cipher; Inputs: plaintext, ciphertext, key (hex strings), and number of bits (digit string > 0 and < 30)

Sequential Key Search Program import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class FindKeySeq{ public static void main(String[] args){ // Parse command line arguments. if (args.length != 4) usage(); plaintext = Hex.toByteArray (args[0]); ciphertext = Hex.toByteArray (args[1]); partialkey = Hex.toByteArray (args[2]); n = Integer.parseInt (args[3]);

Sequential Key Search Program import edu.rit.util.Hex; import edu.rit.crypto.blockcipher.AES256Cipher; public class FindKeySeq{ public static void main(String[] args){ // Set up variables for doing trial encryptions. keylsbs = ((partialkey[28] & 0xFF) << 24) | ((partialkey[29] & 0xFF) << 16) | ((partialkey[30] & 0xFF) << 8) | ((partialkey[31] & 0xFF) ); maxcounter = (1 << n) - 1; trialkey = new byte[32]; System.arraycopy(partialkey, 0, trialkey, 0, 32); trialciphertext = new byte [16]; cipher = new AES256Cipher(trialkey);

Sequential Key Search Program // Try every possible combination of low-order key bits. for (int counter = 0; counter <= maxcounter; ++ counter){ // Fill in low-order key bits. int lsbs = keylsbs | counter; trialkey[28] = (byte) (lsbs >>> 24); trialkey[29] = (byte) (lsbs >>> 16); trialkey[30] = (byte) (lsbs >>> 8); trialkey[31] = (byte) (lsbs ); // Try the key. cipher.setKey(trialkey); cipher.encrypt(plaintext, trialciphertext); // If the result equals the ciphertext, we found the key. if (match(ciphertext, trialciphertext)){ foundkey = new byte[32]; System.arraycopy(trialkey, 0, foundkey, 0, 32); }

Sequential Key Search Program /** * Returns true if the two byte arrays match. */ private static boolean match(byte[] a, byte[] b){ boolean matchsofar = true; int n = a.length; for (int i = 0; i < n; ++ i) matchsofar = matchsofar && a[i] == b[i]; return matchsofar; }

Massively Parallel Problem If we had 2 n processors, each one could try a key simultaneously We must clump the search space into subranges and dispatch these to parallel for loops Also called embarrassingly parallel