TransWikia.com

[ARM]How does this checksum code works and how to revert it in C?

Reverse Engineering Asked by 78dtat78da on August 10, 2021

I am trying to reverse a simple code that gets a string and calculates it’s checksum. I’ve been trying to understand every instruction, but they look different from what is said in arm documentation.
Here’s the full code(Using no$gba debugger)
Pink signals the checksum code

I’ve reached the code knowing that once the checksum has been calculated it is stored in the r0 register. Docs specify that EOR receives 2 args, while here is taking 4.
eor r3,r3,r0,asr 8h I’ve figured out that this will be something like r3 = (r3^r0)>>8 but I’m not really sure. In addition, C/C++ doesn’t specify if the >> operator performs arithmetical or logical shifts (asr)

Same confusion is created with the mov’s instructions. The sub inst. would be reversed in something like r2–; or r2=r2-1;

Thanks for your time.

EDIT: The checksum is 2 bytes long, and I am giving some examples:

String: AAAAAAB — Checksum: 0xB649 (While debugging, write in little endian)

String: AAAAAAA — Checksum: 0x68BC
(NOTE: Checksum can’t be worked out by performing operations with different checksum samples)

One Answer

A disassembler and decompiler like Ghidra can be used to obtain a C equivalent code.

Also, as specified by @RadLexus, the ARM documentation can be found here: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0068b/BABGIEBE.html

Correct answer by 78dtat78da on August 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP