class 25: reversing reverse
DESCRIPTION
Reverse Engineeringlist-reverseAnalyzing running time and spacemlist-reverse!TRANSCRIPT
Class 25: Reversing Reverse
cs1120 Fall 2011David Evans21 October 2011
2
Reverse Engineering
Forward (Normal) Engineering
What you Want Design a Solution
Reverse Engineering
Some ArtifactUnderstand how it works
48-bit LFSR
f( )∙
RNG
Challenge Key stream
ID
+
Response
++
48-bit stream cipherMutual authentication protocol
Note: when the artifact you start with is natural, this is called “science”!
3
Reversing Crypto Circuits
Pictures from Karsten Nohl (UVa CpE PhD 2009)
500x Magnification Microscope
4
Chip Logic Layer
4 NAND: Y = !(A & B & C & D)
5
(Mostly) Automated Analysis
Identify Logic Gates Trace Wires Connecting Them
48-bit LFSR
f( )∙
RNG
Challenge Key stream
ID
+
Response
++
48-bit stream cipherMutual authentication
protocol
7
8
Plan
Review: list-reverse(Forward and Reversing) mlist-reverse!Forward and Reverse Lists (Doubly-Linked Lists)
I still have unclaimed Exams! I will start charging exam storage fees Monday.Note: if you want to reverse engineering my storage fees protocol, you could try waiting later (but I don’t recommend it!)
9
Reversing
10
Analyzing list-reverse(define (list-reverse p) (if (null? p) null (list-append (list-reverse (cdr p)) (list (car p)))))
11
Reversing(define (list-reverse p) (if (null? p) null (list-append (list-reverse (cdr p)) (list (car p)))))
Running time is in (N2) where N is number of elements in p.
Number of new cons cells: for the list-appends: N-1 + N-2 + … + 1 = N2/ 2 + for the (list (car p)): N memory use is in (N2)
12
mlist-reverse!Define a mlist-reverse! that reverses the elements of a mutable list. The output should be a mutable list with the elements in the reverse order. The number of cons cells it creates should not scale with the length of the list. (The input list can be mutated arbitrarily!)
Revers!ing a List
1
m1:
2 3
revm1:
14
15
Close…but not quite
(define (mlist-reverse! p) (if (null? (mcdr p)) p (let ((rest (mlist-reverse! (mcdr p)))) (set-mcdr! p null) (mlist-append! rest p) rest)))
(define (mlist-reverse! p) (if (null? (mcdr p)) p ((lambda (rest) (begin (set-mcdr! p null) (mlist-append! rest p) rest)) (mlist-reverse! (mcdr p))))) > m1
{1 2 3 4}> (mlist-reverse! m1){4 3 2 1}> m1{1}
16
Charge
Next week: Finish mlist-reverse!Programming with Objects, Python
I still have unclaimed Exams! I will start charging exam storage fees Monday. You can come to my office now to get yours.