]>
git.zerfleddert.de Git - rsbs2/blob - rsb-crc.c
fa40c498099e3b3838e8e325f00b844940287bc1
1 #define POLY 0x04c11db7
3 /* Theory of operation:
4 * (arm-elf-objdump -b binary -m arm -M reg-names-raw -D RSB_S2_SINGLE.bin)
6 * 440: push {r4, r5, r6, r7, r8, r9, r10, r11, r14}
10 * 450: mov r6, #0 ; 0x0
12 * 458: add r3, r6, r10
14 * 460: lsl r3, r3, #24
15 * 464: eor r11, r11, r3
16 * 468: mov r5, #8 ; 0x8
17 * 46c: and r3, r11, #-2147483648 ; 0x80000000
18 * 470: cmp r3, #0 ; 0x0
20 * 478: lsl r3, r11, #1
21 * 47c: ldr r12, [pc, #64] ; 0x4c4
22 * 480: eor r0, r3, r12
25 * 48c: lsl r11, r11, #1
26 * 490: sub r5, r5, #1 ; 0x1
27 * 494: cmp r5, #0 ; 0x0
29 * 49c: add r6, r6, #1 ; 0x1
33 * 4ac: pop {r4, r5, r6, r7, r8, r9, r10, r11, r15}
34 * 4c4: DATA: 0x04c11db7
37 unsigned int rsb_crc(unsigned int r11_crc
, unsigned char *r10_buf
, unsigned int r14_len
) {
38 unsigned int r6_pos
= 0;
42 while (r6_pos
< r14_len
) {
43 r3_data
= (*(r6_pos
+r10_buf
)) << 24;
44 r11_crc
= r11_crc
^ r3_data
;
49 r3_data
= r11_crc
& 0x80000000;
52 r3_data
= r11_crc
<< 1;
53 r11_crc
= r3_data
^ POLY
;
55 r11_crc
= r11_crc
<< 1;