CRACK Solution

Alternating Lock

CRACK alternating XOR / additive cipher by position parity

In-game screenshot of Alternating Lock
In-game view
FamilyCRACK Graph0.590 DifficultyMedium Ring04 IDz5_alt_cipher

Prerequisites

ABS DIFFERENCE

Unlocks

BIT LADDER

Accepted input ALTERN8
Techniquealternating XOR / additive cipher by position parity Rulenonzero SampleALTERN8

Walkthrough

Recover the accepted input below, then submit it to the CRACK verifier.

Reject Samples

  • ALTERN9
  • altern8
  • ALTERN
  • ALTERN88
  • FLIPFLP
Verifier Listing
; z5_alt_cipher: one key 0x1F, two operations selected by position parity.
; Length must be 7. Even positions (0,2,4,6) XOR the input byte with 0x1F; odd
; positions (1,3,5) ADD 0x1F (mod 256). The transformed byte is compared to a
; stored target. The dispatch is a test of bit 0 of the position counter. To
; crack it: even => stored XOR 0x1F, odd => (stored: 0x1F) & 0xFF. Inverting the
; seven targets recovers ALTERN8. r0 = 1 on accept; rule: nonzero.
;
; Maps cleanly to the 8-bit core (byte-wise, single byte key). The parity test
; is (i AND 1). Targets 0x5E 0x6B 0x4B 0x64 0x4D 0x6D 0x27 of "ALTERN8".

        len   r2
        cmp   r2, 7
        jnz   bad

        mov   r7, 0
loop:   cmp   r7, 7
        jge   ok
        ldb   r0, [r7]

        ; dispatch on parity: even -> XOR, odd -> ADD, same key 0x1F
        mov   r3, r7
        and   r3, 1
        cmp   r3, 0
        jz    even
        add   r0, 0x1F      ; odd position: additive
        jmp   sel
even:   xor   r0, 0x1F      ; even position: XOR

sel:    cmp   r7, 0
        jz    t0
        cmp   r7, 1
        jz    t1
        cmp   r7, 2
        jz    t2
        cmp   r7, 3
        jz    t3
        cmp   r7, 4
        jz    t4
        cmp   r7, 5
        jz    t5
        mov   r1, 0x27      ; position 6
        jmp   chk
t0:     mov   r1, 0x5E
        jmp   chk
t1:     mov   r1, 0x6B
        jmp   chk
t2:     mov   r1, 0x4B
        jmp   chk
t3:     mov   r1, 0x64
        jmp   chk
t4:     mov   r1, 0x4D
        jmp   chk
t5:     mov   r1, 0x6D
chk:    cmp   r0, r1
        jnz   bad
        inc   r7
        jmp   loop

ok:     mov   r0, 1
        ret
bad:    mov   r0, 0
        ret