90 likes | 193 Views
Computer Science 320. Introduction to Hybrid SMP/ Clusters. Massively Parallel AES Key Search. Inputs: 128-bit plain text block 128-bit cipher text block 256-bit key with N lower-order bits missing N, the number of missing lower-order key bits Output: The correct key to encode the text
E N D
Computer Science 320 Introduction to Hybrid SMP/Clusters
Massively Parallel AES Key Search • Inputs: • 128-bit plain text block • 128-bit cipher text block • 256-bit key with N lower-order bits missing • N, the number of missing lower-order key bits • Output: The correct key to encode the text • Method: try all 2N possible missing bit strings to find the key that does encrypt the plain text correctly
Sequential Version for (intcntr = 0; cntr < maxcount; ++cntr){ // Try key } Tries up to 2N possible keys
SMP Version new ParallelTeam().execute(new ParallelRegion(){ public void run() throws Exception{ execute(0, maxcounter, new IntegerForLoop(){ public void run(){ for (intcntr = first; cntr <= last; ++cntr){ // Try key } } }); } }); Splits 2N possible keys evenly among K threads
Cluster Version Range chunk = new Range(0, maxcounter – 1).subrange(size, rank); int lb = chunk.lb(); int ub = chunk.ub(); for (int cntr = lb; cntr <= ub; ++cntr){ // Try key } Splits 2N possible keys evenly among K nodes
Hybrid Version Range chunk = new Range(0, maxcounter – 1).subrange(size, rank); int lb = chunk.lb(); int ub = chunk.ub(); new ParallelTeam().execute(new ParallelRegion(){ public void run() throws Exception{ execute(lb, ub, new IntegerForLoop(){ public void run(){ for (int cntr = first; cntr <= last; ++cntr){ // Try key } } }); } }); Splits 2N possible keys evenly among Kp nodes * Kt threads per node
Specify # Nodes and # Threads Range chunk = new Range(0, maxcounter – 1).subrange(size, rank); int lb = chunk.lb(); int ub = chunk.ub(); new ParallelTeam().execute(new ParallelRegion(){ public void run() throws Exception{ execute(lb, ub, new IntegerForLoop(){ public void run(){ for (int cntr = first; cntr <= last; ++cntr){ // Try key } } }); } }); $ java –Dpj.port=28000 –Dpj.np=8 -Dpj.nt=8 . . .
Improvement: Early Return for (intcntr = first; cntr <= last; ++cntr){ intlsbs = keylsbs | cntr; trialKey[28] = (byte) (lsbs >>> 24); trialKey[29] = (byte) (lsbs >>> 16); trialKey[30] = (byte) (lsbs >>> 8); trialKey[31] = (byte) (lsbs ); cipher.setKey(trialKey); cipher.encrypt(plainText, trialciphertext); if (match(ciphertext, trialciphertext)){ foundKey = new byte[32] System.arraycopy(trialkey, 0, foundkey, 0, 32); } } . . . if (foundKey != null) System.out.println(Hex.toString(foundkey)); Would like to quit this thread, other threads in the same node, and other nodes early, when the correct key is found
Improvement: Sizeup for (intcntr = first; cntr <= last; ++cntr){ intlsbs = keylsbs | cntr; trialKey[28] = (byte) (lsbs >>> 24); trialKey[29] = (byte) (lsbs >>> 16); trialKey[30] = (byte) (lsbs >>> 8); trialKey[31] = (byte) (lsbs ); cipher.setKey(trialKey); cipher.encrypt(plainText, trialciphertext); if (match(ciphertext, trialciphertext)){ foundKey = new byte[32] System.arraycopy(trialkey, 0, foundkey, 0, 32); } if (foundKey != null) System.out.println(Hex.toString(foundkey)); Would also like to extend the size of N beyond 30 bits