Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1-3. RC4 (20pts) Lem E. Tweakit is an aspiring embedded systems develope

ID: 3789281 • Letter: P

Question

Problem 1-3. RC4 (20pts) Lem E. Tweakit is an aspiring embedded systems developer. Recall that RC4’s internal state consists of an “S-Box” (S[]) and two pointers (i and j). Lem, constrained by hardware, wants to implement the swap(S[i], S[j]) operation from RC4’s Pseudo-Random Generation Algorithm (PRGA) without using a temporary variable. To perform the swap, Lem’s PRGA uses the following algorithm:

Algorithm 1 LEM-SWAP(x, y)

1: x = x y

2: y = x y

3: y = x y

4: x = x y

Alyssa P. Hacker, who studied the RC4 stream cipher in CS4538, is concerned. In particular, Alyssa argues that his implementation exhibits a weakness that will compromise the privacy of data encrypted using his implementation of the RC4 PRGA.

(a) Alyssa is correct. Why? Explain your answer, providing a proof if necessary.

(b) Fix Lem’s PRGA implementation by fixing LEM-SWAP(). Without using a temporary variable, provide the corrected LEM-SWAP() and show its correctness.

Having fixed LEM-SWAP(), Alyssa digs deeper into Lem’s implementation. She notices another oddity: to save state space, his S-Box is an identity permutation of 128 elements (half the size of traditional RC4)! All KSA and PRGA operations are otherwise the same, but modulo 128.

(c) How will Lem’s use of a 128 element S-Box affect the security of the resulting ciphertext? Explain your answer.

Explanation / Answer

count0 equ H’0C’

count1 equ H’0D’

porta equ H’05’

portb equ H’06’

status equ H’03’

trisa equ H’05’

trisb equ H’06’

org H’0’

;beginning of program

goto start

start clrf porta

clrf portb

bsf status,5

movlw 0

movwf trisa ;all Port A bits outputs

movlw 2

movwf trisb ;Port B bit 1 an input

bcf status,5

;beginning of first loop

top movlw H’0E’

movwf count0

inner1 movlw H’0C3’

movwf count1

loop1 decfsz count1,1

goto loop1

decfsz count0,1

goto inner1

movlw H’1’

xorwf porta,1 ;toggle the LED

btfss portb,1 ;test the pushbutton

goto top ;jump to first loop if button pressed

;beginning of second loop

movlw H’0E’ ;continue with second loop if button released

movwf count0

inner2 movlw H’0C3’

movwf count1

loop2 decfsz count1,1

goto loop2

decfsz count0,1

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote