]>
cvs.zerfleddert.de Git - rsbs2/blob - src/rsb-crc.c
4 #define POLY 0x04c11db7
6 uint32_t rsb_crc(uint32_t r11_crc
, uint8_t *r10_buf
, uint32_t r14_len
) {
11 while (r6_pos
< r14_len
) {
12 r3_data
= (*(r6_pos
+r10_buf
)) << 24;
13 r11_crc
= r11_crc
^ r3_data
;
18 r3_data
= r11_crc
& 0x80000000;
21 r3_data
= r11_crc
<< 1;
22 r11_crc
= r3_data
^ POLY
;
24 r11_crc
= r11_crc
<< 1;
35 uint32_t rsb_crc2(uint8_t *r0_buf
, uint32_t r1_buflen
, uint32_t r2_magic
, uint32_t *crc_out
) {
39 r4_len
= *(uint32_t*)(r0_buf
+ 0x20);
41 if (*((uint32_t*)(r0_buf
+ 0x24)) != r2_magic
)
42 return 2; /* MAGIC does not match */
44 if (r1_buflen
< r4_len
)
45 return 3; /* image to small */
47 *crc_out
= ~rsb_crc(~0x0, r0_buf
, r4_len
);
49 file_crc
= *((uint32_t*)(r0_buf
+ r4_len
));
51 if (file_crc
!= *crc_out
)