130 likes | 248 Views
MD5 Cryptographic Hash. Team Rogue VI Jile Gao(jxg3950@rit.edu) Matthew Allen(mma3543@rit.edu. Agenda. MD5 Primitive Original Design Original Measurements Analysis Revised Design Revised Measurements Revised Analysis What we learned? Discussion of future work Questions.
E N D
MD5 Cryptographic Hash Team Rogue VI Jile Gao(jxg3950@rit.edu) Matthew Allen(mma3543@rit.edu
Agenda • MD5 Primitive • Original Design • Original Measurements • Analysis • Revised Design • Revised Measurements • Revised Analysis • What we learned? • Discussion of future work • Questions
The MD5 Primitive • Written by R Rivest at MIT in 1991 • MD5 replaces MD4 • Accepts a message of arbitrary length and outputs a 128 bit digest/signature • Designed to be fast on 32 bit machines • No large S-Tables
Original Design • Used the reference implementation to decipher the spec • Static Object • Read in from file in 1024 byte chunks and processed in 64 byte smaller chunks • Each chunk is transformed to four 32 bit ints that are used as part of the next transform • The last chunk is different • The final digest is the last four ints output from transform in low to high bit sequence
Original Measurements • Bad… Just plain BAD • Longer than 12 hours run time(14400ms per) • Redesigned to remove the IO problems and just work with the encrypts • 3000000 in 114.432s or 38.14ms per • Arraycopy was the worst offender(42.5%) • Transform was next at 19.3%
Analysis • Nothing we can do with arraycopy other than find a way to stop copying so much • Several times in the implementation there are new arrays created • There are only four rounds so it can’t be unrolled
Revised Design • Turned into a dynamic object • Turned state array into state variables • Removed array creation from functions • Unrolled I from II(etc)(inlined) • Inlined the bitwise rotates
Revised Measurements • Much better • 3000000 in 92.724 or 30.90ms per • Roughly a 20% increase in performance
Revised Analysis • The inlining of the rotates and I(etc) functions greatly helped • Transform is the only user modifiable function with high percentages and is about as optimized as possible • Arraycopy is non-controllable • Arraycopy 55.1% of results • Transform 21.3% of results
What we learned? • Inlining reduces the number of method calls and speeds up processing • Converting arrays to variables reduces the number of repeated memory allocations • The spec is convoluted and potentially difficult to understand • The reference implementation is useful in translating the spec • The profiler didn’t point out anything useful
Discussion of future work • Unrolling the decode function • For the truly insane, inline the FF, GG, HH and II functions inside transform
Review • MD5 Primitive • Original Design • Original Measurements • Analysis • Revised Design • Revised Measurements • Revised Analysis • What we learned? • Discussion of future work